Skip to content

Instantly share code, notes, and snippets.

@bobbyno
Created October 3, 2014 18:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bobbyno/57a3f5ce397acb5af054 to your computer and use it in GitHub Desktop.
Save bobbyno/57a3f5ce397acb5af054 to your computer and use it in GitHub Desktop.
makefile trickery
# Example of iterating over a list of projects
projects = $(shell find . -name Dockerfile -exec dirname {} \;)
graceful:
# Find all projects with a Dockerfile, then call the local-stop target
# on them before a vagrant halt. Makes faulty exits more explicit.
$(foreach p,$(projects), \
make -i -C $p local-stop ;)
vagrant halt
# Example of changing a given line of a file
props = ./buildAgent/conf/buildAgent.properties
swap = /tmp/props && mv /tmp/props $(props)
local-build: local-props build
prod-build: prod-props build
# Changes line 8 of the build agent properties file
local-props:
awk 'NR==8 {$$0="serverUrl=http://192.168.33.10:8111"} 1' $(props) > $(swap)
prod-props:
awk 'NR==8 {$$0="serverUrl=http://build.example.com:8111"} 1' $(props) > $(swap)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment