From 9d5ef0c1151ad0e87120014132d39bc738b948bf Mon Sep 17 00:00:00 2001 From: Jason N <33561705+JasonN3@users.noreply.github.com> Date: Thu, 15 Feb 2024 09:22:02 -0500 Subject: [PATCH] POC of OS Install --- .github/workflows/iso.yml | 107 +++++++++++++++++++++ .gitignore | 12 +++ Makefile | 78 +++++++++++++++ lorax_templates/configure_upgrades.tmpl.in | 3 + lorax_templates/set_installer.tmpl.in | 1 + xorriso/gen_input.sh.in | 15 +++ 6 files changed, 216 insertions(+) create mode 100644 .github/workflows/iso.yml create mode 100644 .gitignore create mode 100644 Makefile create mode 100644 lorax_templates/configure_upgrades.tmpl.in create mode 100644 lorax_templates/set_installer.tmpl.in create mode 100644 xorriso/gen_input.sh.in diff --git a/.github/workflows/iso.yml b/.github/workflows/iso.yml new file mode 100644 index 0000000..85b7f62 --- /dev/null +++ b/.github/workflows/iso.yml @@ -0,0 +1,107 @@ +name: Create and publish an ISO + +on: + push: + branches: + - 'main' + tags: + - 'v*' + pull_request: + + workflow_call: + inputs: + IMAGE_VERSION: + required: true + type: string + IMAGE_ARCH: + required: true + type: string + IMAGE_NAME: + required: true + type: string + IMAGE_REPO: + required: true + type: string + VARIANT: + required: true + type: string + BUILD_REPO: + required: false + type: string + default: JasonN3/container-installer + BUILD_REF: + required: false + type: string + default: main + +env: + IMAGE_VERSION: ${{ github.event.inputs.IMAGE_VERSION || '39' }} + IMAGE_ARCH: ${{ github.event.inputs.IMAGE_ARCH || 'x86_64' }} + IMAGE_NAME: ${{ github.event.inputs.IMAGE_NAME || 'base-main' }} + IMAGE_REPO: ${{ github.event.inputs.IMAGE_REPO || 'ghcr.io/ublue-os' }} + VARIANT: ${{ github.event.inputs.VARIANT || 'Silverblue' }} + CURR_REPO: ${{ github.event.inputs.BUILD_REPO || github.repository }} + CURR_REF: ${{ github.event.inputs.BUILD_REF || github.ref }} + +jobs: + build-and-push-iso: + runs-on: ubuntu-latest + container: + image: fedora:39 + options: "--privileged" + permissions: + contents: read + packages: write + + steps: + - name: Install make and git + run: dnf install -y make git + + - name: Checkout repository + uses: actions/checkout@v4 + with: + repository: ${{ env.CURR_REPO }} + ref: ${{ env.CURR_REF }} + submodules: recursive + + - name: Install dependencies + run: make install-deps + + - name: Download image + run: | + make container/${IMAGE_NAME}-${IMAGE_VERSION} \ + arch=${IMAGE_ARCH} \ + version=${IMAGE_VERSION} \ + image_repo=${IMAGE_REPO} \ + image_name=${IMAGE_NAME} \ + variant=${VARIANT} + + - name: Create boot.iso + run: | + make boot.iso \ + arch=${IMAGE_ARCH} \ + version=${IMAGE_VERSION} \ + image_repo=${IMAGE_REPO} \ + image_name=${IMAGE_NAME} \ + variant=${VARIANT} + + - name: Create deploy.iso + run: | + make ${IMAGE_NAME}-${IMAGE_VERSION}.iso \ + arch=${IMAGE_ARCH} \ + version=${IMAGE_VERSION} \ + image_repo=${IMAGE_REPO} \ + image_name=${IMAGE_NAME} \ + variant=${VARIANT} + mkdir end_iso + mv ${IMAGE_NAME}-${IMAGE_VERSION}.iso end_iso/ + + - name: Upload ISO as artifact + uses: actions/upload-artifact@v4 + with: + name: ISOs + path: end_iso/*.iso + if-no-files-found: error + retention-days: 0 + compression-level: 0 + overwrite: true \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..03894b9 --- /dev/null +++ b/.gitignore @@ -0,0 +1,12 @@ +/debugdata +/container +/pkglists +/results +/lorax_templates/*.tmpl +/xorriso/input.txt +/xorriso/*.sh +/original-pkgsizes.txt +/final-pkgsizes.txt +/lorax.conf +/*.iso +/*.log \ No newline at end of file diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..d384476 --- /dev/null +++ b/Makefile @@ -0,0 +1,78 @@ +arch = x86_64 +version = 39 +base_dir = $(shell pwd) +image_repo = ghcr.io/ublue-os +image_name = base-main +variant = Silverblue + +image_repo_escaped = $(subst /,\/,$(image_repo)) +image_repo_double_escaped = $(subst \,\\\,$(image_repo_escaped)) + +ifeq ($(variant),'Server') +lorax_args = --macboot --noupgrade +else +lorax_args = --nomacboot +endif + +$(image_name)-$(version).iso: boot.iso container/$(image_name)-$(version) xorriso/input.txt + xorriso -dialog on < $(base_dir)/xorriso/input.txt + +boot.iso: lorax_templates/set_installer.tmpl lorax_templates/configure_upgrades.tmpl + rm -Rf $(base_dir)/results + lorax -p $(image_name) -v $(version) -r $(version) -t $(variant) \ + --isfinal --buildarch=$(arch) --volid=$(image_name)-$(arch)-$(version) \ + $(lorax_args) \ + --repo /etc/yum.repos.d/fedora.repo \ + --repo /etc/yum.repos.d/fedora-updates.repo \ + --add-template $(base_dir)/lorax_templates/set_installer.tmpl \ + --add-template $(base_dir)/lorax_templates/configure_upgrades.tmpl \ + $(base_dir)/results/ + mv $(base_dir)/results/images/boot.iso $(base_dir)/ + +container/$(image_name)-$(version): + mkdir container + podman pull $(image_repo)/$(image_name):$(version) + podman save --format oci-dir -o $(base_dir)/container/$(image_name)-$(version) $(image_repo)/$(image_name):$(version) + podman rmi $(image_repo)/$(image_name):$(version) + +install-deps: + dnf install -y lorax xorriso podman git rpm-ostree + + + +lorax_templates/%.tmpl: lorax_templates/%.tmpl.in + sed 's/@IMAGE_NAME@/$(image_name)/' $(base_dir)/lorax_templates/$*.tmpl.in > $(base_dir)/lorax_templates/$*.tmpl + sed 's/@IMAGE_REPO@/$(image_repo_escaped)/' $(base_dir)/lorax_templates/$*.tmpl > $(base_dir)/lorax_templates/$*.tmpl.tmp + mv $(base_dir)/lorax_templates/$*.tmpl{.tmp,} + sed 's/@VERSION@/$(version)/' $(base_dir)/lorax_templates/$*.tmpl > $(base_dir)/lorax_templates/$*.tmpl.tmp + mv $(base_dir)/lorax_templates/$*.tmpl{.tmp,} + sed 's/@IMAGE_REPO_ESCAPED@/$(image_repo_double_escaped)/' $(base_dir)/lorax_templates/$*.tmpl > $(base_dir)/lorax_templates/$*.tmpl.tmp + mv $(base_dir)/lorax_templates/$*.tmpl{.tmp,} + + + +xorriso/input.txt: xorriso/gen_input.sh + bash $(base_dir)/xorriso/gen_input.sh | tee $(base_dir)/xorriso/input.txt + +xorriso/%.sh: xorriso/%.sh.in + sed 's/@IMAGE_NAME@/$(image_name)/' $(base_dir)/xorriso/$*.sh.in > $(base_dir)/xorriso/$*.sh + sed 's/@VERSION@/$(version)/' $(base_dir)/xorriso/$*.sh > $(base_dir)/xorriso/$*.sh.tmp + mv $(base_dir)/xorriso/$*.sh{.tmp,} + sed 's/@ARCH@/$(arch)/' $(base_dir)/xorriso/$*.sh > $(base_dir)/xorriso/$*.sh.tmp + mv $(base_dir)/xorriso/$*.sh{.tmp,} + + +clean: + rm -Rf $(base_dir)/container || true + rm -Rf $(base_dir)/debugdata || true + rm -Rf $(base_dir)/pkglists || true + rm -Rf $(base_dir)/results || true + rm -f $(base_dir)/lorax_templates/*.tmpl || true + rm -f $(base_dir)/xorriso/input.txt || true + rm -f $(base_dir)/xorriso/*.sh || true + rm -f $(base_dir)/{original,final}-pkgsizes.txt || true + rm -f $(base_dir)/lorax.conf || true + rm -f $(base_dir)/*.iso || true + rm -f $(base_dir)/*.log || true + + diff --git a/lorax_templates/configure_upgrades.tmpl.in b/lorax_templates/configure_upgrades.tmpl.in new file mode 100644 index 0000000..2bbb92a --- /dev/null +++ b/lorax_templates/configure_upgrades.tmpl.in @@ -0,0 +1,3 @@ +append usr/share/anaconda/interactive-defaults.ks "%post --erroronfail" +append usr/share/anaconda/interactive-defaults.ks "sed -i 's/container-image-reference=.*/container-image-reference=ostree-image-signed:docker:\/\/@IMAGE_REPO_ESCAPED@\/@IMAGE_NAME@:@VERSION@/' /ostree/deploy/default/deploy/*.origin" +append usr/share/anaconda/interactive-defaults.ks "%end" \ No newline at end of file diff --git a/lorax_templates/set_installer.tmpl.in b/lorax_templates/set_installer.tmpl.in new file mode 100644 index 0000000..13332ff --- /dev/null +++ b/lorax_templates/set_installer.tmpl.in @@ -0,0 +1 @@ +append usr/share/anaconda/interactive-defaults.ks "ostreecontainer --url=/run/install/repo/@IMAGE_NAME@-@VERSION@ --transport=oci --no-signature-verification" \ No newline at end of file diff --git a/xorriso/gen_input.sh.in b/xorriso/gen_input.sh.in new file mode 100644 index 0000000..167e3b0 --- /dev/null +++ b/xorriso/gen_input.sh.in @@ -0,0 +1,15 @@ +#!/bin/bash + +echo "-indev $(pwd)/boot.iso" +echo "-outdev $(pwd)/@IMAGE_NAME@-@VERSION@.iso" +echo "-boot_image any replay" +echo "-volid @IMAGE_NAME@-@ARCH@-@VERSION@" +echo "-joliet on" +echo "-compliance joliet_long_names" +cd container +for file in $(find @IMAGE_NAME@-@VERSION@) +do + echo "-map $(pwd)/${file} ${file}" + echo "-chmod 0444 ${file}" +done +echo "-end" \ No newline at end of file