#!/usr/bin/make -f # -*- makefile -*- # debian makefile for weewx # Copyright 2013-2020 Matthew Wall # Uncomment this to turn on verbose mode. #export DH_VERBOSE=1 # determine which python we should use PKG=weewx PYTHON=python2 ifneq (,$(filter python3,$(DEB_BUILD_OPTIONS))) #PKG=python3-weewx PYTHON=python3 endif SRC=$(CURDIR) DST=$(CURDIR)/debian/$(PKG) DST_EXECDIR=$(DST)/usr/bin DST_BINDIR =$(DST)/usr/share/weewx DST_DOCDIR =$(DST)/usr/share/doc/weewx DST_INITDIR=$(DST)/etc/init.d DST_CFGDIR =$(DST)/etc/weewx # these are the entry points ENTRIES=weewxd wee_config wee_database wee_debug wee_device wee_extension wee_import wee_reports wunderfixer %: dh $@ --with python2,python3 override_dh_auto_clean: dh_auto_clean rm -rf build dist rm -f *.egg-info # this install rule duplicates what the weewx setup.py would do. we should # be able to remove this when the weewx setup.py respects --no-prompt and # when --prefix works properly. install: dh_testdir dh_testroot dh_prep dh_installdirs # create the directory structure mkdir -p $(DST_EXECDIR) mkdir -p $(DST_INITDIR) mkdir -p $(DST_BINDIR) mkdir -p $(DST_DOCDIR) mkdir -p $(DST_CFGDIR) # copy files from the source tree cp -r $(SRC)/bin/* $(DST_BINDIR) cp -r $(SRC)/docs/* $(DST_DOCDIR) cp -r $(SRC)/examples $(DST_DOCDIR) cp -r $(SRC)/skins $(DST_CFGDIR) cp -r $(SRC)/util/apache $(DST_CFGDIR) cp -r $(SRC)/util/import $(DST_CFGDIR) cp -r $(SRC)/util/logrotate.d $(DST_CFGDIR) cp -r $(SRC)/util/logwatch $(DST_CFGDIR) cp -r $(SRC)/util/rsyslog.d $(DST_CFGDIR) cp -r $(SRC)/util/udev $(DST_CFGDIR) # patch paths in files we care about cat $(SRC)/weewx.conf | sed \ -e 's%^WEEWX_ROOT =.*%WEEWX_ROOT = /%' \ -e 's%SKIN_ROOT =.*%SKIN_ROOT = /etc/weewx/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 cat $(SRC)/util/init.d/weewx.debian | sed \ -e 's%WEEWX_BIN=.*%WEEWX_BIN=/usr/bin/weewxd%' \ -e 's%WEEWX_CFG=.*%WEEWX_CFG=/etc/weewx/weewx.conf%' \ > $(DST_INITDIR)/weewx chmod 755 $(DST_INITDIR)/weewx # make a virgin copy of the configuration file cp $(DST_CFGDIR)/weewx.conf $(DST_CFGDIR)/weewx.conf.dist # insert the correct shebang for f in $(ENTRIES); do \ sed -i "s%^#!/usr/bin.*%#!/usr/bin/$(PYTHON)%" $(DST_BINDIR)/$$f; \ done # create symlinks to the code entry points for f in $(ENTRIES); do \ ln -s ../share/weewx/$$f $(DST)/usr/bin/$$f; \ done # keep lintian happy cp $(SRC)/debian/copyright $(DST_DOCDIR) # 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 binary-arch: binary: binary-indep binary-arch .PHONY: build clean binary-indep binary-arch binary install configure