From 28522b737e1b468fb8d58527323e33dd0be9f42b Mon Sep 17 00:00:00 2001 From: Petter Reinholdtsen Date: Thu, 28 Apr 2022 15:30:07 +0200 Subject: [PATCH] Add build rules for Debian package --- Makefile | 15 ++---- deb/changelog | 2 +- deb/control | 23 +++++++++ deb/copyright | 118 ++++++++++++++++++++++++++++++++++++++++++++++ deb/create_deb.sh | 110 ------------------------------------------ deb/postinst | 16 +++++-- deb/postrm | 17 ++++--- deb/preinst | 4 -- deb/prerm | 6 --- deb/rules | 17 +++++++ deb/source/format | 1 + deb/watch | 8 ++++ 12 files changed, 197 insertions(+), 140 deletions(-) create mode 100644 deb/control create mode 100644 deb/copyright delete mode 100755 deb/create_deb.sh delete mode 100755 deb/preinst delete mode 100755 deb/prerm create mode 100755 deb/rules create mode 100644 deb/source/format create mode 100644 deb/watch diff --git a/Makefile b/Makefile index 63a13f1..bc9dfe1 100644 --- a/Makefile +++ b/Makefile @@ -149,13 +149,9 @@ DRIVER_OBJS:=$(patsubst src/%.cc,$(BUILD)/%.o,$(DRIVER_OBJS)) all: $(BUILD)/wmbusmeters $(BUILD)/wmbusmetersd $(BUILD)/wmbusmeters.g $(BUILD)/wmbusmeters-admin $(BUILD)/testinternals -deb: wmbusmeters_$(DEBVERSION)_$(DEBARCH).deb - -check_deb: - lintian --no-tag-display-limit wmbusmeters_$(DEBVERSION)_$(DEBARCH).deb - -clean_deb: - rm -f wmbusmeters_$(DEBVERSION)_$(DEBARCH).deb +deb: + test -L debian || ln -s deb debian + debuild # Check docs verifies that all options in the source have been mentioned in the README and in the man page. # Also any option not in the source but mentioned in the docs is warned for as well. @@ -176,9 +172,6 @@ install: $(BUILD)/wmbusmeters check_docs uninstall: @./uninstall.sh / -wmbusmeters_$(DEBVERSION)_$(DEBARCH).deb: - @./deb/create_deb.sh $(BUILD) $@ $(DEBVERSION) $(DEBARCH) - snapcraft: snapcraft @@ -372,3 +365,5 @@ list_copyrights: # Include dependency information generated by gcc in a previous compile. include $(wildcard $(patsubst %.o,%.d,$(PROG_OBJS) $(DRIVER_OBJS))) + +.PHONY: deb diff --git a/deb/changelog b/deb/changelog index 297c2cb..eb7944e 100644 --- a/deb/changelog +++ b/deb/changelog @@ -1,5 +1,5 @@ wmbusmeters (1.3.0-1) stable; urgency=medium - * First package upload (Closes: #xxxxxx) + * First package upload (Closes: #998721). -- Fredrik Öhrström Sat, 26 Jun 2021 12:39:00 +0100 diff --git a/deb/control b/deb/control new file mode 100644 index 0000000..51db2f3 --- /dev/null +++ b/deb/control @@ -0,0 +1,23 @@ +Source: wmbusmeters +Section: kernel +Priority: optional +Maintainer: Petter Reinholdtsen +Build-Depends: debhelper-compat (= 13) + , librtlsdr-dev + , libncurses-dev + , rtl-wmbus +Standards-Version: 4.5.1 +Homepage: https://github.com/weetmuts/wmbusmeters +Vcs-Browser: https://github.com/weetmuts/wmbusmeters +Vcs-Git: https://github.com/weetmuts/wmbusmeters.git +Rules-Requires-Root: no + +Package: wmbusmeters +Architecture: any +Depends: ${shlibs:Depends}, ${misc:Depends} + , rtl-wmbus +Description: read wireless and wired M-BUS telegrams from utility meters + Receives and decodes C1,T1 or S1 telegrams (using + the wireless or wired mbus protocol) to acquire utility meter + readings. The readings can then be published using MQTT, + curled to a REST api, inserted into a database or stored in a log file. diff --git a/deb/copyright b/deb/copyright new file mode 100644 index 0000000..2d0d217 --- /dev/null +++ b/deb/copyright @@ -0,0 +1,118 @@ +Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ +Upstream-Name: wmbusmeters +Source: https://github.com/weetmuts/wmbusmeters +Upstream-Contact: Fredrik Öhrström + +Files: * +Copyright: 2017-2022 Fredrik Öhrström +License: GPL-3+ + +Files: src/aes.cc +Copyright: 2019 kokke +License: CC0 + +Files: src/aes.h +Copyright: 2019 kokke +License: CC0 + +Files: src/driver_iperl.cc +Copyright: 2022 Fredrik Öhrström + 2018 David Mallon +License: GPL-3+ + +Files: src/driver_minomess.cc +Copyright: 2021 Olli Salonen +License: GPL-3+ + +Files: src/driver_sharky774.cc +Copyright: 2021 Vincent Privat + 2022 Fredrik Öhrström +License: GPL-3+ + +Files: src/driver_sharky.cc +Copyright: 2021 Vincent Privat +License: GPL-3+ + +Files: src/manufacturer_specificities.cc +Copyright: 2019 Jacek Tomasiak + 2021 Vincent Privat +License: GPL-3+ + +Files: src/manufacturer_specificities.h +Copyright: 2019 Jacek Tomasiak + 2021 Vincent Privat +License: GPL-3+ + +Files: src/meter_emerlin868.cc +Copyright: 2020 Fredrik Öhrström + 2018 David Mallon +License: GPL-3+ + +Files: src/meter_ev200.cc +Copyright: 2020 Fredrik Öhrström + 2018 David Mallon +License: GPL-3+ + +Files: src/meter_hydrus.cc +Copyright: 2020 Fredrik Öhrström + 2021 Vincent Privat +License: GPL-3+ + +Files: src/meter_izar.cc +Copyright: 2019 Jacek Tomasiak + 2020 Fredrik Öhrström + 2021 Vincent Privat +License: GPL-3+ + +Files: src/meter_multical403.cc +Copyright: 2020 Fredrik Öhrström + 2020 Eric Bus +License: GPL-3+ + +Files: src/meter_multical602.cc +Copyright: 2021 Fredrik Öhrström + 2020 Eric Bus +License: GPL-3+ + +Files: src/meter_multical603.cc +Copyright: 2020 Fredrik Öhrström + 2020 Eric Bus +License: GPL-3+ + +Files: src/meter_multical803.cc +Copyright: 2020 Fredrik Öhrström + 2020 Eric Bus + 2020 Nikodem Jędrzejczak +License: GPL-3+ + +Files: src/meter_sensostar.cc +Copyright: 2020 Patrick Schwarz +License: GPL-3+ + +Files: src/meter_topaseskr.cc +Copyright: 2020 Fredrik Öhrström + 2020 Avandorp +License: GPL-3+ + +Files: src/sha256.cc +Copyright: 2013 Tom St Denis + 2013 WaterJuice +License: CC0 + +Files: src/sha256.h +Copyright: 2013 Tom St Denis + 2013 WaterJuice +License: CC0 + +License: GPL-3+ + 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 2 of the License, or + (at your option) any later version. + . + On Debian systems, the complete text of the GNU General Public License + version 3 can be found in file "/usr/share/common-licenses/GPL-3". + +License: CC0 + The authors, and therefore would be copyright holders, have as much + as possible relinguished their copyright to the public domain. diff --git a/deb/create_deb.sh b/deb/create_deb.sh deleted file mode 100755 index 0fa86aa..0000000 --- a/deb/create_deb.sh +++ /dev/null @@ -1,110 +0,0 @@ -#!/bin/sh - -BUILD=$1 -DEB=$2 -DEBVERSION=$3 -DEBARCH=$4 - -if [ -z "$BUILD" ] -then - echo "You must supply a directory for the deb contents." - exit 1 -fi - -if [ ! -x "$BUILD/wmbusmeters" ] -then - echo "You have to build wmbusmeters first." - exit 1 -fi - -if [ "$USER" != "root" ] -then - echo 'You have to run this command as "sudo make deb"' - exit 1 -fi - -if [ -z "$DEB" ] -then - echo "Uou must supply a name for the deb file." - exit 1 -fi - -if [ -z "$DEBVERSION" ] -then - echo "You must supply deb version." - exit 1 -fi - -if [ -z "$DEBARCH" ] -then - echo "You must supply a deb arch." - exit 1 -fi - -# Now run the standard install script into the directory -# that is to become the deb package. -rm -rf $BUILD/debian/wmbusmeters -mkdir -p $BUILD/debian/wmbusmeters/DEBIAN -./install.sh $BUILD/wmbusmeters $BUILD/debian/wmbusmeters --no-adduser - -ISIZE=$(du -s --apparent-size build/debian/wmbusmeters/ | cut -f 1) - -# Remove the conf and log files, they are to be installed by postinst. -rm $BUILD/debian/wmbusmeters/etc/wmbusmeters.conf -rm -rf $BUILD/debian/wmbusmeters/etc/wmbusmetersd -rm -rf $BUILD/debian/wmbusmeters/var/log/wmbusmeters - -cat >> $BUILD/debian/wmbusmeters/DEBIAN/conffiles << EOF -/etc/logrotate.d/wmbusmeters -EOF -mkdir -p $BUILD/debian/wmbusmeters/usr/share/doc/wmbusmeters - -# Install the changelog. -cp deb/changelog $BUILD/debian/wmbusmeters/usr/share/doc/wmbusmeters/changelog.Debian -gzip -v9 -n $BUILD/debian/wmbusmeters/usr/share/doc/wmbusmeters/changelog.Debian - -# Automatically collect copyright information. -./deb/collect_copyrights.sh $BUILD/debian/wmbusmeters/usr/share/doc/wmbusmeters/copyright - -# Install the install/remove scripts. -for x in preinst postinst prerm postrm -do - cp deb/$x $BUILD/debian/wmbusmeters/DEBIAN/ - chmod 555 $BUILD/debian/wmbusmeters/DEBIAN/$x -done - -# Build the control file. -cat >> $BUILD/debian/wmbusmeters/DEBIAN/control << EOF -Package: wmbusmeters -Version: $DEBVERSION -Maintainer: Fredrik Öhrström -Architecture: $DEBARCH -Installed-Size: $ISIZE -Depends: libc6 (>= 2.27) -Section: kernel -Priority: optional -Homepage: https://github.com/weetmuts/wmbusmeters -Description: read wireless and wired mbus telegrams from utility meters - Wmbusmeters receives and decodes C1,T1 or S1 telegrams (using - the wireless or wired mbus protocol) to acquire utility meter - readings. The readings can then be published using MQTT, - curled to a REST api, inserted into a database or stored in a log file. - . - Installing this package results in a full installation, including the - configuration files and the daemon. Configuration files for an existing - installation are preserved. -EOF - -# Change owner to root -chown -R root:root $BUILD/debian/wmbusmeters - -# Package the deb. -(cd $BUILD/debian; dpkg-deb --build wmbusmeters .) - -# Move the built deb back to the source root. -mv $BUILD/debian/wmbusmeters_${DEBVERSION}_${DEBARCH}.deb . - -chown $SUDO_USER:$SUDO_USER wmbusmeters_${DEBVERSION}_${DEBARCH}.deb - -echo Built package $ -echo But the deb package is not yet working correctly! Work in progress. diff --git a/deb/postinst b/deb/postinst index 85eb023..25c972f 100755 --- a/deb/postinst +++ b/deb/postinst @@ -1,6 +1,16 @@ #!/bin/sh -ADD_WMBUSMETERS_USER +set -e -# Start wmbusmeters service -systemctl start wmbusmeters.service +# Add the wmbusmeters group unless it's already there +addgroup --quiet --system wmbusmeters || true + +# creating wmbusmeters user unless it's already there +if ! getent passwd wmbusmeters >/dev/null; then + adduser --system --ingroup wmbusmeters \ + --home / --no-create-home \ + --gecos "wmbusmeters daemon" \ + wmbusmeters +fi + +#DEBHELPER# diff --git a/deb/postrm b/deb/postrm index 98d3967..7261998 100755 --- a/deb/postrm +++ b/deb/postrm @@ -1,11 +1,16 @@ #!/bin/bash -# More cleanup? +set -e -ID=$(id -u wmbusmeters 2>/dev/null) - -if [ ! "$ID" = "" ] -then - userdel wmbusmeters +# FIXME Is it safe to remove userand group on removal, or is it owning +# any files? +if false && getent passwd wmbusmeters >/dev/null; then + userdel wmbusmetersq echo user: removed wmbusmeters fi +if false && getent group wmbusmeters >/dev/null; then + groupdel wmbusmeters + echo group: removed wmbusmeters +fi + +#DEBHELPER# diff --git a/deb/preinst b/deb/preinst deleted file mode 100755 index 3264ed9..0000000 --- a/deb/preinst +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh - -# Shutdown wmbusmeters service if it is running. -systemctl stop wmbusmeters.service diff --git a/deb/prerm b/deb/prerm deleted file mode 100755 index 65f7820..0000000 --- a/deb/prerm +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/bash - -# Stop the service - -echo "Stopping any wmbusmeters.service running..." -systemctl stop wmbusmeters.service || true diff --git a/deb/rules b/deb/rules new file mode 100755 index 0000000..ae0cf04 --- /dev/null +++ b/deb/rules @@ -0,0 +1,17 @@ +#!/usr/bin/make -f +# See debhelper(7) (uncomment to enable) +# output every command that modifies files on the build system. +#export DH_VERBOSE = 1 + + +# see FEATURE AREAS in dpkg-buildflags(1) +export DEB_BUILD_MAINT_OPTIONS = hardening=+all + +# see ENVIRONMENT in dpkg-buildflags(1) +# package maintainers to append CFLAGS +export DEB_CFLAGS_MAINT_APPEND = -Wall -pedantic +# package maintainers to append LDFLAGS +export DEB_LDFLAGS_MAINT_APPEND = -Wl,--as-needed + +%: + dh $@ diff --git a/deb/source/format b/deb/source/format new file mode 100644 index 0000000..163aaf8 --- /dev/null +++ b/deb/source/format @@ -0,0 +1 @@ +3.0 (quilt) diff --git a/deb/watch b/deb/watch new file mode 100644 index 0000000..2ef1ca5 --- /dev/null +++ b/deb/watch @@ -0,0 +1,8 @@ +# See uscan(1) for format + +# Compulsory line, this is a version 4 file +version=4 + +opts="filenamemangle=s%(?:.*?)?v?(\d[\d.]*)\.tar\.gz%wmbusmeters-$1.tar.gz%" \ + https://github.com/weetmuts/wmbusmeters/tags \ + (?:.*?/)?v?(\d[\d.]*)\.tar\.gz debian uupdate