From f44ddc1838bfd64fcc3d34b0976527a9afe75e9c Mon Sep 17 00:00:00 2001 From: Jason Hildebrand Date: Tue, 20 Sep 2022 13:02:41 -0500 Subject: [PATCH] Makefile: Abstract how we call sed, for compatibility with both Linux and OSX. Also fix sed call so that it is idempotent. --- Makefile | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/Makefile b/Makefile index 22e9fa98e..bcd6e1025 100644 --- a/Makefile +++ b/Makefile @@ -6,6 +6,14 @@ ENV_FILE=$(shell \ fi; \ echo .env) +# handle sed -i differences (see https://stackoverflow.com/a/4247319/3204023 for more context) +ifeq ($(shell uname -s),Darwin) + SED_DASH_I=sed -i '' +else # GNU/Linux + SED_DASH_I=sed -i +endif + + # If custom.makefile exists include it. -include custom.Makefile @@ -369,15 +377,9 @@ demo_content: # if prod do this by default # if [ -d "islandora_workbench" ]; then rm -rf islandora_workbench; fi [ -d "islandora_workbench" ] || (git clone -b new_staging --single-branch https://github.com/DonRichards/islandora_workbench) -ifeq ($(shell uname -s),Linux) - sed -i 's/^nopassword.*/password\: $(shell cat secrets/live/DRUPAL_DEFAULT_ACCOUNT_PASSWORD) /g' islandora_workbench/demoBDcreate* - sed -i 's/http:/https:/g' islandora_workbench/demoBDcreate* -endif -ifeq ($(shell uname -s),Darwin) - sed -i '' 's/^nopassword.*/password\: $(shell cat secrets/live/DRUPAL_DEFAULT_ACCOUNT_PASSWORD) /g' islandora_workbench/demoBDcreate* - sed -i '' 's/http:/https:/g' islandora_workbench/demoBDcreate* -endif - sed -i '' 's/author_email\="mjordan@sfu"\,/author_email="mjordan@sfu", packages=["i7Import", "i8demo_BD", "input_data"],/g' islandora_workbench/setup.py + $(SED_DASH_I) 's/^nopassword.*/password\: $(shell cat secrets/live/DRUPAL_DEFAULT_ACCOUNT_PASSWORD) /g' islandora_workbench/demoBDcreate* + $(SED_DASH_I) 's/http:/https:/g' islandora_workbench/demoBDcreate* + $(SED_DASH_I) 's/author_email\="mjordan@sfu"\,$$/author_email="mjordan@sfu", packages=["i7Import", "i8demo_BD", "input_data"],/g' islandora_workbench/setup.py cd islandora_workbench && docker build -t workbench-docker . cd islandora_workbench && docker run -it --rm --network="host" -v $(shell pwd)/islandora_workbench:/workbench --name my-running-workbench workbench-docker bash -lc "(cd /workbench && python setup.py install 2>&1 && ./workbench --config demoBDcreate_all_localhost.yml)" $(MAKE) reindex-solr @@ -518,4 +520,4 @@ fix_masonry: ## This fixes a know issues with views when using the make local build. The error must be triggered before this will work. fix_views: docker cp scripts/patch_views.sh $$(docker ps --format "{{.Names}}" | grep drupal):/var/www/drupal/patch_views.sh - docker-compose exec -T drupal with-contenv bash -lc "bash /var/www/drupal/patch_views.sh ; rm /var/www/drupal/patch_views.sh ; drush cr" \ No newline at end of file + docker-compose exec -T drupal with-contenv bash -lc "bash /var/www/drupal/patch_views.sh ; rm /var/www/drupal/patch_views.sh ; drush cr"