Created
January 22, 2024 13:16
-
-
Save M4rtinK/ef7a1da8ab3ed2649236e9f5cb1e96ed to your computer and use it in GitHub Desktop.
Automatically update Fedora boot.iso with Anaconda installer changes. v1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Create a self contained ISO image containing Anaconda changes | |
# ============================================================= | |
# | |
# This script fetches a Fedora Rawhide boot.iso, clones the Anaconda | |
# installer upstream repo, creates an updates image from the repo | |
# and then produces an output iso that includes and automatically | |
# applies the updates image. | |
# | |
# How to use | |
# ========== | |
# 0. adjust the user configuration variables | |
# - Rawhide ISO name (pick suitable Rawhide nightly) | |
# - Anaconda tag (check Anaconda version on the image, | |
# best by downloading the image and checking Anaconda | |
# version number on TTY2 or possibly from image build logs) | |
# 1. clone Anaconda or run this script at least once | |
# (it will clone the Anaconda repo if none is found) | |
# 2. change Anaconda source code as necessary | |
# 3. run the script (NOTE: the image creation step requires sudo) | |
# 4. boot the resulting output boot.iso via the VM software of your | |
# choice (virt manager, Boxes, Cockpit Machines, virt-install, etc.) | |
# User configuration variables | |
# =================================== | |
RAWHIDE_ISO="Fedora-Everything-netinst-x86_64-Rawhide-20240119.n.0.iso" | |
ANACONDA_TAG="anaconda-40.17-1" | |
ANACONDA_GIT_URL="https://github.com/rhinstaller/anaconda" | |
RAWHIDE_ISO_URL_PREFIX="https://dl.fedoraproject.org/pub/fedora/linux/development/rawhide/Everything/x86_64/iso/" | |
RAWHIDE_ISO_URL=${RAWHIDE_ISO_URL_PREFIX}${RAWHIDE_ISO} | |
OUTPUT_ISO=${ANACONDA_TAG}"_boot.iso" | |
# check if we have the Rawhide boot.iso | |
if [ -f ${RAWHIDE_ISO} ]; then | |
echo "** Rawhide boot.iso exists, skipping download" | |
else | |
echo "** downloading Rawhide boot iso from:" | |
echo ${RAWHIDE_ISO_URL} | |
wget ${RAWHIDE_ISO_URL} | |
fi | |
# check if the file was actually downloaded | |
if [ ! -f ${RAWHIDE_ISO} ]; then | |
echo "** Rawhide boot.iso download failed, check if the image URL is valid" | |
exit 1 | |
fi | |
# check if we have the Anaconda checkout | |
if [ -d "anaconda" ]; then | |
echo "** Anaconda checkout exists, skipping download" | |
else | |
echo "** cloning Anaconda:" | |
echo ${ANACONDA_GIT_URL} | |
git clone ${ANACONDA_GIT_URL} | |
fi | |
# create updates image | |
pushd anaconda | |
./scripts/makeupdates -k -c -t ${ANACONDA_TAG} | |
popd | |
# make sure the images folder exists | |
# - we need this folder so that we end up | |
# with the /images/updates.img path on the | |
# boot.iso | |
# - if /images/updates.img if detected when the | |
# boot.iso boots, the updates image is automatically | |
# applied | |
mkdir -p images | |
# copy the updates image to the folder | |
cp anaconda/updates.img images/ | |
# check if mkksiso (needed the create the modified image) exists | |
if ! command -v mkksiso &> /dev/null | |
then | |
echo "mkksiso tool not fond, please install the lorax package first" | |
exit 1 | |
fi | |
# remove previous output image, if any (or else mkksiso will refuse to build a new one) | |
if [ -f ${OUTPUT_ISO} ]; then | |
echo "** removing previous output iso" | |
rm -f ${OUTPUT_ISO} | |
fi | |
# create a modified boot.iso that automatically uses the updates image | |
# by placing it in the updates folder on the image | |
echo "** generating output iso with updates image" | |
sudo mkksiso -a images ${RAWHIDE_ISO} ${OUTPUT_ISO} | |
echo "** output iso ready, boot it with a VM runner of your choice:" | |
echo ${OUTPUT_ISO} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment