Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use distgen to get distro and version combinations #75

Merged
merged 1 commit into from
Apr 18, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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