From 49047fbb197b2f198bdcc87f8a0b1f9714c5b44c Mon Sep 17 00:00:00 2001 From: Torxed Date: Sat, 2 Aug 2025 21:00:18 +0200 Subject: [PATCH] Autostart the dummy installer, as well as prepare the ISO will all the AUR and Python dependencies --- .gitignore | 3 +- README.md | 4 ++ aur-mirror.patch | 10 ++++ build_iso.sh | 117 +++++++++++++++++++++++++++++++++++++++------ efi-autoboot.patch | 8 ++++ permissions.patch | 13 +++++ 6 files changed, 140 insertions(+), 15 deletions(-) create mode 100644 aur-mirror.patch create mode 100644 efi-autoboot.patch create mode 100644 permissions.patch diff --git a/.gitignore b/.gitignore index a41c0c5..1e0a55d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ out/ -**/**.iso \ No newline at end of file +**/**.iso +/*.txt \ No newline at end of file diff --git a/README.md b/README.md index 9a7a695..ee8f4fc 100644 --- a/README.md +++ b/README.md @@ -21,6 +21,10 @@ $ docker run --rm \ -v "./build_iso.sh:/build_iso.sh:ro" \ -v "./archiso:/archiso:ro" \ -v "./grub-autoboot.patch:/grub-autoboot.patch:ro" \ + -v "./efi-autoboot.patch:/efi-autoboot.patch:ro" \ + -v "./permissions.patch:/permissions.patch:ro" \ + -v "./aur-mirror.patch:/aur-mirror.patch:ro" \ + -v "./check_connectivity.sh:/check_connectivity.sh:ro" \ archlinux/archlinux:latest /build_iso.sh ``` diff --git a/aur-mirror.patch b/aur-mirror.patch new file mode 100644 index 0000000..6a33d78 --- /dev/null +++ b/aur-mirror.patch @@ -0,0 +1,10 @@ +--- a/pacman.conf ++++ b/pacman.conf +@@ -98,3 +98,7 @@ + #[custom] + #SigLevel = Optional TrustAll + #Server = file:///home/custompkgs ++ ++[aur] ++SigLevel = Optional TrustAll ++Server = file:///var/cache/omarchy/mirror/aur/ diff --git a/build_iso.sh b/build_iso.sh index 15fd1d5..b66fcc3 100755 --- a/build_iso.sh +++ b/build_iso.sh @@ -2,37 +2,126 @@ set -e +# Note that these are packages installed to the Arch container +# used to build the ISO. pacman-key --init pacman --noconfirm -Sy archlinux-keyring -pacman --noconfirm -Sy archiso git - -# Packages to add to the archiso profile packages -# As a base example (the TUI packages needs to be here) -packages=( - git - impala -) +pacman --noconfirm -Sy archiso git python-pip sudo base-devel cache_dir=$(realpath --canonicalize-missing ~/.cache/omarchy/iso_$(date +%Y-%m-%d)) +aur_cache_dir="/var/cache/omarchy/mirror/aur" + +# We need to fiddle with pip settings +# in order to install to the correct place +# as well as ignore some errors to make this less verbose +export PIP_ROOT="$cache_dir/airootfs/" +export PIP_ROOT_USER_ACTION="ignore" +export PIP_NO_WARN_SCRIPT_LOCATION=1 +export PIP_BREAK_SYSTEM_PACKAGES=1 + +# Arch packages to add to the archiso profile packages +# As a base example (the TUI packages needs to be here) +arch_packages=( + git + impala + gum + openssl +) +# These are Python specific packages that will get installed +# onto the ISO +python_packages=( + terminaltexteffects +) +aur_packages=( + tzupdate +) + +build_aur() { + PACKAGE=$1 + BUILDDEST=$2 + + mkdir -p /etc/sudoers.d/ + useradd --create-home --shell /bin/bash aurbuilder + echo "aurbuilder ALL=(ALL:ALL) NOPASSWD: ALL" > /etc/sudoers.d/aurbuilder + + sudo -H -u aurbuilder git clone "https://aur.archlinux.org/$1.git" "/home/aurbuilder/$1" + + # TODO: We should add --sign here, to sign these packages + # with a key that we trust and want to use. It's only used internally in the ISO. + # but it would make sure we don't install unsigned packages even during our build process. + (cd "/home/aurbuilder/$1" && sudo -H -u aurbuilder makepkg --clean --cleanbuild --force --noconfirm --needed --syncdeps --rmdeps) + mv "/home/aurbuilder/$1/"*.pkg.tar.zst "$BUILDDEST/" + + rm -rf "/home/aurbuilder/$1" + + rm /etc/sudoers.d/aurbuilder + USERGROUPS_ENAB=yes userdel aurbuilder +} mkdir -p $cache_dir/ +mkdir -p $aur_cache_dir/ + +# We base our ISO on the official arch ISO (releng) config cp -r archiso/configs/releng/* $cache_dir/ +# We clone the installer, and move it to the root users home folder +# since this is the default user in the official releng ISO profile. +git clone -b fix-networking --single-branch https://github.com/Torxed/omarchy-installer "$cache_dir/airootfs/root/omarchy-installer" +mv "$cache_dir/airootfs/root/omarchy-installer/installer" "$cache_dir/airootfs/root/installer" +mv "$cache_dir/airootfs/root/omarchy-installer/logo.txt" "$cache_dir/airootfs/root/logo.txt" +rm -rf "$cache_dir/airootfs/root/omarchy-installer" + +# Copy in the connectivity check script +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 omarchy-tui -cat <<- _EOF_ | tee $cache_dir/airootfs/root/.zprofile - check_connectivity.sh && omarchy-tui +# Then we'll start the omarchy installer +cat <<- _EOF_ | tee $cache_dir/airootfs/root/.automated_script.sh + #!/usr/bin/env bash + + if [[ \$(tty) == "/dev/tty1" ]]; then + sh ./check_connectivity.sh && sh ./installer + fi _EOF_ -# Add packages to the archiso profile packages -for package in "${packages[@]}"; do +# Add Arch packages to the archiso profile packages +for package in "${arch_packages[@]}"; do echo "$package" >> "$cache_dir/packages.x86_64" done -# We patch grub to our liking: +# We have to build the AUR packages one by one +# and place them in a local mirror for the ISO build process. +# Otherwise the ISO won't be able to source them +if [ ${#aur_packages[@]} -gt 0 ]; then + for package in "${aur_packages[@]}"; do + if build_aur "$package" "$aur_cache_dir/"; then + echo "$package" >> "$cache_dir/packages.x86_64" + fi + done + + ls -l "$aur_cache_dir/" + repo-add --new "$aur_cache_dir/aur.db.tar.gz" "$aur_cache_dir/"*.pkg.tar.zst + + # And patch in the mirror to the pacman.conf to include our AUR repo + (cd $cache_dir/ && git apply /aur-mirror.patch) +fi + +# We patch permissions, grub and efi loaders to our liking: +(cd $cache_dir/ && git apply /permissions.patch) (cd $cache_dir/ && git apply /grub-autoboot.patch) +(cd $cache_dir/ && git apply /efi-autoboot.patch) # We could also use: +# patch -p1 < aur-mirror.patch +# patch -p1 < permissions.patch # patch -p1 < grub-autoboot.patch +# patch -p1 < efi-autoboot.patch + +# Remove the default motd +rm "$cache_dir/airootfs/etc/motd" + +# Install Python packages for the installer into the ISO +# file system. +pip install "${python_packages[@]}" mkarchiso -v -w "$cache_dir/work/" -o "/out/" "$cache_dir/" \ No newline at end of file diff --git a/efi-autoboot.patch b/efi-autoboot.patch new file mode 100644 index 0000000..b09b983 --- /dev/null +++ b/efi-autoboot.patch @@ -0,0 +1,8 @@ +--- a/efiboot/loader/loader.conf ++++ b/efiboot/loader/loader.conf +@@ -1,3 +1,3 @@ +-timeout 15 ++timeout 0 + default 01-archiso-x86_64-linux.conf +-beep on ++beep off diff --git a/permissions.patch b/permissions.patch new file mode 100644 index 0000000..43104db --- /dev/null +++ b/permissions.patch @@ -0,0 +1,13 @@ +--- a/profiledef.sh ++++ b/profiledef.sh +@@ -21,7 +21,8 @@ + ["/root"]="0:0:750" + ["/root/.automated_script.sh"]="0:0:755" + ["/root/.gnupg"]="0:0:700" ++ ["/root/installer"]="0:0:755" ++ ["/root/check_connectivity.sh"]="0:0:755" + ["/usr/local/bin/choose-mirror"]="0:0:755" +- ["/usr/local/bin/Installation_guide"]="0:0:755" +- ["/usr/local/bin/livecd-sound"]="0:0:755" ++ ["/usr/bin/tte"]="0:0:755" + )