|
#!/bin/bash |
|
|
|
# ============================================================================= # |
|
# Copyright © 2025 Guiorgy # |
|
# # |
|
# This program is free software: you can redistribute it and/or modify it under # |
|
# the terms of the GNU General Public License as published by the Free Software # |
|
# Foundation, either version 3 of the License, or (at your option) any later # |
|
# version. # |
|
# # |
|
# This program is distributed in the hope that it will be useful, but WITHOUT # |
|
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # |
|
# FOR A PARTICULAR PURPOSE. # |
|
# # |
|
# You can see the full GNU General Public License at # |
|
# <https://www.gnu.org/licenses/> for more details. # |
|
# ============================================================================= # |
|
|
|
VERSION="2.8.4" |
|
|
|
# Prepare source |
|
if [[ ! -f nut-"$VERSION".tar.gz ]]; then |
|
echo 'Downloading source code' |
|
wget https://github.com/networkupstools/nut/releases/download/v"$VERSION"/nut-"$VERSION".tar.gz |
|
fi |
|
if [[ ! -d nut-"$VERSION" ]]; then |
|
echo 'Extracting source code' |
|
tar -xvzf nut-"$VERSION".tar.gz |
|
fi |
|
cd nut-"$VERSION" |
|
|
|
# When using git clone |
|
#./autogen.sh |
|
#./ci_build.sh |
|
|
|
echo 'Configuring' |
|
# Source: https://sources.debian.org/src/nut/2.8.4%2Breally-2/debian/rules |
|
DEB_CONFIGURE_EXTRA_FLAGS=( |
|
--prefix=/usr |
|
--sysconfdir=/etc/nut |
|
--includedir=/usr/include |
|
--mandir=/usr/share/man |
|
--libdir=/usr/lib/x86_64-linux-gnu |
|
--libexecdir=/usr/libexec |
|
--with-ssl --with-nss |
|
# --with-cgi |
|
--with-dev |
|
--enable-static |
|
--with-statepath=/run/nut |
|
--with-altpidpath=/run/nut |
|
--with-drvpath=/usr/libexec/nut |
|
--with-cgipath=/usr/lib/cgi-bin/nut |
|
--with-htmlpath=/usr/share/nut/www |
|
--with-pidpath=/run/nut |
|
--datadir=/usr/share/nut |
|
--with-pkgconfig-dir=/usr/lib/x86_64-linux-gnu/pkgconfig |
|
--with-user=nut --with-group=nut |
|
--with-udev-dir=/usr/lib/udev |
|
--with-systemdsystemunitdir=/usr/lib/systemd/system |
|
--with-systemdshutdowndir=/usr/lib/systemd/system-shutdown |
|
--with-systemdtmpfilesdir=/usr/lib/tmpfiles.d |
|
--with-python=python3 --with-python3=/usr/bin/python3 |
|
) |
|
./configure --enable-inplace-runtime --with-usb --without-linux_i2c "${DEB_CONFIGURE_EXTRA_FLAGS[@]}" |
|
|
|
CPUS="$(nproc)" |
|
echo "Building using $CPUS jobs" |
|
make -j "$CPUS" all |
|
|
|
echo "Testing using $CPUS jobs" |
|
make -j "$CPUS" check |
|
|
|
echo 'Copying bindaries to bin' |
|
find . \( -type f -executable -o -type l \) -executable -exec cp --parents -t /build/bin {} + |
|
|
|
echo 'Done!' |
|
|
|
# Wait for the termination signal |
|
#tail -f /dev/null & wait $! |