1
0
Fork 0
mirror of https://github.com/JasonN3/build-container-installer.git synced 2025-12-25 10:57:55 +01:00
This commit is contained in:
Jason N. 2024-03-27 11:39:03 -04:00
parent 2aeb0bde72
commit a6aeab7ac9
9 changed files with 66 additions and 63 deletions

View file

@ -89,8 +89,7 @@ jobs:
- name: Run ISO checks - name: Run ISO checks
run: | run: |
mv ${{ inputs[format('iso_name-{0}', matrix.version)] }} deploy.iso make test/iso \
make test-iso \
ARCH=${{ needs.load_vars.outputs.ARCH}} \ ARCH=${{ needs.load_vars.outputs.ARCH}} \
IMAGE_NAME=${{ needs.load_vars.outputs.IMAGE_NAME}} \ IMAGE_NAME=${{ needs.load_vars.outputs.IMAGE_NAME}} \
IMAGE_REPO=${{ needs.load_vars.outputs.IMAGE_REPO}} \ IMAGE_REPO=${{ needs.load_vars.outputs.IMAGE_REPO}} \
@ -99,7 +98,8 @@ jobs:
VARIANT=${{ needs.load_vars.outputs.VARIANT }} \ VARIANT=${{ needs.load_vars.outputs.VARIANT }} \
FLATPAK_REMOTE_REFS_DIR=${{ needs.load_vars.outputs.FLATPAK_REMOTE_REFS_DIR }} \ FLATPAK_REMOTE_REFS_DIR=${{ needs.load_vars.outputs.FLATPAK_REMOTE_REFS_DIR }} \
SECURE_BOOT_KEY_URL=${{ needs.load_vars.outputs.SECURE_BOOT_KEY_URL }} \ 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 - name: Set status
if: inputs.pr && always() if: inputs.pr && always()

View file

@ -7,7 +7,7 @@ export EXTRA_BOOT_PARAMS =
export IMAGE_NAME = base export IMAGE_NAME = base
export IMAGE_REPO = quay.io/fedora-ostree-desktops export IMAGE_REPO = quay.io/fedora-ostree-desktops
export IMAGE_TAG = $(VERSION) 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 ROOTFS_SIZE = 4
export VARIANT = Server export VARIANT = Server
export VERSION = 39 export VERSION = 39
@ -21,10 +21,12 @@ export FLATPAK_DIR =
# Secure boot # Secure boot
export ENROLLMENT_PASSWORD = export ENROLLMENT_PASSWORD =
export SECURE_BOOT_KEY_URL = export SECURE_BOOT_KEY_URL =
export ISO_NAME = $(_BASE_DIR)/build/deploy.iso
################### ###################
# Hidden vars # Hidden vars
SHELL = /bin/sh
# Cache # Cache
export DNF_CACHE = export DNF_CACHE =
export PACKAGE_MANAGER = dnf export PACKAGE_MANAGER = dnf
@ -33,12 +35,14 @@ export PACKAGE_MANAGER = dnf
## Formatting = lowercase ## Formatting = lowercase
# Get a list of templates for the feature # Get a list of templates for the feature
# $1 = feature # $1 = feature
get_templates = $(shell ls lorax_templates/$(1)_*.tmpl) \ define get_templates
$(foreach file,$(notdir $(shell ls lorax_templates/scripts/post/$(1)_*)),lorax_templates/post_$(file).tmpl) $(wildcard lorax_templates/$(1)_*.tmpl)
$(foreach file,$(notdir $(wildcard lorax_templates/scripts/post/$(1)_*)),lorax_templates/post_$(file).tmpl)
endef
# Generated/internal vars # Generated/internal vars
## Formatting = _UPPERCASE ## Formatting = _UPPERCASE
_BASE_DIR = $(shell pwd) export _BASE_DIR = $(shell pwd)
_IMAGE_REPO_ESCAPED = $(subst /,\/,$(IMAGE_REPO)) _IMAGE_REPO_ESCAPED = $(subst /,\/,$(IMAGE_REPO))
_IMAGE_REPO_DOUBLE_ESCAPED = $(subst \,\\\,$(_IMAGE_REPO_ESCAPED)) _IMAGE_REPO_DOUBLE_ESCAPED = $(subst \,\\\,$(_IMAGE_REPO_ESCAPED))
_LORAX_ARGS = _LORAX_ARGS =
@ -104,21 +108,18 @@ _SUBDIRS = container external flatpak_refs lorax_templates repos xorriso
# Step 7: Build end ISO # Step 7: Build end ISO
## Default action ## 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 mkdir $(_BASE_DIR)/build || true
xorriso -dialog on < $(_BASE_DIR)/xorriso/input.txt xorriso -dialog on < $(_BASE_DIR)/xorriso/input.txt
implantisomd5 build/deploy.iso implantisomd5 $(ISO_NAME)
# Step 3: Build boot.iso using Lorax # Step 3: Build boot.iso using Lorax
boot.iso: external/lorax/branch-$(VERSION) $(filter lorax_templates/%,$(_LORAX_TEMPLATES)) $(_REPO_FILES) results/images/boot.iso: external/lorax/branch-$(VERSION) $(filter lorax_templates/%,$(_LORAX_TEMPLATES)) $(_REPO_FILES)
rm -Rf $(_BASE_DIR)/results || true $(if $(wildcard results), rm -Rf results)
mv /etc/rpm/macros.image-language-conf $(_TEMP_DIR)/macros.image-language-conf || true mv /etc/rpm/macros.image-language-conf $(_TEMP_DIR)/macros.image-language-conf || true
# Download the secure boot key # Download the secure boot key
if [ -n "$(SECURE_BOOT_KEY_URL)" ]; \ $(if $(SECURE_BOOT_KEY_URL), curl --fail -L -o $(_BASE_DIR)/sb_pubkey.der $(SECURE_BOOT_KEY_URL))
then \
curl --fail -L -o $(_BASE_DIR)/sb_pubkey.der $(SECURE_BOOT_KEY_URL); \
fi
lorax -p $(IMAGE_NAME) -v $(VERSION) -r $(VERSION) -t $(VARIANT) \ 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 \ --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) \ --rootfs-size $(ROOTFS_SIZE) \
$(foreach var,$(_TEMPLATE_VARS),--add-template-var "$(shell echo $(var) | tr '[:upper:]' '[:lower:]')=$($(var))") \ $(foreach var,$(_TEMPLATE_VARS),--add-template-var "$(shell echo $(var) | tr '[:upper:]' '[:lower:]')=$($(var))") \
$(_BASE_DIR)/results/ $(_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 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) FILES_TO_CLEAN = $(wildcard build debugdata pkglists results original-pkgsizes.txt final-pkgsizes.txt lorax.conf *.iso *log)
.PHONY: clean
clean: clean:
rm -Rf $(FILES_TO_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: 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 $(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/*/*)) .PHONY: $(_SUBDIRS) test $(wildcard test/*) $(wildcard test/*/*)
$(_SUBMAKES): test $(addsuffix /*,$(_SUBDIRS) test):
$(eval DIR=$(firstword $(subst /, ,$@))) $(eval DIR=$(firstword $(subst /, ,$@)))
$(eval TARGET=$(subst $(DIR)/,,$@)) $(if $(filter-out $(DIR),$@), $(eval TARGET=$(subst $(DIR)/,,$@)),$(eval TARGET=))
$(MAKE) -w -C $(DIR) $(TARGET) $(MAKE) -w -C $(DIR) $(TARGET)
$(addsuffix /%,$(_SUBMAKES)): .DEFAULT:
$(eval DIR=$(firstword $(subst /, ,$@))) $(eval DIR=$(firstword $(subst /, ,$@)))
$(eval TARGET=$(subst $(DIR)/,,$@)) $(if $(filter-out $(DIR),$@), $(eval TARGET=$(subst $(DIR)/,,$@)),$(eval TARGET=))
$(MAKE) -w -C $(DIR) $(TARGET) $(MAKE) -w -C $(DIR) $(TARGET)
.PHONY: clean install-deps $(_SUBMAKES) test

View file

@ -148,7 +148,6 @@ runs:
DIR_REFS=$(cat ${{ inputs.flatpak_remote_refs_dir }}/* | tr '\n' ' ' ) DIR_REFS=$(cat ${{ inputs.flatpak_remote_refs_dir }}/* | tr '\n' ' ' )
# Generate install script # Generate install script
cat << EOF > ${{ github.workspace }}/${FLATPAK_DIR}/script.sh cat << EOF > ${{ github.workspace }}/${FLATPAK_DIR}/script.sh
cat /flatpak_dir/script.sh
mkdir -p /flatpak/flatpak /flatpak/triggers mkdir -p /flatpak/flatpak /flatpak/triggers
mkdir /var/tmp || true mkdir /var/tmp || true
chmod -R 1777 /var/tmp chmod -R 1777 /var/tmp

View file

@ -7,9 +7,12 @@ mknod -m 0660 /dev/loop0 b 7 0 2>/dev/null || true
for i for i
do do
key=$(echo ${i} | cut -d= -f1) if [[ ${i} =~ = ]]
value=$(echo ${i} | cut -d= -f2-) then
export ${key}="${value}" key=$(echo ${i} | cut -d= -f1)
value=$(echo ${i} | cut -d= -f2-)
export ${key}="${value}"
fi
done done
if [[ -d /cache/skopeo ]] if [[ -d /cache/skopeo ]]
@ -22,14 +25,8 @@ then
mkdir /cache/dnf mkdir /cache/dnf
fi fi
# Pull container # Run make command
make container/${IMAGE_NAME}-${IMAGE_TAG} "$@" make "$@"
# Build base ISO
make boot.iso "$@"
# Add container to ISO
make build/deploy.iso "$@"
# Make output dir in github workspace # Make output dir in github workspace
mkdir /github/workspace/build || true mkdir /github/workspace/build || true

View file

@ -2,7 +2,8 @@
# $1 = script to convert # $1 = script to convert
# $2 = file on ISO to write # $2 = file on ISO to write
# $3 = whether to copy the '<%' lines to the template # $3 = whether to copy the '<%' lines to the template
convert_post_to_tmpl = header=0; \ define convert_post_to_tmpl
header=0; \
skip=0; \ skip=0; \
while read -r line; \ while read -r line; \
do \ do \
@ -33,7 +34,7 @@ convert_post_to_tmpl = header=0; \
fi; \ fi; \
done < scripts/post/$(1); \ done < scripts/post/$(1); \
echo "append $(2) \"%end\"" >> post_$(1).tmpl echo "append $(2) \"%end\"" >> post_$(1).tmpl
endef
post_%.tmpl: scripts/post/% post_%.tmpl: scripts/post/%
$(call convert_post_to_tmpl,$*,usr/share/anaconda/post-scripts/$*.ks,true) $(call convert_post_to_tmpl,$*,usr/share/anaconda/post-scripts/$*.ks,true)

View file

@ -1,11 +1,10 @@
repos: $(_REPO_FILES) repos: $(_REPO_FILES)
# Step 2: Replace vars in repo files # Step 2: Replace vars in repo files
repos/%.repo: /etc/yum.repos.d/%.repo %.repo: /etc/yum.repos.d/%.repo
mkdir repos || true cp /etc/yum.repos.d/$*.repo $*.repo
cp /etc/yum.repos.d/$*.repo $(_BASE_DIR)/repos/$*.repo sed -i "s/\$$releasever/${VERSION}/g" $*.repo
sed -i "s/\$$releasever/${VERSION}/g" $(_BASE_DIR)/repos/$*.repo sed -i "s/\$$basearch/${ARCH}/g" $*.repo
sed -i "s/\$$basearch/${ARCH}/g" $(_BASE_DIR)/repos/$*.repo
install-deps: install-deps:

View file

@ -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 DIR=$(firstword $(subst /, ,$@)))
$(eval TARGET=$(subst $(DIR)/,,$@)) $(eval TARGET=$(subst $(DIR)/,,$@))
$(MAKE) -w -C $(DIR) $(TARGET) $(MAKE) -w -C $(DIR) $(TARGET)
@ -11,4 +13,4 @@ install-deps:
if [ "$(PACKAGE_MANAGER)" =~ apt.* ]; then $(PACKAGE_MANAGER) update; fi 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 $(PACKAGE_MANAGER) install -y qemu qemu-utils xorriso unzip qemu-system-x86 netcat socat jq isomd5sum ansible make coreutils squashfs-tools
.PHONY: all $(TESTS) .PHONY: all $(filter-out README.md Makefile,$(wildcard *)) $(filter-out README.md Makefile,$(wildcard */*))

View file

@ -1,8 +1,8 @@
xorriso/input.txt: xorriso/gen_input.sh 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/boot/grub2/grub.cfg
sed -i 's/quiet/quiet $(EXTRA_BOOT_PARAMS)/g' results/EFI/BOOT/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) $(eval _VARS = ARCH _BASE_DIR FLATPAK_DIR IMAGE_NAME IMAGE_TAG ISO_NAME VERSION)
$(foreach var,$(_VARS),$(var)=$($(var))) bash $(_BASE_DIR)/xorriso/gen_input.sh | tee $(_BASE_DIR)/xorriso/input.txt $(foreach var,$(_VARS),$(var)=$($(var))) bash gen_input.sh | tee input.txt
install-deps: install-deps:

View file

@ -1,15 +1,22 @@
#!/bin/bash #!/bin/bash
echo "-report_about WARNING" echo "-report_about WARNING"
echo "-indev $(pwd)/boot.iso" echo "-indev ${_BASE_DIR}/results/images/boot.iso"
echo "-outdev $(pwd)/build/deploy.iso" echo "-outdev ${ISO_NAME}"
echo "-boot_image any replay" echo "-boot_image any replay"
echo "-joliet on" echo "-joliet on"
echo "-compliance joliet_long_names" echo "-compliance joliet_long_names"
echo "-map $(pwd)/results/boot/grub2/grub.cfg boot/grub2/grub.cfg" pushd ${_BASE_DIR}/results > /dev/null
echo "-chmod 0444 boot/grub2/grub.cfg" for file in $(find *)
echo "-map $(pwd)/results/EFI/BOOT/grub.cfg EFI/BOOT/grub.cfg" do
echo "-chmod 0444 EFI/BOOT/grub.cfg" 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}" ]] if [[ -n "${FLATPAK_DIR}" ]]
then then