Skip to content

Commit f63dc9d

Browse files
committed
Add generate-all capability
1 parent 6236673 commit f63dc9d

File tree

4 files changed

+59
-21
lines changed

4 files changed

+59
-21
lines changed

Diff for: clean.sh

+2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#! /bin/sh
22

33
set -e
4+
test -f auto_targets.mk && rm auto_targets.mk
5+
46
for version
57
do
68
remove_images=

Diff for: common.mk

+4-19
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ build = $(SHELL) $(common_dir)/build.sh
1313
test = $(SHELL) $(common_dir)/test.sh
1414
tag = $(SHELL) $(common_dir)/tag.sh
1515
clean = $(SHELL) $(common_dir)/clean.sh
16-
generator = $(SHELL) $(common_dir)/generate.sh
1716

1817
ifeq ($(TARGET),rhel7)
1918
SKIP_SQUASH ?= 0
@@ -30,13 +29,11 @@ else ifeq ($(TARGET),centos6)
3029
else
3130
OS := centos7
3231
DOCKERFILE ?= Dockerfile
33-
DG_CONF ?= centos-7-x86_64.yaml
32+
DG_CONF := centos-7-x86_64.yaml
3433
endif
3534

3635
SKIP_SQUASH ?= 1
3736
DOCKER_BUILD_CONTEXT ?= .
38-
DISTGEN_BIN ?= /usr/bin/dg
39-
MANIFEST_FILE ?= manifest.sh
4037

4138
script_env = \
4239
SKIP_SQUASH=$(SKIP_SQUASH) \
@@ -47,11 +44,6 @@ script_env = \
4744
OPENSHIFT_NAMESPACES="$(OPENSHIFT_NAMESPACES)" \
4845
CUSTOM_REPO="$(CUSTOM_REPO)"
4946

50-
generation_env = \
51-
DG_CONF=$(DG_CONF) \
52-
DG=$(DISTGEN_BIN) \
53-
MANIFEST_FILE=$(MANIFEST_FILE)
54-
5547
# TODO: switch to 'build: build-all' once parallel builds are relatively safe
5648
.PHONY: build build-serial build-all
5749
build: build-serial
@@ -99,14 +91,7 @@ clean:
9991

10092
.PHONY: generate
10193
generate:
102-
@$(MAKE) auto_targets.mk
103-
@$(MAKE) exec-gen-rules
104-
rm auto_targets.mk
105-
106-
auto_targets.mk: $(generator) $(MANIFEST_FILE)
107-
VERSIONS="$(VERSIONS)" $(generation_env) $(generator)
108-
109-
include auto_targets.mk
94+
$(MAKE) VERSIONS="$(VERSIONS)" DG_CONF=$(DG_CONF) -f $(common_dir)/gen.mk gen
11095

111-
.PHONY: exec-gen-rules
112-
exec-gen-rules: $(DISTGEN_TARGETS) $(COPY_TARGETS) $(SYMLINK_TARGETS)
96+
generate-all:
97+
$(MAKE) VERSIONS="$(VERSIONS)" DG_CONF="rhel-7-x86_64.yaml fedora-27-x86_64.yaml centos-7-x86_64.yaml" -f $(common_dir)/gen.mk gen

Diff for: gen.mk

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Helper for generating image repository files
2+
3+
ifndef common_dir
4+
common_dir = common
5+
endif
6+
7+
generator = $(common_dir)/generate.sh
8+
# default path for dg binary from package distgen
9+
DISTGEN_BIN ?= /usr/bin/dg
10+
MANIFEST_FILE ?= manifest.sh
11+
12+
generation_env = \
13+
DG=$(DISTGEN_BIN) \
14+
MANIFEST_FILE=$(MANIFEST_FILE)
15+
16+
.PHONY: gen
17+
gen: auto_targets.mk exec-gen-rules
18+
rm auto_targets.mk
19+
20+
21+
auto_targets.mk: $(generator) $(MANIFEST_FILE)
22+
VERSIONS="$(VERSIONS)" DG_CONF="$(DG_CONF)" $(generation_env) $(generator)
23+
24+
include auto_targets.mk
25+
26+
.PHONY: exec-gen-rules
27+
exec-gen-rules: $(DISTGEN_TARGETS) $(COPY_TARGETS) $(SYMLINK_TARGETS)

Diff for: generate.sh

+26-2
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,31 @@ parse_rules() {
4747
distgen)
4848
[[ -z "$src" ]] && echo "src has to be specified in distgen rule" && exit 1
4949
[[ -z "$dest" ]] && echo "dest has to be specified in distgen rule" && exit 1
50-
core_subst=$core
50+
51+
if [[ "$dest" == "Dockerfile"* ]]; then
52+
if [[ "$dest" == "Dockerfile.rhel7" ]]; then
53+
if [[ "$DG_CONF" == *"rhel-7-x86_64.yaml"* ]]; then
54+
conf=rhel-7-x86_64.yaml
55+
else
56+
continue
57+
fi
58+
elif [[ "$dest" == *"Dockerfile.fedora" ]]; then
59+
if [[ "$DG_CONF" == *"fedora-27-x86_64.yaml"* ]]; then
60+
conf=fedora-27-x86_64.yaml
61+
else
62+
continue
63+
fi
64+
elif [[ "$dest" == *"Dockerfile" ]]; then
65+
if [[ "$DG_CONF" == *"centos-7-x86_64.yaml"* ]]; then
66+
conf=centos-7-x86_64.yaml
67+
else
68+
continue
69+
fi
70+
fi
71+
else
72+
conf=centos-7-x86_64.yaml
73+
fi
74+
core_subst=$(echo $core | sed -e "s~__conf__~"${conf}"~g")
5175
;;
5276
link)
5377
[[ -z "$link_name" ]] && echo "link_name has to be specified in link rule" && exit 1
@@ -85,7 +109,7 @@ for version in ${VERSIONS}; do
85109
# distgen targets
86110
rules="$DISTGEN_RULES"
87111
core="${DG} --multispec specs/multispec.yml \\
88-
--template \"\$<\" --distro \"$DG_CONF\" \\
112+
--template \"\$<\" --distro \"__conf__\" \\
89113
--multispec-selector version=\"$version\" --output \"\$@\" ; \\"
90114
message="Generating \"\$@\" using distgen"
91115
creator="distgen"

0 commit comments

Comments
 (0)