Skip to content

Commit

Permalink
Merge pull request #5098 from jkonecny12/f39-add-iso-build-scripts-to…
Browse files Browse the repository at this point in the history
…-templates

F39 add iso build scripts to templates
  • Loading branch information
jkonecny12 committed Sep 1, 2023
2 parents 8f8d761 + 2edbdae commit 55d5aa9
Show file tree
Hide file tree
Showing 9 changed files with 345 additions and 10 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/differential-shellcheck.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ jobs:
with:
severity: warning
token: ${{ secrets.GITHUB_TOKEN }}
exclude-path:
- '*.j2'
- '**/*.j2'

- if: ${{ always() }}
name: Upload artifact with ShellCheck defects in SARIF format
Expand Down
11 changes: 9 additions & 2 deletions dockerfile/anaconda-iso-creator/lorax-build
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
#!/bin/bash
# ======================================
# WARNING!
# THIS FILE IS GENERATED FROM A TEMPLATE
# DO NOT EDIT THIS FILE MANUALLY!
# ======================================
# The template is located in: lorax-build.j2

#
# Build a boot.iso by lorax. The boot.iso will be stored in the `/images/` directory.
# We have to build the RPMs files of Anaconda first and then add them as volume
Expand Down Expand Up @@ -34,8 +41,8 @@ createrepo_c $REPO_DIR
# The download.fedoraproject.org automatic redirector often selects download-ib01.f.o. for GitHub's cloud, which is too unreliable; use a mirror
# The --volid argument can cause different network interface naming: https://github.com/rhinstaller/kickstart-tests/issues/448
lorax -p Fedora -v "$VERSION_ID" -r "$VERSION_ID" \
--volid Fedora-S-dvd-x86_64-rawh \
-s http://dl.fedoraproject.org/pub/fedora/linux/development/rawhide/Everything/x86_64/os/ \
--volid Fedora-S-dvd-x86_64-39 \
-s http://dl.fedoraproject.org/pub/fedora/linux/development/39/Everything/x86_64/os/ \
-s file://$REPO_DIR/ \
"$@" \
output || cp *.log "$OUT_DIR"
Expand Down
11 changes: 9 additions & 2 deletions dockerfile/anaconda-iso-creator/lorax-build-webui
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
#!/bin/bash
# ======================================
# WARNING!
# THIS FILE IS GENERATED FROM A TEMPLATE
# DO NOT EDIT THIS FILE MANUALLY!
# ======================================
# The template is located in: lorax-build-webui.j2

#
# Build a Web UI boot.iso by lorax. The boot.iso will be stored in the `/images/` directory.
# We have to build the RPMs files of Anaconda first and then add them as volume
Expand Down Expand Up @@ -43,9 +50,9 @@ patch -p2 -i /adjust-templates-for-webui.patch
# The download.fedoraproject.org automatic redirector often selects download-ib01.f.o. for GitHub's cloud, which is too unreliable; use a mirror
# The --volid argument can cause different network interface naming: https://github.com/rhinstaller/kickstart-tests/issues/448
lorax -p Fedora -v "$VERSION_ID" -r "$VERSION_ID" \
--volid Fedora-S-dvd-x86_64-rawh \
--volid Fedora-S-dvd-x86_64-39 \
--sharedir ./templates.d/99-generic/ \
-s http://dl.fedoraproject.org/pub/fedora/linux/development/rawhide/Everything/x86_64/os/ \
-s http://dl.fedoraproject.org/pub/fedora/linux/development/39/Everything/x86_64/os/ \
-s https://fedorapeople.org/groups/anaconda/webui_new_payload/repo/ \
-s file://$REPO_DIR/ \
-i anaconda-webui -i webui_payload -i cockpit-ws -i cockpit-bridge -i firefox -i dbus-glib --rootfs-size 5 \
Expand Down
62 changes: 62 additions & 0 deletions dockerfile/anaconda-iso-creator/lorax-build-webui.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
#!/bin/bash
#
# Build a Web UI boot.iso by lorax. The boot.iso will be stored in the `/images/` directory.
# We have to build the RPMs files of Anaconda first and then add them as volume
# mount to /anaconda-rpms to the container (could be RO mount).
#
# Compared to the normal boot.iso we need to patch the templates but other than
# that it's mostly the same.
#
# To run this please do:
#
# sudo make -f ./Makefile.am container-rpms-scratch
# sudo podman run -i --rm --privileged --tmpfs /var/tmp:rw,mode=1777 -v `pwd`/result/build/01-rpm-build:/anaconda-rpms:ro -v `pwd`/output-dir:/images:z --entrypoint /lorax-build-webui quay.io/rhinstaller/anaconda-iso-creator:master
#
#
# Input directory:
# /anaconda-rpms/ (Anaconda RPM files for the build)
#
# Output directory:
# /images (Where the boot.iso will be stored)
#

set -eux

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

INPUT_RPMS=/anaconda-rpms/
OUT_DIR=/images/
REPO_DIR=/tmp/anaconda-rpms/

# create repo from provided Anaconda RPMs
mkdir -p $REPO_DIR
cp -a $INPUT_RPMS/* $REPO_DIR || echo "RPM files can't be copied!" # We could just do the build with official repositories only
createrepo_c $REPO_DIR

cp -r /usr/share/lorax/templates.d/ /lorax/
patch -p2 -i /adjust-templates-for-webui.patch

# build boot.iso with our rpms
. /etc/os-release
# The download.fedoraproject.org automatic redirector often selects download-ib01.f.o. for GitHub's cloud, which is too unreliable; use a mirror
# The --volid argument can cause different network interface naming: https://github.com/rhinstaller/kickstart-tests/issues/448
lorax -p Fedora -v "$VERSION_ID" -r "$VERSION_ID" \
{% if distro_release == "rawhide" %}
--volid Fedora-S-dvd-x86_64-rawh \
{% else %}
--volid Fedora-S-dvd-x86_64-{$ distro_release $} \
{% endif %}
--sharedir ./templates.d/99-generic/ \
-s http://dl.fedoraproject.org/pub/fedora/linux/development/{$ distro_release $}/Everything/x86_64/os/ \
-s https://fedorapeople.org/groups/anaconda/webui_new_payload/repo/ \
-s file://$REPO_DIR/ \
-i anaconda-webui -i webui_payload -i cockpit-ws -i cockpit-bridge -i firefox -i dbus-glib --rootfs-size 5 \
"$@" \
output || cp *.log "$OUT_DIR"

cp output/images/boot.iso "$OUT_DIR"

# fix permissions to user permissions on the built artifacts
chown -Rv --reference="$INPUT_RPMS" "$OUT_DIR"
50 changes: 50 additions & 0 deletions dockerfile/anaconda-iso-creator/lorax-build.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#!/bin/bash
#
# Build a boot.iso by lorax. The boot.iso will be stored in the `/images/` directory.
# We have to build the RPMs files of Anaconda first and then add them as volume
# mount to /anaconda-rpms to the container (could be RO mount).
#
# sudo make -f ./Makefile.am container-rpms-scratch
# sudo podman run -i --rm --privileged --tmpfs /var/tmp:rw,mode=1777 -v `pwd`/result/build/01-rpm-build:/anaconda-rpms:ro -v `pwd`/output-dir:/images:z quay.io/rhinstaller/anaconda-iso-creator:master
#
# Input directory:
# /anaconda-rpms/ (Anaconda RPM files for the build)
#
# Output directory:
# /images (Where the boot.iso will be stored)
#

set -eux

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

INPUT_RPMS=/anaconda-rpms/
OUT_DIR=/images/
REPO_DIR=/tmp/anaconda-rpms/

# create repo from provided Anaconda RPMs
mkdir -p $REPO_DIR
cp -a $INPUT_RPMS/* $REPO_DIR || echo "RPM files can't be copied!" # We could just do the build with official repositories only
createrepo_c $REPO_DIR

# build boot.iso with our rpms
. /etc/os-release
# The download.fedoraproject.org automatic redirector often selects download-ib01.f.o. for GitHub's cloud, which is too unreliable; use a mirror
# The --volid argument can cause different network interface naming: https://github.com/rhinstaller/kickstart-tests/issues/448
lorax -p Fedora -v "$VERSION_ID" -r "$VERSION_ID" \
{% if distro_release == "rawhide" %}
--volid Fedora-S-dvd-x86_64-rawh \
{% else %}
--volid Fedora-S-dvd-x86_64-{$ distro_release $} \
{% endif %}
-s http://dl.fedoraproject.org/pub/fedora/linux/development/{$ distro_release $}/Everything/x86_64/os/ \
-s file://$REPO_DIR/ \
"$@" \
output || cp *.log "$OUT_DIR"

cp output/images/boot.iso "$OUT_DIR"

# fix permissions to user permissions on the built artifacts
chown -Rv --reference="$INPUT_RPMS" "$OUT_DIR"
9 changes: 8 additions & 1 deletion dockerfile/anaconda-live-iso-creator/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# ======================================
# WARNING!
# THIS FILE IS GENERATED FROM A TEMPLATE
# DO NOT EDIT THIS FILE MANUALLY!
# ======================================
# The template is located in: Dockerfile.j2

# Dockerfile to build Live iso with Anaconda from the repository.
# To find out how to build this container please look on the ./tests/README.rst file.
# This container has to be started as --privileged and with precreated loop devices otherwise
Expand Down Expand Up @@ -49,7 +56,7 @@ RUN set -ex; \
# required for ksflatten
pykickstart; \
mkdir /fedora-kickstarts; \
git clone https://pagure.io/fedora-kickstarts.git /fedora-kickstarts; \
git clone -b f39 https://pagure.io/fedora-kickstarts.git /fedora-kickstarts; \
cd /fedora-kickstarts; \
ksflatten -o /lorax/workstation.ks -c fedora-live-workstation.ks; \
# cleanups of parts which don't need to be part of the container
Expand Down
67 changes: 67 additions & 0 deletions dockerfile/anaconda-live-iso-creator/Dockerfile.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# Dockerfile to build Live iso with Anaconda from the repository.
# To find out how to build this container please look on the ./tests/README.rst file.
# This container has to be started as --privileged and with precreated loop devices otherwise
# lorax won't work correctly.
#
# Execution example:
#
# make -f ./Makefile.am container-rpms-scratch # Create Anaconda RPM in `pwd`/result/... directory.
# sudo make -f ./Makefile.am anaconda-live-iso-creator-build
#
# # /var/tmp tmpfs speeds up lorax and avoids https://bugzilla.redhat.com/show_bug.cgi?id=1906364
# sudo podman run -i --rm --privileged --tmpfs /var/tmp:rw,mode=1777 -v `pwd`/result/build/01-rpm-build:/anaconda-rpms:ro -v `pwd`/output-dir:/images:z quay.io/rhinstaller/anaconda-live-iso-creator:master
#
# note:
# - add `--network=slirp4netns` if you need to share network with host computer to reach
# repositories (VPN for example)
#

# The `image` arg will set base image for the build.
# possible values:
# registry.fedoraproject.org/fedora:35
# registry.fedoraproject.org/fedora:rawhide
# registry-proxy.engineering.redhat.com/rh-osbs/ubi9:latest # private source
# registry.access.redhat.com/ubi8/ubi # public source
ARG image
FROM ${image}
# FROM starts a new build stage with new ARGs. Put any ARGs after FROM unless required by the FROM itself.
# see https://docs.docker.com/engine/reference/builder/#understand-how-arg-and-from-interact
LABEL maintainer=anaconda-devel@lists.fedoraproject.org

# Prepare environment and install build dependencies
RUN set -ex; \
dnf update -y; \
dnf install -y \
createrepo_c \
# for clonning cockpit-project/bots/
git \
# to be able to read ip of the container and pass that to VM
iproute \
lorax-lmc-virt; \
dnf clean all

RUN mkdir /lorax /anaconda-rpms /images

# Generate kickstart file for Fedora Workstation
# TODO: add our local repository to the kickstart file
RUN set -ex; \
dnf install -y \
# required for ksflatten
pykickstart; \
mkdir /fedora-kickstarts; \
{% if distro_release == "rawhide" %}
git clone -b main https://pagure.io/fedora-kickstarts.git /fedora-kickstarts; \
{% else %}
git clone -b f{$ distro_release $} https://pagure.io/fedora-kickstarts.git /fedora-kickstarts; \
{% endif %}
cd /fedora-kickstarts; \
ksflatten -o /lorax/workstation.ks -c fedora-live-workstation.ks; \
# cleanups of parts which don't need to be part of the container
dnf remove -y pykickstart; dnf clean all; \
rm -rf /fedora-kickstarts

COPY ["lmc-build", "/"]

WORKDIR /lorax

ENTRYPOINT /lmc-build
17 changes: 12 additions & 5 deletions dockerfile/anaconda-live-iso-creator/lmc-build
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
#!/bin/bash
# ======================================
# WARNING!
# THIS FILE IS GENERATED FROM A TEMPLATE
# DO NOT EDIT THIS FILE MANUALLY!
# ======================================
# The template is located in: lmc-build.j2

#
# Build a Fedora Workstation Live ISO by livemedia-creator. The Live iso will be stored in the `/images/` directory.
# We have to build the RPMs files of Anaconda first and then add them as volume
Expand Down Expand Up @@ -56,12 +63,12 @@ popd


#### get ISO for build ####
# download new cockpit CI rawhide iso (it's gated)
# download new cockpit CI iso (it's gated)
mkdir /var/tmp/lmc-build
pushd /var/tmp/lmc-build
git clone --depth 1 https://github.com/cockpit-project/bots.git
./bots/image-download fedora-rawhide-boot
cp -L ./bots/images/fedora-rawhide-boot /lorax/fedora-rawhide-boot.iso
./bots/image-download fedora-39-boot
cp -L ./bots/images/fedora-39-boot /lorax/fedora-boot.iso
rm -rf ./bots
popd

Expand Down Expand Up @@ -104,10 +111,10 @@ livemedia-creator \
--iso-name="Fedora-Workstation.iso" \
--macboot \
--project=Fedora-Workstation-Live \
--releasever=Rawhide \
--releasever=39 \
--vcpus=$proposed_cpu \
--ram=$proposed_mem \
--iso=/lorax/fedora-rawhide-boot.iso \
--iso=/lorax/fedora-boot.iso \
--ks=$WORKSTATION_KS \
--logfile="$LOG_DIR/build.log" \
--resultdir=/lorax/result
Expand Down
Loading

0 comments on commit 55d5aa9

Please sign in to comment.