Building NUT on Debian, Raspbian and Ubuntu - networkupstools/nut GitHub Wiki
âšī¸ NOTE:
Instructions below cover specifically builds similar to the latest respective distro packaging recipes as of this writing. An arguably more detailed and portable procedure can be found at https://github.com/networkupstools/nut/wiki/Building-NUT-for-in%E2%80%90place-upgrades-or-non%E2%80%90disruptive-tests page.
Although there are recent versions of NUT in the Debian, Raspbian and Ubuntu archives, you may need to compile a newer version of a driver to test a specific patch. These instructions are intended to help you build a copy of NUT that will partially install over the official .debs, and use the same pathnames.
- make sure you have uncommented "deb-src" lines to match the "deb" lines in /etc/apt/sources*
- run
sudo apt-get update
if you had to change any sources - run
sudo apt-get build-dep nut
- optional: remove
asciidoc
(or install the build-deps manually, and omit asciidoc) to save a bit of build time - run
sudo apt-get -y install git
if you do not already have Git installed - clone the source to your working directory:
git clone https://github.com/networkupstools/nut.git
cd nut
and run./autogen.sh
- run this mega-command (alternatively, consult https://salsa.debian.org/debian/nut/-/blob/debian/debian/rules for current and historic definitions used in actual packaging):
./configure --prefix=/usr \
--includedir=/usr/include --mandir=/usr/share/man \
--infodir=/usr/share/info --sysconfdir=/etc/nut --localstatedir=/var \
--libexecdir=/usr/lib/nut --srcdir=. --enable-maintainer-mode \
--disable-silent-rules --libdir=/usr/lib/`gcc -print-multiarch` \
--with-ssl --with-nss --with-cgi --with-dev --enable-static \
--with-statepath=/var/run/nut --with-altpidpath=/var/run/nut \
--with-drvpath=/lib/nut --with-cgipath=/usr/lib/cgi-bin/nut \
--with-htmlpath=/usr/share/nut/www --with-pidpath=/var/run/nut \
--datadir=/usr/share/nut --with-pkgconfig-dir=/usr/lib/`gcc -print-multiarch`/pkgconfig \
--with-user=nut --with-group=nut --with-udev-dir=/lib/udev \
--with-systemdsystemunitdir=/lib/systemd/system
- run
make
- You can either run the drivers from the source tree for quick tests (usually in "dump mode" to see what device data they recognize), or run
sudo make install
from thedrivers
directory to partially overwrite the contents of the NUT .deb files (if you had packages installed earlier).
You can also install everything (by sudo make install
from base directory) this way, especially to take advantage of new tools and enhancements made since the packaged release, but it may not be the best plan: the NUT systemd files are not necessarily the same as the Debian/Ubuntu ones. However, by configuring the same pathnames and then installing the drivers, the new drivers should be able to be launched by the existing .deb init/systemd scripts.
You may have to verify that locations such as /var/run/nut
or /var/state/ups
exist and are writable by nut
user account, and that systemd units (NUT services, targets and paths) are enabled for auto-start. OS integration currently provided by NUT itself since 2.8.0 release includes a systemd-tmpfiles
action which runs before starting the daemon units to create the properly-owned locations for PID files etc., and a nut-driver-enumerator
(script and units) that take care of automatic enablement and registration of NUT units, including service instances for each driver based on content of ups.conf
and its changes over time (so there is less of a role for direct upsdrvctl
usage - note the new upsdrvsvcctl
where needed).
Reinstalling the .deb files should revert most of the changes, although newly-added NUT drivers (which did not exist in a packaged release) will be left behind in /lib/nut
.
Debian, Ubuntu and derivatives
i386 (32-bit)
gcc -print-multiarch
should return i386-linux-gnu
x86_64 (64-bit)
gcc -print-multiarch
should return x86_64-linux-gnu
Raspbian
ARMv7 (32-bit)
gcc -print-multiarch
should return arm-linux-gnueabihf