From 3b727b819fc46f7b020765c3c39236fb3064aafa Mon Sep 17 00:00:00 2001 From: Jason Nagin <33561705+JasonN3@users.noreply.github.com> Date: Mon, 5 May 2025 10:20:51 -0400 Subject: [PATCH] dynamically generate template --- Makefile | 32 +++++++++++------------ lorax_templates/Makefile | 4 +++ lorax_templates/install_include_post.tmpl | 20 -------------- 3 files changed, 20 insertions(+), 36 deletions(-) delete mode 100644 lorax_templates/install_include_post.tmpl diff --git a/Makefile b/Makefile index 20bc28d..284a541 100644 --- a/Makefile +++ b/Makefile @@ -27,7 +27,7 @@ export install_pkg _IMAGE_REPO_ESCAPED := $(subst /,\/,$(IMAGE_REPO)) _IMAGE_REPO_DOUBLE_ESCAPED := $(subst \,\\\,$(_IMAGE_REPO_ESCAPED)) _LORAX_ARGS := -_LORAX_TEMPLATES := $(call get_templates,install) +export _LORAX_TEMPLATES := $(call get_templates,install) install_include_post.tmpl _REPO_FILES := $(subst /etc/yum.repos.d,repos,$(REPOS)) _TEMP_DIR := $(shell mktemp -d) _TEMPLATE_VARS := ARCH IMAGE_NAME IMAGE_REPO _IMAGE_REPO_DOUBLE_ESCAPED _IMAGE_REPO_ESCAPED IMAGE_SIGNED IMAGE_TAG REPOS _RHEL VARIANT VERSION WEB_UI @@ -35,7 +35,7 @@ _VOLID := $(firstword $(subst -, ,$(IMAGE_NAME)))-$(ARCH)-$( ifeq ($(findstring redhat.repo,$(REPOS)),redhat.repo) export _RHEL := true -_LORAX_TEMPLATES += $(call get_templates,rhel) +export _LORAX_TEMPLATES += $(call get_templates,rhel) else undefine _RHEL endif @@ -53,17 +53,17 @@ _LORAX_ARGS += -i anaconda-webui endif ifneq ($(DNF_CACHE),) -_LORAX_ARGS += --cachedir $(DNF_CACHE) -_LORAX_TEMPLATES += $(call get_templates,cache) -_TEMPLATE_VARS += DNF_CACHE + _LORAX_ARGS += --cachedir $(DNF_CACHE) +export _LORAX_TEMPLATES += $(call get_templates,cache) + _TEMPLATE_VARS += DNF_CACHE endif ifneq ($(FLATPAK_DIR),) -_FLATPAK_REPO_GPG := $(shell curl -L $(FLATPAK_REMOTE_URL) | grep -i '^GPGKey=' | cut -d= -f2) + _FLATPAK_REPO_GPG := $(shell curl -L $(FLATPAK_REMOTE_URL) | grep -i '^GPGKey=' | cut -d= -f2) export _FLATPAK_REPO_URL := $(shell curl -L $(FLATPAK_REMOTE_URL) | grep -i '^URL=' | cut -d= -f2) -_LORAX_ARGS += -i flatpak-libs -_LORAX_TEMPLATES += $(call get_templates,flatpak) -_TEMPLATE_VARS += FLATPAK_DIR FLATPAK_REMOTE_NAME FLATPAK_REMOTE_REFS FLATPAK_REMOTE_URL _FLATPAK_REPO_GPG _FLATPAK_REPO_URL + _LORAX_ARGS += -i flatpak-libs +export _LORAX_TEMPLATES += $(call get_templates,flatpak) + _TEMPLATE_VARS += FLATPAK_DIR FLATPAK_REMOTE_NAME FLATPAK_REMOTE_REFS FLATPAK_REMOTE_URL _FLATPAK_REPO_GPG _FLATPAK_REPO_URL else ifneq ($(FLATPAK_REMOTE_REFS_DIR),) COLLECTED_REFS := $(foreach file,$(filter-out README.md Makefile,$(wildcard $(FLATPAK_REMOTE_REFS_DIR)/*)),$(shell cat $(file))) @@ -71,19 +71,19 @@ export FLATPAK_REMOTE_REFS += $(sort $(COLLECTED_REFS)) endif ifneq ($(FLATPAK_REMOTE_REFS),) -_FLATPAK_REPO_GPG := $(shell curl -L $(FLATPAK_REMOTE_URL) | grep -i '^GPGKey=' | cut -d= -f2) + _FLATPAK_REPO_GPG := $(shell curl -L $(FLATPAK_REMOTE_URL) | grep -i '^GPGKey=' | cut -d= -f2) export _FLATPAK_REPO_URL := $(shell curl -L $(FLATPAK_REMOTE_URL) | grep -i '^URL=' | cut -d= -f2) -_LORAX_ARGS += -i flatpak-libs -_LORAX_TEMPLATES += $(call get_templates,flatpak) \ - external/fedora-lorax-templates/ostree-based-installer/lorax-embed-flatpaks.tmpl -_TEMPLATE_VARS += FLATPAK_DIR FLATPAK_REMOTE_NAME FLATPAK_REMOTE_REFS FLATPAK_REMOTE_URL _FLATPAK_REPO_GPG _FLATPAK_REPO_URL + _LORAX_ARGS += -i flatpak-libs +export _LORAX_TEMPLATES += $(call get_templates,flatpak) \ + external/fedora-lorax-templates/ostree-based-installer/lorax-embed-flatpaks.tmpl + _TEMPLATE_VARS += FLATPAK_DIR FLATPAK_REMOTE_NAME FLATPAK_REMOTE_REFS FLATPAK_REMOTE_URL _FLATPAK_REPO_GPG _FLATPAK_REPO_URL endif endif ifneq ($(SECURE_BOOT_KEY_URL),) -_LORAX_TEMPLATES += $(call get_templates,secureboot) -_TEMPLATE_VARS += ENROLLMENT_PASSWORD +export _LORAX_TEMPLATES += $(call get_templates,secureboot) + _TEMPLATE_VARS += ENROLLMENT_PASSWORD endif _SUBDIRS := container external flatpak_refs lorax_templates repos xorriso test diff --git a/lorax_templates/Makefile b/lorax_templates/Makefile index d022767..d569a45 100644 --- a/lorax_templates/Makefile +++ b/lorax_templates/Makefile @@ -39,6 +39,10 @@ endef post_%.tmpl: scripts/post/% $(call convert_post_to_tmpl,$*,usr/share/anaconda/post-scripts/$*.ks,true) +install_include_post.tmpl: + echo '<%page />' > install_include_post.tmpl + for file in $(patsubst post_%.tmpl, %, $(filter post_%, $(notdir $(_LORAX_TEMPLATES)))); do echo "append usr/share/anaconda/interactive-defaults.ks \"%include /usr/share/anaconda/post-scripts/$${file}.ks\"" >> install_include_post.tmpl; done + install-deps: FILES=$(wildcard post_*) diff --git a/lorax_templates/install_include_post.tmpl b/lorax_templates/install_include_post.tmpl deleted file mode 100644 index c5c61f9..0000000 --- a/lorax_templates/install_include_post.tmpl +++ /dev/null @@ -1,20 +0,0 @@ -<%page args="version"/> - -<% -import os -def list_files(directory): - try: - files = os.listdir(directory) - return files - except OSError as e: - return [f"Error: {e}"] # Return error message as a list - -directory_to_list = "scripts/post" -file_list = list_files(directory_to_list) -%> - -% if int(version) >= 42: -% for file_name in file_list: -append usr/share/anaconda/interactive-defaults.ks "%include /usr/share/anaconda/post-scripts/${file_name}.ks" -% endfor -% endif \ No newline at end of file