Mercurial > hg > beaglert
comparison Makefile @ 535:d0414ec15f63 prerelease
Improved Makefile output for update target
author | Liam Donovan <l.b.donovan@qmul.ac.uk> |
---|---|
date | Thu, 23 Jun 2016 21:23:27 +0100 |
parents | 617da76ae4d9 |
children | 3980b707634d |
comparison
equal
deleted
inserted
replaced
530:fcf36d293458 | 535:d0414ec15f63 |
---|---|
315 | 315 |
316 updateclean: ## Cleans the $(UPDATES_DIR) folder | 316 updateclean: ## Cleans the $(UPDATES_DIR) folder |
317 @[ -n $(UPDATE_DIR) ] && rm -rf $(UPDATE_DIR) && mkdir -p $(UPDATE_DIR) | 317 @[ -n $(UPDATE_DIR) ] && rm -rf $(UPDATE_DIR) && mkdir -p $(UPDATE_DIR) |
318 | 318 |
319 checkupdate: ## Unzips the zip file in $(UPDATES_DIR) and checks that it contains a valid | 319 checkupdate: ## Unzips the zip file in $(UPDATES_DIR) and checks that it contains a valid |
320 # Check that exactly one zip file exists | 320 @echo Validating archive... |
321 @cd $(UPDATES_DIR) && COUNT=`ls -l *.zip | wc -l` && [ $$COUNT -eq 1 ] && rm -rf `ls | grep -v "\.zip$$"` | 321 @cd $(UPDATES_DIR) && COUNT=`ls -l *.zip | wc -l` && [ $$COUNT -eq 1 ] && rm -rf `ls | grep -v "\.zip$$"` |
322 @#TODO: heuristics on available space. Use unzip -l and df | 322 @#TODO: heuristics on available space. Use unzip -l and df |
323 @echo uncompressed size: `unzip -l \`ls $(UPDATES_DIR)/*.zip\` | tail -n1 | awk '{print $$1}'` | 323 @echo uncompressed size: `unzip -l \`ls $(UPDATES_DIR)/*.zip\` | tail -n1 | awk '{print $$1}'` |
324 # Delete and re-create the temp directory (first, make sure it is not an empty string!) | 324 @# Delete and re-create the temp directory (first, make sure it is not an empty string!) |
325 @[ -n $(UPDATE_SOURCE_DIR_BASE) ] && rm -rf $(UPDATE_SOURCE_DIR_BASE) && mkdir -p $(UPDATE_SOURCE_DIR_BASE) | 325 @[ -n $(UPDATE_SOURCE_DIR_BASE) ] && rm -rf $(UPDATE_SOURCE_DIR_BASE) && mkdir -p $(UPDATE_SOURCE_DIR_BASE) |
326 # Unzip the contents to the temp folder | 326 @echo Unzipping archive... |
327 @cd $(UPDATE_SOURCE_DIR_BASE) && unzip -qq $(UPDATES_DIR)/*zip | 327 @cd $(UPDATE_SOURCE_DIR_BASE) && unzip -qq $(UPDATES_DIR)/*zip |
328 #TODO: this should not be needed. Remove comments. Strip the top-level folder ( if there is only one ) | 328 #TODO: this should not be needed. Remove comments. Strip the top-level folder ( if there is only one ) |
329 #@DIR=`ls -d $(UPDATE_SOURCE_DIR)` && COUNT=`echo $$DIR | wc -l` &&\ | 329 #@DIR=`ls -d $(UPDATE_SOURCE_DIR)` && COUNT=`echo $$DIR | wc -l` &&\ |
330 [ $$COUNT -eq 1 ] && mv $(UPDATE_SOURCE_DIR)/* /tmp/supertemp && rm -rf $(UPDATE_SOURCE_DIR) && mv /tmp/supertemp $(UPDATE_SOURCE_DIR) | 330 [ $$COUNT -eq 1 ] && mv $(UPDATE_SOURCE_DIR)/* /tmp/supertemp && rm -rf $(UPDATE_SOURCE_DIR) && mv /tmp/supertemp $(UPDATE_SOURCE_DIR) |
331 | 331 |
332 # Now actually check if some key-files and folders are there | 332 @echo Validating unzipped archive... |
333 @cd $(UPDATE_SOURCE_DIR) && FAIL=0 && for path in $(UPDATE_REQUIRED_PATHS); do `ls $$path >/dev/null 2>&1` || { FAIL=1; break; }; done;\ | 333 @cd $(UPDATE_SOURCE_DIR) && FAIL=0 && for path in $(UPDATE_REQUIRED_PATHS); do `ls $$path >/dev/null 2>&1` || { FAIL=1; break; }; done;\ |
334 [ $$FAIL -eq 0 ] || { echo "$$path was not found in the zip archive. Maybe it is corrupted?"; exit 1; } | 334 [ $$FAIL -eq 0 ] || { echo "$$path was not found in the zip archive. Maybe it is corrupted?"; exit 1; } |
335 # Success. You can continue the install with "make update" | 335 @echo ...done |
336 UPDATE_LOG?=~/update.log | 336 UPDATE_LOG?=~/update.log |
337 LOG=>> $(UPDATE_LOG) 2>&1 | 337 LOG=>> $(UPDATE_LOG) 2>&1 |
338 updateunsafe: ## Installs the update from $(UPDATES_DIR) in a more brick-friendly way | 338 updateunsafe: ## Installs the update from $(UPDATES_DIR) in a more brick-friendly way |
339 @echo > $(UPDATE_LOG) | 339 @echo > $(UPDATE_LOG) |
340 # Re-perform the check, just in case ... | 340 # Re-perform the check, just in case ... |
343 @cd $(UPDATE_SOURCE_DIR)/scripts && BBB_ADDRESS=root@127.0.0.1 BBB_BELA_HOME=$(BELA_DIR) ./update_board -y --no-frills | 343 @cd $(UPDATE_SOURCE_DIR)/scripts && BBB_ADDRESS=root@127.0.0.1 BBB_BELA_HOME=$(BELA_DIR) ./update_board -y --no-frills |
344 @screen -S update-Bela -d -m bash -c "echo Restart the IDE $(LOG) &&\ | 344 @screen -S update-Bela -d -m bash -c "echo Restart the IDE $(LOG) &&\ |
345 $(MAKE) --no-print-directory idestart $(LOG) && echo Update succesful $(LOG);" $(LOG) | 345 $(MAKE) --no-print-directory idestart $(LOG) && echo Update succesful $(LOG);" $(LOG) |
346 update: ## Installs the update from $(UPDATES_DIR) | 346 update: ## Installs the update from $(UPDATES_DIR) |
347 update: stop | 347 update: stop |
348 # Truncate the log file | 348 @# Truncate the log file |
349 @echo > $(UPDATE_LOG) | 349 @echo > $(UPDATE_LOG) |
350 # Re-perform the check, just in case ... | 350 @echo Re-perform the check, just in case ... >> $(UPDATE_LOG) |
351 @cd $(UPDATE_SOURCE_DIR) && FAIL=0 && for path in $(UPDATE_REQUIRED_PATHS); do `ls $$path >/dev/null 2>&1` || { FAIL=1; break; }; done;\ | 351 @cd $(UPDATE_SOURCE_DIR) && FAIL=0 && for path in $(UPDATE_REQUIRED_PATHS); do `ls $$path >/dev/null 2>&1` || { FAIL=1; break; }; done;\ |
352 [ $$FAIL -eq 0 ] || { echo "$$path was not found in the zip archive. Maybe it is corrupted?"; exit 1; } | 352 [ $$FAIL -eq 0 ] || { echo "$$path was not found in the zip archive. Maybe it is corrupted?"; exit 1; } |
353 @[ -n $(UPDATE_BELA_PATCH) ] && mkdir -p $(UPDATE_BELA_PATCH) | 353 @[ -n $(UPDATE_BELA_PATCH) ] && mkdir -p $(UPDATE_BELA_PATCH) |
354 @#TODO: this would allow to trim trailing slashes in case we want to be safer: a="`pwd`/" ; target=${a%/} ; echo $target | 354 @#TODO: this would allow to trim trailing slashes in case we want to be safer: a="`pwd`/" ; target=${a%/} ; echo $target |
355 # Clean folder | |
356 @$(MAKE) --no-print-directory coreclean | 355 @$(MAKE) --no-print-directory coreclean |
357 # Duplicate the Bela folder $(BELA_DIR) to $(UPDATE_BELA_PATCH) ... | 356 @echo Backing up $(BELA_DIR) to $(UPDATE_BELA_PATCH) ... | tee -a $(UPDATE_LOG) |
358 @rsync -a --delete-during --exclude Documentation $(BELA_DIR)/ $(UPDATE_BELA_PATCH) | 357 @rsync -a --delete-during --exclude Documentation $(BELA_DIR)/ $(UPDATE_BELA_PATCH) |
359 # Also backing it up in $(UPDATE_BELA_BACKUP) ... | 358 @echo Backing up $(BELA_DIR) to $(UPDATE_BELA_BACKUP) ... | tee -a $(UPDATE_LOG) |
360 @[ -n $(UPDATE_BELA_BACKUP) ] && mkdir -p $(UPDATE_BELA_BACKUP) | 359 @[ -n $(UPDATE_BELA_BACKUP) ] && mkdir -p $(UPDATE_BELA_BACKUP) |
361 @rsync -a --delete-during $(BELA_DIR)/ $(UPDATE_BELA_BACKUP) | 360 @rsync -a --delete-during $(BELA_DIR)/ $(UPDATE_BELA_BACKUP) |
362 # Here's the trick: we run "update_board" ssh'ing into the BeagleBone itself! | 361 @echo Running update script... | tee -a $(UPDATE_LOG) |
363 @cd $(UPDATE_SOURCE_DIR)/scripts && BBB_ADDRESS=root@127.0.0.1 BBB_BELA_HOME=$(UPDATE_BELA_PATCH) ./update_board -y --no-frills | 362 @cd $(UPDATE_SOURCE_DIR)/scripts && BBB_ADDRESS=root@127.0.0.1 BBB_BELA_HOME=$(UPDATE_BELA_PATCH) ./update_board -y --no-frills |
364 # If everything went ok, we now have the updated version of $(BELA_DIR) in $(UPDATE_BELA_PATCH) and a backup of $(BELA_DIR) in $(UPDATE_BELA_BACKUP) | 363 @echo Restoring directory structure... | tee -a $(UPDATE_LOG) |
365 # So let's operate the magic swap. $(BELA_DIR) is moved to $(UPDATE_BELA_MV_BACKUP) and $(UPDATE_BELA_PATCH) is moved to $(BELA_DIR). | |
366 # If something goes wrong at thie stage, you can always find your old $(BELA_DIR) folder at $(UPDATE_BELA_BACKUP) | |
367 # The fun part is that this Makefile is moved as well... | |
368 # We are about to kill the IDE, so just in case you are running this from within the IDE, we run the remainder of this update in a screen. | |
369 # Output will be logged to $(UPDATE_LOG) | |
370 @screen -S update-Bela -d -m bash -c '\ | 364 @screen -S update-Bela -d -m bash -c '\ |
371 [ -n $(UPDATE_BELA_MV_BACKUP) ] $(LOG) && rm -rf $(UPDATE_BELA_MV_BACKUP) $(LOG) &&\ | 365 [ -n $(UPDATE_BELA_MV_BACKUP) ] $(LOG) && rm -rf $(UPDATE_BELA_MV_BACKUP) $(LOG) &&\ |
372 echo Kill the IDE $(LOG) && \ | 366 echo Kill the IDE $(LOG) && \ |
373 $(MAKE) --no-print-directory idestop $(LOG) &&\ | 367 $(MAKE) --no-print-directory idestop $(LOG) &&\ |
374 mv $(BELA_DIR) $(UPDATE_BELA_MV_BACKUP) $(LOG) && mv $(UPDATE_BELA_PATCH) $(BELA_DIR) $(LOG) &&\ | 368 mv $(BELA_DIR) $(UPDATE_BELA_MV_BACKUP) $(LOG) && mv $(UPDATE_BELA_PATCH) $(BELA_DIR) $(LOG) &&\ |