Commit 26f159cf authored by Philip Müller's avatar Philip Müller

[script] add optional removal dependencies

parent eed9e128
......@@ -25,6 +25,10 @@ DEPENDS_32="..."
DEPENDS_64="lib32-..."
DEPKMOD="..."
# Optional remove dependencies
OPTREMDEPENDS="..."
OPTREMDEPENDS_32="..."
OPTREMDEPENDS_64="lib32-..."
# Conflicts
MHWDCONFLICTS="..."
......
......@@ -268,7 +268,7 @@ if [ "${INSTALL}" == "true" ]; then
MHWD_CHECK_PKGS
if [ "${PACKAGES}" != "" ]; then
${PACMAN} -Rsu ${PACKAGES}
${PACMAN} -Rs ${PACKAGES}
if [ "$?" -ne "0" ]; then
echo "Error: pacman failed!"
exit 1
......@@ -277,6 +277,10 @@ if [ "${INSTALL}" == "true" ]; then
PACKAGES=""
[ "${OPTREMDEPENDS}" != "" ] && DEPENDS="${DEPENDS} ${OPTREMDEPENDS}"
[ "${OPTREMDEPENDS_32}" != "" ] && DEPENDS_32="${DEPENDS_32} ${OPTREMDEPENDS_32}"
[ "${OPTREMDEPENDS_64}" != "" ] && DEPENDS_64="${DEPENDS_64} ${OPTREMDEPENDS_64}"
# Install dependencies
if [ "${DEPENDS}" != "" ]; then
PACKAGES="${DEPENDS}"
......@@ -316,6 +320,7 @@ if [ "${REMOVE}" == "true" ]; then
fi
PACKAGES=""
OPTREMPACKAGES=""
# Check for extramodules
MHWD_CHECK_KMODS
......@@ -349,6 +354,44 @@ if [ "${REMOVE}" == "true" ]; then
fi
fi
PACKAGES=""
# Remove OPTREM dependencies
# Has to be run after normal dependencies were removed, since said dependencies may optionally depend on an OPTREM package
if [ "${OPTREMDEPENDS}" != "" ]; then
OPTREMPACKAGES="${OPTREMDEPENDS}"
fi
if [ "${ARCH}" == "i686" ] && [ "${OPTREMDEPENDS_32}" != "" ]; then
OPTREMPACKAGES="${OPTREMPACKAGES} ${OPTREMDEPENDS_32}"
fi
if [ "${ARCH}" == "x86_64" ] && [ "${OPTREMDEPENDS_64}" != "" ]; then
if [ "${MHWD64_IS_LIB32}" == "true" ]; then
OPTREMPACKAGES="${OPTREMPACKAGES} ${OPTREMDEPENDS_64}"
else
OPTREMPACKAGES="${OPTREMPACKAGES}"
fi
fi
for PKG in "${OPTREMPACKAGES}"
do
# Check if package is needed anywhere, otherwise remove packages
# Usage of -Rsu is not enough, since pacman doesn't consider optional dependencies
if [ "$(pacman -Qi ${PKG} | egrep "Required By|Optional For" | awk '{ print $4}' | grep -v 'None')" == "" ]; then
PACKAGES="${PACKAGES} ${PKG}"
fi
done
# Check if packages are installed
MHWD_CHECK_PKGS
if [ "${PACKAGES}" != "" ]; then
${PACMAN} -Rs ${PACKAGES}
if [ "$?" -ne "0" ]; then
echo "Error: pacman failed!"
exit 1
fi
fi
# Run postremove function
if [ "`grep "post_remove" "${CONFIGPATH}" | cut -d"#" -f1 | cut -d"(" -f1 | grep "post_remove"`" == "post_remove" ]; then
post_remove
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment