diff --git a/Makefile b/Makefile index b2ca492..9ab705d 100644 --- a/Makefile +++ b/Makefile @@ -18,7 +18,7 @@ _IMAGE_REPO_ESCAPED = $(subst /,\/,$(IMAGE_REPO)) _IMAGE_REPO_DOUBLE_ESCAPED = $(subst \,\\\,$(_IMAGE_REPO_ESCAPED)) _VOLID = $(firstword $(subst -, ,$(IMAGE_NAME)))-$(ARCH)-$(IMAGE_TAG) _REPO_FILES = $(subst /etc/yum.repos.d,repos,$(REPOS)) -_LORAX_TEMPLATES = $(subst .in,,$(shell ls lorax_templates/*.tmpl.in)) +_LORAX_TEMPLATES = $(subst .in,,$(shell ls lorax_templates/*.tmpl.in)) $(foreach file,$(subst scripts/,,$(subst post/,post_,$(shell ls lorax_templates/scripts/post))),$(file).tmpl) ifeq ($(VARIANT),Server) _LORAX_ARGS = --macboot --noupgrade @@ -38,6 +38,12 @@ build/deploy.iso: boot.iso container/$(IMAGE_NAME)-$(IMAGE_TAG) xorriso/input.t implantisomd5 build/deploy.iso # Step 1: Generate Lorax Templates +lorax_templates/post_%.tmpl: lorax_templates/scripts/post/% + # Support interactive-defaults.ks + while readline -r line; echo "append usr/share/anaconda/interactive-defaults.ks \"${line}\"" >> lorax_templates/post_%.tmpl; done < lorax_templates/scripts/post/% + # Support new Anacond method + while readline -r line; echo "append usr/share/anaconda/post-scripts/configure_upgrades.ks \"${line}\"" >> lorax_templates/post_%.tmpl; done < lorax_templates/scripts/post/% + lorax_templates/%.tmpl: lorax_templates/%.tmpl.in $(eval _VARS = IMAGE_NAME IMAGE_TAG _IMAGE_REPO_DOUBLE_ESCAPED _IMAGE_REPO_ESCAPED) $(foreach var,$(_VARS),$(var)=$($(var))) envsubst '$(foreach var,$(_VARS),$$$(var))' < $(_BASE_DIR)/lorax_templates/$*.tmpl.in > $(_BASE_DIR)/lorax_templates/$*.tmpl diff --git a/lorax_templates/configure_upgrades.tmpl.in b/lorax_templates/configure_upgrades.tmpl.in deleted file mode 100644 index 6ecbd84..0000000 --- a/lorax_templates/configure_upgrades.tmpl.in +++ /dev/null @@ -1,18 +0,0 @@ -append usr/share/anaconda/interactive-defaults.ks "%post --erroronfail" -append usr/share/anaconda/interactive-defaults.ks "if (which bootc &> /dev/null)" -append usr/share/anaconda/interactive-defaults.ks "then" -append usr/share/anaconda/interactive-defaults.ks "bootc switch ${_IMAGE_REPO_ESCAPED}\/${IMAGE_NAME}:${IMAGE_TAG}" -append usr/share/anaconda/interactive-defaults.ks "else" -append usr/share/anaconda/interactive-defaults.ks "sed -i 's/container-image-reference=.*/container-image-reference=ostree-image-signed:docker:\/\/${_IMAGE_REPO_DOUBLE_ESCAPED}\/${IMAGE_NAME}:${IMAGE_TAG}/' /ostree/deploy/default/deploy/*.origin" -append usr/share/anaconda/interactive-defaults.ks "fi" -append usr/share/anaconda/interactive-defaults.ks "%end" - -append usr/share/anaconda/post-scripts/configure_upgrades.ks "%post --erroronfail" -append usr/share/anaconda/post-scripts/configure_upgrades.ks "if (which bootc &> /dev/null)" -append usr/share/anaconda/post-scripts/configure_upgrades.ks "then" -append usr/share/anaconda/post-scripts/configure_upgrades.ks "bootc switch ${_IMAGE_REPO_ESCAPED}\/${IMAGE_NAME}:${IMAGE_TAG}" -append usr/share/anaconda/post-scripts/configure_upgrades.ks "else" -append usr/share/anaconda/post-scripts/configure_upgrades.ks "sed -i 's/container-image-reference=.*/container-image-reference=ostree-image-signed:docker:\/\/${_IMAGE_REPO_DOUBLE_ESCAPED}\/${IMAGE_NAME}:${IMAGE_TAG}/' /ostree/deploy/default/deploy/*.origin" -append usr/share/anaconda/post-scripts/configure_upgrades.ks "fi" -append usr/share/anaconda/post-scripts/configure_upgrades.ks "%end" - diff --git a/lorax_templates/scripts/post/configure_upgrades b/lorax_templates/scripts/post/configure_upgrades new file mode 100644 index 0000000..6b19faa --- /dev/null +++ b/lorax_templates/scripts/post/configure_upgrades @@ -0,0 +1,6 @@ +if (which bootc &> /dev/null) +then + bootc switch ${_IMAGE_REPO_ESCAPED}\/${IMAGE_NAME}:${IMAGE_TAG} +else + sed -i 's/container-image-reference=.*/container-image-reference=ostree-image-signed:docker:\/\/${_IMAGE_REPO_DOUBLE_ESCAPED}\/${IMAGE_NAME}:${IMAGE_TAG}/' /ostree/deploy/default/deploy/*.origin +fi \ No newline at end of file