Revision 5690d84c

View differences:

setup.sh
332 332
#                 Error: Unexpected user input.
333 333
#
334 334
function stm32flashSetup {
335
  local stm32flashdir=$(dirname $(realpath ${BASH_SOURCE[0]}))/Host/Source/stm32flash/
335
  local amirobltdir=$(dirname $(realpath ${BASH_SOURCE[0]}))
336
  local stm32flashdir=${amirobltdir}/Host/Source/stm32flash/
336 337
  local userdir=$(pwd)
337 338

  
338 339
  # if the stm32flash folder is not empty
......
344 345
      Y|y)
345 346
        printInfo "wiping ${stm32flashdir}...\n"
346 347
        # checkout base commit and delete all local branches
348
        cd $amirobltdir
347 349
        git submodule update --force --checkout $stm32flashdir | tee -a $LOG_FILE
348 350
        cd $stm32flashdir
349 351
        local git_branches=($(git for-each-ref --format="%(refname)"))
......
352 354
            git branch -D ${branch##*/} | tee -a $LOG_FILE
353 355
          fi
354 356
        done
355
        cd $userdir
357
        cd $amirobltdir
356 358
        # deinit stm32flash submodule and delete any remaining files
357 359
        git submodule deinit -f $stm32flashdir 2>&1 | tee -a $LOG_FILE
358 360
        rm -rf $stm32flashdir/*
361
        cd $userdir
359 362
        ;;
360 363
      N|n)
361 364
        printWarning "stm32flash setup aborted by user\n"
......
370 373

  
371 374
  # initialize submodule
372 375
  printInfo "initializing stm32flash submodule...\n"
376
  cd $amirobltdir
373 377
  git submodule update --init $stm32flashdir 2>&1 | tee -a $LOG_FILE
374 378
  while [ ${PIPESTATUS[0]} -ne 0 ]; do
375 379
    printWarning "initialitaion failed. Retry? [y/n]\n"
......
380 384
        git submodule update --init $stm32flashdir 2>&1 | tee -a $LOG_FILE;;
381 385
      N|n)
382 386
        printWarning "stm32flash initialization aborted by user\n"
387
        cd $userdir
383 388
        return 1
384 389
        ;;
385 390
      *) # sanity check (return error)
386 391
        printError "unexpected input: $userinput\n"; return -1;;
387 392
    esac
388 393
  done
394
  cd $userdir
389 395

  
390 396
  # build the stm32flash tool
391 397
  printInfo "compiling stm32flash\n"
......
490 496
#                 No error or warning occurred.
491 497
#
492 498
function main {
493
  local userdir=$(pwd)
494
  cd $(realpath $(dirname ${BASH_SOURCE[0]}))
495

  
496 499
  # print welcome/info text if not suppressed
497 500
  if [[ $@ != *"--noinfo"* ]]; then
498 501
    printWelcomeText
......
505 508
  if [[ $@ == *"--help"* || $@ == *"-h"* ]]; then
506 509
    printHelp
507 510
    printf "\n"
508
    cd $userdir
509 511
    quitScript
510 512
  fi
511 513

  
......
551 553
        -c|--compiler)
552 554
          compilerSetup; printf "\n"; shift 1;;
553 555
        -q|--quit)
554
          cd $userdir; quitScript; shift 1;;
556
          quitScript; shift 1;;
555 557
        --log=*|--LOG=*) # already handled; ignore
556 558
          shift 1;;
557 559
        --log|--LOG) # already handled; ignore
......
592 594
      C|c)
593 595
        compilerSetup; printf "\n";;
594 596
      Q|q)
595
        cd $userdir; quitScript;;
597
        quitScript;;
596 598
      *) # sanity check (exit with error)
597 599
        printError "unexpected argument: $userinput\n";;
598 600
    esac
599 601
  done
600 602

  
601
  cd $USER_DIR
602 603
  exit 0
603 604
}
604 605

  

Also available in: Unified diff