1
0
Fork 0
mirror of https://github.com/JasonN3/build-container-installer.git synced 2025-12-25 10:57:55 +01:00

Run setup using ostreecontainer

This commit is contained in:
Jason N 2024-02-15 09:08:55 -05:00 committed by GitHub
parent 1828adb299
commit a00fc343c6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 177 additions and 32 deletions

View file

@ -8,9 +8,40 @@ on:
- 'v*'
pull_request:
env:
IMAGE_REGISTRY: ghcr.io/${{ github.repository_owner }}
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:
@ -18,53 +49,58 @@ jobs:
container:
image: fedora:39
options: "--privileged"
volumes:
- /:/host
permissions:
contents: read
packages: write
steps:
- name: Cleanup host space
run: |
df -h /host || true
rm -rf /host/usr/local/lib/android || true
rm -rf /host/usr/share/dotnet || true
rm -rf /host/opt/ghc || true
rm -rf /host/usr/local/.ghcup || true
df -h /host || true
- name: Install tools
run: |
dnf install -y \
lorax \
xorriso \
git \
rpm-ostree
- 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: Create boot.iso
env:
version: "39"
arch: "x86_64"
- name: Install dependencies
run: make install-deps
- name: Download image
run: |
lorax -p Fedora -v $version -r $version -t Server \
--isfinal --buildarch=${arch} --volid=Fedora-S-dvd-${arch}-${version} \
--macboot --noupgrade \
--repo /etc/yum.repos.d/fedora.repo \
--repo /etc/yum.repos.d/fedora-updates.repo \
--rootfs-size 9 \
./results/
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: results/images/boot.iso
path: end_iso/*.iso
if-no-files-found: error
retention-days: 0
compression-level: 0

12
.gitignore vendored Normal file
View file

@ -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

78
Makefile Normal file
View file

@ -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

View file

@ -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"

View file

@ -0,0 +1 @@
append usr/share/anaconda/interactive-defaults.ks "ostreecontainer --url=/run/install/repo/@IMAGE_NAME@-@VERSION@ --transport=oci --no-signature-verification"

15
xorriso/gen_input.sh.in Normal file
View file

@ -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"