PACKAGE=proxmox-offline-mirror
BUILDDIR ?= $(PACKAGE)-$(DEB_VERSION_UPSTREAM)
-BUILDDIR_TMP ?= $(BUILDDIR).tmp
SUBDIRS := docs
COMPILEDIR := target/debug
endif
+USR_BIN := \
+ proxmox-offline-mirror \
+ proxmox-offline-mirror-helper
+
+COMPILED_BINS := \
+ $(addprefix $(COMPILEDIR)/,$(USR_BIN))
+
all: cargo-build $(SUBDIRS)
.PHONY: cargo-build
cargo build $(CARGO_BUILD_ARGS)
.PHONY: $(SUBDIRS)
-$(SUBDIRS):
+$(SUBDIRS): cargo-build
$(MAKE) -C $@
-.PHONY: build
-build: $(BUILDDIR)
-$(BUILDDIR):
- rm -rf $(BUILDDIR) $(BUILDDIR_TMP); mkdir $(BUILDDIR_TMP)
- rm -f debian/control
+$(COMPILED_BINS): cargo-build
+
+install: $(COMPILED_BINS)
+ $(MAKE) -C docs install DESTDIR=../debian/proxmox-offline-mirror-docs
+ install -dm755 $(DESTDIR)$(BINDIR)
+ $(foreach i,$(USR_BIN), \
+ install -m755 $(COMPILEDIR)/$(i) $(DESTDIR)$(BINDIR)/ ;)
+
+update-dcontrol: $(BUILDDIR)
debcargo package \
--config debian/debcargo.toml \
--changelog-ready \
--no-overlay-write-back \
- --directory $(BUILDDIR_TMP) \
+ --directory $(BUILDDIR) \
$(PACKAGE) \
$(shell dpkg-parsechangelog -l debian/changelog -SVersion | sed -e 's/-.*//')
- cat $(BUILDDIR_TMP)/debian/control debian/control.extra > debian/control
+ cat $(BUILDDIR)/debian/control debian/control.extra > debian/control
+ rm -f debian/control
cp -a debian/control $(BUILDDIR_TMP)/debian/control
- rm -f $(BUILDDIR_TMP)/Cargo.lock
- find $(BUILDDIR_TMP)/debian -name "*.hint" -delete
- mv $(BUILDDIR_TMP) $(BUILDDIR)
+ wrap-and-sort -t -k-f debian/control
+
+.PHONY: build
+build: $(BUILDDIR)
+$(BUILDDIR):
+ rm -rf $@ $@.tmp; mkdir $@.tmp
+ cp -a src docs debian Cargo.toml Makefile defines.mk $@.tmp/
+ mv $@.tmp $@
.PHONY: deb
deb: $(DEB)
#!/usr/bin/make -f
include /usr/share/dpkg/pkg-info.mk
+include /usr/share/rustc/architecture.mk
+
+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
+
+export DEB_CARGO_CRATE=proxmox-offline-mirror_$(DEB_VERSION_UPSTREAM)
+export DEB_CARGO_PACKAGE=proxmox-offline-mirror
-export DEB_VERSION DEB_VERSION_UPSTREAM
-export BUILD_MODE=release-deb
%:
- dh $@ --buildsystem cargo --with=bash-completion
+ dh $@ --with=bash-completion
+
+override_dh_auto_configure:
+ @perl -ne 'if (/^version\s*=\s*"(\d+(?:\.\d+)+)"/) { my $$v_cargo = $$1; my $$v_deb = "$(DEB_VERSION_UPSTREAM)"; \
+ die "ERROR: d/changelog <-> Cargo.toml version mismatch: $$v_cargo != $$v_deb\n" if $$v_cargo ne $$v_deb; exit(0); }' Cargo.toml
+ $(CARGO) prepare-debian $(CURDIR)/debian/cargo_registry --link-from-system
+ dh_auto_configure
override_dh_auto_test:
# skip for now to avoid additional debug builds - no tests anyway
# dh_auto_test -- test --all
-override_dh_auto_install:
- DESTDIR=debian/proxmox-offline-mirror dh_auto_install
- DESTDIR=../debian/proxmox-offline-mirror-docs make -C docs install
- rm debian/proxmox-offline-mirror/usr/bin/docgen
- mkdir -p debian/proxmox-offline-mirror-helper/usr/bin
- mv debian/proxmox-offline-mirror/usr/bin/proxmox-offline-mirror-helper \
- debian/proxmox-offline-mirror-helper/usr/bin
-
override_dh_missing:
dh_missing --fail-missing