Files
weewx/pkg/debian/rules
2023-11-23 22:05:22 -05:00

123 lines
3.7 KiB
Makefile
Executable File

#!/usr/bin/make -f
# -*- makefile -*-
# debian makefile for weewx
# Copyright 2013-2023 Matthew Wall
# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1
PKG=weewx
PYTHON=python3
SRC=$(CURDIR)
DST=$(CURDIR)/debian/$(PKG)
DST_BINDIR=$(DST)/usr/share/weewx
DST_CFGDIR=$(DST)/etc/weewx
DST_USERDIR=$(DST)/usr/share/weewx/user
# these are the entry points
ENTRIES=weewxd weectl
%:
dh $@ --with python3
override_dh_auto_clean:
dh_auto_clean
rm -rf build dist
rm -f *.egg-info
# this rule grabs all of the bits from the source tree and puts them into
# a staging area that has the directory structure of a debian system. it
# explicitly does *not* do things the 'python way' using pip.
install:
dh_testdir
dh_testroot
dh_prep
dh_installdirs
# create the directory structure
mkdir -p $(DST_BINDIR)
mkdir -p $(DST_CFGDIR)
mkdir -p $(DST_USERDIR)
mkdir -p $(DST)/usr/bin
mkdir -p $(DST)/etc/default
mkdir -p $(DST)/etc/systemd/system
mkdir -p $(DST)/etc/udev/rules.d
mkdir -p $(DST)/var/lib/weewx
mkdir -p $(DST)/var/log/weewx
mkdir -p $(DST)/var/www/html/weewx
# copy the weewx code
cp -r $(SRC)/src/* $(DST_BINDIR)
# create the user extensions directory
cp $(SRC)/src/weewx_data/bin/user/__init__.py $(DST_USERDIR)
cp $(SRC)/src/weewx_data/bin/user/extensions.py $(DST_USERDIR)
# copy selected ancillary files to the config dir
cp -r $(SRC)/src/weewx_data/examples $(DST_CFGDIR)
cp -r $(SRC)/src/weewx_data/skins $(DST_CFGDIR)
cp -r $(SRC)/src/weewx_data/util/apache $(DST_CFGDIR)
cp -r $(SRC)/src/weewx_data/util/import $(DST_CFGDIR)
cp -r $(SRC)/src/weewx_data/util/logrotate.d $(DST_CFGDIR)
cp -r $(SRC)/src/weewx_data/util/logwatch $(DST_CFGDIR)
cp -r $(SRC)/src/weewx_data/util/rsyslog.d $(DST_CFGDIR)
cp -r $(SRC)/src/weewx_data/util/udev $(DST_CFGDIR)
# create the default configuration
cat $(SRC)/src/weewx_data/weewx.conf | sed \
-e 's%^WEEWX_ROOT =.*%WEEWX_ROOT = /etc/weewx%' \
-e 's%^USER_ROOT =.*%USER_ROOT = /usr/share/weewx/user%' \
-e 's%SKIN_ROOT =.*%SKIN_ROOT = skins%' \
-e 's%HTML_ROOT = public_html%HTML_ROOT = /var/www/html/weewx%' \
-e 's%SQLITE_ROOT = .*%SQLITE_ROOT = /var/lib/weewx%' \
> $(DST_CFGDIR)/weewx.conf
# make a virgin copy of the configuration file
cp $(DST_CFGDIR)/weewx.conf $(DST_CFGDIR)/weewx.conf.dist
# create the system init configuration
# FIXME: if no systemd, then install sysV script
cat $(SRC)/src/weewx_data/util/systemd/weewx.service | sed \
-e 's%ExecStart=.*%ExecStart=/usr/bin/weewxd --daemon --pidfile=/run/weewx/weewxd.pid /etc/weewx/weewx.conf%' \
-e 's%#Type=.*%Type=forking%' \
-e 's%#RuntimeDirectory=.*%RuntimeDirectory=weewx%' \
-e 's%#RuntimeDirectoryMode=.*%RuntimeDirectoryMode=775%' \
-e 's%#PIDFile=.*%PIDFile=/run/weewx/weewxd.pid%' \
-e 's%#User=weewx%User=weewx%' \
-e 's%#Group=weewx%Group=weewx%' \
> $(DST)/etc/systemd/system/weewx.service
# create the entry points
for f in $(ENTRIES); do \
cp $(SRC)/bin/$$f $(DST)/usr/bin; \
done
# the defaults file indicates which python and weewx to use
cat $(SRC)/src/weewx_data/util/default/weewx | sed \
-e 's%WEEWX_PYTHON=.*%WEEWX_PYTHON=$(PYTHON)%' \
-e 's%WEEWX_BINDIR=.*%WEEWX_BINDIR=/usr/share/weewx%' \
-e 's%WEEWX_CFG=.*%WEEWX_CFG=/etc/weewx/weewx.conf%' \
> $(DST)/etc/default/weewx
# put the udev rules in place
cp $(SRC)/src/weewx_data/util/udev/rules.d/weewx.rules $(DST)/etc/udev/rules.d
# additional debian control files that dpkg-buildpackage seems to ignore
mkdir -p $(DST)/DEBIAN
cp $(SRC)/debian/config $(DST)/DEBIAN
cp $(SRC)/debian/templates $(DST)/DEBIAN
binary-indep: install
dh_installchangelogs
dh_fixperms
dh_installdeb
dh_gencontrol
dh_md5sums
dh_builddeb -- -Zgzip
binary-arch:
binary: binary-indep binary-arch
.PHONY: build clean binary-indep binary-arch binary install configure