Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

POC of OS Install #2

Merged
merged 13 commits into from
Feb 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
107 changes: 107 additions & 0 deletions .github/workflows/iso.yml
Original file line number Diff line number Diff line change
@@ -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
12 changes: 12 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -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 changes: 78 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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


3 changes: 3 additions & 0 deletions lorax_templates/configure_upgrades.tmpl.in
Original file line number Diff line number Diff line change
@@ -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"
1 change: 1 addition & 0 deletions lorax_templates/set_installer.tmpl.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
append usr/share/anaconda/interactive-defaults.ks "ostreecontainer --url=/run/install/repo/@IMAGE_NAME@-@VERSION@ --transport=oci --no-signature-verification"
15 changes: 15 additions & 0 deletions xorriso/gen_input.sh.in
Original file line number Diff line number Diff line change
@@ -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"