add new function for package cleaning

This commit is contained in:
Tobias Powalowski 2023-02-07 07:09:08 +01:00
parent 8bd2bd8e3c
commit 5cdeee7b51
2 changed files with 13 additions and 7 deletions

View file

@ -65,13 +65,17 @@ _clean_container() {
rm -r "${1}"/usr/share/{aclocal,applications,audit,awk,common-lisp,emacs,et,fish,gdb,gettext,gettext-[0-9]*,glib-[0-9]*,gnupg,gtk-doc,iana-etc,icons,icu,keyutils,libalpm,libgpg-error,makepkg-template,misc,mkinitcpio,pixmaps,pkgconfig,readline,screen,smartmontools,ss,tabset,vala,xml,zoneinfo-leaps,man,doc,info,i18n/locales,locale,xtables}
rm -r "${1}"/usr/lib/{audit,awk,binfmt.d,cmake,dracut,e2fsprogs,engines-[0-9]*,environment.d,gawk,getconf,gettext,girepository-[0-9]*,glib-[0-9]*,gnupg,gssproxy,guile,icu,krb5,ldscripts,libnl,pkgconfig,python[0-9]*,rsync,sasl2,siconv,tar,xfsprogs,xtables}
fi
# remove packages from pacman db that are not included in initramfs
_RM_PACMAN_DB="grub libxml2 icu gettext refind amd-ucode intel-ucode edk2-shell cdrtools \
libisoburn libburn libisofs mkinitcpio memtest linux-api-headers jansson libwbclient \
libbsd libmd libpcap libnftnl libnfnetlink libnetfilter_conntrack libsasl libldap"
for i in ${_RM_PACMAN_DB}; do
rm -rf ${1}/var/lib/pacman/local/${i}* &>/dev/null
done
}
_clean_packages() {
if [[ "${_CLEANUP_CONTAINER}" == "1" ]]; then
# remove packages from pacman db that are not included in initramfs
_RM_PACKAGES="grub libxml2 icu gettext refind amd-ucode intel-ucode edk2-shell cdrtools \
libisoburn libburn libisofs mkinitcpio memtest linux-api-headers jansson libwbclient \
libbsd libmd libpcap libnftnl libnfnetlink libnetfilter_conntrack libsasl libldap"
echo "Uninstalling ${_RM_PACKAGES}..."
${_PACMAN} -RDD ${_RM_PACKAGES} ${_PACMAN_DEFAULTS} &>/dev/null || exit 1
fi
}
# removing mkinitcpio hooks to speed up process, removing not needed initramdisks

View file

@ -19,6 +19,7 @@ if echo "${_BASENAME}" | grep -qw "${_RUNNING_ARCH}"; then
_clean_cache "${1}"
_install_archboot "${1}" || exit 1
_clean_cache "${1}"
_clean_packages "${1}" || exit 1
_umount_special "${1}" || exit 1
_clean_container "${1}"
_generate_keyring "${1}" || exit 1
@ -48,6 +49,7 @@ else
_install_archboot "${1}" "use_binfmt" || exit 1
_clean_mkinitcpio "${1}"
_clean_container "${1}" 2>/dev/null
_clean_packages "${1}" || exit 1
else
echo "Error: binfmt usage is only supported on x86_64!"
exit 1