Skip to content

Commit

Permalink
Use distgen to get distro and version combinations
Browse files Browse the repository at this point in the history
Isolate distgen multi rules that are used for each (distro, version)
combination not excluded in multispec, Use output of distgen's
--multispec-combinations flag to get the rigth versions and distros

Required-by: postgresql-container#266
  • Loading branch information
mcyprian authored and pkubatrh committed Apr 18, 2018
1 parent 6b9d2d7 commit 2c28a31
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 25 deletions.
2 changes: 1 addition & 1 deletion gen.mk
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ auto_targets.mk: $(generator) $(MANIFEST_FILE)
include auto_targets.mk

.PHONY: exec-gen-rules
exec-gen-rules: $(DISTGEN_TARGETS) $(COPY_TARGETS) $(SYMLINK_TARGETS)
exec-gen-rules: $(DISTGEN_TARGETS) $(DISTGEN_MULTI_TARGETS) $(COPY_TARGETS) $(SYMLINK_TARGETS)
66 changes: 42 additions & 24 deletions generate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ test -f auto_targets.mk && rm auto_targets.mk

DESTDIR="${DESTDIR:-$PWD}"

DISTGEN_COMBINATIONS=$(${DG} --multispec specs/multispec.yml --multispec-combinations)

clean_rule_variables(){
src=""
dest=""
Expand Down Expand Up @@ -47,32 +49,27 @@ parse_rules() {
distgen)
[[ -z "$src" ]] && echo "src has to be specified in distgen rule" && exit 1
[[ -z "$dest" ]] && echo "dest has to be specified in distgen rule" && exit 1
core_subst=$core
;;
distgen_multi)
[[ -z "$src" ]] && echo "src has to be specified in distgen rule" && exit 1
[[ -z "$dest" ]] && echo "dest has to be specified in distgen rule" && exit 1

if [[ "$dest" == "Dockerfile"* ]]; then
if [[ "$dest" == "Dockerfile.rhel7" ]]; then
if [[ "$DG_CONF" == *"rhel-7-x86_64.yaml"* ]]; then
conf=rhel-7-x86_64.yaml
else
continue
fi
elif [[ "$dest" == *"Dockerfile.fedora" ]]; then
if [[ "$DG_CONF" == *"fedora-27-x86_64.yaml"* ]]; then
conf=fedora-27-x86_64.yaml
else
continue
fi
elif [[ "$dest" == *"Dockerfile" ]]; then
if [[ "$DG_CONF" == *"centos-7-x86_64.yaml"* ]]; then
conf=centos-7-x86_64.yaml
else
continue
fi
if [[ "$dest" == "Dockerfile.rhel7" ]]; then
if ! [[ "$DG_CONF" =~ rhel-[0-9]{,2}-x86_64.yaml ]]; then
continue
fi
elif [[ "$dest" == *"Dockerfile.fedora" ]]; then
if ! [[ "$DG_CONF" =~ fedora-[0-9]{,2}-x86_64.yaml ]]; then
continue
fi
elif [[ "$dest" == *"Dockerfile" ]]; then
if ! [[ "$DG_CONF" =~ centos-[0-9]{,2}-x86_64.yaml ]]; then
continue
fi
else
conf=centos-7-x86_64.yaml
fi
core_subst=$(echo $core | sed -e "s~__conf__~"${conf}"~g")
;;
core_subst=$core
;;
link)
[[ -z "$link_name" ]] && echo "link_name has to be specified in link rule" && exit 1
[[ -z "$link_target" ]] && echo "link_target has to be specified in link rule" && exit 1
Expand Down Expand Up @@ -109,7 +106,7 @@ for version in ${VERSIONS}; do
# distgen targets
rules="$DISTGEN_RULES"
core="${DG} --multispec specs/multispec.yml \\
--template \"\$<\" --distro \"__conf__\" \\
--template \"\$<\" --distro centos-7-x86_64.yaml \\
--multispec-selector version=\"$version\" --output \"\$@\" ; \\"
message="Generating \"\$@\" using distgen"
creator="distgen"
Expand All @@ -125,6 +122,21 @@ for version in ${VERSIONS}; do
SYMLINK_TARGETS+="$targets"
done

while read -r combination; do
version=${combination##*=}
DG_CONF=$(echo $combination | cut -d' ' -f2)
# distgen multi targets
rules="$DISTGEN_MULTI_RULES"
core="${DG} --multispec specs/multispec.yml \\
--template \"\$<\" \\
--output \"\$@\" \\
$combination ; \\"
message="Generating \"\$@\" using distgen"
creator="distgen_multi"
parse_rules
DISTGEN_MULTI_TARGETS+="$targets"
done <<< ${DISTGEN_COMBINATIONS}

# adding COPY_TARGETS variable at the bottom of auto_targets.mk file
cat -v >> auto_targets.mk << EOF
COPY_TARGETS = \\
Expand All @@ -135,6 +147,12 @@ EOF
cat -v >> auto_targets.mk << EOF
DISTGEN_TARGETS = \\
$DISTGEN_TARGETS
EOF

# adding DISTGEN_MULTI_TARGETS variable at the bottom of auto_targets.mk file
cat -v >> auto_targets.mk << EOF
DISTGEN_MULTI_TARGETS = \\
$DISTGEN_MULTI_TARGETS
EOF

cat -v >> auto_targets.mk << EOF
Expand Down

0 comments on commit 2c28a31

Please sign in to comment.