add Debian packaging

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@proxmox.com>
This commit is contained in:
Fiona Ebner 2022-10-21 15:02:46 +02:00 committed by Wolfgang Bumiller
parent 28f222cd6e
commit cadc74576d
8 changed files with 150 additions and 0 deletions

5
.gitignore vendored
View File

@ -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

73
Makefile Normal file
View File

@ -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@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 {} ';'

5
debian/changelog vendored Normal file
View File

@ -0,0 +1,5 @@
rust-proxmox-mail-forward (0.1.0-1) stable; urgency=medium
* Initial release.
-- Proxmox Support Team <support@proxmox.com> Thu, 20 Oct 2022 11:28:37 +0200

1
debian/compat vendored Normal file
View File

@ -0,0 +1 @@
12

30
debian/control vendored Normal file
View File

@ -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@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@pam user in Proxmox Backup Server and Proxmox VE.

16
debian/copyright vendored Normal file
View File

@ -0,0 +1,16 @@
Copyright (C) 2022 Proxmox Server Solutions GmbH
This software is written by Proxmox Server Solutions GmbH <support@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/>.

2
debian/lintian-overrides vendored Normal file
View File

@ -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

18
debian/rules vendored Executable file
View File

@ -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