Clean up confusing / repetitive build
This commit is contained in:
1 parent
3f64ac5656
commit
b423f7481d
1 file changed
+13
-44
+13
-44
@@ -8,8 +8,7 @@ pacman-key --init
|
|||||||
pacman --noconfirm -Sy archlinux-keyring
|
pacman --noconfirm -Sy archlinux-keyring
|
||||||
pacman --noconfirm -Sy archiso git python-pip sudo base-devel jq
|
pacman --noconfirm -Sy archiso git python-pip sudo base-devel jq
|
||||||
|
|
||||||
# Use a fixed build cache directory inside the container
|
build_cache_dir="/var/cache"
|
||||||
build_cache_dir=$(realpath --canonicalize-missing ~/.cache/omarchy/iso)
|
|
||||||
offline_mirror_dir="$build_cache_dir/airootfs/var/cache/omarchy/mirror/offline"
|
offline_mirror_dir="$build_cache_dir/airootfs/var/cache/omarchy/mirror/offline"
|
||||||
offline_ruby_dir="$build_cache_dir/airootfs/var/cache/omarchy/ruby"
|
offline_ruby_dir="$build_cache_dir/airootfs/var/cache/omarchy/ruby"
|
||||||
|
|
||||||
@@ -36,21 +35,16 @@ arch_packages=(
|
|||||||
|
|
||||||
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://pkgs.omarchy.org/$arch
|
||||||
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 into one array
|
||||||
all_packages=()
|
# Start with base ISO packages (including our arch_packages already appended)
|
||||||
for package_file in /builder/packages/omarchy.packages /builder/packages/archinstall.packages; do
|
all_packages=($(cat "$build_cache_dir/packages.x86_64"))
|
||||||
if [ -f "$package_file" ]; then
|
|
||||||
echo "Reading $package_file..."
|
# Add packages from omarchy and archinstall
|
||||||
while IFS= read -r package; do
|
[ -f /builder/packages/omarchy.packages ] && all_packages+=($(grep -v '^#' /builder/packages/omarchy.packages | grep -v '^$'))
|
||||||
# Skip empty lines and comments
|
[ -f /builder/packages/archinstall.packages ] && all_packages+=($(grep -v '^#' /builder/packages/archinstall.packages | grep -v '^$'))
|
||||||
[[ -z "$package" || "$package" =~ ^[[:space:]]*# ]] && continue
|
|
||||||
all_packages+=("$package")
|
|
||||||
done <"$package_file"
|
|
||||||
fi
|
|
||||||
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
|
||||||
@@ -60,11 +54,6 @@ prepare_offline_mirror() {
|
|||||||
|
|
||||||
mkdir -p /tmp/offlinedb
|
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
|
|
||||||
|
|
||||||
# Download all the packages to the offline mirror inside the ISO
|
# Download all the packages to the offline mirror inside the ISO
|
||||||
echo "Downloading all packages (including AUR) to offline mirror: ${all_packages[@]}"
|
echo "Downloading all packages (including AUR) to offline mirror: ${all_packages[@]}"
|
||||||
pacman --config $build_cache_dir/pacman.conf \
|
pacman --config $build_cache_dir/pacman.conf \
|
||||||
@@ -100,6 +89,9 @@ mkdir -p $offline_ruby_dir/
|
|||||||
# We base our ISO on the official arch ISO (releng) config
|
# We base our ISO on the official arch ISO (releng) config
|
||||||
cp -r archiso/configs/releng/* $build_cache_dir/
|
cp -r archiso/configs/releng/* $build_cache_dir/
|
||||||
|
|
||||||
|
# Add our needed packages to packages.x86_64 right away
|
||||||
|
printf '%s\n' "${arch_packages[@]}" >>"$build_cache_dir/packages.x86_64"
|
||||||
|
|
||||||
# Apply all the general patches early (same as online.sh)
|
# Apply all the general patches early (same as online.sh)
|
||||||
# Need to do this from the cache_dir
|
# Need to do this from the cache_dir
|
||||||
cd $build_cache_dir
|
cd $build_cache_dir
|
||||||
@@ -119,7 +111,7 @@ ruby_tarball="ruby-3.4.5-rails-8.0.2.1-x86_64.tar.gz"
|
|||||||
if [ ! -f "$offline_ruby_dir/$ruby_tarball" ]; then
|
if [ ! -f "$offline_ruby_dir/$ruby_tarball" ]; then
|
||||||
echo "Downloading Ruby tarball..."
|
echo "Downloading Ruby tarball..."
|
||||||
curl -fsSL -o "$offline_ruby_dir/$ruby_tarball" \
|
curl -fsSL -o "$offline_ruby_dir/$ruby_tarball" \
|
||||||
"https://pkgs.omarchy.org/ruby/x86_64/$ruby_tarball"
|
"https://pkgs.omarchy.org/ruby/$ruby_tarball"
|
||||||
else
|
else
|
||||||
echo "Ruby tarball already cached, skipping download"
|
echo "Ruby tarball already cached, skipping download"
|
||||||
fi
|
fi
|
||||||
@@ -158,9 +150,6 @@ chmod 755 "$build_cache_dir/airootfs/var/cache/pacman/pkg"
|
|||||||
# file system.
|
# file system.
|
||||||
pip install "${python_packages[@]}"
|
pip install "${python_packages[@]}"
|
||||||
|
|
||||||
# Add our needed packages to packages.x86_64
|
|
||||||
printf '%s\n' "${arch_packages[@]}" >>"$build_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.
|
||||||
(cd $build_cache_dir/ && git apply --reverse /builder/patches/offline/enable-multilib.patch)
|
(cd $build_cache_dir/ && git apply --reverse /builder/patches/offline/enable-multilib.patch)
|
||||||
@@ -173,26 +162,6 @@ cp $build_cache_dir/pacman.conf "$build_cache_dir/airootfs/etc/pacman.conf"
|
|||||||
# but in the container.
|
# but in the container.
|
||||||
mkdir -p /var/cache/omarchy/mirror
|
mkdir -p /var/cache/omarchy/mirror
|
||||||
cp -r "$offline_mirror_dir" "/var/cache/omarchy/mirror/"
|
cp -r "$offline_mirror_dir" "/var/cache/omarchy/mirror/"
|
||||||
mkdir -p /var/cache/omarchy/ruby
|
|
||||||
cp -r "$offline_ruby_dir" "/var/cache/omarchy/"
|
|
||||||
|
|
||||||
# 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 "$build_cache_dir/packages.x86_64"))
|
|
||||||
|
|
||||||
mkdir -p /tmp/cleandb
|
|
||||||
|
|
||||||
echo "Populating host offline mirror with ISO packages: ${iso_packages[@]}"
|
|
||||||
# We need to exclude AUR packages like tzupdate since they're not in upstream repos
|
|
||||||
# They should already be downloaded to the offline mirror from the earlier step
|
|
||||||
pacman --config /etc/pacman.conf \
|
|
||||||
--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
|
# Finally, we assemble the entire ISO
|
||||||
mkarchiso -v -w "$build_cache_dir/work/" -o "/out/" "$build_cache_dir/"
|
mkarchiso -v -w "$build_cache_dir/work/" -o "/out/" "$build_cache_dir/"
|
||||||
Reference in new issue
Block a user