From 83224e7729e91849b9b8f8506c33e85061f78d6f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20K=C3=B6nig?= Date: Mon, 16 Dec 2024 09:30:25 +0100 Subject: [PATCH] Improve dependency package output MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Christian König --- automated install/basic-install.sh | 49 ++++++++++++++++++++++++------ 1 file changed, 40 insertions(+), 9 deletions(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index f1ef8887..976bcf72 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -480,7 +480,16 @@ build_dependency_package(){ echo "${PIHOLE_META_PACKAGE_CONTROL_APT}" > "${tempdir}"/DEBIAN/control # Build the package - dpkg-deb --build --root-owner-group "${tempdir}" pihole-meta.deb + local str="Building dependency package pihole-meta.deb" + printf " %b %s..." "${INFO}" "${str}" + + if dpkg-deb --build --root-owner-group "${tempdir}" pihole-meta.deb &>/dev/null; then + printf "%b %b %s\\n" "${OVER}" "${TICK}" "${str}" + else + printf "%b %b %s\\n" "${OVER}" "${CROSS}" "${str}" + printf "%b Error: Building pihole-meta.deb failed. %b\\n" "${COL_LIGHT_RED}" "${COL_NC}" + return 1 + fi # Move back into the directory the user started in popd &> /dev/null || return 1 @@ -504,7 +513,16 @@ build_dependency_package(){ fi # Build the package - rpmbuild -bb "${tempdir}"/SPECS/pihole-meta.spec --define "_topdir ${tempdir}" + local str="Building dependency package pihole-meta.rpm" + printf " %b %s..." "${INFO}" "${str}" + + if rpmbuild -bb "${tempdir}"/SPECS/pihole-meta.spec --define "_topdir ${tempdir}" &>/dev/null; then + printf "%b %b %s\\n" "${OVER}" "${TICK}" "${str}" + else + printf "%b %b %s\\n" "${OVER}" "${CROSS}" "${str}" + printf "%b Error: Building pihole-meta.rpm failed. %b\\n" "${COL_LIGHT_RED}" "${COL_NC}" + return 1 + fi # Move the package to the /tmp directory mv "${tempdir}"/RPMS/noarch/pihole-meta*.rpm /tmp/pihole-meta.rpm @@ -1507,23 +1525,37 @@ notify_package_updates_available() { install_dependent_packages() { # Install meta dependency package + local str="Installing Pi-hole dependency package" + printf " %b %s..." "${INFO}" "${str}" # 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 + if eval "${PKG_INSTALL}" "/tmp/pihole-meta.deb" &>/dev/null; then + printf "%b %b %s\\n" "${OVER}" "${TICK}" "${str}" + rm /tmp/pihole-meta.deb + else + printf "%b %b %s\\n" "${OVER}" "${CROSS}" "${str}" + printf " %b Error: Unable to install Pi-hole dependency package.\\n" "${COL_LIGHT_RED}" + return 1 + fi else - printf " %b Error: Unable to find Pi-hole dependency meta package.\\n" "${COL_LIGHT_RED}" + printf " %b Error: Unable to find Pi-hole dependency package.\\n" "${COL_LIGHT_RED}" return 1 fi # Install Fedora/CentOS packages elif is_command rpm; then if [ -f /tmp/pihole-meta.rpm ]; then - eval "${PKG_INSTALL}" "/tmp/pihole-meta.rpm" - rm /tmp/pihole-meta.rpm + if eval "${PKG_INSTALL}" "/tmp/pihole-meta.rpm" &>/dev/null; then + printf "%b %b %s\\n" "${OVER}" "${TICK}" "${str}" + rm /tmp/pihole-meta.rpm + else + printf "%b %b %s\\n" "${OVER}" "${CROSS}" "${str}" + printf " %b Error: Unable to install Pi-hole dependency package.\\n" "${COL_LIGHT_RED}" + return 1 + fi else - printf " %b Error: Unable to find Pi-hole dependency meta package.\\n" "${COL_LIGHT_RED}" + printf " %b Error: Unable to find Pi-hole dependency package.\\n" "${COL_LIGHT_RED}" return 1 fi @@ -2354,7 +2386,6 @@ main() { build_dependency_package # Install Pi-hole dependencies - printf " %b Installing required dependencies ...\\n" "${INFO}" install_dependent_packages # Check that the installed OS is officially supported - display warning if not