diff --git a/README.md b/README.md index 9f83154..ea7d9ed 100644 --- a/README.md +++ b/README.md @@ -24,6 +24,7 @@ $ docker run --rm \ -v "./efi-autoboot.patch:/efi-autoboot.patch:ro" \ -v "./permissions.patch:/permissions.patch:ro" \ -v "./aur-mirror.patch:/aur-mirror.patch:ro" \ + -v "./offline-mirror.patch:/offline-mirror.patch:ro" \ -v "./check_connectivity.sh:/check_connectivity.sh:ro" \ -v "./omarchy.packages:/omarchy.packages:ro" \ -v "./archinstall.packages:/archinstall.packages:ro" \ diff --git a/aur-mirror.patch b/aur-mirror.patch index 6a33d78..fc0478e 100644 --- a/aur-mirror.patch +++ b/aur-mirror.patch @@ -1,10 +1,10 @@ --- a/pacman.conf +++ b/pacman.conf -@@ -98,3 +98,7 @@ +@@ -98,3 +98,7 @@ Include = /etc/pacman.d/mirrorlist #[custom] #SigLevel = Optional TrustAll #Server = file:///home/custompkgs + +[aur] +SigLevel = Optional TrustAll -+Server = file:///var/cache/omarchy/mirror/aur/ ++Server = https://omarchy.blyg.se/$repo/os/$arch/ diff --git a/build_iso.sh b/build_iso.sh index d760da2..43dc69a 100755 --- a/build_iso.sh +++ b/build_iso.sh @@ -10,7 +10,6 @@ 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" -aur_mirror_dir="/var/cache/omarchy/mirror/aur" # We need to fiddle with pip settings # in order to install to the correct place @@ -20,12 +19,6 @@ export PIP_ROOT_USER_ACTION="ignore" export PIP_NO_WARN_SCRIPT_LOCATION=1 export PIP_BREAK_SYSTEM_PACKAGES=1 -# Function using the AUR web JSON RPC to query if a package exists in AUR -is_aur_package() { - resultcount=`wget -qO- "https://aur.archlinux.org/rpc/?v=5&type=info&arg=$1" 2>/dev/null | jq .resultcount` - [ "$resultcount" = "1" ] -} - # These packages will be installed **into** the ISO, and # won't be available to either archinstall or omarchy installer. python_packages=( @@ -37,141 +30,55 @@ arch_packages=( gum openssl wget + tzupdate # This is technically an AUR package ) -aur_packages=( - tzupdate -) - -# The following package lists are what will be available -# in the ISO as "offline mirror packages". -offline_arch_packages=() -offline_aur_packages=() - -prep_aur_builder() { - mkdir -p /etc/sudoers.d/ - useradd --create-home --shell /bin/bash aurbuilder - echo "aurbuilder ALL=(ALL:ALL) NOPASSWD: ALL" > /etc/sudoers.d/aurbuilder -} - -cleanup_aur_builder() { - # Not sure why killall gpg-agent produces "gpg-agent(27): Operation not permitted" yet. - # so || true it is. - sudo -H -u aurbuilder killall gpg-agent 2>/dev/null || true - sudo -H -u aurbuilder killall dirmngr 2>/dev/null || true - sudo -H -u aurbuilder killall keyboxd 2>/dev/null || true - - rm /etc/sudoers.d/aurbuilder - - # Make sure no remaining processes are running under aurbuilder - # pkill -u aurbuilder - killall --user aurbuilder - - # Weirdly, certain processes will be hanging a while - # so we need to sleep before running userdel - USERGROUPS_ENAB=yes userdel aurbuilder -} - -build_aur() { - local PACKAGE=$1 - local BUILDDEST=$2 - # Certain packages name, such as "yaru-icon-theme" differs from the actual - # package/build name, in this example it's "yaru" and we use PackageBase to approximate this. - local AUR_PKG_BASE=`wget -qO- "https://aur.archlinux.org/rpc/?v=5&type=info&arg=$PACKAGE" 2>/dev/null | jq -r .results[0].PackageBase` - - sudo -H -u aurbuilder git clone "https://aur.archlinux.org/$AUR_PKG_BASE.git" "/home/aurbuilder/$PACKAGE" - - # Import any GPG keys defined in the PKGBUILD - # This is normally now how you should treat AUR packages (blind trust). - # But it will be okay if we manually verify packages before each ISO build. - ( - cd "/home/aurbuilder/$PACKAGE" - source PKGBUILD - if [ -n "${validpgpkeys[*]}" ]; then - for key in "${validpgpkeys[@]}"; do - sudo -H -u aurbuilder gpg --recv-keys "$key" || true - done - fi - ) - - # 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/$PACKAGE" && sudo -H -u aurbuilder makepkg --clean --cleanbuild --force --noconfirm --needed --syncdeps --rmdeps) - mv "/home/aurbuilder/$PACKAGE/"*.pkg.tar.zst "$BUILDDEST/" - - rm -rf "/home/aurbuilder/$PACKAGE" -} prepare_offline_mirror() { - # 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 - - # So first we need to figure out if packages are AUR packages or not. - # As we will have to build the AUR before adding them to our mirror. - echo "Categorizing 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/ + 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 "Processing $package_file..." + echo "Reading $package_file..." while IFS= read -r package; do # Skip empty lines and comments [[ -z "$package" || "$package" =~ ^[[:space:]]*# ]] && continue - - # Check if it exists in AUR - if is_aur_package "$package"; then - offline_aur_packages+=("$package") - echo " AUR: $package" - else - offline_arch_packages+=("$package") - echo " Arch: $package" - fi + all_packages+=("$package") done < "$package_file" fi done - if [ ${#offline_aur_packages[@]} -gt 0 ]; then - prep_aur_builder + 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) - for package in "${offline_aur_packages[@]}"; do - build_aur "$package" "$offline_mirror_dir/" - done - - cleanup_aur_builder - fi - - if [ ${#offline_arch_packages[@]} -gt 0 ]; then mkdir -p /tmp/offlinedb + + echo "$cache_dir/" + ls -l "$cache_dir/" - # Download all our official packages - pacman --noconfirm -Syw "${offline_arch_packages[@]}" \ + # 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 - fi - - # Apply offline mirror "patches" if we have any offline packages - # This will disable online mirrors completely, - # for now this is the best option to avoid errors trying to sync official mirrors. - if [ ${#offline_aur_packages[@]} -gt 0 ] || [ ${#offline_arch_packages[@]} -gt 0 ]; then + 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" - # Comment out the [core] and [extra] repository sections to disable online repos - # Otherwise they might interfere - sed -i 's/^\[core\]/#\[core\]/' "$cache_dir/airootfs/etc/pacman.conf" - sed -i '/^\[core\]/,/^Include = \/etc\/pacman\.d\/mirrorlist$/ s/^Include = \/etc\/pacman\.d\/mirrorlist$/#Include = \/etc\/pacman\.d\/mirrorlist/' "$cache_dir/airootfs/etc/pacman.conf" - sed -i 's/^\[extra\]/#\[extra\]/' "$cache_dir/airootfs/etc/pacman.conf" - sed -i '/^\[extra\]/,/^Include = \/etc\/pacman\.d\/mirrorlist$/ s/^Include = \/etc\/pacman\.d\/mirrorlist$/#Include = \/etc\/pacman\.d\/mirrorlist/' "$cache_dir/airootfs/etc/pacman.conf" - - # Add offline repository to pacman.conf so the installers can do - # package lookups and installs - cat >> "$cache_dir/airootfs/etc/pacman.conf" << EOF - - [offline] - SigLevel = Optional TrustAll - Server = file:///var/cache/omarchy/mirror/offline/ -EOF + # 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 } @@ -190,18 +97,11 @@ make_archiso_offline() { } mkdir -p $cache_dir/ -mkdir -p $aur_mirror_dir/ +mkdir -p $offline_mirror_dir/ # We base our ISO on the official arch ISO (releng) config cp -r archiso/configs/releng/* $cache_dir/ -mkdir -p $offline_mirror_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. -# 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 - prepare_offline_mirror make_archiso_offline @@ -212,6 +112,8 @@ mv "$cache_dir/airootfs/root/omarchy-installer/installer" "$cache_dir/airootfs/r 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 git@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" @@ -228,27 +130,13 @@ cat <<- _EOF_ | tee $cache_dir/airootfs/root/.automated_script.sh --config user_configuration.json \ --creds user_credentials.json \ --silent && \ - wget -qO- https://omarchy.org/install | bash + export OMARCHY_USER=\$(ls /home/) && \ + cp -r /root/omarchy "/home/\$OMARCHY_USER/" && \ + chown \$OMARCHY_USER "/home/\$OMARCHY_USER/omarchy" \ + su - \$OMARCHY_USER -c "source /home/\$OMARCHY_USER/omarchy/install.sh" fi _EOF_ -# 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_mirror_dir/"; then - echo "$package" >> "$cache_dir/packages.x86_64" - fi - done - - ls -l "$aur_mirror_dir/" - repo-add --new "$aur_mirror_dir/aur.db.tar.gz" "$aur_mirror_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) @@ -266,4 +154,38 @@ rm "$cache_dir/airootfs/etc/motd" # file system. pip install "${python_packages[@]}" +# Add our needed packages to 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. +(cd "$cache_dir" && git apply /offline-mirror.patch) +cp $cache_dir/pacman.conf "$cache_dir/airootfs/etc/pacman.conf" + +# And we also need to duplicate the offline mirror. +# Because inside the ISO it will look for packages in /var/cache/omarchy/mirror/offline +# but that means the build of the ISO itself will also look at this location +# but in the container. +mkdir -p /var/cache/omarchy/mirror +cp -r "$offline_mirror_dir" "/var/cache/omarchy/mirror/" + +# 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 + +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 + +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/" \ No newline at end of file diff --git a/offline-mirror.patch b/offline-mirror.patch new file mode 100644 index 0000000..c0d1941 --- /dev/null +++ b/offline-mirror.patch @@ -0,0 +1,29 @@ +--- a/pacman.conf ++++ b/pacman.conf +@@ -75,14 +75,14 @@ LocalFileSigLevel = Optional + #[core-testing] + #Include = /etc/pacman.d/mirrorlist + +-[core] +-Include = /etc/pacman.d/mirrorlist ++# [core] ++# Include = /etc/pacman.d/mirrorlist + + #[extra-testing] + #Include = /etc/pacman.d/mirrorlist + +-[extra] +-Include = /etc/pacman.d/mirrorlist ++# [extra] ++# Include = /etc/pacman.d/mirrorlist + + # If you want to run 32 bit applications on your x86_64 system, + # enable the multilib repositories as required here. +@@ -98,3 +98,7 @@ Include = /etc/pacman.d/mirrorlist + #[custom] + #SigLevel = Optional TrustAll + #Server = file:///home/custompkgs ++ ++[offline] ++SigLevel = Optional TrustAll ++Server = file:///var/cache/omarchy/mirror/offline/ diff --git a/omarchy.packages b/omarchy.packages index 4261843..b186434 100644 --- a/omarchy.packages +++ b/omarchy.packages @@ -52,7 +52,7 @@ iwd jq kdenlive kvantum-qt5 -lazydocker-bin +lazydocker lazygit less libpulse @@ -61,7 +61,7 @@ libreoffice-fresh linux linux-firmware llvm -localsend-bin +localsend luarocks mako man-db @@ -76,9 +76,9 @@ noto-fonts-emoji noto-fonts-extra nss-mdns obs-studio -obsidian-bin +obsidian pamixer -pinta +# pinta pipewire pipewire-alsa pipewire-jack @@ -110,7 +110,7 @@ ufw ufw-docker unzip uwsm -walker-bin +walker waybar wget whois @@ -125,9 +125,16 @@ xdg-desktop-portal-hyprland xmlstarlet xournalpp yaru-icon-theme -yay-bin -# TODO: Figure out how to dynamically find, build, and install -debug packages -# yay-bin-debug +yay +yay-debug zoom zoxide -zram-generator \ No newline at end of file +zram-generator +webp-pixbuf-loader +autoconf-archive +intltool +gtk4-layer-shell +sassc +libsass +dart +qt5-remoteobjects \ No newline at end of file diff --git a/permissions.patch b/permissions.patch index 43104db..c032fa2 100644 --- a/permissions.patch +++ b/permissions.patch @@ -1,13 +1,15 @@ --- a/profiledef.sh +++ b/profiledef.sh -@@ -21,7 +21,8 @@ +@@ -21,7 +21,10 @@ file_permissions=( ["/root"]="0:0:750" ["/root/.automated_script.sh"]="0:0:755" ["/root/.gnupg"]="0:0:700" + ["/root/installer"]="0:0:755" ++ ["/var/cache/omarchy/mirror/offline/"]="0:0:775" + ["/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" ++ ["/usr/lib/omarchy-installer"]="0:0:755" )