diff options
author | Jake Buchholz <tomalok@gmail.com> | 2019-05-10 17:01:29 -0700 |
---|---|---|
committer | Jake Buchholz <tomalok@gmail.com> | 2019-05-10 17:01:29 -0700 |
commit | 46d8e7dc293693e01e8ba5d6318a54b989863972 (patch) | |
tree | 35e0032e99b53849e878aae56910429f74c00dee | |
parent | 94eaa29f9a6cefb347c3d88292ca7f60700dd7fd (diff) | |
download | alpine-ec2-ami-feature/build_profiles.tar.bz2 alpine-ec2-ami-feature/build_profiles.tar.xz alpine-ec2-ami-feature/build_profiles.zip |
Update release & fix a couple bugsfeature/build_profiles
* 3.9.4 is released, update core profiles
* fix consecutive make with different profiles
+ 'make PROFILE=a; make PROFILE=b' would make 'a' builds twice
+ build/profile --> build/profile/$PROFILE
* 'make PACKER=path-to-packer-bin ...' allows use of alternate packer, defaults to what's in $PATH
+ needed this to test out pre-1.4.1 packer binaries
-rw-r--r-- | Makefile | 16 | ||||
-rw-r--r-- | packer.conf | 2 | ||||
-rw-r--r-- | profiles/base/1 | 2 | ||||
-rw-r--r-- | profiles/version/3.9 | 2 | ||||
-rw-r--r-- | profiles/version/edge | 3 | ||||
-rwxr-xr-x | scripts/make-amis | 22 | ||||
-rw-r--r-- | scripts/resolve-profile.py.in | 2 |
7 files changed, 31 insertions, 18 deletions
@@ -4,23 +4,27 @@ TARGET_PROFILES := $(wildcard profiles/*.conf) | |||
4 | PROFILE := default | 4 | PROFILE := default |
5 | BUILD := | 5 | BUILD := |
6 | 6 | ||
7 | # by default, use the 'packer' in the path | ||
8 | PACKER := packer | ||
9 | export PACKER | ||
10 | |||
7 | .PHONY: amis clean | 11 | .PHONY: amis clean |
8 | 12 | ||
9 | amis: build build/profile build/packer.json | 13 | amis: build build/packer.json build/profile/$(PROFILE) |
10 | build/make-amis $(BUILD) | 14 | build/make-amis $(PROFILE) $(BUILD) |
11 | 15 | ||
12 | build: $(SCRIPTS) | 16 | build: $(SCRIPTS) |
13 | [ -d build ] || mkdir build | 17 | [ -d build/profile ] || mkdir -p build/profile |
14 | python3 -m venv build/.py3 | 18 | python3 -m venv build/.py3 |
15 | build/.py3/bin/pip install pyhocon pyyaml boto3 | 19 | build/.py3/bin/pip install pyhocon pyyaml boto3 |
16 | (cd build; for i in $(ALL_SCRIPTS); do ln -sf ../$$i .; done) | 20 | (cd build; for i in $(ALL_SCRIPTS); do ln -sf ../$$i .; done) |
17 | 21 | ||
18 | build/profile: build build/resolve-profile.py $(CORE_PROFILES) $(TARGET_PROFILES) | ||
19 | build/resolve-profile.py $(PROFILE) | ||
20 | |||
21 | build/packer.json: build packer.conf | 22 | build/packer.json: build packer.conf |
22 | build/.py3/bin/pyhocon -i packer.conf -f json > build/packer.json | 23 | build/.py3/bin/pyhocon -i packer.conf -f json > build/packer.json |
23 | 24 | ||
25 | build/profile/$(PROFILE): build build/resolve-profile.py $(CORE_PROFILES) $(TARGET_PROFILES) | ||
26 | build/resolve-profile.py $(PROFILE) | ||
27 | |||
24 | %.py: %.py.in build | 28 | %.py: %.py.in build |
25 | sed "s|@PYTHON@|#!`pwd`/build/.py3/bin/python|" $< > $@ | 29 | sed "s|@PYTHON@|#!`pwd`/build/.py3/bin/python|" $< > $@ |
26 | chmod +x $@ | 30 | chmod +x $@ |
diff --git a/packer.conf b/packer.conf index 685c9e1..dd669c4 100644 --- a/packer.conf +++ b/packer.conf | |||
@@ -91,7 +91,7 @@ provisioners = [ | |||
91 | post-processors = [ | 91 | post-processors = [ |
92 | { | 92 | { |
93 | type = "manifest" | 93 | type = "manifest" |
94 | output = "profile/{{user `profile_build`}}/manifest.json" | 94 | output = "profile/{{user `profile`}}/{{user `profile_build`}}/manifest.json" |
95 | custom_data { | 95 | custom_data { |
96 | profile = "{{user `profile`}}" | 96 | profile = "{{user `profile`}}" |
97 | build = "{{user `profile_build`}}" | 97 | build = "{{user `profile_build`}}" |
diff --git a/profiles/base/1 b/profiles/base/1 index abd1413..17b66b2 100644 --- a/profiles/base/1 +++ b/profiles/base/1 | |||
@@ -45,7 +45,6 @@ pkgs { | |||
45 | linux-virt = true | 45 | linux-virt = true |
46 | alpine-mirrors = true | 46 | alpine-mirrors = true |
47 | chrony = true | 47 | chrony = true |
48 | haveged = true | ||
49 | nvme-cli = true | 48 | nvme-cli = true |
50 | openssh = true | 49 | openssh = true |
51 | sudo = true | 50 | sudo = true |
@@ -59,7 +58,6 @@ svcs { | |||
59 | mdev = "sysinit" | 58 | mdev = "sysinit" |
60 | acpid = "boot" | 59 | acpid = "boot" |
61 | bootmisc = "boot" | 60 | bootmisc = "boot" |
62 | haveged = "boot" | ||
63 | hostname = "boot" | 61 | hostname = "boot" |
64 | hwclock = "boot" | 62 | hwclock = "boot" |
65 | modules = "boot" | 63 | modules = "boot" |
diff --git a/profiles/version/3.9 b/profiles/version/3.9 index 3d950e0..5288c16 100644 --- a/profiles/version/3.9 +++ b/profiles/version/3.9 | |||
@@ -5,7 +5,7 @@ include "../base/current" | |||
5 | 5 | ||
6 | # set version-specific vars | 6 | # set version-specific vars |
7 | version = "3.9" | 7 | version = "3.9" |
8 | release = "3.9.3" | 8 | release = "3.9.4" |
9 | end_of_life = null # set to "YYYY-MM-DD" when known | 9 | end_of_life = null # set to "YYYY-MM-DD" when known |
10 | repos { | 10 | repos { |
11 | "http://dl-cdn.alpinelinux.org/alpine/v3.9/main": true | 11 | "http://dl-cdn.alpinelinux.org/alpine/v3.9/main": true |
diff --git a/profiles/version/edge b/profiles/version/edge index 13195fe..5fe3da7 100644 --- a/profiles/version/edge +++ b/profiles/version/edge | |||
@@ -15,6 +15,3 @@ repos { | |||
15 | "http://dl-cdn.alpinelinux.org/alpine/edge/community": true | 15 | "http://dl-cdn.alpinelinux.org/alpine/edge/community": true |
16 | "http://dl-cdn.alpinelinux.org/alpine/edge/testing": true | 16 | "http://dl-cdn.alpinelinux.org/alpine/edge/testing": true |
17 | } | 17 | } |
18 | # haveged/rngd no longer needed with Alpine kernels >= 4.19.36 | ||
19 | pkgs { haveged = false } | ||
20 | svcs { haveged = false } | ||
diff --git a/scripts/make-amis b/scripts/make-amis index e0a699e..0f18add 100755 --- a/scripts/make-amis +++ b/scripts/make-amis | |||
@@ -1,13 +1,27 @@ | |||
1 | #!/bin/sh | 1 | #!/bin/sh |
2 | 2 | ||
3 | export PACKER=${PACKER:-packer} | ||
4 | |||
3 | cd build | 5 | cd build |
4 | 6 | ||
5 | # if no build(s) specified, do all profile's builds! | 7 | # we need a profile |
6 | [ $# -gt 0 ] && BUILDS="$@" || BUILDS=$(ls profile) | 8 | if [ $# -eq 0 ]; then |
9 | echo "Usage: $(basename $0) <profile> [ <build> ... ]" >&2 | ||
10 | exit 1 | ||
11 | fi | ||
12 | |||
13 | PROFILE=$1; shift | ||
14 | |||
15 | # no build(s) specified? do all the builds! | ||
16 | [ $# -gt 0 ] && BUILDS="$@" || BUILDS=$(ls profile/$PROFILE) | ||
7 | 17 | ||
8 | for B in $BUILDS | 18 | for B in $BUILDS |
9 | do | 19 | do |
10 | BUILD="profile/$B" | 20 | BUILD="profile/$PROFILE/$B" |
11 | ( packer build -var-file=$BUILD/vars.json packer.json; echo $? >$BUILD/exit ) | tee $BUILD/output | 21 | ( "$PACKER" build -var-file=$BUILD/vars.json packer.json; echo $? >$BUILD/exit ) | tee $BUILD/output |
12 | echo "=-> $(cat $BUILD/exit) <-=" | 22 | echo "=-> $(cat $BUILD/exit) <-=" |
23 | # TODO: check exit & output | ||
24 | # - AMI already exist? continue in case other builds need building | ||
25 | # - New release for version? maybe update release var and try again? | ||
26 | # - SIGINT or unknown issue? cleanup / exit | ||
13 | done | 27 | done |
diff --git a/scripts/resolve-profile.py.in b/scripts/resolve-profile.py.in index 050da00..433a72e 100644 --- a/scripts/resolve-profile.py.in +++ b/scripts/resolve-profile.py.in | |||
@@ -11,7 +11,7 @@ profile = sys.argv[1] | |||
11 | profile_conf = os.path.join(script_dir, '..', 'profiles', profile + '.conf') | 11 | profile_conf = os.path.join(script_dir, '..', 'profiles', profile + '.conf') |
12 | 12 | ||
13 | # where we store profile's builds | 13 | # where we store profile's builds |
14 | profile_dir = os.path.join(script_dir, 'profile') | 14 | profile_dir = os.path.join(script_dir, 'profile', profile) |
15 | 15 | ||
16 | builds = ConfigFactory.parse_file(profile_conf)['builds'] | 16 | builds = ConfigFactory.parse_file(profile_conf)['builds'] |
17 | 17 | ||