]> git.proxmox.com Git - proxmox-offline-mirror.git/commitdiff
avoid debcargo on build
authorThomas Lamprecht <t.lamprecht@proxmox.com>
Tue, 30 May 2023 11:48:40 +0000 (13:48 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Tue, 30 May 2023 11:50:40 +0000 (13:50 +0200)
Switch over to a more manual build oriented on proxmox-backup and
pve-lxc-syscalld.

nothing against debcargo directly, but currently it's really tailored
to Debians re-package upstream crate needs, and that shows.

Once we can generate control files from it without requiring all
build dependencies, and potentially some other stuff fixed, we could
re-introduce it.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
Makefile
debian/proxmox-offline-mirror-helper.install [new file with mode: 0644]
debian/proxmox-offline-mirror.install [new file with mode: 0644]
debian/rules

index 4b8cfd30edfb66be446751a7ff7deeda1b0b2e6d..99d9df811d641ac2c421f9f9d7b52509db8e2eb3 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -4,7 +4,6 @@ include defines.mk
 
 PACKAGE=proxmox-offline-mirror
 BUILDDIR ?= $(PACKAGE)-$(DEB_VERSION_UPSTREAM)
-BUILDDIR_TMP ?= $(BUILDDIR).tmp
 
 SUBDIRS := docs
 
@@ -22,6 +21,13 @@ else
 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
@@ -29,26 +35,36 @@ 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)
diff --git a/debian/proxmox-offline-mirror-helper.install b/debian/proxmox-offline-mirror-helper.install
new file mode 100644 (file)
index 0000000..54033b2
--- /dev/null
@@ -0,0 +1 @@
+usr/bin/proxmox-offline-mirror-helper
diff --git a/debian/proxmox-offline-mirror.install b/debian/proxmox-offline-mirror.install
new file mode 100644 (file)
index 0000000..c5cf0e4
--- /dev/null
@@ -0,0 +1 @@
+usr/bin/proxmox-offline-mirror
index a45da527bd338505953160cafedf588f7b74a084..444f7035f2d0e30a9c2a6e5c36ac65d7c1e43469 100644 (file)
@@ -1,24 +1,32 @@
 #!/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