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:
1 parent
ccd54ece8f
commit
217f84de33
3 files changed
+204
-60
No files matched your search
@@ -8,12 +8,18 @@ git submodule update --init --recursive --jobs=8
|
|||||||
BUILD_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
BUILD_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||||
mkdir -p "$BUILD_ROOT/out"
|
mkdir -p "$BUILD_ROOT/out"
|
||||||
|
|
||||||
|
# Determine which build script to use
|
||||||
|
if [[ $1 == "--offline" ]]; then
|
||||||
|
BUILD_SCRIPT="build_iso.sh"
|
||||||
|
else
|
||||||
|
BUILD_SCRIPT="build_online_iso.sh"
|
||||||
|
fi
|
||||||
|
|
||||||
# Run the builder
|
# Run the builder
|
||||||
docker run --rm \
|
docker run --rm \
|
||||||
--privileged \
|
|
||||||
--privileged \
|
--privileged \
|
||||||
-v "$BUILD_ROOT/out/:/out/" \
|
-v "$BUILD_ROOT/out/:/out/" \
|
||||||
-v "$BUILD_ROOT/build_iso.sh:/build_iso.sh:ro" \
|
-v "$BUILD_ROOT/$BUILD_SCRIPT:/$BUILD_SCRIPT:ro" \
|
||||||
-v "$BUILD_ROOT/archiso:/archiso:ro" \
|
-v "$BUILD_ROOT/archiso:/archiso:ro" \
|
||||||
-v "$BUILD_ROOT/grub-autoboot.patch:/grub-autoboot.patch:ro" \
|
-v "$BUILD_ROOT/grub-autoboot.patch:/grub-autoboot.patch:ro" \
|
||||||
-v "$BUILD_ROOT/efi-autoboot.patch:/efi-autoboot.patch:ro" \
|
-v "$BUILD_ROOT/efi-autoboot.patch:/efi-autoboot.patch:ro" \
|
||||||
@@ -23,7 +29,7 @@ docker run --rm \
|
|||||||
-v "$BUILD_ROOT/check_connectivity.sh:/check_connectivity.sh:ro" \
|
-v "$BUILD_ROOT/check_connectivity.sh:/check_connectivity.sh:ro" \
|
||||||
-v "$BUILD_ROOT/omarchy.packages:/omarchy.packages:ro" \
|
-v "$BUILD_ROOT/omarchy.packages:/omarchy.packages:ro" \
|
||||||
-v "$BUILD_ROOT/archinstall.packages:/archinstall.packages:ro" \
|
-v "$BUILD_ROOT/archinstall.packages:/archinstall.packages:ro" \
|
||||||
archlinux/archlinux:latest /build_iso.sh
|
archlinux/archlinux:latest /$BUILD_SCRIPT
|
||||||
|
|
||||||
# Make iso accessible to all
|
# Make iso accessible to all
|
||||||
sudo chmod 777 -R "$BUILD_ROOT/out"
|
sudo chmod 777 -R "$BUILD_ROOT/out"
|
||||||
+58
-57
@@ -22,75 +22,75 @@ export PIP_BREAK_SYSTEM_PACKAGES=1
|
|||||||
# These packages will be installed **into** the ISO, and
|
# These packages will be installed **into** the ISO, and
|
||||||
# won't be available to either archinstall or omarchy installer.
|
# won't be available to either archinstall or omarchy installer.
|
||||||
python_packages=(
|
python_packages=(
|
||||||
terminaltexteffects
|
terminaltexteffects
|
||||||
)
|
)
|
||||||
arch_packages=(
|
arch_packages=(
|
||||||
git
|
git
|
||||||
impala
|
impala
|
||||||
gum
|
gum
|
||||||
openssl
|
openssl
|
||||||
wget
|
wget
|
||||||
tzupdate # This is technically an AUR package
|
tzupdate # This is technically an AUR package
|
||||||
)
|
)
|
||||||
|
|
||||||
prepare_offline_mirror() {
|
prepare_offline_mirror() {
|
||||||
# Certain packages in omarchy.packages are AUR packages.
|
# 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/
|
# 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..."
|
echo "Reading and combining packages from all package files..."
|
||||||
|
|
||||||
# Combine all packages from both files into one array
|
# Combine all packages from both files into one array
|
||||||
all_packages=()
|
all_packages=()
|
||||||
for package_file in omarchy.packages archinstall.packages; do
|
for package_file in omarchy.packages archinstall.packages; do
|
||||||
if [ -f "$package_file" ]; then
|
if [ -f "$package_file" ]; then
|
||||||
echo "Reading $package_file..."
|
echo "Reading $package_file..."
|
||||||
while IFS= read -r package; do
|
while IFS= read -r package; do
|
||||||
# Skip empty lines and comments
|
# Skip empty lines and comments
|
||||||
[[ -z "$package" || "$package" =~ ^[[:space:]]*# ]] && continue
|
[[ -z "$package" || "$package" =~ ^[[:space:]]*# ]] && continue
|
||||||
all_packages+=("$package")
|
all_packages+=("$package")
|
||||||
done < "$package_file"
|
done <"$package_file"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
if [ ${#all_packages[@]} -gt 0 ]; then
|
if [ ${#all_packages[@]} -gt 0 ]; then
|
||||||
# This assume we've manually built all the AUR packages
|
# This assume we've manually built all the AUR packages
|
||||||
# and made them accessible "online" during the build process:
|
# and made them accessible "online" during the build process:
|
||||||
(cd $cache_dir/ && git apply /aur-mirror.patch)
|
(cd $cache_dir/ && git apply /aur-mirror.patch)
|
||||||
|
|
||||||
mkdir -p /tmp/offlinedb
|
mkdir -p /tmp/offlinedb
|
||||||
|
|
||||||
# Change DownloadUser from alpm to root to fix permission issues when downloading to cache dir
|
# 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.
|
# 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.
|
# 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
|
sed -i 's/^#*DownloadUser = alpm/DownloadUser = root/' /etc/pacman.conf
|
||||||
|
|
||||||
# Download all the packages to the offline mirror inside the ISO
|
# Download all the packages to the offline mirror inside the ISO
|
||||||
pacman --config $cache_dir/pacman.conf \
|
pacman --config $cache_dir/pacman.conf \
|
||||||
--noconfirm -Syw "${all_packages[@]}" \
|
--noconfirm -Syw "${all_packages[@]}" \
|
||||||
--cachedir $offline_mirror_dir/ \
|
--cachedir $offline_mirror_dir/ \
|
||||||
--dbpath /tmp/offlinedb
|
--dbpath /tmp/offlinedb
|
||||||
|
|
||||||
repo-add --new "$offline_mirror_dir/offline.db.tar.gz" "$offline_mirror_dir/"*.pkg.tar.zst
|
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"
|
rm "$cache_dir/airootfs/etc/pacman.d/hooks/uncomment-mirrors.hook"
|
||||||
|
|
||||||
# Revert the "online" AUR patch, as we'll replace it with the proper
|
# Revert the "online" AUR patch, as we'll replace it with the proper
|
||||||
# offline patched mirror for the ISO later.
|
# offline patched mirror for the ISO later.
|
||||||
(cd $cache_dir && git apply -R /aur-mirror.patch)
|
(cd $cache_dir && git apply -R /aur-mirror.patch)
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
make_archiso_offline() {
|
make_archiso_offline() {
|
||||||
# This function will simply disable any online activity we have.
|
# This function will simply disable any online activity we have.
|
||||||
# for instance the reflector.service which tries to optimize
|
# for instance the reflector.service which tries to optimize
|
||||||
# mirror order by fetching the latest mirror list by default.
|
# mirror order by fetching the latest mirror list by default.
|
||||||
#
|
#
|
||||||
# We'll leave some things online, like NTP as that won't
|
# 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
|
# interfere with anything, on the flip side it will help if we do
|
||||||
# have internet connectivity.
|
# have internet connectivity.
|
||||||
|
|
||||||
rm "$cache_dir/airootfs/etc/systemd/system/multi-user.target.wants/reflector.service"
|
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/systemd/system/reflector.service.d"
|
||||||
rm -rf "$cache_dir/airootfs/etc/xdg/reflector"
|
rm -rf "$cache_dir/airootfs/etc/xdg/reflector"
|
||||||
}
|
}
|
||||||
|
|
||||||
mkdir -p $cache_dir/
|
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
|
# We add in our auto-start applications
|
||||||
# First we'll check for an active internet connection
|
# First we'll check for an active internet connection
|
||||||
# Then we'll start the omarchy installer
|
# 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
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
if [[ \$(tty) == "/dev/tty1" ]]; then
|
if [[ \$(tty) == "/dev/tty1" ]]; then
|
||||||
@@ -188,7 +188,7 @@ rm "$cache_dir/airootfs/etc/motd"
|
|||||||
pip install "${python_packages[@]}"
|
pip install "${python_packages[@]}"
|
||||||
|
|
||||||
# Add our needed packages to packages.x86_64
|
# 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
|
# 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.
|
# 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
|
# And we have to use the hosts pacman.conf since all other pacman.conf
|
||||||
# files are prepped for offline use by this point.
|
# files are prepped for offline use by this point.
|
||||||
pacman --config /etc/pacman.conf \
|
pacman --config /etc/pacman.conf \
|
||||||
--noconfirm -Syw $(echo "${iso_packages[@]}" | sed 's/tzupdate//g') \
|
--noconfirm -Syw $(echo "${iso_packages[@]}" | sed 's/tzupdate//g') \
|
||||||
--cachedir "/var/cache/omarchy/mirror/offline/" \
|
--cachedir "/var/cache/omarchy/mirror/offline/" \
|
||||||
--dbpath /tmp/cleandb
|
--dbpath /tmp/cleandb
|
||||||
|
|
||||||
repo-add --new "/var/cache/omarchy/mirror/offline/offline.db.tar.gz" "/var/cache/omarchy/mirror/offline/"*.pkg.tar.zst
|
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
|
# 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/"
|
||||||
|
|
||||||
Executable
+137
@@ -0,0 +1,137 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
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 python-pip sudo base-devel jq wget
|
||||||
|
|
||||||
|
cache_dir=$(realpath --canonicalize-missing ~/.cache/omarchy/iso_$(date +%Y-%m-%d))
|
||||||
|
offline_mirror_dir="$cache_dir/airootfs/var/cache/omarchy/mirror/offline"
|
||||||
|
|
||||||
|
# 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
|
||||||
|
|
||||||
|
# These packages will be installed **into** the ISO, and
|
||||||
|
# won't be available to either archinstall or omarchy installer.
|
||||||
|
python_packages=(
|
||||||
|
terminaltexteffects
|
||||||
|
)
|
||||||
|
arch_packages=(
|
||||||
|
git
|
||||||
|
gum
|
||||||
|
openssl
|
||||||
|
wget
|
||||||
|
)
|
||||||
|
|
||||||
|
mkdir -p $cache_dir/
|
||||||
|
mkdir -p $offline_mirror_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 https://github.com/omacom-io/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"
|
||||||
|
|
||||||
|
git clone -b dev --single-branch https://github.com/basecamp/omarchy.git "$cache_dir/airootfs/root/omarchy"
|
||||||
|
|
||||||
|
# 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 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 && \
|
||||||
|
archinstall \
|
||||||
|
--config user_configuration.json \
|
||||||
|
--creds user_credentials.json \
|
||||||
|
--silent && \
|
||||||
|
export OMARCHY_USER=\`ls /mnt/home/\` && \
|
||||||
|
|
||||||
|
mkdir -p /mnt/home/\$OMARCHY_USER/.local/share/ && \
|
||||||
|
cp -r /root/omarchy "/mnt/home/\$OMARCHY_USER/.local/share/" && \
|
||||||
|
chown -R 1000:1000 "/mnt/home/\$OMARCHY_USER/.local/" && \
|
||||||
|
chmod +x /mnt/home/\$OMARCHY_USER/.local/share/omarchy/install.sh && \
|
||||||
|
chmod +x /mnt/home/\$OMARCHY_USER/.local/share/omarchy/install/apps/mimetypes.sh && \
|
||||||
|
chmod +x /mnt/home/\$OMARCHY_USER/.local/share/omarchy/install/apps/webapps.sh && \
|
||||||
|
chmod +x /mnt/home/\$OMARCHY_USER/.local/share/omarchy/install/apps/xtras.sh && \
|
||||||
|
chmod +x /mnt/home/\$OMARCHY_USER/.local/share/omarchy/install/config/detect-keyboard-layout.sh && \
|
||||||
|
chmod +x /mnt/home/\$OMARCHY_USER/.local/share/omarchy/install/config/fix-fkeys.sh && \
|
||||||
|
chmod +x /mnt/home/\$OMARCHY_USER/.local/share/omarchy/install/config/network.sh && \
|
||||||
|
chmod +x /mnt/home/\$OMARCHY_USER/.local/share/omarchy/install/config/nvidia.sh && \
|
||||||
|
chmod +x /mnt/home/\$OMARCHY_USER/.local/share/omarchy/install/config/power.sh && \
|
||||||
|
chmod +x /mnt/home/\$OMARCHY_USER/.local/share/omarchy/install/config/timezones.sh && \
|
||||||
|
chmod +x /mnt/home/\$OMARCHY_USER/.local/share/omarchy/install/config/config.sh && \
|
||||||
|
chmod +x /mnt/home/\$OMARCHY_USER/.local/share/omarchy/install/config/identification.sh && \
|
||||||
|
chmod +x /mnt/home/\$OMARCHY_USER/.local/share/omarchy/install/config/increase-sudo-tries.sh && \
|
||||||
|
chmod +x /mnt/home/\$OMARCHY_USER/.local/share/omarchy/install/config/login.sh && \
|
||||||
|
chmod +x /mnt/home/\$OMARCHY_USER/.local/share/omarchy/install/desktop/asdcontrol.sh && \
|
||||||
|
chmod +x /mnt/home/\$OMARCHY_USER/.local/share/omarchy/install/desktop/bluetooth.sh && \
|
||||||
|
chmod +x /mnt/home/\$OMARCHY_USER/.local/share/omarchy/install/desktop/fonts.sh && \
|
||||||
|
chmod +x /mnt/home/\$OMARCHY_USER/.local/share/omarchy/install/desktop/hyprlandia.sh && \
|
||||||
|
chmod +x /mnt/home/\$OMARCHY_USER/.local/share/omarchy/install/desktop/printer.sh && \
|
||||||
|
chmod +x /mnt/home/\$OMARCHY_USER/.local/share/omarchy/install/desktop/theme.sh && \
|
||||||
|
chmod +x /mnt/home/\$OMARCHY_USER/.local/share/omarchy/install/desktop/desktop.sh && \
|
||||||
|
chmod +x /mnt/home/\$OMARCHY_USER/.local/share/omarchy/install/development/development.sh && \
|
||||||
|
chmod +x /mnt/home/\$OMARCHY_USER/.local/share/omarchy/install/development/nvim.sh && \
|
||||||
|
chmod +x /mnt/home/\$OMARCHY_USER/.local/share/omarchy/install/development/ruby.sh && \
|
||||||
|
chmod +x /mnt/home/\$OMARCHY_USER/.local/share/omarchy/install/development/docker.sh && \
|
||||||
|
chmod +x /mnt/home/\$OMARCHY_USER/.local/share/omarchy/install/development/firewall.sh && \
|
||||||
|
chmod +x /mnt/home/\$OMARCHY_USER/.local/share/omarchy/install/development/terminal.sh && \
|
||||||
|
chmod +x /mnt/home/\$OMARCHY_USER/.local/share/omarchy/install/preflight/migrations.sh && \
|
||||||
|
chmod +x /mnt/home/\$OMARCHY_USER/.local/share/omarchy/install/preflight/aur.sh && \
|
||||||
|
chmod +x /mnt/home/\$OMARCHY_USER/.local/share/omarchy/install/preflight/guard.sh && \
|
||||||
|
chmod +x /mnt/home/\$OMARCHY_USER/.local/share/omarchy/install/preflight/gum.sh && \
|
||||||
|
chmod +x /mnt/home/\$OMARCHY_USER/.local/share/omarchy/install/preflight/tte.sh && \
|
||||||
|
echo '' > /mnt/home/\$OMARCHY_USER/.local/share/omarchy/install/preflight/tte.sh && \
|
||||||
|
echo '' > /mnt/home/\$OMARCHY_USER/.local/share/omarchy/install/preflight/gum.sh && \
|
||||||
|
HOME=/home/\$OMARCHY_USER arch-chroot -u \$OMARCHY_USER /mnt/ /bin/bash -c "source /home/\$OMARCHY_USER/.local/share/omarchy/install.sh"
|
||||||
|
fi
|
||||||
|
_EOF_
|
||||||
|
|
||||||
|
# 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[@]}"
|
||||||
|
|
||||||
|
# Add our needed packages to packages.x86_64
|
||||||
|
printf '%s\n' "${arch_packages[@]}" >>"$cache_dir/packages.x86_64"
|
||||||
|
|
||||||
|
# Because this weird glitch with archiso, we also need to sync down
|
||||||
|
# all the packages we need to build the ISO, but we'll do that in the
|
||||||
|
# "host" mirror location, as we don't want them inside the ISO taking up space.
|
||||||
|
# We'll also remove tzupdate as it won't be found in upstream mirrors.
|
||||||
|
iso_packages=($(cat "$cache_dir/packages.x86_64"))
|
||||||
|
|
||||||
|
mkdir -p /tmp/cleandb
|
||||||
|
|
||||||
|
# Finally, we assemble the entire ISO
|
||||||
|
mkarchiso -v -w "$cache_dir/work/" -o "/out/" "$cache_dir/"
|
||||||
Reference in new issue
Block a user