Mercurial > hg > beaglert
comparison Makefile @ 453:4cccb13bf406 prerelease
Minor edits to Makefile
author | Giulio Moro <giuliomoro@yahoo.it> |
---|---|
date | Sun, 19 Jun 2016 22:36:38 +0100 |
parents | fdb30affab1c |
children | 0567af952cfa |
comparison
equal
deleted
inserted
replaced
452:7b63e3295343 | 453:4cccb13bf406 |
---|---|
305 ideconnect: ## Brings in the foreground the IDE that currently is running in a screen (if any), can detach with ctrl-a ctrl-d. | 305 ideconnect: ## Brings in the foreground the IDE that currently is running in a screen (if any), can detach with ctrl-a ctrl-d. |
306 @screen -r -S $(BELA_IDE_SCREEN_NAME) | 306 @screen -r -S $(BELA_IDE_SCREEN_NAME) |
307 | 307 |
308 BELA_DIR:=$(shell dirname $(realpath $(lastword $(MAKEFILE_LIST)))) | 308 BELA_DIR:=$(shell dirname $(realpath $(lastword $(MAKEFILE_LIST)))) |
309 UPDATES_DIR?=/root/Bela/updates | 309 UPDATES_DIR?=/root/Bela/updates |
310 UPDATE_SOURCE_DIR?=/tmp/belaUpdate | 310 UPDATE_SOURCE_DIR_BASE?=/tmp/belaUpdate |
311 UPDATE_SOURCE_DIR=$(UPDATE_SOURCE_DIR_BASE)/Bela | |
311 UPDATE_REQUIRED_PATHS?=scripts include core scripts/update_board | 312 UPDATE_REQUIRED_PATHS?=scripts include core scripts/update_board |
312 UPDATE_BELA_TEMP?=/tmp/belaTemp | 313 UPDATE_BELA_PATCH?=/tmp/belaPatch |
313 UPDATE_BELA_BACKUP?=/tmp/belaBak | 314 UPDATE_BELA_BACKUP?=/tmp/belaBak |
314 UPDATE_BELA_MV_BACKUP?=/tmp/belaMvBak | 315 UPDATE_BELA_MV_BACKUP?=/tmp/belaMvBak |
315 | 316 |
316 updateclean: ## Cleans the $(UPDATES_DIR) folder | 317 updateclean: ## Cleans the $(UPDATES_DIR) folder |
317 @[ -n $(UPDATE_DIR) ] && rm -rf $(UPDATE_DIR) && mkdir -p $(UPDATE_DIR) | 318 @[ -n $(UPDATE_DIR) ] && rm -rf $(UPDATE_DIR) && mkdir -p $(UPDATE_DIR) |
319 checkupdate: ## Unzips the zip file in $(UPDATES_DIR) and checks that it contains a valid | 320 checkupdate: ## Unzips the zip file in $(UPDATES_DIR) and checks that it contains a valid |
320 # Check that exactly one zip file exists | 321 # Check that exactly one zip file exists |
321 @cd $(UPDATES_DIR) && COUNT=`ls -l *.zip | wc -l` && [ $$COUNT -eq 1 ] && rm -rf `ls | grep -v "\.zip$$"` | 322 @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 | 323 @#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}'` | 324 @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 empty!!) | 325 # Delete and re-create the temp directory (first, make sure it is not an empty string!) |
325 @[ -n $(UPDATE_SOURCE_DIR) ] && rm -rf $(UPDATE_SOURCE_DIR) && mkdir -p $(UPDATE_SOURCE_DIR) | 326 @[ -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 | 327 # Unzip the contents to the temp folder |
327 @cd $(UPDATE_SOURCE_DIR) && unzip -qq $(UPDATES_DIR)/*zip | 328 @cd $(UPDATE_SOURCE_DIR_BASE) && unzip -qq $(UPDATES_DIR)/*zip |
328 # Strip the top-level folder ( if there is only one ) | 329 # Strip the top-level folder ( if there is only one ) |
329 @DIR=`ls -d $(UPDATE_SOURCE_DIR)` && COUNT=`echo $$DIR | wc -l` &&\ | 330 #@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) | 331 [ $$COUNT -eq 1 ] && mv $(UPDATE_SOURCE_DIR)/* /tmp/supertemp && rm -rf $(UPDATE_SOURCE_DIR) && mv /tmp/supertemp $(UPDATE_SOURCE_DIR) |
331 # Now actually check if some key-files and folders are there | 332 # Now actually check if some key-files and folders are there |
332 @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;\ |
333 [ $$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" | |
334 UPDATE_LOG?=~/update.log | 336 UPDATE_LOG?=~/update.log |
335 LOG=>> $(UPDATE_LOG) 2>&1 | 337 LOG=>> $(UPDATE_LOG) 2>&1 |
336 update: ## Installs the update from $(UPDATES_DIR) | 338 update: ## Installs the update from $(UPDATES_DIR) |
337 update: stop | 339 update: stop |
338 # Truncate the log file | 340 # Truncate the log file |
339 @echo > $(UPDATE_LOG) | 341 @echo > $(UPDATE_LOG) |
340 # Re-perform the check, just in case ... | 342 # Re-perform the check, just in case ... |
341 # Now actually check if some key-files and folders are there | 343 # Now actually check if some key-files and folders are there |
342 @cd $(UPDATE_SOURCE_DIR) && FAIL=0 && for path in $(UPDATE_REQUIRED_PATHS); do `ls $$path >/dev/null 2>&1` || { FAIL=1; break; }; done;\ | 344 @cd $(UPDATE_SOURCE_DIR) && FAIL=0 && for path in $(UPDATE_REQUIRED_PATHS); do `ls $$path >/dev/null 2>&1` || { FAIL=1; break; }; done;\ |
343 [ $$FAIL -eq 0 ] || { echo "$$path was not found in the zip archive. Maybe it is corrupted?"; exit 1; } | 345 [ $$FAIL -eq 0 ] || { echo "$$path was not found in the zip archive. Maybe it is corrupted?"; exit 1; } |
344 # Duplicate the Bela folder $(BELA_DIR) to $(UPDATE_BELA_TEMP) | 346 # Duplicate the Bela folder $(BELA_DIR) to $(UPDATE_BELA_PATCH) ... |
345 @[ -n $(UPDATE_BELA_TEMP) ] && mkdir -p $(UPDATE_BELA_TEMP) | 347 @[ -n $(UPDATE_BELA_PATCH) ] && mkdir -p $(UPDATE_BELA_PATCH) |
346 @#TODO: this would allow to trim trailing slashes in case we want to be safer: a="`pwd`/" ; target=${a%/} ; echo $target | 348 @#TODO: this would allow to trim trailing slashes in case we want to be safer: a="`pwd`/" ; target=${a%/} ; echo $target |
347 @rsync -a --delete-before $(BELA_DIR)/ $(UPDATE_BELA_TEMP) | 349 @rsync -a --delete-before $(BELA_DIR)/ $(UPDATE_BELA_PATCH) |
348 # Also back it up in $(UPDATE_BELA_BACKUP). | 350 # Also backing it up in $(UPDATE_BELA_BACKUP)... |
349 @[ -n $(UPDATE_BELA_BACKUP) ] && mkdir -p $(UPDATE_BELA_BACKUP) | 351 @[ -n $(UPDATE_BELA_BACKUP) ] && mkdir -p $(UPDATE_BELA_BACKUP) |
350 @rsync -a $(BELA_DIR)/ $(UPDATE_BELA_BACKUP) | 352 @rsync -a $(BELA_DIR)/ $(UPDATE_BELA_BACKUP) |
351 @#TODO: add command line switch for update_board which avoids useless stuff (e.g.: setting the date, start/stop the IDE) | 353 # Here's the trick: we run "update_board" ssh'ing into the BeagleBone itself! |
352 @cd $(UPDATE_SOURCE_DIR)/scripts && BBB_ADDRESS=root@127.0.0.1 BBB_BELA_HOME=$(UPDATE_BELA_TEMP) ./update_board -y | 354 @cd $(UPDATE_SOURCE_DIR)/scripts && BBB_ADDRESS=root@127.0.0.1 BBB_BELA_HOME=$(UPDATE_BELA_PATCH) ./update_board -y --no-frills |
353 # If everything went ok, we now have the updated version of $(BELA_DIR) in $(UPDATE_BELA_TEMP) and a backup of $(BELA_DIR) in $(UPDATE_BELA_BACKUP) | 355 # 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) |
354 # So let's operate the magic swap. $(BELA_DIR) is moved to $(UPDATE_BELA_MV_BACKUP) and $(UPDATE_BELA_TEMP) is moved to $(BELA_DIR). | 356 # 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). |
355 # If something goes wrong at thie stage, you can always find your old $(BELA_DIR) folder at $(UPDATE_BELA_BACKUP) | 357 # If something goes wrong at thie stage, you can always find your old $(BELA_DIR) folder at $(UPDATE_BELA_BACKUP) |
356 # The fun part is that this Makefile is moved as well... | 358 # The fun part is that this Makefile is moved as well... |
357 # 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. | 359 # 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. |
358 # Output will be logged to $(UPDATE_LOG) | 360 # Output will be logged to $(UPDATE_LOG) |
359 @screen -S update-Bela -d -m bash -c '\ | 361 @screen -S update-Bela -d -m bash -c '\ |
360 echo so let us just make a backup of the Makefile we are working on TODO: remove this one $(LOG);\ | |
361 cp $(BELA_DIR)/Makefile /tmp/ $(LOG) &&\ | |
362 [ -n $(UPDATE_BELA_MV_BACKUP) ] $(LOG) && rm -rf $(UPDATE_BELA_MV_BACKUP) $(LOG) &&\ | 362 [ -n $(UPDATE_BELA_MV_BACKUP) ] $(LOG) && rm -rf $(UPDATE_BELA_MV_BACKUP) $(LOG) &&\ |
363 echo Kill the IDE $(LOG) && \ | 363 echo Kill the IDE $(LOG) && \ |
364 $(MAKE) --no-print-directory idestop $(LOG) &&\ | 364 $(MAKE) --no-print-directory idestop $(LOG) &&\ |
365 mv $(BELA_DIR) $(UPDATE_BELA_MV_BACKUP) $(LOG) && mv $(UPDATE_BELA_TEMP) $(BELA_DIR) $(LOG) &&\ | 365 mv $(BELA_DIR) $(UPDATE_BELA_MV_BACKUP) $(LOG) && mv $(UPDATE_BELA_PATCH) $(BELA_DIR) $(LOG) &&\ |
366 echo Hope we are still alive here $(LOG) &&\ | 366 echo Hope we are still alive here $(LOG) &&\ |
367 echo Restart the IDE $(LOG) &&\ | 367 echo Restart the IDE $(LOG) &&\ |
368 make --no-print-directory -C $(BELA_DIR) idestart $(LOG) &&\ | 368 make --no-print-directory -C $(BELA_DIR) idestart $(LOG) &&\ |
369 echo Update succesful $(LOG); \ | 369 echo Update succesful $(LOG); \ |
370 ' $(LOG) | 370 ' $(LOG) |