[pbs-devel] [PATCH proxmox-mail-forward 2/3] add Debian packaging

Fiona Ebner f.ebner at proxmox.com
Fri Oct 21 15:02:46 CEST 2022


It is a setuid binary owned by root, since the initial step of reading
the configuration files on both PVE and PBS requires higher privileges
which can't be mapped easily otherwise.

Used parts of the packaging in proxmox-backup as a basis.

Signed-off-by: Fiona Ebner <f.ebner at proxmox.com>
---
 .gitignore               |  5 +++
 Makefile                 | 73 ++++++++++++++++++++++++++++++++++++++++
 debian/changelog         |  5 +++
 debian/compat            |  1 +
 debian/control           | 30 +++++++++++++++++
 debian/copyright         | 16 +++++++++
 debian/lintian-overrides |  2 ++
 debian/rules             | 18 ++++++++++
 8 files changed, 150 insertions(+)
 create mode 100644 Makefile
 create mode 100644 debian/changelog
 create mode 100644 debian/compat
 create mode 100644 debian/control
 create mode 100644 debian/copyright
 create mode 100644 debian/lintian-overrides
 create mode 100755 debian/rules

diff --git a/.gitignore b/.gitignore
index 1e7caa9..3bee320 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,2 +1,7 @@
 Cargo.lock
 target/
+proxmox-mail-forward-*/
+*proxmox-mail-forward*.buildinfo
+*proxmox-mail-forward*.tar.?z
+*proxmox-mail-forward*.changes
+*proxmox-mail-forward*.deb
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..89e7843
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,73 @@
+include /usr/share/dpkg/pkg-info.mk
+include /usr/share/dpkg/architecture.mk
+
+PACKAGE=proxmox-mail-forward
+BUILDDIR ?= $(PACKAGE)-$(DEB_VERSION_UPSTREAM)
+BUILDDIR_TMP ?= $(BUILDDIR).tmp
+
+ifeq ($(BUILD_MODE), release)
+CARGO_BUILD_ARGS += --release
+COMPILEDIR := target/release
+else
+COMPILEDIR := target/debug
+endif
+
+CARGO ?= cargo
+
+DEB=$(PACKAGE)_$(DEB_VERSION_UPSTREAM_REVISION)_$(DEB_BUILD_ARCH).deb
+DBG_DEB=$(PACKAGE)-dbgsym_$(DEB_VERSION_UPSTREAM_REVISION)_$(DEB_BUILD_ARCH).deb
+DSC=rust-$(PACKAGE)_$(DEB_VERSION_UPSTREAM_REVISION).dsc
+
+DEBS=$(DEB) $(DBG_DEB)
+
+.PHONY: build
+build:
+	@echo "Setting Cargo.toml version to: $(DEB_VERSION_UPSTREAM)"
+	sed -i -e 's/^version =.*$$/version = "$(DEB_VERSION_UPSTREAM)"/' Cargo.toml
+	rm -rf $(BUILDDIR) $(BUILDDIR_TMP); mkdir $(BUILDDIR_TMP)
+	cp -a debian \
+	  Cargo.toml src \
+	  Makefile \
+	  $(BUILDDIR_TMP)
+	rm -f $(BUILDDIR_TMP)/Cargo.lock
+	find $(BUILDDIR_TMP)/debian -name "*.hint" -delete
+	mv $(BUILDDIR_TMP) $(BUILDDIR)
+
+.PHONY: deb
+$(DEBS): deb
+deb: build
+	cd $(BUILDDIR); dpkg-buildpackage -b -us -uc --no-pre-clean
+	lintian $(DEBS)
+
+.PHONY: dsc
+dsc: $(DSC)
+$(DSC): build
+	cd $(BUILDDIR); dpkg-buildpackage -S -us -uc -d -nc
+	lintian $(DSC)
+
+.PHONY: dinstall
+dinstall: $(DEBS)
+	dpkg -i $(DEBS)
+
+.PHONY: cargo-build
+cargo-build:
+	$(CARGO) build $(CARGO_BUILD_ARGS) \
+	    --package proxmox-mail-forward \
+	    --bin proxmox-mail-forward
+
+install: cargo-build
+	install -dm755 $(DESTDIR)/usr/bin
+	install -m4755 -o root -g root $(COMPILEDIR)/proxmox-mail-forward $(DESTDIR)/usr/bin/proxmox-mail-forward
+
+.PHONY: upload
+upload: $(DEBS)
+	tar cf - $(DEBS) | ssh -X repoman at repo.proxmox.com -- upload --product "pve,pbs" --dist bullseye --arch $(DEB_BUILD_ARCH)
+
+.PHONY: distclean
+distclean: clean
+
+.PHONY: clean
+clean:
+	cargo clean
+	rm -rf *.deb *.buildinfo *.changes *.dsc rust-$(PACKAGE)_*.tar.?z $(BUILDDIR) $(BUILDDIR_TMP)
+	find . -name '*~' -exec rm {} ';'
diff --git a/debian/changelog b/debian/changelog
new file mode 100644
index 0000000..cb9cc94
--- /dev/null
+++ b/debian/changelog
@@ -0,0 +1,5 @@
+rust-proxmox-mail-forward (0.1.0-1) stable; urgency=medium
+
+  * Initial release.
+
+ -- Proxmox Support Team <support at proxmox.com>  Thu, 20 Oct 2022 11:28:37 +0200
diff --git a/debian/compat b/debian/compat
new file mode 100644
index 0000000..48082f7
--- /dev/null
+++ b/debian/compat
@@ -0,0 +1 @@
+12
diff --git a/debian/control b/debian/control
new file mode 100644
index 0000000..72e00ff
--- /dev/null
+++ b/debian/control
@@ -0,0 +1,30 @@
+Source: rust-proxmox-mail-forward
+Section: rust
+Priority: optional
+Build-Depends: debhelper (>= 12),
+ cargo:native,
+ rustc:native,
+ libstd-rust-dev,
+ librust-anyhow-1+default-dev,
+ librust-log-0.4+default-dev (>= 0.4.17-~~),
+ librust-nix-0.24+default-dev,
+ librust-proxmox-schema-1+default-dev (>= 1.3.4-~~),
+ librust-proxmox-section-config-1+default-dev,
+ librust-proxmox-sys-0.4+default-dev,
+ librust-serde-1+default-dev,
+ librust-serde-1+derive-dev,
+ librust-syslog-4+default-dev
+Maintainer: Proxmox Support Team <support at proxmox.com>
+Standards-Version: 4.5.1
+Vcs-Git: git://git.proxmox.com/git/proxmox-mail-forward.git
+Vcs-Browser: https://git.proxmox.com/?p=proxmox-mail-forward.git
+Homepage: https://www.proxmox.com
+Rules-Requires-Root: binary-targets
+
+Package: proxmox-mail-forward
+Architecture: any
+Depends: ${misc:Depends},
+         ${shlibs:Depends},
+Description: Proxmox mail forward helper
+ This package contains the Proxmox mail forward helper. It forwards mails to the
+ address(es) of the root at pam user in Proxmox Backup Server and Proxmox VE.
diff --git a/debian/copyright b/debian/copyright
new file mode 100644
index 0000000..d2d30fc
--- /dev/null
+++ b/debian/copyright
@@ -0,0 +1,16 @@
+Copyright (C) 2022 Proxmox Server Solutions GmbH
+
+This software is written by Proxmox Server Solutions GmbH <support at proxmox.com>
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU Affero General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU Affero General Public License for more details.
+
+You should have received a copy of the GNU Affero General Public License
+along with this program.  If not, see <http://www.gnu.org/licenses/>.
diff --git a/debian/lintian-overrides b/debian/lintian-overrides
new file mode 100644
index 0000000..bdd0599
--- /dev/null
+++ b/debian/lintian-overrides
@@ -0,0 +1,2 @@
+proxmox-mail-forward: no-manual-page usr/bin/proxmox-mail-forward
+proxmox-mail-forward: setuid-binary usr/bin/proxmox-mail-forward 4755 root/root
diff --git a/debian/rules b/debian/rules
new file mode 100755
index 0000000..0e5f66c
--- /dev/null
+++ b/debian/rules
@@ -0,0 +1,18 @@
+#!/usr/bin/make -f
+# See debhelper(7) (uncomment to enable)
+# output every command that modifies files on the build system.
+DH_VERBOSE = 1
+
+export BUILD_MODE=release
+
+CARGO=/usr/share/cargo/bin/cargo
+
+export CFLAGS CXXFLAGS CPPFLAGS LDFLAGS
+export DEB_HOST_RUST_TYPE DEB_HOST_GNU_TYPE
+export CARGO_HOME = $(CURDIR)/debian/cargo_home
+
+%:
+	dh $@
+
+override_dh_fixperms:
+	dh_fixperms --exclude proxmox-mail-forward
-- 
2.30.2






More information about the pbs-devel mailing list