diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index 4e112f81..abfb13f3 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -102,8 +102,8 @@ fi r=20 c=70 -# Content of Pi-hole's meta package control file -PIHOLE_META_PACKAGE_CONTROL_DEBIAN=$( +# Content of Pi-hole's meta package control file on APT based systems +PIHOLE_META_PACKAGE_CONTROL_APT=$( cat </dev/null || return 1 + + # Prepare directory structure and control file mkdir -p /tmp/pihole-meta/DEBIAN chmod 0755 /tmp/pihole-meta/DEBIAN touch /tmp/pihole-meta/DEBIAN/control - echo "${PIHOLE_META_PACKAGE_CONTROL_DEBIAN}" > /tmp/pihole-meta/DEBIAN/control + + # Write the control file + echo "${PIHOLE_META_PACKAGE_CONTROL_APT}" > /tmp/pihole-meta/DEBIAN/control + + # Build the package dpkg-deb --build --root-owner-group pihole-meta + # Move back into the directory the user started in popd &> /dev/null || return 1 fi + + if is_command rpm; then + # move into the tmp directory + pushd /tmp &>/dev/null || return 1 + + # Prepare directory structure and spec file + mkdir -p /tmp/pihole-meta/SPECS + touch /tmp/pihole-meta/SPECS/pihole-meta.spec + echo "${PIHOLE_META_PACKAGE_CONTROL_RPM}" > /tmp/pihole-meta/SPECS/pihole-meta.spec + + # check if we need to install the build dependencies + if ! is_command rpmbuild; then + local REMOVE_RPM_BUILD=true + eval "${PKG_INSTALL}" "rpm-build" + fi + + # Build the package + rpmbuild -bb /tmp/pihole-meta/SPECS/pihole-meta.spec + + # Move the package to the /tmp directory + mv /tmp/pihole-meta/RPMS/noarch/pihole-meta*.rpm /tmp/pihole-meta.rpm + + # Remove the build dependencies when we've installed them + if [ -n "${REMOVE_RPM_BUILD}" ]; then + local PKG_REMOVE + PKG_REMOVE="${PKG_MANAGER} remove -y" + eval "${PKG_REMOVE}" "rpm-build" + fi + + # Move back into the directory the user started in + popd &> /dev/null || return 1 + fi + + # Remove the build directory + rm -rf /tmp/pihole-meta } # A function for checking if a directory is a git repository @@ -1412,18 +1475,28 @@ notify_package_updates_available() { install_dependent_packages() { # Install meta dependency package + # Install Debian/Ubuntu packages if is_command apt-get; then if [ -f /tmp/pihole-meta.deb ]; then eval "${PKG_INSTALL}" "/tmp/pihole-meta.deb" rm /tmp/pihole-meta.deb else - printf " %b Error: Unable to find dependency meta package.\\n" "${COL_LIGHT_RED}" + printf " %b Error: Unable to find Pi-hole dependency meta package.\\n" "${COL_LIGHT_RED}" return 1 fi fi # Install Fedora/CentOS packages + if is_command rpm; then + if [ -f /tmp/pihole-meta.rpm ]; then + eval "${PKG_INSTALL}" "/tmp/pihole-meta.rpm" + rm /tmp/pihole-meta.rpm + else + printf " %b Error: Unable to find Pi-hole dependency meta package.\\n" "${COL_LIGHT_RED}" + return 1 + fi + fi printf "\\n" return 0 } @@ -2248,7 +2321,7 @@ main() { # Notify user of package availability notify_package_updates_available - # Build dependecy package + # Build dependency package build_dependency_package # Install Pi-hole dependencies diff --git a/test/test_any_automated_install.py b/test/test_any_automated_install.py index 7d9a49ad..70f554e4 100644 --- a/test/test_any_automated_install.py +++ b/test/test_any_automated_install.py @@ -532,4 +532,3 @@ def test_package_manager_has_pihole_deps(host): assert "No package" not in output.stdout assert output.rc == 0 -