Mercurial > hg > beaglert
changeset 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 | fcf36d293458 |
children | b97fe1dc4278 |
files | Makefile |
diffstat | 1 files changed, 11 insertions(+), 17 deletions(-) [+] |
line wrap: on
line diff
--- a/Makefile Thu Jun 23 19:17:43 2016 +0100 +++ b/Makefile Thu Jun 23 21:23:27 2016 +0100 @@ -317,22 +317,22 @@ @[ -n $(UPDATE_DIR) ] && rm -rf $(UPDATE_DIR) && mkdir -p $(UPDATE_DIR) checkupdate: ## Unzips the zip file in $(UPDATES_DIR) and checks that it contains a valid - # Check that exactly one zip file exists + @echo Validating archive... @cd $(UPDATES_DIR) && COUNT=`ls -l *.zip | wc -l` && [ $$COUNT -eq 1 ] && rm -rf `ls | grep -v "\.zip$$"` @#TODO: heuristics on available space. Use unzip -l and df @echo uncompressed size: `unzip -l \`ls $(UPDATES_DIR)/*.zip\` | tail -n1 | awk '{print $$1}'` - # Delete and re-create the temp directory (first, make sure it is not an empty string!) + @# Delete and re-create the temp directory (first, make sure it is not an empty string!) @[ -n $(UPDATE_SOURCE_DIR_BASE) ] && rm -rf $(UPDATE_SOURCE_DIR_BASE) && mkdir -p $(UPDATE_SOURCE_DIR_BASE) - # Unzip the contents to the temp folder + @echo Unzipping archive... @cd $(UPDATE_SOURCE_DIR_BASE) && unzip -qq $(UPDATES_DIR)/*zip #TODO: this should not be needed. Remove comments. Strip the top-level folder ( if there is only one ) #@DIR=`ls -d $(UPDATE_SOURCE_DIR)` && COUNT=`echo $$DIR | wc -l` &&\ [ $$COUNT -eq 1 ] && mv $(UPDATE_SOURCE_DIR)/* /tmp/supertemp && rm -rf $(UPDATE_SOURCE_DIR) && mv /tmp/supertemp $(UPDATE_SOURCE_DIR) - # Now actually check if some key-files and folders are there + @echo Validating unzipped archive... @cd $(UPDATE_SOURCE_DIR) && FAIL=0 && for path in $(UPDATE_REQUIRED_PATHS); do `ls $$path >/dev/null 2>&1` || { FAIL=1; break; }; done;\ [ $$FAIL -eq 0 ] || { echo "$$path was not found in the zip archive. Maybe it is corrupted?"; exit 1; } - # Success. You can continue the install with "make update" + @echo ...done UPDATE_LOG?=~/update.log LOG=>> $(UPDATE_LOG) 2>&1 updateunsafe: ## Installs the update from $(UPDATES_DIR) in a more brick-friendly way @@ -345,28 +345,22 @@ $(MAKE) --no-print-directory idestart $(LOG) && echo Update succesful $(LOG);" $(LOG) update: ## Installs the update from $(UPDATES_DIR) update: stop - # Truncate the log file + @# Truncate the log file @echo > $(UPDATE_LOG) - # Re-perform the check, just in case ... + @echo Re-perform the check, just in case ... >> $(UPDATE_LOG) @cd $(UPDATE_SOURCE_DIR) && FAIL=0 && for path in $(UPDATE_REQUIRED_PATHS); do `ls $$path >/dev/null 2>&1` || { FAIL=1; break; }; done;\ [ $$FAIL -eq 0 ] || { echo "$$path was not found in the zip archive. Maybe it is corrupted?"; exit 1; } @[ -n $(UPDATE_BELA_PATCH) ] && mkdir -p $(UPDATE_BELA_PATCH) @#TODO: this would allow to trim trailing slashes in case we want to be safer: a="`pwd`/" ; target=${a%/} ; echo $target - # Clean folder @$(MAKE) --no-print-directory coreclean - # Duplicate the Bela folder $(BELA_DIR) to $(UPDATE_BELA_PATCH) ... + @echo Backing up $(BELA_DIR) to $(UPDATE_BELA_PATCH) ... | tee -a $(UPDATE_LOG) @rsync -a --delete-during --exclude Documentation $(BELA_DIR)/ $(UPDATE_BELA_PATCH) - # Also backing it up in $(UPDATE_BELA_BACKUP) ... + @echo Backing up $(BELA_DIR) to $(UPDATE_BELA_BACKUP) ... | tee -a $(UPDATE_LOG) @[ -n $(UPDATE_BELA_BACKUP) ] && mkdir -p $(UPDATE_BELA_BACKUP) @rsync -a --delete-during $(BELA_DIR)/ $(UPDATE_BELA_BACKUP) - # Here's the trick: we run "update_board" ssh'ing into the BeagleBone itself! + @echo Running update script... | tee -a $(UPDATE_LOG) @cd $(UPDATE_SOURCE_DIR)/scripts && BBB_ADDRESS=root@127.0.0.1 BBB_BELA_HOME=$(UPDATE_BELA_PATCH) ./update_board -y --no-frills - # 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) - # 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). - # If something goes wrong at thie stage, you can always find your old $(BELA_DIR) folder at $(UPDATE_BELA_BACKUP) - # The fun part is that this Makefile is moved as well... - # 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. - # Output will be logged to $(UPDATE_LOG) + @echo Restoring directory structure... | tee -a $(UPDATE_LOG) @screen -S update-Bela -d -m bash -c '\ [ -n $(UPDATE_BELA_MV_BACKUP) ] $(LOG) && rm -rf $(UPDATE_BELA_MV_BACKUP) $(LOG) &&\ echo Kill the IDE $(LOG) && \