mirror of
https://github.com/pi-hole/pi-hole.git
synced 2024-11-15 02:42:58 +00:00
Merge pull request #3537 from MichaIng/patch-2
Further failsafe check for available APT packages
This commit is contained in:
commit
c5ed8f8bed
1 changed files with 21 additions and 6 deletions
|
@ -85,6 +85,8 @@ QUERY_LOGGING=true
|
||||||
INSTALL_WEB_INTERFACE=true
|
INSTALL_WEB_INTERFACE=true
|
||||||
PRIVACY_LEVEL=0
|
PRIVACY_LEVEL=0
|
||||||
CACHE_SIZE=10000
|
CACHE_SIZE=10000
|
||||||
|
# Placeholder variable for the list of available APT packages to be parsed subsequently
|
||||||
|
APT_PACKAGE_LIST=""
|
||||||
|
|
||||||
if [ -z "${USER}" ]; then
|
if [ -z "${USER}" ]; then
|
||||||
USER="$(id -un)"
|
USER="$(id -un)"
|
||||||
|
@ -179,6 +181,19 @@ is_command() {
|
||||||
command -v "${check_command}" >/dev/null 2>&1
|
command -v "${check_command}" >/dev/null 2>&1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
is_apt_package(){
|
||||||
|
# Checks whether a package, or one that provides it, is available in
|
||||||
|
# the installed APT repository lists.
|
||||||
|
local check_package=$1
|
||||||
|
|
||||||
|
# Obtain the list of available packages once
|
||||||
|
if [[ -z $APT_PACKAGE_LIST ]]; then
|
||||||
|
APT_PACKAGE_LIST=$(apt-cache dumpavail | grep -E '^P(ackage|rovides):')
|
||||||
|
fi
|
||||||
|
|
||||||
|
grep -qE " $check_package(,|$)" <<< "$APT_PACKAGE_LIST"
|
||||||
|
}
|
||||||
|
|
||||||
os_check() {
|
os_check() {
|
||||||
if [ "$PIHOLE_SKIP_OS_CHECK" != true ]; then
|
if [ "$PIHOLE_SKIP_OS_CHECK" != true ]; then
|
||||||
# This function gets a list of supported OS versions from a TXT record at versions.pi-hole.net
|
# This function gets a list of supported OS versions from a TXT record at versions.pi-hole.net
|
||||||
|
@ -303,10 +318,10 @@ if is_command apt-get ; then
|
||||||
# Update package cache. This is required already here to assure apt-cache calls have package lists available.
|
# Update package cache. This is required already here to assure apt-cache calls have package lists available.
|
||||||
update_package_cache || exit 1
|
update_package_cache || exit 1
|
||||||
# Debian 7 doesn't have iproute2 so check if it's available first
|
# Debian 7 doesn't have iproute2 so check if it's available first
|
||||||
if apt-cache show iproute2 > /dev/null 2>&1; then
|
if is_apt_package iproute2; then
|
||||||
iproute_pkg="iproute2"
|
iproute_pkg="iproute2"
|
||||||
# Otherwise, check if iproute is available
|
# Otherwise, check if iproute is available
|
||||||
elif apt-cache show iproute > /dev/null 2>&1; then
|
elif is_apt_package iproute; then
|
||||||
iproute_pkg="iproute"
|
iproute_pkg="iproute"
|
||||||
# Else print error and exit
|
# Else print error and exit
|
||||||
else
|
else
|
||||||
|
@ -326,10 +341,10 @@ if is_command apt-get ; then
|
||||||
# Check if installed php is v 7.0, or newer to determine packages to install
|
# Check if installed php is v 7.0, or newer to determine packages to install
|
||||||
if [[ "$phpInsNewer" != true ]]; then
|
if [[ "$phpInsNewer" != true ]]; then
|
||||||
# Prefer the php metapackage if it's there
|
# Prefer the php metapackage if it's there
|
||||||
if apt-cache show php > /dev/null 2>&1; then
|
if is_apt_package php; then
|
||||||
phpVer="php"
|
phpVer="php"
|
||||||
# Else fall back on the php5 package if it's there
|
# Else fall back on the php5 package if it's there
|
||||||
elif apt-cache show php5 > /dev/null 2>&1; then
|
elif is_apt_package php5; then
|
||||||
phpVer="php5"
|
phpVer="php5"
|
||||||
# Else print error and exit
|
# Else print error and exit
|
||||||
else
|
else
|
||||||
|
@ -341,9 +356,9 @@ if is_command apt-get ; then
|
||||||
phpVer="php$phpInsMajor.$phpInsMinor"
|
phpVer="php$phpInsMajor.$phpInsMinor"
|
||||||
fi
|
fi
|
||||||
# We also need the correct version for `php-sqlite` (which differs across distros)
|
# We also need the correct version for `php-sqlite` (which differs across distros)
|
||||||
if apt-cache show "${phpVer}-sqlite3" > /dev/null 2>&1; then
|
if is_apt_package "${phpVer}-sqlite3"; then
|
||||||
phpSqlite="sqlite3"
|
phpSqlite="sqlite3"
|
||||||
elif apt-cache show "${phpVer}-sqlite" > /dev/null 2>&1; then
|
elif is_apt_package "${phpVer}-sqlite"; then
|
||||||
phpSqlite="sqlite"
|
phpSqlite="sqlite"
|
||||||
else
|
else
|
||||||
printf " %b Aborting installation: No SQLite PHP module was found in APT repository.\\n" "${CROSS}"
|
printf " %b Aborting installation: No SQLite PHP module was found in APT repository.\\n" "${CROSS}"
|
||||||
|
|
Loading…
Reference in a new issue