add yay AUR-helper (#139)

- call yay through a wrapper to take care of root/sudo handling
- add yay-prepare to reinstall everything that was stripped for size (like /usr/include)
- yay-prepare creates a yay user and sudo rights
- the wrapper is installed in /usr/bin/yay, we want it to clash with yay-packages that aren't adapted to SystemRescue
This commit is contained in:
Gerd v. Egidy 2022-10-02 15:28:47 +02:00
parent 1df64290fa
commit 704d7a9e5c
4 changed files with 108 additions and 0 deletions

View file

@ -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.*}

23
airootfs/usr/bin/yay Executable file
View file

@ -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"

View file

@ -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

View file

@ -272,6 +272,7 @@ xorg-drivers
xorg-server
xorg-xinit
xz
yay
yubikey-manager
yubikey-personalization-gui
zerofree