aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJake Buchholz <tomalok@gmail.com>2019-05-10 17:01:29 -0700
committerJake Buchholz <tomalok@gmail.com>2019-05-10 17:01:29 -0700
commit46d8e7dc293693e01e8ba5d6318a54b989863972 (patch)
tree35e0032e99b53849e878aae56910429f74c00dee
parent94eaa29f9a6cefb347c3d88292ca7f60700dd7fd (diff)
downloadalpine-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--Makefile16
-rw-r--r--packer.conf2
-rw-r--r--profiles/base/12
-rw-r--r--profiles/version/3.92
-rw-r--r--profiles/version/edge3
-rwxr-xr-xscripts/make-amis22
-rw-r--r--scripts/resolve-profile.py.in2
7 files changed, 31 insertions, 18 deletions
diff --git a/Makefile b/Makefile
index 2eded08..ecd467e 100644
--- a/Makefile
+++ b/Makefile
@@ -4,23 +4,27 @@ TARGET_PROFILES := $(wildcard profiles/*.conf)
4PROFILE := default 4PROFILE := default
5BUILD := 5BUILD :=
6 6
7# by default, use the 'packer' in the path
8PACKER := packer
9export PACKER
10
7.PHONY: amis clean 11.PHONY: amis clean
8 12
9amis: build build/profile build/packer.json 13amis: build build/packer.json build/profile/$(PROFILE)
10 build/make-amis $(BUILD) 14 build/make-amis $(PROFILE) $(BUILD)
11 15
12build: $(SCRIPTS) 16build: $(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
18build/profile: build build/resolve-profile.py $(CORE_PROFILES) $(TARGET_PROFILES)
19 build/resolve-profile.py $(PROFILE)
20
21build/packer.json: build packer.conf 22build/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
25build/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 = [
91post-processors = [ 91post-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
7version = "3.9" 7version = "3.9"
8release = "3.9.3" 8release = "3.9.4"
9end_of_life = null # set to "YYYY-MM-DD" when known 9end_of_life = null # set to "YYYY-MM-DD" when known
10repos { 10repos {
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
19pkgs { haveged = false }
20svcs { 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
3export PACKER=${PACKER:-packer}
4
3cd build 5cd 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) 8if [ $# -eq 0 ]; then
9 echo "Usage: $(basename $0) <profile> [ <build> ... ]" >&2
10 exit 1
11fi
12
13PROFILE=$1; shift
14
15# no build(s) specified? do all the builds!
16[ $# -gt 0 ] && BUILDS="$@" || BUILDS=$(ls profile/$PROFILE)
7 17
8for B in $BUILDS 18for B in $BUILDS
9do 19do
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
13done 27done
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]
11profile_conf = os.path.join(script_dir, '..', 'profiles', profile + '.conf') 11profile_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
14profile_dir = os.path.join(script_dir, 'profile') 14profile_dir = os.path.join(script_dir, 'profile', profile)
15 15
16builds = ConfigFactory.parse_file(profile_conf)['builds'] 16builds = ConfigFactory.parse_file(profile_conf)['builds']
17 17