From a6aeab7ac9cc5db7542d5ced1dc9410d9132064b Mon Sep 17 00:00:00 2001 From: "Jason N." <33561705+JasonN3@users.noreply.github.com> Date: Wed, 27 Mar 2024 11:39:03 -0400 Subject: [PATCH] fixes --- .github/workflows/test_iso.yml | 6 ++-- Makefile | 50 ++++++++++++++++------------------ action.yml | 1 - entrypoint.sh | 19 ++++++------- lorax_templates/Makefile | 5 ++-- repos/Makefile | 9 +++--- test/Makefile | 10 ++++--- xorriso/Makefile | 10 +++---- xorriso/gen_input.sh | 19 +++++++++---- 9 files changed, 66 insertions(+), 63 deletions(-) diff --git a/.github/workflows/test_iso.yml b/.github/workflows/test_iso.yml index efcf873..ec37f6c 100644 --- a/.github/workflows/test_iso.yml +++ b/.github/workflows/test_iso.yml @@ -89,8 +89,7 @@ jobs: - name: Run ISO checks run: | - mv ${{ inputs[format('iso_name-{0}', matrix.version)] }} deploy.iso - make test-iso \ + make test/iso \ ARCH=${{ needs.load_vars.outputs.ARCH}} \ IMAGE_NAME=${{ needs.load_vars.outputs.IMAGE_NAME}} \ IMAGE_REPO=${{ needs.load_vars.outputs.IMAGE_REPO}} \ @@ -99,7 +98,8 @@ jobs: VARIANT=${{ needs.load_vars.outputs.VARIANT }} \ FLATPAK_REMOTE_REFS_DIR=${{ needs.load_vars.outputs.FLATPAK_REMOTE_REFS_DIR }} \ SECURE_BOOT_KEY_URL=${{ needs.load_vars.outputs.SECURE_BOOT_KEY_URL }} \ - ENROLLMENT_PASSWORD=${{ needs.load_vars.outputs.ENROLLMENT_PASSWORD }} + ENROLLMENT_PASSWORD=${{ needs.load_vars.outputs.ENROLLMENT_PASSWORD }} \ + ISO_NAME=${{ inputs[format('iso_name-{0}', matrix.version)] }} - name: Set status if: inputs.pr && always() diff --git a/Makefile b/Makefile index 83ab500..2907b80 100644 --- a/Makefile +++ b/Makefile @@ -7,7 +7,7 @@ export EXTRA_BOOT_PARAMS = export IMAGE_NAME = base export IMAGE_REPO = quay.io/fedora-ostree-desktops export IMAGE_TAG = $(VERSION) -REPOS = $(subst :,\:,$(shell ls /etc/yum.repos.d/*.repo)) +REPOS = $(subst :,\:,$(wildcard /etc/yum.repos.d/*.repo)) export ROOTFS_SIZE = 4 export VARIANT = Server export VERSION = 39 @@ -21,10 +21,12 @@ export FLATPAK_DIR = # Secure boot export ENROLLMENT_PASSWORD = export SECURE_BOOT_KEY_URL = +export ISO_NAME = $(_BASE_DIR)/build/deploy.iso ################### # Hidden vars +SHELL = /bin/sh # Cache export DNF_CACHE = export PACKAGE_MANAGER = dnf @@ -33,12 +35,14 @@ export PACKAGE_MANAGER = dnf ## Formatting = lowercase # Get a list of templates for the feature # $1 = feature -get_templates = $(shell ls lorax_templates/$(1)_*.tmpl) \ - $(foreach file,$(notdir $(shell ls lorax_templates/scripts/post/$(1)_*)),lorax_templates/post_$(file).tmpl) +define get_templates + $(wildcard lorax_templates/$(1)_*.tmpl) + $(foreach file,$(notdir $(wildcard lorax_templates/scripts/post/$(1)_*)),lorax_templates/post_$(file).tmpl) +endef # Generated/internal vars ## Formatting = _UPPERCASE -_BASE_DIR = $(shell pwd) +export _BASE_DIR = $(shell pwd) _IMAGE_REPO_ESCAPED = $(subst /,\/,$(IMAGE_REPO)) _IMAGE_REPO_DOUBLE_ESCAPED = $(subst \,\\\,$(_IMAGE_REPO_ESCAPED)) _LORAX_ARGS = @@ -104,21 +108,18 @@ _SUBDIRS = container external flatpak_refs lorax_templates repos xorriso # Step 7: Build end ISO ## Default action -build/deploy.iso: boot.iso container/$(IMAGE_NAME)-$(IMAGE_TAG) xorriso/input.txt +build/deploy.iso: results/images/boot.iso container/$(IMAGE_NAME)-$(IMAGE_TAG) xorriso/input.txt mkdir $(_BASE_DIR)/build || true xorriso -dialog on < $(_BASE_DIR)/xorriso/input.txt - implantisomd5 build/deploy.iso + implantisomd5 $(ISO_NAME) # Step 3: Build boot.iso using Lorax -boot.iso: external/lorax/branch-$(VERSION) $(filter lorax_templates/%,$(_LORAX_TEMPLATES)) $(_REPO_FILES) - rm -Rf $(_BASE_DIR)/results || true +results/images/boot.iso: external/lorax/branch-$(VERSION) $(filter lorax_templates/%,$(_LORAX_TEMPLATES)) $(_REPO_FILES) + $(if $(wildcard results), rm -Rf results) mv /etc/rpm/macros.image-language-conf $(_TEMP_DIR)/macros.image-language-conf || true - # Download the secure boot key - if [ -n "$(SECURE_BOOT_KEY_URL)" ]; \ - then \ - curl --fail -L -o $(_BASE_DIR)/sb_pubkey.der $(SECURE_BOOT_KEY_URL); \ - fi +# Download the secure boot key + $(if $(SECURE_BOOT_KEY_URL), curl --fail -L -o $(_BASE_DIR)/sb_pubkey.der $(SECURE_BOOT_KEY_URL)) lorax -p $(IMAGE_NAME) -v $(VERSION) -r $(VERSION) -t $(VARIANT) \ --isfinal --squashfs-only --buildarch=$(ARCH) --volid=$(_VOLID) --sharedir $(_BASE_DIR)/external/lorax/share/templates.d/99-generic \ @@ -131,32 +132,29 @@ boot.iso: external/lorax/branch-$(VERSION) $(filter lorax_templates/%,$(_LORAX_T --rootfs-size $(ROOTFS_SIZE) \ $(foreach var,$(_TEMPLATE_VARS),--add-template-var "$(shell echo $(var) | tr '[:upper:]' '[:lower:]')=$($(var))") \ $(_BASE_DIR)/results/ - mv $(_BASE_DIR)/results/images/boot.iso $(_BASE_DIR)/ mv -f $(_TEMP_DIR)/macros.image-language-conf /etc/rpm/macros.image-language-conf || true FILES_TO_CLEAN = $(wildcard build debugdata pkglists results original-pkgsizes.txt final-pkgsizes.txt lorax.conf *.iso *log) +.PHONY: clean clean: rm -Rf $(FILES_TO_CLEAN) - $(foreach DIR,$(_SUBDIRS),$(MAKE) -C $(DIR) clean;) + $(foreach DIR,$(_SUBDIRS),$(MAKE) -w -C $(DIR) clean;) +.PHONY: install-deps install-deps: - if [ "$(PACKAGE_MANAGER)" =~ apt.* ]; then $(PACKAGE_MANAGER) update; fi + $(if $(findstring apt,$(PACKAGE_MANAGER)),$(PACKAGE_MANAGER) update) $(PACKAGE_MANAGER) install -y lorax xorriso coreutils gettext - $(foreach DIR,$(_SUBDIRS),$(MAKE) -C $(DIR) install-deps;) + $(foreach DIR,$(_SUBDIRS),$(MAKE) -w -C $(DIR) install-deps;) -test-vm: ansible_inventory - -_SUBMAKES = $(_SUBDIRS) test $(filter-out README.md Makefile,$(wildcard test/*)) $(filter-out README.md Makefile,$(wildcard test/*/*)) -$(_SUBMAKES): +.PHONY: $(_SUBDIRS) test $(wildcard test/*) $(wildcard test/*/*) +test $(addsuffix /*,$(_SUBDIRS) test): $(eval DIR=$(firstword $(subst /, ,$@))) - $(eval TARGET=$(subst $(DIR)/,,$@)) + $(if $(filter-out $(DIR),$@), $(eval TARGET=$(subst $(DIR)/,,$@)),$(eval TARGET=)) $(MAKE) -w -C $(DIR) $(TARGET) -$(addsuffix /%,$(_SUBMAKES)): +.DEFAULT: $(eval DIR=$(firstword $(subst /, ,$@))) - $(eval TARGET=$(subst $(DIR)/,,$@)) + $(if $(filter-out $(DIR),$@), $(eval TARGET=$(subst $(DIR)/,,$@)),$(eval TARGET=)) $(MAKE) -w -C $(DIR) $(TARGET) - -.PHONY: clean install-deps $(_SUBMAKES) test diff --git a/action.yml b/action.yml index c856f54..62e8374 100644 --- a/action.yml +++ b/action.yml @@ -148,7 +148,6 @@ runs: DIR_REFS=$(cat ${{ inputs.flatpak_remote_refs_dir }}/* | tr '\n' ' ' ) # Generate install script cat << EOF > ${{ github.workspace }}/${FLATPAK_DIR}/script.sh - cat /flatpak_dir/script.sh mkdir -p /flatpak/flatpak /flatpak/triggers mkdir /var/tmp || true chmod -R 1777 /var/tmp diff --git a/entrypoint.sh b/entrypoint.sh index e7c579f..95247bf 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -7,9 +7,12 @@ mknod -m 0660 /dev/loop0 b 7 0 2>/dev/null || true for i do - key=$(echo ${i} | cut -d= -f1) - value=$(echo ${i} | cut -d= -f2-) - export ${key}="${value}" + if [[ ${i} =~ = ]] + then + key=$(echo ${i} | cut -d= -f1) + value=$(echo ${i} | cut -d= -f2-) + export ${key}="${value}" + fi done if [[ -d /cache/skopeo ]] @@ -22,14 +25,8 @@ then mkdir /cache/dnf fi -# Pull container -make container/${IMAGE_NAME}-${IMAGE_TAG} "$@" - -# Build base ISO -make boot.iso "$@" - -# Add container to ISO -make build/deploy.iso "$@" +# Run make command +make "$@" # Make output dir in github workspace mkdir /github/workspace/build || true diff --git a/lorax_templates/Makefile b/lorax_templates/Makefile index ca0e4b7..d022767 100644 --- a/lorax_templates/Makefile +++ b/lorax_templates/Makefile @@ -2,7 +2,8 @@ # $1 = script to convert # $2 = file on ISO to write # $3 = whether to copy the '<%' lines to the template -convert_post_to_tmpl = header=0; \ +define convert_post_to_tmpl + header=0; \ skip=0; \ while read -r line; \ do \ @@ -33,7 +34,7 @@ convert_post_to_tmpl = header=0; \ fi; \ done < scripts/post/$(1); \ echo "append $(2) \"%end\"" >> post_$(1).tmpl - +endef post_%.tmpl: scripts/post/% $(call convert_post_to_tmpl,$*,usr/share/anaconda/post-scripts/$*.ks,true) diff --git a/repos/Makefile b/repos/Makefile index 80aedd7..ba0b6d6 100644 --- a/repos/Makefile +++ b/repos/Makefile @@ -1,11 +1,10 @@ repos: $(_REPO_FILES) # Step 2: Replace vars in repo files -repos/%.repo: /etc/yum.repos.d/%.repo - mkdir repos || true - cp /etc/yum.repos.d/$*.repo $(_BASE_DIR)/repos/$*.repo - sed -i "s/\$$releasever/${VERSION}/g" $(_BASE_DIR)/repos/$*.repo - sed -i "s/\$$basearch/${ARCH}/g" $(_BASE_DIR)/repos/$*.repo +%.repo: /etc/yum.repos.d/%.repo + cp /etc/yum.repos.d/$*.repo $*.repo + sed -i "s/\$$releasever/${VERSION}/g" $*.repo + sed -i "s/\$$basearch/${ARCH}/g" $*.repo install-deps: diff --git a/test/Makefile b/test/Makefile index 58eedb9..92244a1 100644 --- a/test/Makefile +++ b/test/Makefile @@ -1,8 +1,10 @@ -TESTS=$(filter-out README.md Makefile,$(wildcard *)) $(filter-out README.md Makefile,$(wildcard */*)) +all: $(filter-out README.md Makefile,$(wildcard *)) -all: $(TESTS) +$(filter-out README.md Makefile,$(wildcard *)): + $(eval DIR=$(firstword $(subst /, ,$@))) + $(MAKE) -w -C $(DIR) -$(TESTS): +$(filter-out README.md Makefile,$(wildcard */*)): $(eval DIR=$(firstword $(subst /, ,$@))) $(eval TARGET=$(subst $(DIR)/,,$@)) $(MAKE) -w -C $(DIR) $(TARGET) @@ -11,4 +13,4 @@ install-deps: if [ "$(PACKAGE_MANAGER)" =~ apt.* ]; then $(PACKAGE_MANAGER) update; fi $(PACKAGE_MANAGER) install -y qemu qemu-utils xorriso unzip qemu-system-x86 netcat socat jq isomd5sum ansible make coreutils squashfs-tools -.PHONY: all $(TESTS) \ No newline at end of file +.PHONY: all $(filter-out README.md Makefile,$(wildcard *)) $(filter-out README.md Makefile,$(wildcard */*)) \ No newline at end of file diff --git a/xorriso/Makefile b/xorriso/Makefile index 8530e04..15129cf 100644 --- a/xorriso/Makefile +++ b/xorriso/Makefile @@ -1,8 +1,8 @@ -xorriso/input.txt: xorriso/gen_input.sh - sed -i 's/quiet/quiet $(EXTRA_BOOT_PARAMS)/g' results/boot/grub2/grub.cfg - sed -i 's/quiet/quiet $(EXTRA_BOOT_PARAMS)/g' results/EFI/BOOT/grub.cfg - $(eval _VARS = FLATPAK_DIR IMAGE_NAME IMAGE_TAG ARCH VERSION) - $(foreach var,$(_VARS),$(var)=$($(var))) bash $(_BASE_DIR)/xorriso/gen_input.sh | tee $(_BASE_DIR)/xorriso/input.txt +input.txt: gen_input.sh + sed -i 's/quiet/quiet $(EXTRA_BOOT_PARAMS)/g' ../results/boot/grub2/grub.cfg + sed -i 's/quiet/quiet $(EXTRA_BOOT_PARAMS)/g' ../results/EFI/BOOT/grub.cfg + $(eval _VARS = ARCH _BASE_DIR FLATPAK_DIR IMAGE_NAME IMAGE_TAG ISO_NAME VERSION) + $(foreach var,$(_VARS),$(var)=$($(var))) bash gen_input.sh | tee input.txt install-deps: diff --git a/xorriso/gen_input.sh b/xorriso/gen_input.sh index 2646b6c..251e805 100644 --- a/xorriso/gen_input.sh +++ b/xorriso/gen_input.sh @@ -1,15 +1,22 @@ #!/bin/bash echo "-report_about WARNING" -echo "-indev $(pwd)/boot.iso" -echo "-outdev $(pwd)/build/deploy.iso" +echo "-indev ${_BASE_DIR}/results/images/boot.iso" +echo "-outdev ${ISO_NAME}" echo "-boot_image any replay" echo "-joliet on" echo "-compliance joliet_long_names" -echo "-map $(pwd)/results/boot/grub2/grub.cfg boot/grub2/grub.cfg" -echo "-chmod 0444 boot/grub2/grub.cfg" -echo "-map $(pwd)/results/EFI/BOOT/grub.cfg EFI/BOOT/grub.cfg" -echo "-chmod 0444 EFI/BOOT/grub.cfg" +pushd ${_BASE_DIR}/results > /dev/null +for file in $(find *) +do + if [[ "$file" == "images/boot.iso" ]] + then + continue + fi + echo "-map ${_BASE_DIR}/results/${file} ${file}" + echo "-chmod 0444 ${file}" +done +popd > /dev/null if [[ -n "${FLATPAK_DIR}" ]] then