1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 23:07:36 +00:00

Ports: Register all dependencies of ports

Previously, only `manual` installs would register dependencies of an
installed port package. Since in the future we might want to check all
dependents, not only those for manually installed packages, we should
take care to register dependencies for `auto` installs as well.

Additionally, this surpresses some unnecessary verbose output from the
package management and fixes warnings when the package DB directory did
not yet exist.
This commit is contained in:
Jelle Raaijmakers 2021-10-20 00:14:54 +02:00 committed by Linus Groh
parent 7ff99cb516
commit 28e0aa59a8

View file

@ -382,39 +382,49 @@ func_defined clean_all || clean_all() {
done done
} }
addtodb() { addtodb() {
if [ ! -f "$packagesdb" ]; then if [ -n "$(package_install_state $port $version)" ]; then
echo "Note: $packagesdb does not exist. Creating." echo "Note: $port $version already installed."
mkdir -p "${DESTDIR}/usr/Ports/" return
touch "$packagesdb"
fi fi
if ! grep -E "^(auto|manual) $port $version" "$packagesdb" > /dev/null; then
echo "Adding $port $version to database of installed ports..." echo "Adding $port $version to database of installed ports..."
if [ "${1:-}" = "--auto" ]; then if [ "${1:-}" = "--auto" ]; then
echo "auto $port $version" >> "$packagesdb" echo "auto $port $version" >> "$packagesdb"
else else
echo "manual $port $version" >> "$packagesdb" echo "manual $port $version" >> "$packagesdb"
if [ ! -z "${dependlist:-}" ]; then
echo "dependency $port$dependlist" >> "$packagesdb"
fi fi
if [ "${#depends[@]}" -gt 0 ]; then
echo "dependency $port ${depends[@]}" >> "$packagesdb"
fi fi
echo "Successfully installed $port $version." echo "Successfully installed $port $version."
else }
>&2 echo "Warning: $port $version already installed. Not adding to database of installed ports!" ensure_packagesdb() {
if [ ! -f "$packagesdb" ]; then
mkdir -p "$(dirname $packagesdb)"
touch "$packagesdb"
fi fi
} }
package_install_state() {
local port=$1
local version=${2:-}
ensure_packagesdb
grep -E "^(auto|manual) $port $version" "$packagesdb" | cut -d' ' -f1
}
installdepends() { installdepends() {
for depend in "${depends[@]}"; do for depend in "${depends[@]}"; do
dependlist="${dependlist:-} $depend" if [ -z "$(package_install_state $depend)" ]; then
done
for depend in "${depends[@]}"; do
if ! grep "$depend" "$packagesdb" > /dev/null; then
(cd "../$depend" && ./package.sh --auto) (cd "../$depend" && ./package.sh --auto)
fi fi
done done
} }
uninstall() { uninstall() {
if grep "^manual $port " "$packagesdb" > /dev/null; then if [ "$(package_install_state $port)" != "manual" ]; then
if [ -f plist ]; then >&2 echo "Error: $port is not installed. Cannot uninstall."
return
elif [ ! -f plist ]; then
>&2 echo "Error: This port does not have a plist yet. Cannot uninstall."
return
fi
for f in `cat plist`; do for f in `cat plist`; do
case $f in case $f in
*/) */)
@ -428,12 +438,6 @@ uninstall() {
# Without || true, mv will not be executed if you are uninstalling your only remaining port. # Without || true, mv will not be executed if you are uninstalling your only remaining port.
grep -v "^manual $port " "$packagesdb" > packages.db.tmp || true grep -v "^manual $port " "$packagesdb" > packages.db.tmp || true
mv packages.db.tmp "$packagesdb" mv packages.db.tmp "$packagesdb"
else
>&2 echo "Error: This port does not have a plist yet. Cannot uninstall."
fi
else
>&2 echo "Error: $port is not installed. Cannot uninstall."
fi
} }
do_installdepends() { do_installdepends() {
echo "Installing dependencies of $port..." echo "Installing dependencies of $port..."