Revision 57cbd1cd kernel/kernelsetup.sh
kernel/kernelsetup.sh | ||
---|---|---|
263 | 263 |
return 0 |
264 | 264 |
} |
265 | 265 |
|
266 |
### check whether commands are available ####################################### |
|
267 |
# Checks whether the specified commands are available and can be executed. |
|
268 |
# |
|
269 |
# usage: checkCommand [<command> <command> ...] |
|
270 |
# arguments: <command> |
|
271 |
# Name of the command to check. |
|
272 |
# return: 0 |
|
273 |
# All requested commands are available. |
|
274 |
# >0 |
|
275 |
# Number of requested commands that were not found. |
|
276 |
# -1 |
|
277 |
# No argument given. |
|
278 |
# |
|
279 |
function checkCommands { |
|
280 |
local status=0 |
|
281 |
|
|
282 |
# return if no argument was specified |
|
283 |
if [ $# -eq 0 ]; then |
|
284 |
return -1 |
|
285 |
fi |
|
286 |
|
|
287 |
# check all specified commands |
|
288 |
while [ $# -gt 0 ]; do |
|
289 |
command -v $1 &>/dev/null |
|
290 |
if [ $? -ne 0 ]; then |
|
291 |
printWarning "Command '$1' not available.\n" |
|
292 |
status=$((status + 1)) |
|
293 |
fi |
|
294 |
shift 1 |
|
295 |
done |
|
296 |
|
|
297 |
return $status |
|
298 |
} |
|
299 |
|
|
266 | 300 |
################################################################################ |
267 | 301 |
# SPECIFIC FUNCTIONS # |
268 | 302 |
################################################################################ |
... | ... | |
333 | 367 |
# Warning: Aborted by user. |
334 | 368 |
# -1 |
335 | 369 |
# Error: Unexpected user input. |
370 |
# -1 |
|
371 |
# Error: Missing dependency. |
|
336 | 372 |
# |
337 | 373 |
function initChibiOS { |
338 | 374 |
printInfo "initializing ChibiOS submodule...\n" |
... | ... | |
358 | 394 |
esac |
359 | 395 |
fi |
360 | 396 |
|
397 |
# check dependencies |
|
398 |
checkCommands git |
|
399 |
if [ $? -ne 0 ]; then |
|
400 |
printError "Missing dependencies detected.\n" |
|
401 |
return -2 |
|
402 |
fi |
|
403 |
|
|
361 | 404 |
# initialize submodule to default branch |
362 | 405 |
cd $kerneldir |
363 | 406 |
git submodule update --init $chibiosdir 2>&1 | tee -a $LOG_FILE |
... | ... | |
403 | 446 |
local chibiosdir=${kerneldir}/ChibiOS |
404 | 447 |
local git_branch_patched="AMiRo-OS" |
405 | 448 |
|
449 |
# check dependencies |
|
450 |
checkCommands git |
|
451 |
if [ $? -ne 0 ]; then |
|
452 |
printError "Missing dependencies detected.\n" |
|
453 |
return -2 |
|
454 |
fi |
|
455 |
|
|
406 | 456 |
# if the ChibiOS folder is empty |
407 | 457 |
if [ -z "$(ls -A $chibiosdir)" ]; then |
408 | 458 |
printWarning "$chibiosdir is empty. Please initialize first.\n" |
... | ... | |
615 | 665 |
local chibiosdir=${kerneldir}/ChibiOS |
616 | 666 |
local git_branch_patched="AMiRo-OS" |
617 | 667 |
|
668 |
# check dependencies |
|
669 |
checkCommands git |
|
670 |
if [ $? -ne 0 ]; then |
|
671 |
printError "Missing dependencies detected.\n" |
|
672 |
return -2 |
|
673 |
fi |
|
674 |
|
|
618 | 675 |
# if the ChibiOS folder is empty |
619 | 676 |
if [ -z "$(ls -A $chibiosdir)" ]; then |
620 | 677 |
printInfo "$chibiosdir is alread empty\n" |
Also available in: Unified diff