Add option to build online ISO (#6)

* We will use iwctl directly

* Make it possible to tweak build script

* Allow the toggling

* Add online iso build option

* Formatting
This commit is contained in:
David Heinemeier Hansson authored and GitHub committed 2025-08-19 10:21:44 +02:00
1 parent ccd54ece8f
commit 217f84de33
3 files changed
+209 -65

No files matched your search

+63 -62
View File
@@ -22,75 +22,75 @@ export PIP_BREAK_SYSTEM_PACKAGES=1
# These packages will be installed **into** the ISO, and
# won't be available to either archinstall or omarchy installer.
python_packages=(
terminaltexteffects
terminaltexteffects
)
arch_packages=(
git
impala
gum
openssl
wget
tzupdate # This is technically an AUR package
git
impala
gum
openssl
wget
tzupdate # This is technically an AUR package
)
prepare_offline_mirror() {
# Certain packages in omarchy.packages are AUR packages.
# These needs to be pre-built and placed in https://omarchy.blyg.se/aur/os/x86_64/
echo "Reading and combining packages from all package files..."
# Combine all packages from both files into one array
all_packages=()
for package_file in omarchy.packages archinstall.packages; do
if [ -f "$package_file" ]; then
echo "Reading $package_file..."
while IFS= read -r package; do
# Skip empty lines and comments
[[ -z "$package" || "$package" =~ ^[[:space:]]*# ]] && continue
all_packages+=("$package")
done < "$package_file"
fi
done
# Certain packages in omarchy.packages are AUR packages.
# These needs to be pre-built and placed in https://omarchy.blyg.se/aur/os/x86_64/
echo "Reading and combining packages from all package files..."
if [ ${#all_packages[@]} -gt 0 ]; then
# This assume we've manually built all the AUR packages
# and made them accessible "online" during the build process:
(cd $cache_dir/ && git apply /aur-mirror.patch)
# Combine all packages from both files into one array
all_packages=()
for package_file in omarchy.packages archinstall.packages; do
if [ -f "$package_file" ]; then
echo "Reading $package_file..."
while IFS= read -r package; do
# Skip empty lines and comments
[[ -z "$package" || "$package" =~ ^[[:space:]]*# ]] && continue
all_packages+=("$package")
done <"$package_file"
fi
done
mkdir -p /tmp/offlinedb
# Change DownloadUser from alpm to root to fix permission issues when downloading to cache dir
# TODO: We should move the build root from /root/.cache/omarchy/ into /var/cache instead.
# That way alpm:alpm will have access, which is the default pacman download user now days.
sed -i 's/^#*DownloadUser = alpm/DownloadUser = root/' /etc/pacman.conf
if [ ${#all_packages[@]} -gt 0 ]; then
# This assume we've manually built all the AUR packages
# and made them accessible "online" during the build process:
(cd $cache_dir/ && git apply /aur-mirror.patch)
# Download all the packages to the offline mirror inside the ISO
pacman --config $cache_dir/pacman.conf \
--noconfirm -Syw "${all_packages[@]}" \
--cachedir $offline_mirror_dir/ \
--dbpath /tmp/offlinedb
repo-add --new "$offline_mirror_dir/offline.db.tar.gz" "$offline_mirror_dir/"*.pkg.tar.zst
mkdir -p /tmp/offlinedb
rm "$cache_dir/airootfs/etc/pacman.d/hooks/uncomment-mirrors.hook"
# Revert the "online" AUR patch, as we'll replace it with the proper
# offline patched mirror for the ISO later.
(cd $cache_dir && git apply -R /aur-mirror.patch)
fi
# Change DownloadUser from alpm to root to fix permission issues when downloading to cache dir
# TODO: We should move the build root from /root/.cache/omarchy/ into /var/cache instead.
# That way alpm:alpm will have access, which is the default pacman download user now days.
sed -i 's/^#*DownloadUser = alpm/DownloadUser = root/' /etc/pacman.conf
# Download all the packages to the offline mirror inside the ISO
pacman --config $cache_dir/pacman.conf \
--noconfirm -Syw "${all_packages[@]}" \
--cachedir $offline_mirror_dir/ \
--dbpath /tmp/offlinedb
repo-add --new "$offline_mirror_dir/offline.db.tar.gz" "$offline_mirror_dir/"*.pkg.tar.zst
rm "$cache_dir/airootfs/etc/pacman.d/hooks/uncomment-mirrors.hook"
# Revert the "online" AUR patch, as we'll replace it with the proper
# offline patched mirror for the ISO later.
(cd $cache_dir && git apply -R /aur-mirror.patch)
fi
}
make_archiso_offline() {
# This function will simply disable any online activity we have.
# for instance the reflector.service which tries to optimize
# mirror order by fetching the latest mirror list by default.
#
# We'll leave some things online, like NTP as that won't
# interfere with anything, on the flip side it will help if we do
# have internet connectivity.
# This function will simply disable any online activity we have.
# for instance the reflector.service which tries to optimize
# mirror order by fetching the latest mirror list by default.
#
# We'll leave some things online, like NTP as that won't
# interfere with anything, on the flip side it will help if we do
# have internet connectivity.
rm "$cache_dir/airootfs/etc/systemd/system/multi-user.target.wants/reflector.service"
rm -rf "$cache_dir/airootfs/etc/systemd/system/reflector.service.d"
rm -rf "$cache_dir/airootfs/etc/xdg/reflector"
rm "$cache_dir/airootfs/etc/systemd/system/multi-user.target.wants/reflector.service"
rm -rf "$cache_dir/airootfs/etc/systemd/system/reflector.service.d"
rm -rf "$cache_dir/airootfs/etc/xdg/reflector"
}
mkdir -p $cache_dir/
@@ -117,7 +117,7 @@ cp /check_connectivity.sh "$cache_dir/airootfs/root/check_connectivity.sh"
# We add in our auto-start applications
# First we'll check for an active internet connection
# Then we'll start the omarchy installer
cat <<- _EOF_ | tee $cache_dir/airootfs/root/.automated_script.sh
cat <<-_EOF_ | tee $cache_dir/airootfs/root/.automated_script.sh
#!/usr/bin/env bash
if [[ \$(tty) == "/dev/tty1" ]]; then
@@ -188,7 +188,7 @@ rm "$cache_dir/airootfs/etc/motd"
pip install "${python_packages[@]}"
# Add our needed packages to packages.x86_64
printf '%s\n' "${arch_packages[@]}" >> "$cache_dir/packages.x86_64"
printf '%s\n' "${arch_packages[@]}" >>"$cache_dir/packages.x86_64"
# We have to do this, because `mkarchiso` copies in the pacman.conf
# in use during the build process - so it needs to be made offline.
@@ -214,11 +214,12 @@ echo "Populating host offline mirror with ISO packages: ${iso_packages[@]}"
# And we have to use the hosts pacman.conf since all other pacman.conf
# files are prepped for offline use by this point.
pacman --config /etc/pacman.conf \
--noconfirm -Syw $(echo "${iso_packages[@]}" | sed 's/tzupdate//g') \
--cachedir "/var/cache/omarchy/mirror/offline/" \
--dbpath /tmp/cleandb
--noconfirm -Syw $(echo "${iso_packages[@]}" | sed 's/tzupdate//g') \
--cachedir "/var/cache/omarchy/mirror/offline/" \
--dbpath /tmp/cleandb
repo-add --new "/var/cache/omarchy/mirror/offline/offline.db.tar.gz" "/var/cache/omarchy/mirror/offline/"*.pkg.tar.zst
# Finally, we assemble the entire ISO
mkarchiso -v -w "$cache_dir/work/" -o "/out/" "$cache_dir/"
mkarchiso -v -w "$cache_dir/work/" -o "/out/" "$cache_dir/"