mirror of
https://github.com/pi-hole/pi-hole.git
synced 2024-12-26 14:50:17 +00:00
Create dependency package on RPM distros
Signed-off-by: Christian König <github@yubiuser.dev>
This commit is contained in:
parent
fd5b3be03f
commit
f08c54e166
2 changed files with 82 additions and 10 deletions
|
@ -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 <<EOM
|
||||
Package: pihole-meta
|
||||
Version: 0.1
|
||||
|
@ -114,6 +114,29 @@ Depends: grep,dnsutils,binutils,git,iproute2,dialog,ca-certificates,cron,curl,ip
|
|||
EOM
|
||||
)
|
||||
|
||||
# Content of Pi-hole's meta package control file on RPM based systems
|
||||
PIHOLE_META_PACKAGE_CONTROL_RPM=$(
|
||||
cat <<EOM
|
||||
%define _topdir /tmp/pihole-meta
|
||||
Name: pihole-meta
|
||||
Version: 0.1
|
||||
Release: 1
|
||||
License: EUPL
|
||||
BuildArch: noarch
|
||||
Summary: Pi-hole dependency meta package
|
||||
Requires: grep,curl,psmisc,sudo, unzip,jq,git,dialog,ca-certificates, bind-utils, iproute, procps-ng, chkconfig, binutils, cronie, findutils, libcap, nmap-ncat, lshw, bash-completion
|
||||
%description
|
||||
Pi-hole dependency meta package
|
||||
%prep
|
||||
%build
|
||||
%files
|
||||
%install
|
||||
%changelog
|
||||
* Sun Sep 29 2024 Pi-hole Team - 0.1
|
||||
- First version being packaged
|
||||
EOM
|
||||
)
|
||||
|
||||
######## Undocumented Flags. Shhh ########
|
||||
# These are undocumented flags; some of which we can use when repairing an installation
|
||||
# The runUnattended flag is one example of this
|
||||
|
@ -402,9 +425,6 @@ package_manager_detect() {
|
|||
PKG_INSTALL="${PKG_MANAGER} install -y"
|
||||
# CentOS package manager returns 100 when there are packages to update so we need to || true to prevent the script from exiting.
|
||||
PKG_COUNT="${PKG_MANAGER} check-update | grep -E '(.i686|.x86|.noarch|.arm|.src|.riscv64)' | wc -l || true"
|
||||
OS_CHECK_DEPS=(bind-utils)
|
||||
INSTALLER_DEPS=(iproute newt procps-ng chkconfig binutils)
|
||||
PIHOLE_DEPS=(cronie findutils libcap nmap-ncat lshw bash-completion)
|
||||
|
||||
# If neither apt-get or yum/dnf package managers were found
|
||||
else
|
||||
|
@ -421,16 +441,59 @@ build_dependency_package(){
|
|||
chmod 0755 /tmp/pihole-meta
|
||||
|
||||
if is_command apt-get; then
|
||||
# move into the directory
|
||||
|
||||
# move into the tmp directory
|
||||
pushd /tmp &>/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
|
||||
|
|
|
@ -532,4 +532,3 @@ def test_package_manager_has_pihole_deps(host):
|
|||
|
||||
assert "No package" not in output.stdout
|
||||
assert output.rc == 0
|
||||
|
||||
|
|
Loading…
Reference in a new issue