149 lines
5.9 KiB
Makefile
Executable file
149 lines
5.9 KiB
Makefile
Executable file
#!/usr/bin/make -f
|
|
|
|
DEB_HOST_ARCH_OS ?= $(shell dpkg-architecture -qDEB_HOST_ARCH_OS 2>/dev/null)
|
|
|
|
DEB_BUILD_MAINT_OPTIONS=hardening=+all
|
|
DEB_LDFLAGS_MAINT_APPEND=-Wl,-z,defs -Wl,-O1 -Wl,--as-needed
|
|
include /usr/share/dpkg/buildflags.mk
|
|
|
|
DEB_CONFIGURE_EXTRA_FLAGS := --prefix= \
|
|
--sysconfdir=/etc/nut \
|
|
--includedir=/usr/include \
|
|
--mandir=/usr/share/man \
|
|
--libdir=\$${prefix}/lib/$(DEB_HOST_MULTIARCH) \
|
|
--with-ssl --with-nss \
|
|
--with-cgi \
|
|
--with-dev \
|
|
--enable-static \
|
|
--with-statepath=/run/nut \
|
|
--with-altpidpath=/run/nut \
|
|
--with-drvpath=/lib/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/$(DEB_HOST_MULTIARCH)/pkgconfig \
|
|
--with-user=nut --with-group=nut
|
|
|
|
ifeq (linux,$(DEB_HOST_ARCH_OS))
|
|
DEB_CONFIGURE_EXTRA_FLAGS+=--with-udev-dir=/lib/udev --with-systemdsystemunitdir=/lib/systemd/system
|
|
endif
|
|
|
|
# only build documentation if asciidoc is installed
|
|
ifneq ($(shell which asciidoc),)
|
|
DEB_CONFIGURE_EXTRA_FLAGS+=--with-doc=html-chunked,pdf
|
|
endif
|
|
|
|
%:
|
|
dh $@ --with python2 --with python3 --with autoreconf --with systemd
|
|
|
|
override_dh_auto_configure:
|
|
dh_auto_configure -- $(DEB_CONFIGURE_EXTRA_FLAGS)
|
|
|
|
override_dh_autoreconf:
|
|
dh_autoreconf --as-needed
|
|
|
|
override_dh_install:
|
|
dh_install --list-missing
|
|
|
|
override_dh_auto_install-arch:
|
|
dh_auto_install -a
|
|
|
|
# install the bash completion script
|
|
mkdir -p $(CURDIR)/debian/tmp/usr/share/bash-completion/completions/
|
|
cp $(CURDIR)/scripts/misc/nut.bash_completion \
|
|
$(CURDIR)/debian/tmp/usr/share/bash-completion/completions/nut
|
|
|
|
# install the avahi service file
|
|
mkdir -p $(CURDIR)/debian/tmp/etc/avahi/services
|
|
cp $(CURDIR)/scripts/avahi/nut.service \
|
|
$(CURDIR)/debian/tmp/etc/avahi/services
|
|
|
|
# install Augeas lenses
|
|
mkdir -p $(CURDIR)/debian/tmp/usr/share/augeas/lenses/dist/tests
|
|
cp $(CURDIR)/scripts/augeas/*.aug \
|
|
$(CURDIR)/debian/tmp/usr/share/augeas/lenses/dist/
|
|
cp $(CURDIR)/scripts/augeas/tests/test_nut.aug \
|
|
$(CURDIR)/debian/tmp/usr/share/augeas/lenses/dist/tests/
|
|
|
|
# install the default configuration
|
|
for f in $(CURDIR)/debian/tmp/etc/nut/*; do \
|
|
nf=`basename $${f} | sed 's/\(.*\).sample/\1/'`; \
|
|
mv $${f} $(CURDIR)/debian/tmp/etc/nut/$${nf}; \
|
|
done
|
|
|
|
# Move -dev file to /usr
|
|
mv $(CURDIR)/debian/tmp/lib/$(DEB_HOST_MULTIARCH)/libupsclient.a \
|
|
$(CURDIR)/debian/tmp/usr/lib/$(DEB_HOST_MULTIARCH)/libupsclient.a
|
|
rm -f $(CURDIR)/debian/tmp/lib/$(DEB_HOST_MULTIARCH)/libupsclient.so
|
|
ln -s /lib/$(DEB_HOST_MULTIARCH)/libupsclient.so.4 \
|
|
$(CURDIR)/debian/tmp/usr/lib/$(DEB_HOST_MULTIARCH)/libupsclient.so
|
|
mv $(CURDIR)/debian/tmp/lib/$(DEB_HOST_MULTIARCH)/libnutclient.a \
|
|
$(CURDIR)/debian/tmp/usr/lib/$(DEB_HOST_MULTIARCH)/libnutclient.a
|
|
rm -f $(CURDIR)/debian/tmp/lib/$(DEB_HOST_MULTIARCH)/libnutclient.so
|
|
ln -s /lib/$(DEB_HOST_MULTIARCH)/libnutclient.so.0 \
|
|
$(CURDIR)/debian/tmp/usr/lib/$(DEB_HOST_MULTIARCH)/libnutclient.so
|
|
|
|
rm -f $(CURDIR)/debian/tmp/lib/$(DEB_HOST_MULTIARCH)/libnutscan.so
|
|
ln -s /lib/$(DEB_HOST_MULTIARCH)/libnutscan.so.1 \
|
|
$(CURDIR)/debian/tmp/usr/lib/$(DEB_HOST_MULTIARCH)/libnutscan.so
|
|
|
|
# Move daemons and install wrappers
|
|
mv $(CURDIR)/debian/tmp/sbin/upsmon $(CURDIR)/debian/tmp/lib/nut/upsmon
|
|
mv $(CURDIR)/debian/tmp/sbin/upsd $(CURDIR)/debian/tmp/lib/nut/upsd
|
|
install -m 0755 debian/local/upsmon $(CURDIR)/debian/tmp/sbin/upsmon
|
|
install -m 0755 debian/local/upsd $(CURDIR)/debian/tmp/sbin/upsd
|
|
|
|
# Install systemd files only on systems where it's supported
|
|
ifeq (linux,$(DEB_HOST_ARCH_OS))
|
|
install -m 644 -D $(CURDIR)/debian/tmp/lib/systemd/system/nut-monitor.service \
|
|
$(CURDIR)/debian/nut-client/lib/systemd/system/nut-monitor.service
|
|
install -D $(CURDIR)/debian/tmp/lib/systemd/system-shutdown/nutshutdown \
|
|
$(CURDIR)/debian/nut-server/lib/systemd/system-shutdown/nutshutdown
|
|
install -m 644 -D $(CURDIR)/debian/tmp/lib/systemd/system/nut-driver.service \
|
|
$(CURDIR)/debian/nut-server/lib/systemd/system/nut-driver.service
|
|
install -m 644 -D $(CURDIR)/debian/tmp/lib/systemd/system/nut-server.service \
|
|
$(CURDIR)/debian/nut-server/lib/systemd/system/nut-server.service
|
|
|
|
# Add a symlink to mask the LSB initscript
|
|
ln -s nut-monitor.service $(CURDIR)/debian/nut-client/lib/systemd/system/nut-client.service
|
|
ln -s /dev/null $(CURDIR)/debian/nut-client/lib/systemd/system/ups-monitor.service
|
|
|
|
# Install tmpfiles config file to create /run/nut directory
|
|
install -m 644 -D $(CURDIR)/debian/nut-client.tmpfiles \
|
|
$(CURDIR)/debian/nut-client/usr/lib/tmpfiles.d/nut-client.conf
|
|
install -m 644 -D $(CURDIR)/debian/nut-server.tmpfiles \
|
|
$(CURDIR)/debian/nut-server/usr/lib/tmpfiles.d/nut-server.conf
|
|
endif
|
|
|
|
override_dh_auto_install-indep:
|
|
dh_auto_install -i
|
|
|
|
#install documentation
|
|
mkdir -p $(CURDIR)/debian/tmp/usr/share/doc/nut-doc/pdf
|
|
mkdir -p $(CURDIR)/debian/tmp/usr/share/doc/nut-doc/html
|
|
cp $(CURDIR)/docs/*.pdf $(CURDIR)/debian/tmp/usr/share/doc/nut-doc/pdf
|
|
cp $(CURDIR)/docs/FAQ.html $(CURDIR)/debian/tmp/usr/share/doc/nut-doc/html
|
|
|
|
for f in $(CURDIR)/docs/*.chunked/; do \
|
|
nf=`basename $${f} | sed 's/\(.*\)\.chunked/\1/'`; \
|
|
cp -a $${f} $(CURDIR)/debian/tmp/usr/share/doc/nut-doc/html/$${nf}/; \
|
|
done
|
|
|
|
override_dh_installinit:
|
|
dh_installinit --restart-after-upgrade --error-handler=handle_start_failure
|
|
|
|
override_dh_systemd_start:
|
|
dh_systemd_start --restart-after-upgrade
|
|
|
|
override_dh_compress:
|
|
dh_compress -X.pdf
|
|
|
|
override_dh_installdocs:
|
|
dh_installdocs -A ./README ./NEWS ./TODO ./AUTHORS
|
|
|
|
override_dh_installchangelogs:
|
|
# dh_installchangelogs automagically rename history.txt to changelog, let's try
|
|
# to avoid that
|
|
dh_installchangelogs -pnut -Xhistory.txt
|
|
dh_installchangelogs --remaining-packages
|