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

Add example of using livemedia-creator inside GitHub Actions #1374

Closed
wants to merge 1 commit into from
Closed
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
79 changes: 79 additions & 0 deletions .github/workflows/example-livemedia-creator.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
name: Build Fedora ISO
# An example of how to use livemedia-creator in GitHub Actions
# to build a custom Fedora ISO.


on:
workflow_dispatch:
inputs:
# Force host version to match OS it's building.
# Recommended since we use '--no-virt' in livemedia-creator
# https://weldr.io/lorax/livemedia-creator.html#anaconda-image-install-no-virt
fedora_release:
description: 'Fedora release to build'
required: true
default: 39
type: number

kickstart_path:
description: 'Path to the kickstart file'
required: true
default: './docs/fedora-livemedia.ks'
type: string

jobs:

fedora-build:
runs-on: ubuntu-latest
container:
image: "fedora:${{ inputs.fedora_release }}"
# --privileged needed for livemedia-creator
options: --privileged
steps:
- uses: actions/checkout@v4

- name: Install dependencies
# zstd: Lets you use github caching actions inside fedora too
# pykickstart: To lint the kickstart file
# lorax lorax-lmc-novirt anaconda: To actually build the ISO
run: dnf install -y zstd lorax lorax-lmc-novirt anaconda pykickstart

- name: Lint Kickstart file
run: ksvalidator "${{ inputs.kickstart_path }}"

## Create the ISO
- name: Create the custom ISO
# --no-virt: Needed since we're in a container, no host CPU
# --squashfs-only: Just to speed things up, not required
run: |
livemedia-creator \
--ks "${{ inputs.kickstart_path }}" \
--no-virt \
--make-iso \
--iso-only \
--squashfs-only \
--iso-name Fedora-custom-example.iso \
--project Fedora \
--volid "Fedora-${{ inputs.fedora_release }}" \
--releasever "${{ inputs.fedora_release }}" \
--resultdir ./Results

- name: Upload ISO
uses: actions/[email protected]
with:
name: "Fedora-custom-example-${{ inputs.fedora_release }}.iso"
path: ./Results/Fedora-custom-example.iso
overwrite: True

## Capture debug info if run fails, AND logs exist:
- name: "DEBUG: Print program.log"
if: failure() && hashFiles('./program.log') != ''
run: |
ls -hl ./program.log
cat ./program.log

- name: "DEBUG: Print livemedia.log"
if: failure() && hashFiles('./livemedia.log') != ''
run: |
ls -hl ./program.log
cat ./livemedia.log
2 changes: 1 addition & 1 deletion .tito/packages/lorax
Original file line number Diff line number Diff line change
@@ -1 +1 @@
39.5-1 ./
40.4-1 ./
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ local-srpm: local $(PKGNAME).spec
lorax.spec

test-in-copy:
rsync -a --exclude=.git /lorax-ro/ /lorax/
rsync -a --no-perms --exclude=.git /lorax-ro/ /lorax/
make -C /lorax/ $(RUN_TESTS)
cp /lorax/.coverage /test-results/

Expand Down
41 changes: 39 additions & 2 deletions lorax.spec
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
%define debug_package %{nil}

Name: lorax
Version: 39.5
Version: 40.4
Release: 1%{?dist}
Summary: Tool for creating the anaconda install images

Expand Down Expand Up @@ -50,7 +50,7 @@ Requires: psmisc
Requires: libselinux-python3
Requires: python3-mako
Requires: python3-kickstart >= 3.19
Requires: python3-dnf >= 3.2.0
Requires: python3-libdnf5
Requires: python3-librepo
Requires: python3-pycdio

Expand Down Expand Up @@ -168,6 +168,43 @@ make DESTDIR=$RPM_BUILD_ROOT mandir=%{_mandir} install
%{_datadir}/lorax/templates.d/*

%changelog
* Thu Feb 01 2024 Brian C. Lane <[email protected]> 40.4-1
- mkksiso: Add support for adding an anaconda updates.img ([email protected])
- runtime-install: drop kdump-anaconda-addon ([email protected])
- ltmpl: Handle installing provides with resolve_pkg_spec ([email protected])
- s390: Escape volid before using it ([email protected])
- aarch64: Escape volid before using it ([email protected])
- runtime-install: drop retired pcmciautils ([email protected])
- runtime-install: wget2-wget has replaced wget ([email protected])
- runtime-cleanup: anaconda's new interface needs stdbuf ([email protected])
- ltmpl: Pass packages to add_rpm_install as strings ([email protected])

* Wed Dec 20 2023 Brian C. Lane <[email protected]> 40.3-1
- runtime-install: Work around problem with conflicting packages ([email protected])
- ltmpl: Check for errors after running the transaction ([email protected])

* Tue Dec 12 2023 Brian C. Lane <[email protected]> 40.2-1
- ltmpl: Remove duplicate package objects from dnf5 results ([email protected])
- test-in-podman: Fix problem running in github actions ([email protected])

* Mon Dec 11 2023 Brian C. Lane <[email protected]> 40.1-1
- ltmpl: Filter out other arches, clean up naming ([email protected])
- test: Add pigz to test-packages ([email protected])
- dnfbase: Fix url substitution support ([email protected])
- ltmpl: Add transaction error handling ([email protected])
- test-packages: Make sure python3-libdnf5 is installed ([email protected])
- Updates for latest libdnf5 changes ([email protected])
- spec: Switch to using python3-libdnf5 ([email protected])
- Fix writing out debug info for package files and sizes ([email protected])
- libdnf5: Switch lorax to use libdnf5 ([email protected])
- Add python3-libdnf5 to the list of test packages ([email protected])
- Adjust runtime-postinstall.tmpl for systemd config files move ([email protected])

* Mon Oct 02 2023 Brian C. Lane <[email protected]> 40.0-1
- Remove some unneccessary storage packages from runtime-install ([email protected])
- Do not install polkit-gnome for blivet-gui ([email protected])
- docs: Update the quickstart example command ([email protected])

* Thu Sep 07 2023 Brian C. Lane <[email protected]> 39.5-1
- Explicitly pull in more filesystem packages ([email protected])
- runtime-postinstall: Turn off lvm monitoring ([email protected])
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
data_files.append(("/usr/bin", ["src/bin/image-minimizer", "src/bin/mkksiso"]))

setup(name="lorax",
version="39.5",
version="40.4",
description="Lorax",
long_description="Tools for creating bootable images, including the Anaconda boot.iso",
author="Martin Gracik, Will Woods <[email protected]>, Brian C. Lane <[email protected]>",
Expand Down
6 changes: 6 additions & 0 deletions share/templates.d/99-generic/aarch64.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ KERNELDIR=PXEBOOTDIR
STAGE2IMG="images/install.img"
LORAXDIR="usr/share/lorax/"

## Don't allow spaces or escape characters in the iso label
def valid_label(ch):
return ch.isalnum() or ch == '_'

isolabel = ''.join(ch if valid_label(ch) else '-' for ch in isolabel)

import os
from os.path import basename
from pylorax.sysutils import joinpaths
Expand Down
2 changes: 1 addition & 1 deletion share/templates.d/99-generic/runtime-cleanup.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ removefrom coreutils /usr/bin/pinky /usr/bin/pr /usr/bin/printenv
removefrom coreutils /usr/bin/printf /usr/bin/ptx /usr/bin/runcon
removefrom coreutils /usr/bin/sha224sum /usr/bin/sha384sum
removefrom coreutils /usr/bin/sha512sum /usr/bin/shuf /usr/bin/stat
removefrom coreutils /usr/bin/stdbuf /usr/bin/sum /usr/bin/test
removefrom coreutils /usr/bin/sum /usr/bin/test
removefrom coreutils /usr/bin/timeout /usr/bin/truncate /usr/bin/tsort
removefrom coreutils /usr/bin/unexpand /usr/bin/users /usr/bin/vdir
removefrom coreutils /usr/bin/who /usr/bin/whoami /usr/bin/yes
Expand Down
27 changes: 6 additions & 21 deletions share/templates.d/99-generic/runtime-install.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ GRUB2VER="1:2.06-67"
%>

## anaconda package
installpkg anaconda anaconda-widgets kdump-anaconda-addon anaconda-install-img-deps
installpkg anaconda anaconda-widgets
## work around dnf5 bug - https://github.com/rpm-software-management/dnf5/issues/1111
installpkg anaconda-install-img-deps>=40.15
## Other available payloads
installpkg dnf
installpkg rpm-ostree ostree
Expand Down Expand Up @@ -114,30 +116,16 @@ installpkg kbd kbd-misc
installpkg tar xz curl bzip2

## basic system stuff
installpkg systemd-sysv systemd-units
installpkg rsyslog

## filesystem tools
installpkg btrfs-progs jfsutils xfsprogs ntfs-3g ntfsprogs dosfstools e2fsprogs f2fs-tools
installpkg system-storage-manager
## extra storage tools for rescue mode
installpkg device-mapper-persistent-data
installpkg xfsdump

## extra storage packages
# hostname is needed for iscsi to work, see RHBZ#1593917
installpkg udisks2 udisks2-iscsi hostname

## extra libblockdev plugins
installpkg libblockdev-lvm-dbus

## needed for LUKS escrow
installpkg volume_key
installpkg nss-tools

## blivet-gui-runtime requires PolicyKit-authentication-agent, if we
## don't tell dnf what to pick it picks lxpolkit, which drags in gtk2
installpkg polkit-gnome

## SELinux support
installpkg selinux-policy-targeted audit

Expand All @@ -153,10 +141,7 @@ installpkg nmap-ncat
installpkg pciutils usbutils ipmitool
installpkg mt-st smartmontools
installpkg hdparm
%if basearch not in ("aarch64", "ppc64le", "s390x"):
installpkg pcmciautils
%endif
installpkg libmlx4 rdma-core
installpkg rdma-core
installpkg rng-tools
%if basearch in ("x86_64", "aarch64"):
installpkg dmidecode
Expand Down Expand Up @@ -196,7 +181,7 @@ installpkg python3-pyatspi
## extra tools not required by anaconda
installpkg nano nano-default-editor
installpkg vim-minimal strace lsof dump xz less
installpkg wget rsync bind-utils ftp mtr vconfig
installpkg wget2-wget rsync bind-utils ftp mtr vconfig
installpkg spice-vdagent
installpkg gdisk hexedit sg3_utils

Expand Down
3 changes: 2 additions & 1 deletion share/templates.d/99-generic/runtime-postinstall.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ remove usr/lib/tmpfiles.d/etc.conf

## Make logind activate [email protected] on switch to empty VT
symlink [email protected] lib/systemd/system/[email protected]
replace "#ReserveVT=6" "ReserveVT=2" etc/systemd/logind.conf
mkdir usr/lib/systemd/logind.conf.d
append usr/lib/systemd/logind.conf.d/anaconda-shell.conf "[Login]\nReserveVT=2"

## Don't write the journal to the overlay, just keep it in RAM
remove var/log/journal
Expand Down
8 changes: 7 additions & 1 deletion share/templates.d/99-generic/s390.tmpl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<%page args="kernels, runtime_img, runtime_base, basearch, inroot, outroot"/>
<%page args="kernels, runtime_img, runtime_base, basearch, inroot, outroot, isolabel"/>
<%
configdir="tmp/config_files/s390"
BOOTDIR="images"
Expand All @@ -9,6 +9,12 @@ MKS390IMAGE="/usr/bin/mk-s390image"
# The assumption seems to be that there is only one s390 kernel, ever
kernel = kernels[0]

## Don't allow spaces or escape characters in the iso label
def valid_label(ch):
return ch.isalnum() or ch == '_'

isolabel = ''.join(ch if valid_label(ch) else '-' for ch in isolabel)

import os
from os.path import basename
from pylorax.sysutils import joinpaths
Expand Down
17 changes: 12 additions & 5 deletions src/bin/mkksiso
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ def CheckDiscinfo(path):
raise RuntimeError("iso arch does not match the host arch.")


def MakeKickstartISO(input_iso, output_iso, ks="", add_paths=None,
def MakeKickstartISO(input_iso, output_iso, ks="", updates_image="", add_paths=None,
cmdline="", rm_args="", new_volid="", implantmd5=True,
skip_efi=False):
"""
Expand Down Expand Up @@ -511,7 +511,12 @@ def MakeKickstartISO(input_iso, output_iso, ks="", add_paths=None,
for p in add_paths:
cmd.extend(["-map", p, os.path.basename(p)])

if CheckBigFiles(add_paths):
# include updates image which will be automatically loaded when on correct place
if updates_image:
cmd.extend(["-map", updates_image, "updates/updates.img"])

check_paths = add_paths if not updates_image else add_paths + [updates_image]
if CheckBigFiles(check_paths):
if "-as" not in cmd:
cmd.extend(["-as", "mkisofs"])
cmd.extend(["-iso-level", "3"])
Expand Down Expand Up @@ -555,6 +560,8 @@ def setup_arg_parser():
help="Do not run implantisomd5 on the ouput iso")
parser.add_argument("--ks", type=os.path.abspath, metavar="KICKSTART",
help="Optional kickstart to add to the ISO")
parser.add_argument("-u", "--updates", type=os.path.abspath, metavar="IMAGE",
help="Optional updates image to add to the ISO")
parser.add_argument("-V", "--volid", dest="volid", help="Set the ISO volume id, defaults to input's", default=None)
parser.add_argument("--skip-mkefiboot", action="store_true", dest="skip_efi",
help="Skip running mkefiboot")
Expand Down Expand Up @@ -599,14 +606,14 @@ def main():
log.error("Use either --ks KICKSTART or positional KICKSTART but not both")
errors = True

if not any([args.ks or args.ks_pos, args.add_paths, args.cmdline, args.rm_args, args.volid]):
log.error("Nothing to do - pass one or more of --ks, --add, --cmdline, --rm-args, --volid")
if not any([args.ks or args.ks_pos, args.updates, args.add_paths, args.cmdline, args.rm_args, args.volid]):
log.error("Nothing to do - pass one or more of --ks, --updates, --add, --cmdline, --rm-args, --volid")
errors = True

if errors:
raise RuntimeError("Problems running %s" % sys.argv[0])

MakeKickstartISO(args.input_iso, args.output_iso, args.ks or args.ks_pos,
MakeKickstartISO(args.input_iso, args.output_iso, args.ks or args.ks_pos, args.updates,
args.add_paths, args.cmdline, args.rm_args,
args.volid, args.no_md5sum, args.skip_efi)
except RuntimeError as e:
Expand Down
Loading