mirror of
https://github.com/pi-hole/pi-hole.git
synced 2024-12-25 22:30:17 +00:00
Find which packages already exist and only install new packages. Set up for unintall to know what packages we installed for later removal.
Signed-off-by: Dan Schaper <dan.schaper@pi-hole.net>
This commit is contained in:
parent
c48e6c91f5
commit
2335097c99
1 changed files with 16 additions and 6 deletions
|
@ -97,8 +97,9 @@ if [[ $(command -v apt-get) ]]; then
|
||||||
LIGHTTPD_CFG="lighttpd.conf.debian"
|
LIGHTTPD_CFG="lighttpd.conf.debian"
|
||||||
DNSMASQ_USER="dnsmasq"
|
DNSMASQ_USER="dnsmasq"
|
||||||
|
|
||||||
package_check_install() {
|
package_check() {
|
||||||
dpkg-query -W -f='${Status}' "${1}" 2>/dev/null | grep -c "ok installed" || ${PKG_INSTALL} "${1}"
|
dpkg-query -W -f='${Status}' "${1}" 2>/dev/null | grep "ok installed"
|
||||||
|
return
|
||||||
}
|
}
|
||||||
elif [ $(command -v rpm) ]; then
|
elif [ $(command -v rpm) ]; then
|
||||||
# Fedora Family
|
# Fedora Family
|
||||||
|
@ -738,15 +739,24 @@ install_dependent_packages() {
|
||||||
# Install packages passed in via argument array
|
# Install packages passed in via argument array
|
||||||
# No spinner - conflicts with set -e
|
# No spinner - conflicts with set -e
|
||||||
declare -a argArray1=("${!1}")
|
declare -a argArray1=("${!1}")
|
||||||
|
declare -a installArray
|
||||||
|
|
||||||
|
# Debian based package install - debconf will download the entire package list
|
||||||
|
# so we just create an array of packages not currently installed to cut down on the
|
||||||
|
# amount of download traffic.
|
||||||
|
# NOTE: We may be able to use this installArray in the future to create a list of package that were
|
||||||
|
# installed by us, and remove only the installed packages, and not the entire list.
|
||||||
if command -v debconf-apt-progress &> /dev/null; then
|
if command -v debconf-apt-progress &> /dev/null; then
|
||||||
debconf-apt-progress -- ${PKG_INSTALL} "${argArray1[@]}"
|
|
||||||
else
|
|
||||||
for i in "${argArray1[@]}"; do
|
for i in "${argArray1[@]}"; do
|
||||||
echo -n "::: Checking for $i..."
|
echo -n "::: Checking for $i..."
|
||||||
package_check_install "${i}" &> /dev/null
|
if package_check "${i}" &> /dev/null; then
|
||||||
echo " installed!"
|
echo " installed!"
|
||||||
|
else
|
||||||
|
echo " added to install list!"
|
||||||
|
installArray+=("${i}")
|
||||||
|
fi
|
||||||
done
|
done
|
||||||
|
debconf-apt-progress -- ${PKG_INSTALL} "${installArray[@]}"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue