Revision 1678f270 bootloader/bootloadersetup.sh

View differences:

bootloader/bootloadersetup.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
################################################################################
......
329 363
#                 Warning: Arborted by user.
330 364
#             -1
331 365
#                 Error: Unexpected user input.
366
#             -2
367
#                 Error: Missing dependencies.
332 368
#
333 369
function initAmiroBlt {
334 370
  printInfo "initializing AMiRo-BLT submodule...\n"
......
354 390
    esac
355 391
  fi
356 392

  
393
  # check dependencies
394
  checkCommands git
395
  if [ $? -ne 0 ]; then
396
    printError "Missing dependencies detected.\n"
397
    return -2
398
  fi
399

  
357 400
  # initialize submodule to default branch
358 401
  cd $bootloaderdir
359 402
  git submodule update --init $amirobltdir 2>&1 | tee -a $LOG_FILE
......
412 455
#
413 456
# usage:      wipeAmiroBlt
414 457
# arguments:  n/a
415
# return:     n/a
458
# return:     0
459
#                 No error or warning occurred.
460
#             1
461
#                 Warning: AMiRo-BLT Git submodule already empty
462
#             2
463
#                 Warning: Aborted by user.
464
#             -1
465
#                 Error: Unexpected input occurred
466
#             -2
467
#                 Error: Missing dependencies.
468
#
416 469
function wipeAmiroBlt {
417 470
  printInfo "reset and wipe Git submodule $amirobltdir\n"
418 471
  local userdir=$(pwd)
419 472
  local bootloaderdir=$(dirname $(realpath ${BASH_SOURCE[0]}))
420 473
  local amirobltdir=${bootloaderdir}/AMiRo-BLT
421 474

  
475
  # check dependencies
476
  checkCommands git
477
  if [ $? -ne 0 ]; then
478
    printError "Missing dependencies detected.\n"
479
    return -2
480
  fi
481

  
422 482
  # if the AMiRo-BLT folder is empty
423 483
  if [ -z "$(ls -A $amirobltdir)" ]; then
424 484
    printWarning "$amirobltdir is already empty\n"

Also available in: Unified diff