diff --git a/airootfs/root/customize_airootfs.sh b/airootfs/root/customize_airootfs.sh index fdb6535..583447b 100755 --- a/airootfs/root/customize_airootfs.sh +++ b/airootfs/root/customize_airootfs.sh @@ -60,6 +60,8 @@ systemctl mask ldconfig.service rm -f /etc/pacman.d/gnupg/*~ # Cleanup +# ATTENTION: adapt airootfs/usr/share/sysrescue/bin/yay-prepare when deleting anything that +# could be required for building packages find /usr/lib -type f -name '*.py[co]' -delete -o -type d -name __pycache__ -delete find /usr/lib -type f,l -name '*.a' -delete rm -rf /usr/lib/{libgo.*,libgphobos.*,libgfortran.*} diff --git a/airootfs/usr/bin/yay b/airootfs/usr/bin/yay new file mode 100755 index 0000000..94ae7f4 --- /dev/null +++ b/airootfs/usr/bin/yay @@ -0,0 +1,23 @@ +#!/bin/bash +# +# yay wrapper to adapt yay to SystemRescue +# +# Author: Gerd v. Egidy +# SPDX-License-Identifier: GPL-3.0-or-later +# +# see https://www.system-rescue.org/manual/Installing_packages_from_AUR/ for details +# + +if ! id yay >/dev/null 2>&1; then + echo "system not prepared for running yay yet, call 'yay-prepare'" + exit 1 +fi + +# escape all parameters with ${var@Q} +escArgArray=() +for arg in "$@" ; do + escArgArray+=(${arg@Q}) +done +cmdstr="/usr/bin/yay-real ${escArgArray[@]}" + +su -s /bin/bash yay -c "$cmdstr" diff --git a/airootfs/usr/share/sysrescue/bin/yay-prepare b/airootfs/usr/share/sysrescue/bin/yay-prepare new file mode 100755 index 0000000..c89d06c --- /dev/null +++ b/airootfs/usr/share/sysrescue/bin/yay-prepare @@ -0,0 +1,82 @@ +#! /bin/bash +# +# yay-prepare - prepare SystemRescue for running yay +# +# Author: Gerd v. Egidy +# SPDX-License-Identifier: GPL-3.0-or-later +# +# see https://www.system-rescue.org/manual/Installing_packages_from_AUR/ for details +# + +# abort on failures +set -o errexit -o pipefail -o noclobber -o nounset + +if id yay >/dev/null 2>&1; then + echo "It looks like yay-prepare has already been run, aborting." + exit 1 +fi + +echo "To prepare SystemRescue for using yay many packages must be downloaded and reinstalled." +echo "This will need more than a Gigabyte of Copy-on-Write (CoW) storage, usually in RAM." +echo "Compiling packages will need additional space in CoW." +echo "Consider using a disk-backed CoW-space ('cow_label=' boot option)." +echo + +read -p "Reinstall packages into CoW space now (y/n)? " answer +case ${answer:0:1} in + y|Y ) + echo Ok + ;; + * ) + echo "Aborting" + exit 1 + ;; +esac + +REINSTALL=() + +# loop over all installed packages +IFS=$'\n' +for pkgfile in $(find /var/lib/pacman/local -name files -type f) ; do + + # check if this package contains anything build-related we deleted in customize_airootfs.sh + if grep -q -E "^usr/include/" "$pkgfile" || \ + grep -q -E "^usr/lib/.*\.a\$" "$pkgfile" || \ + grep -q -E "^usr/lib/(libgo\.|libgphobos\.|libgfortran\.)" "$pkgfile" ; then + + # we need to reinstall this package -> find out it's name + DIR=$(dirname "$pkgfile") + DESCFILE="${DIR}/desc" + PKGNAME=$(grep "%NAME%" -A1 "$DESCFILE" | grep -v "%NAME%") + + if [[ -z "$PKGNAME" ]]; then + echo "failed to extract package name from ${pkgfile}" + exit 1 + fi + + REINSTALL+=($PKGNAME) + echo "package $PKGNAME needs to be reinstalled" + fi +done + +# update pacman package database +pacman -Sy + +# reinstall all required packages +pacman -S "${REINSTALL[@]}" + +# install base-devel group, but don't reinstall what we already have +# we want to ask the user for confirmation, but don't give them a choice what to install +# this isn't supported by pacman directly, so we need to get the group contents first and then install them + +BASE_DEVEL_PKGS=$(pacman -Sg base-devel | sed -e "s/^base-devel \(.*\)/\1/") +pacman -S --needed $BASE_DEVEL_PKGS git cmake + +useradd -m yay + +# don't require a password for yay user when installing packages +echo "yay ALL=(ALL:ALL) NOPASSWD: ALL" >/etc/sudoers.d/yay + +echo +echo "all done, ready for yay" +echo diff --git a/packages b/packages index f64acf1..74c0403 100644 --- a/packages +++ b/packages @@ -272,6 +272,7 @@ xorg-drivers xorg-server xorg-xinit xz +yay yubikey-manager yubikey-personalization-gui zerofree