Revision 0136e0ec

View differences:

middleware/middlewaresetup.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
################################################################################
......
327 361
#                 Warning: Arborted by user.
328 362
#             -1
329 363
#                 Error: Unexpected user input.
364
#             -2
365
#                 Error: Missing dependencies.
330 366
#
331 367
function initUrtware {
332 368
  printInfo "initializing uRtWare submodule...\n"
......
352 388
    esac
353 389
  fi
354 390

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

  
355 398
  # initialize submodule to default branch
356 399
  cd $middlewaredir
357 400
  git submodule update --init $urtwaredir 2>&1 | tee -a $LOG_FILE
......
381 424
#
382 425
# usage:      wipeUrtware
383 426
# arguments:  n/a
384
# return:     n/a
427
# return:     0
428
#                 No error or warning occurred.
429
#             1
430
#                 Warning: uRtWare Git submodule already empty
431
#             2
432
#                 Warning: Aborted by user.
433
#             -1
434
#                 Error: Unexpected input occurred
435
#             -2
436
#                 Error: Missing dependencies.
437
#
385 438
function wipeUrtware {
386 439
  local userdir=$(pwd)
387 440
  local middlewaredir=$(dirname $(realpath ${BASH_SOURCE[0]}))
388 441
  local urtwaredir=${middlewaredir}/uRtWare
389 442
  printInfo "reset and wipe Git submodule $urtwaredir\n"
390 443

  
444
  # check dependencies
445
  checkCommands git
446
  if [ $? -ne 0 ]; then
447
    printError "Missing dependencies detected.\n"
448
    return -2
449
  fi
450

  
391 451
  # if the uRtWare folder is empty
392 452
  if [ -z "$(ls -A $urtwaredir)" ]; then
393 453
    printWarning "$urtwaredir is already empty\n"
os/ossetup.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 initAmiroOs {
334 370
  printInfo "initializing AMiRo-OS 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 $osdir
359 402
  git submodule update --init $amiroosdir 2>&1 | tee -a $LOG_FILE
......
412 455
#
413 456
# usage:      wipeAmiroOs
414 457
# arguments:  n/a
415
# return:     n/a
458
# return:     0
459
#                 No error or warning occurred.
460
#             1
461
#                 Warning: AMiRo-OS 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 wipeAmiroOs {
417 470
  printInfo "reset and wipe Git submodule $amiroosdir\n"
418 471
  local userdir=$(pwd)
419 472
  local osdir=$(dirname $(realpath ${BASH_SOURCE[0]}))
420 473
  local amiroosdir=${osdir}/AMiRo-OS
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-OS folder is empty
423 483
  if [ -z "$(ls -A $amiroosdir)" ]; then
424 484
    printWarning "$amiroosdir is already empty\n"
setup.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
################################################################################
tools/ide/QtCreator/QtCreatorSetup.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
################################################################################
tools/ide/idesetup.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
################################################################################

Also available in: Unified diff