forked from pawelgrzeda/packer-templates
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
116 lines (91 loc) · 3.03 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
SHELL := /bin/bash
BRANCH_FILE := tmp/git-meta/packer-templates-branch
SHA_FILE := tmp/git-meta/packer-templates-sha
META_FILES := \
$(BRANCH_FILE) \
$(SHA_FILE) \
$(PWD)/tmp/docker-meta/.dumped \
$(PWD)/tmp/job-board-env/.dumped
SYSTEM_INFO_COMMANDS_FILES := \
packer-assets/opal-system-info-commands.yml \
packer-assets/sardonyx-system-info-commands.yml \
packer-assets/stevonnie-system-info-commands.yml \
packer-assets/ubuntu-1804-minimal-system-info-commands.yml \
packer-assets/ubuntu-1804-system-info-commands.yml
TRAVIS_COOKBOOKS_GIT := https://github.com/travis-ci/travis-cookbooks.git
TRAVIS_COMMIT_RANGE := $(shell echo $${TRAVIS_COMMIT_RANGE:-@...@})
CHEF_COOKBOOK_PATH := $(PWD)/.git::cookbooks \
$(TRAVIS_COOKBOOKS_GIT)::cookbooks@master \
$(TRAVIS_COOKBOOKS_GIT)::community-cookbooks@master \
UNAME := $(shell uname | tr '[:upper:]' '[:lower:]')
BUILDER ?= googlecompute
PACKER_VERSION ?= 1.3.3
CURL ?= curl
GIT ?= git
JQ ?= jq
PACKER ?= packer
SED ?= sed
TRAVIS_PACKER_BUILD ?= travis-packer-build
UNZIP ?= unzip
%: %.yml $(META_FILES)
$(PACKER) --version
$(PACKER) build -only=$(BUILDER) <(bin/yml2json < $<)
%-debug: %.yml $(META_FILES)
$(PACKER) --version
$(PACKER) build -only=$(BUILDER) -debug <(bin/yml2json < $<)
.PHONY: all
all: $(META_FILES) $(PHP_PACKAGES_FILE) $(SYSTEM_INFO_COMMANDS_FILES)
.PHONY: stacks-short
stacks-short:
@$(MAKE) -s stacks | sed 's/-trusty//;s/-xenial//;s/-bionic//'
.PHONY: stacks
stacks: stacks-trusty stacks-xenial
.PHONY: stacks-trusty
stacks-trusty:
@bin/list-stacks trusty
.PHONY: stacks-xenial
stacks-xenial:
@bin/list-stacks xenial
.PHONY: stacks-bionic
stacks-bionic:
@bin/list-stacks bionic
.PHONY: test
test:
./runtests --env .example.env
.PHONY: clean
clean:
$(RM) -r $(PWD)/tmp/docker-meta $(PWD)/tmp/git-meta
find packer-assets/system-info.d -type f | xargs touch
.PHONY: packer-build-trigger
packer-build-trigger:
bin/packer-build-trigger
.PHONY: packer-build-trigger-all-ci
packer-build-trigger-all-ci:
bin/packer-build-trigger $(shell for f in ci-*.yml ; do echo -I $$f ; done)
.PHONY: install-packer
install-packer: tmp/packer.zip
mkdir -p ~/bin
$(UNZIP) -o -d ~/bin $<
chmod +x ~/bin/packer
.PHONY: install-bats
install-bats: tmp/bats/.git
cd tmp/bats && ./install.sh $$HOME
.PHONY: update-gce-images
update-gce-images:
bin/gce-image-update $$(git grep -lE 'source_image: ubuntu' *.yml)
tmp/packer.zip:
$(CURL) -sSLo $@ 'https://releases.hashicorp.com/packer/$(PACKER_VERSION)/packer_$(PACKER_VERSION)_$(UNAME)_amd64.zip'
tmp/bats/.git:
$(GIT) clone https://github.com/sstephenson/bats.git tmp/bats
tmp:
mkdir -p tmp/packer-builder-tmp
$(META_FILES): .git/HEAD
./bin/dump-git-meta ./tmp/git-meta
./bin/write-envdir $(PWD)/tmp/docker-meta 'DOCKER_LOGIN_(USERNAME|PASSWORD|SERVER)'
./bin/write-envdir $(PWD)/tmp/job-board-env 'JOB_BOARD'
packer-assets/%-system-info-commands.yml: $(wildcard packer-assets/system-info.d/*.yml)
chmod 0600 $@
./bin/generate-system-info-commands \
$(shell echo $@ | sed 's,packer-assets/,,;s,-system-info-commands.yml,,') \
>$@
chmod 0400 $@