Skip to content
This repository was archived by the owner on Apr 22, 2024. It is now read-only.

feat: Allow users to override secure boot key and password #40

Merged
merged 25 commits into from
Feb 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
cb88bb6
feat: Allow users to override secure boot key and password when using…
noelmiller Feb 27, 2024
1f1878f
fix: follow redirects
noelmiller Feb 27, 2024
ff1b64e
chore: update docs
noelmiller Feb 27, 2024
4b4d9c9
fix: added comments and removed additional \n
noelmiller Feb 27, 2024
3aac0b6
fix: removed defaults
noelmiller Feb 27, 2024
ba04e86
fix: added conditional for adding public key
noelmiller Feb 27, 2024
9d2fb9c
chore(ci): Added additional test for secure boot
noelmiller Feb 27, 2024
66e0be5
chore(ci): fixed up workflows to match production
noelmiller Feb 27, 2024
88fcc40
fix(ci): added workflow dispatch to test
noelmiller Feb 27, 2024
7702beb
fix(ci): fixed version and added IMAGE_TAG
noelmiller Feb 27, 2024
b5d3305
chore(ci): changed to bluefin to test both 38 and 39 secure boot
noelmiller Feb 27, 2024
8840ff3
Merge branch 'main' into decouple_secure_boot_key
noelmiller Feb 27, 2024
bf9ced7
chore(ci): added required variables to entrypoint
noelmiller Feb 27, 2024
eacb536
chore(ci): added merge_group and added paths-ignore
noelmiller Feb 27, 2024
dbe636a
chore(ci): updated description
noelmiller Feb 27, 2024
e9c5721
chore(ci): set to Silverblue since we are testing Bluefin
noelmiller Feb 27, 2024
ecce977
chore(ci): Fixed secure boot key not found error
noelmiller Feb 27, 2024
fc78338
chore: fixed formatting
noelmiller Feb 27, 2024
f62869b
chore: fixed whitespace
noelmiller Feb 27, 2024
00b5de4
chore(ci): Removed duplicate test
noelmiller Feb 27, 2024
4dbeef1
chore: fix whitespace
noelmiller Feb 27, 2024
83a7deb
chore(ci): fixed test and removed upload to Github Artifacts
noelmiller Feb 27, 2024
8244641
chore: updated README
noelmiller Feb 27, 2024
68bab37
fix: set password to ublue default
noelmiller Feb 27, 2024
111e8f6
fix: changed enrollment password in containerfile
noelmiller Feb 27, 2024
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
5 changes: 5 additions & 0 deletions .github/workflows/build-container-image.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
---
name: Build Container Image
on:
merge_group:
pull_request:
branches:
- main
paths-ignore:
- '*.md'
- 'LICENSE'
- 'CODEOWNERS'
push:
branches:
- main
Expand Down
32 changes: 30 additions & 2 deletions .github/workflows/test-iso.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ on:
- '*.md'
- 'LICENSE'
- 'CODEOWNERS'
workflow_dispatch:

jobs:
build-and-push-iso:
Expand All @@ -18,15 +19,30 @@ jobs:
container:
image: fedora:39
options: "--privileged"
volumes:
- "/:/host"
permissions:
contents: read
packages: write
strategy:
fail-fast: false
matrix:
version:
version:
- 38
- 39
secure_boot:
- true
- false
include:
- secure_boot: true
SECURE_BOOT_KEY_URL: 'https://github.com/ublue-os/akmods/raw/main/certs/public_key.der'
ENROLLMENT_PASSWORD: 'ublue-os'
SECURE_BOOT_STRING: '-secure'
- secure_boot: false
SECURE_BOOT_KEY_URL: ''
ENROLLMENT_PASSWORD: ''
SECURE_BOOT_STRING: ''

steps:
- name: Checkout
uses: actions/checkout@v4
Expand All @@ -41,6 +57,18 @@ jobs:
VERSION: ${{ matrix.version }}
ACTION_REPO: ${{ github.repository }}
ACTION_REF: ${{ github.ref }}
SECURE_BOOT_KEY_URL: ${{ matrix.SECURE_BOOT_KEY_URL }}
ENROLLMENT_PASSWORD: ${{ matrix.ENROLLMENT_PASSWORD }}

- name: Upload ISO as artifact
uses: actions/upload-artifact@v4
with:
name: base-main-${{ matrix.version }}${{ matrix.SECURE_BOOT_STRING }}.iso
path: end_iso/*
if-no-files-found: error
retention-days: 0
compression-level: 0
overwrite: true

check:
name: Check build successful
Expand All @@ -55,4 +83,4 @@ jobs:
run: exit 1
- name: Exit
shell: bash
run: exit 0
run: exit 0
2 changes: 2 additions & 0 deletions Containerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ ENV IMAGE_TAG="${VERSION}"
ENV VARIANT="Kinoite"
ENV VERSION="${VERSION}"
ENV WEB_UI="false"
ENV SECURE_BOOT_KEY_URL=""
ENV ENROLLMENT_PASSWORD="ublue-os"

COPY / /isogenerator
WORKDIR /isogenerator
Expand Down
11 changes: 11 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ IMAGE_TAG = $(VERSION)
EXTRA_BOOT_PARAMS =
VARIANT = Kinoite
WEB_UI = false
ENROLLMENT_PASSWORD = ublue-os
SECURE_BOOT_KEY_URL =

# Generated vars
## Formatting = _UPPERCASE
Expand Down Expand Up @@ -50,6 +52,14 @@ lorax_templates/%.tmpl: lorax_templates/%.tmpl.in
boot.iso: lorax_templates/set_installer.tmpl lorax_templates/configure_upgrades.tmpl
rm -Rf $(_BASE_DIR)/results

# Set the enrollment password
sed 's/@ENROLLMENT_PASSWORD@/$(ENROLLMENT_PASSWORD)/' $(_BASE_DIR)/scripts/enroll-secureboot-key.sh.in > $(_BASE_DIR)/scripts/enroll-secureboot-key.sh

# 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

# Remove the "Test this media & install" menu entry
sed -i '/menuentry '\''Test this media & install @PRODUCT@ @VERSION@'\'' --class fedora --class gnu-linux --class gnu --class os {/,/}/d' /usr/share/lorax/templates.d/99-generic/config_files/x86/grub2-bios.cfg
sed -i '/menuentry '\''Test this media & install @PRODUCT@ @VERSION@'\'' --class fedora --class gnu-linux --class gnu --class os {/,/}/d' /usr/share/lorax/templates.d/99-generic/config_files/x86/grub2-efi.cfg
Expand All @@ -68,6 +78,7 @@ boot.iso: lorax_templates/set_installer.tmpl lorax_templates/configure_upgrades.
sed -i 's/linux @KERNELPATH@ @ROOT@ inst.rescue quiet/linux @KERNELPATH@ @ROOT@ inst.rescue quiet $(EXTRA_BOOT_PARAMS)/g' /usr/share/lorax/templates.d/99-generic/config_files/x86/grub2-bios.cfg
sed -i 's/linuxefi @KERNELPATH@ @ROOT@ inst.rescue quiet/linuxefi @KERNELPATH@ @ROOT@ inst.rescue quiet $(EXTRA_BOOT_PARAMS)/g' /usr/share/lorax/templates.d/99-generic/config_files/x86/grub2-efi.cfg

# Build boot.iso
lorax -p $(IMAGE_NAME) -v $(VERSION) -r $(VERSION) -t $(VARIANT) \
--isfinal --buildarch=$(ARCH) --volid=$(_VOLID) \
$(_LORAX_ARGS) \
Expand Down
31 changes: 18 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,19 +37,24 @@ sudo podman run --rm --privileged --volume .:/isogenerator/output -e VERSION=39
## Customizing
The following variables can be used to customize the create image.

| Variable | Description | Default Value |
| ----------------- | -------------------------------------------------------- | ---------------------- |
| ARCH | Architecture for image to build | x86_64 |
| VERSION | Fedora version of installer to build | 39 |
| IMAGE_REPO | Repository containing the source container image | ghcr.io/ublue-os |
| IMAGE_NAME | Name of the source container image | base-main |
| IMAGE_TAG | Tag of the source container image | *VERSION* |
| EXTRA_BOOT_PARAMS | Extra params used by grub to boot the anaconda installer | \[empty\] |
| VARIANT | Source container variant\* | Kinoite |
| WEB_UI | Enable Anaconda WebUI (experimental) | false |

Available options for VARIANT can be found by running `dnf provides system-release`.
Variant will be the third item in the package name. Example: `fedora-release-kinoite-39-34.noarch` will be kinoite
| Variable | Description | Default Value |
| ----------------- | ------------------------------------------------------------ | ---------------------- |
| ARCH | Architecture for image to build | x86_64 |
| VERSION | Fedora version of installer to build | 39 |
| IMAGE_REPO | Repository containing the source container image | ghcr.io/ublue-os |
| IMAGE_NAME | Name of the source container image | base-main |
| IMAGE_TAG | Tag of the source container image | *VERSION* |
| EXTRA_BOOT_PARAMS | Extra params used by grub to boot the anaconda installer | \[empty\] |
| VARIANT | Source container variant\* | Kinoite |
| WEB_UI | Enable Anaconda WebUI (experimental) | false |
| ENROLLMENT_PASSWORD | Password used to enroll secure boot key into BIOS\*\* | isogenerator |
| SECURE_BOOT_KEY_URL | URL used to download your secure boot key for enrollment\*\* | \[empty\] |

\*Available options for VARIANT can be found by running `dnf provides system-release`. Variant will be the third item in the package name. Example: `fedora-release-kinoite-39-34.noarch` will be kinoite

\*\*NOTE: ENROLLMENT_PASSWORD and SECURE_BOOT_KEY_URL are not required. They are only required if you are creating specific kernel modules or if you are using Universal Blue Kernel Modules.

Our public key for our kmods is located here: https://github.com/ublue-os/akmods/raw/main/certs/public_key.der

## VSCode Dev Container
There is a dev container configuration provided for development. By default it will use the existing container image available at `ghcr.io/ublue-os/isogenerator`, however, you can have it build a new image by editing `.devcontainer/devcontainer.json` and replacing `image` with `build`. `Ctrl+/` can be used to comment and uncomment blocks of code within VSCode.
Expand Down
20 changes: 9 additions & 11 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ inputs:
description: Enable Anaconda WebUI
required: true
default: "false"
ENROLLMENT_PASSWORD:
description: Used for supporting secure boot (requires SECURE_BOOT_KEY_URL to be defined)
required: false
SECURE_BOOT_KEY_URL:
description: Secure boot key that is installed from URL location
required: false
ACTION_REPO:
description: Repository with the build action
required: false
Expand Down Expand Up @@ -107,7 +113,9 @@ runs:
VARIANT=${{ inputs.VARIANT }} \
VERSION=${{ inputs.VERSION }} \
WEB_UI=${{ inputs.WEB_UI }} \
EXTRA_BOOT_PARAMS=${{ inputs.EXTRA_BOOT_PARAMS }}
EXTRA_BOOT_PARAMS=${{ inputs.EXTRA_BOOT_PARAMS }} \
SECURE_BOOT_KEY_URL=${{ inputs.SECURE_BOOT_KEY_URL }} \
ENROLLMENT_PASSWORD=${{ inputs.ENROLLMENT_PASSWORD }}
- name: Create deploy.iso and generate sha256 checksum
shell: bash
Expand All @@ -123,13 +131,3 @@ runs:
mkdir end_iso
sha256sum ${{ inputs.IMAGE_NAME }}-${{ inputs.IMAGE_TAG || inputs.VERSION }}.iso > ./end_iso/${{ inputs.IMAGE_NAME }}-${{ inputs.IMAGE_TAG || inputs.VERSION }}-CHECKSUM
mv ${{ inputs.IMAGE_NAME }}-${{ inputs.IMAGE_TAG || inputs.VERSION }}.iso end_iso/
- name: Upload ISO as artifact
uses: actions/upload-artifact@v4
with:
name: ${{ inputs.IMAGE_NAME }}-${{ inputs.IMAGE_TAG || inputs.VERSION }}.iso
path: end_iso/*
if-no-files-found: error
retention-days: 0
compression-level: 0
overwrite: true
13 changes: 11 additions & 2 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,15 @@
set -eu

# pre-create loop devices manually. In containers we can't use losetup for that.
mknod -m 0660 /dev/loop0 b 7 0 2> /dev/null || true
mknod -m 0660 /dev/loop0 b 7 0 2>/dev/null || true

make output/${IMAGE_NAME}-${IMAGE_TAG}.iso ARCH=${ARCH} VERSION=${VERSION} IMAGE_REPO=${IMAGE_REPO} IMAGE_NAME=${IMAGE_NAME} IMAGE_TAG=${IMAGE_TAG} VARIANT=${VARIANT} WEB_UI=${WEB_UI}
make output/${IMAGE_NAME}-${IMAGE_TAG}.iso \
ARCH=${ARCH} \
VERSION=${VERSION} \
IMAGE_REPO=${IMAGE_REPO} \
IMAGE_NAME=${IMAGE_NAME} \
IMAGE_TAG=${IMAGE_TAG} \
VARIANT=${VARIANT} \
WEB_UI=${WEB_UI} \
SECURE_BOOT_KEY_URL=${SECURE_BOOT_KEY_URL} \
ENROLLMENT_PASSWORD=${ENROLLMENT_PASSWORD}
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,23 @@

set -oue pipefail

readonly SECUREBOOT_KEY="/run/install/repo/ublue-os-akmods-public-key.der"
readonly ENROLLMENT_PASSWORD="ublue-os"

SYS_ID="$(cat /sys/devices/virtual/dmi/id/product_name)"
if [[ ":Jupiter:Galileo:" =~ ":$SYS_ID:" ]]; then
echo "Steam Deck hardware detected. Skipping key enrollment."
exit 0
fi
readonly ENROLLMENT_PASSWORD=@ENROLLMENT_PASSWORD@
readonly SECUREBOOT_KEY="/run/install/repo/sb_pubkey.der"

if [[ ! -d "/sys/firmware/efi" ]]; then
echo "EFI mode not detected. Skipping key enrollment."
exit 0
fi

if [[ ! -f "${SECUREBOOT_KEY}" ]]; then
echo "Secure boot key not found: ${SECUREBOOT_KEY}"
exit 1
echo "Secure boot key not provided: ${SECUREBOOT_KEY}"
exit 0
fi

SYS_ID="$(cat /sys/devices/virtual/dmi/id/product_name)"
if [[ ":Jupiter:Galileo:" =~ ":$SYS_ID:" ]]; then
echo "Steam Deck hardware detected. Skipping key enrollment."
exit 0
fi

mokutil --timeout -1 || :
Expand Down
Binary file removed scripts/ublue-os-akmods-public-key.der
Binary file not shown.
6 changes: 4 additions & 2 deletions xorriso/gen_input.sh.in
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ echo "-outdev $(pwd)/output/@IMAGE_NAME@-@IMAGE_TAG@.iso"
echo "-boot_image any replay"
echo "-joliet on"
echo "-compliance joliet_long_names"
echo "-map $(pwd)/scripts/ublue-os-akmods-public-key.der ublue-os-akmods-public-key.der"
echo "-chmod 0444 /ublue-os-akmods-public-key.der"
if [ -f $(pwd)/sb_pubkey.der ]; then
echo "-map $(pwd)/sb_pubkey.der sb_pubkey.der"
echo "-chmod 0444 /sb_pubkey.der"
fi
echo "-map $(pwd)/scripts/enroll-secureboot-key.sh enroll-secureboot-key.sh"
echo "-chmod 0777 enroll-secureboot-key.sh"
cd container
Expand Down
Loading