buildsys: fixup package building

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
Wolfgang Bumiller 2019-01-31 15:42:47 +01:00
parent a10bb8b941
commit 13b77d1060
2 changed files with 34 additions and 15 deletions

View File

@ -3,6 +3,8 @@ include defines.mk
ARCH:=$(shell dpkg-architecture -qDEB_BUILD_ARCH) ARCH:=$(shell dpkg-architecture -qDEB_BUILD_ARCH)
GITVERSION:=$(shell git rev-parse HEAD) GITVERSION:=$(shell git rev-parse HEAD)
SUBDIRS := etc www
# Binaries usable by users # Binaries usable by users
USR_BIN := \ USR_BIN := \
proxmox-backup-client \ proxmox-backup-client \
@ -16,7 +18,13 @@ SERVICE_BIN := \
proxmox-backup-api \ proxmox-backup-api \
proxmox-backup-proxy proxmox-backup-proxy
ifeq ($(BUILD_MODE), release)
CARGO_BUILD_ARGS += --release
COMPILEDIR := target/release COMPILEDIR := target/release
else
COMPILEDIR := target/debug
endif
COMPILED_BINS := \ COMPILED_BINS := \
$(addprefix $(COMPILEDIR)/,$(USR_BIN) $(USR_SBIN) $(SERVICE_BIN)) $(addprefix $(COMPILEDIR)/,$(USR_BIN) $(USR_SBIN) $(SERVICE_BIN))
@ -30,21 +38,25 @@ DEB=${PACKAGE}_${PKGVER}-${PKGREL}_${ARCH}.deb
DESTDIR= DESTDIR=
all: all: cargo-build $(SUBDIRS)
cargo build
.PHONY: $(SUBDIRS)
$(SUBDIRS):
$(MAKE) -C $@
test: test:
cargo test cargo test
.PHONY: deb # always re-create this dir
deb ${DEB}: .PHONY: build
build:
rm -rf build rm -rf build
# build here to cache results rsync -a debian Makefile defines.mk Cargo.toml src $(SUBDIRS) build/
cargo build --release
$(MAKE) -C www
rsync -a debian Cargo.toml src www etc target build
cd build; dpkg-buildpackage -b -us -uc
.PHONY: deb
deb: $(DEB)
$(DEB): build
cd build; dpkg-buildpackage -b -us -uc
distclean: clean distclean: clean
@ -58,11 +70,11 @@ clean:
dinstall: ${DEB} dinstall: ${DEB}
dpkg -i ${DEB} dpkg -i ${DEB}
.PHONY: build-release .PHONY: cargo-build
build-release: cargo-build:
cargo build --release cargo build $(CARGO_BUILD_ARGS)
$(COMPILED_BINS): build-release $(COMPILED_BINS): cargo-build
install: $(COMPILED_BINS) install: $(COMPILED_BINS)
install -dm755 $(DESTDIR)$(BINDIR) install -dm755 $(DESTDIR)$(BINDIR)

11
debian/rules vendored
View File

@ -7,8 +7,15 @@
%: %:
dh $@ --with=systemd --with=bash-completion dh $@ --with=systemd --with=bash-completion
override_dh_autobuild: override_dh_auto_build:
make PROXY_USER=www-data dh_auto_build -- \
PROXY_USER=www-data BUILD_MODE=release \
LIBDIR=/usr/lib/$(DEB_HOST_MULTIARCH)
override_dh_auto_install:
dh_auto_install -- \
PROXY_USER=www-data BUILD_MODE=release \
LIBDIR=/usr/lib/$(DEB_HOST_MULTIARCH)
override_dh_installinit: override_dh_installinit:
dh_installinit dh_installinit