]> git.proxmox.com Git - pve-xtermjs.git/commitdiff
buildsys: avoid debcargo and dh-cargo on build
authorThomas Lamprecht <t.lamprecht@proxmox.com>
Tue, 23 May 2023 11:44:33 +0000 (13:44 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Tue, 23 May 2023 12:02:48 +0000 (14:02 +0200)
debcargo package requires all dependencies to be installed, even if
we basically just use it for d/control generation, which makes it a
bad choice for build dir generation here (i.e., with a native
package) as the DSC should be buildable without requiring all build
dependencies.

Add a target to update d/control manually (not much tested) and move
the build away from dh-cargo

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
Makefile
debian/rules

index 6512a90f60b4d10619b427ac1518f171564982b7..059d32f6b9feed76db9ad93ce6da4b0c60baaf66 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -4,6 +4,9 @@ include /usr/share/dpkg/architecture.mk
 PACKAGE=pve-xtermjs
 CRATENAME=termproxy
 
+BUILDDIR ?= $(DEB_SOURCE)-$(DEB_VERSION_UPSTREAM)
+ORIG_SRC_TAR=$(DEB_SOURCE)_$(DEB_VERSION_UPSTREAM).orig.tar.gz
+
 export VERSION=$(DEB_VERSION_UPSTREAM_REVISION)
 
 XTERMJSVER=4.16.0
@@ -16,6 +19,7 @@ DEB=$(PACKAGE)_$(DEB_VERSION_UPSTREAM_REVISION)_$(DEB_HOST_ARCH).deb
 DBG_DEB=$(PACKAGE)-dbgsym_$(DEB_VERSION_UPSTREAM_REVISION)_$(DEB_HOST_ARCH).deb
 DSC=rust-$(CRATENAME)_$(DEB_VERSION_UPSTREAM_REVISION).dsc
 
+CARGO ?= cargo
 ifeq ($(BUILD_MODE), release)
 CARGO_BUILD_ARGS += --release
 COMPILEDIR := target/release
@@ -23,37 +27,50 @@ else
 COMPILEDIR := target/debug
 endif
 
-all: cargo-build $(SRCIDR)
+PREFIX = /usr
+BINDIR = $(PREFIX)/bin
+TERMPROXY_BIN := $(addprefix $(COMPILEDIR)/,termproxy)
+
+all:
+
+install: $(TERMPROXY_BIN)
+       install -dm755 $(DESTDIR)$(BINDIR)
+       install -m755 $(TERMPROXY_BIN) $(DESTDIR)$(BINDIR)/
+
+$(TERMPROXY_BIN): .do-cargo-build
+.do-cargo-build:
+       $(CARGO) build $(CARGO_BUILD_ARGS)
+       touch .do-cargo-build
 
-.PHONY: $(SUBDIRS)
-$(SUBDIRS):
-       make -C $@
 
 .PHONY: cargo-build
-cargo-build:
-       cargo build $(CARGO_BUILD_ARGS)
-
-.PHONY: build
-build:
-       rm -rf build
-       rm -f debian/control
-       debcargo package \
+cargo-build: .do-cargo-build
+
+update-dcontrol:
+       rm -rf $(BUILDDIR)
+       $(MAKE) $(BUILDDIR)
+       cd $(BUILDDIR); debcargo package \
          --config debian/debcargo.toml \
          --changelog-ready \
          --no-overlay-write-back \
          --directory build \
          $(CRATENAME) \
-         $(shell dpkg-parsechangelog -l debian/changelog -SVersion | sed -e 's/-.*//')
-       rm build/Cargo.lock
-       find build/debian -name "*.hint" -delete
-       cp build/debian/control debian/control
+         $(DEB_VERSION_UPSTREAM)
+       cd $(BUILDDIR)/build; wrap-and-sort -tkn
+       cp --remove-destination $(BUILDDIR)/build/debian/control debian/control
+
+$(BUILDDIR):
+       rm -rf $@ $@.tmp
+       mkdir $@.tmp
+       cp -a debian/ src/ Makefile Cargo.toml $@.tmp
        echo "git clone git://git.proxmox.com/git/pve-xtermjs.git\\ngit checkout $$(git rev-parse HEAD)" \
            > $@.tmp/debian/SOURCE
 
 .PHONY: deb
 deb: $(DEB)
-$(DEB) $(DBG_DEB): build
-       cd build; dpkg-buildpackage -b -uc -us
+$(DBG_DEB): $(DEB)
+$(DEB): $(BUILDDIR)
+       cd $(BUILDDIR); dpkg-buildpackage -b -uc -us
        lintian $(DEB)
        @echo $(DEB)
 
@@ -85,7 +102,8 @@ distclean: clean
 
 .PHONY: clean
 clean:
-       rm -rf *~ debian/*~ $(PACKAGE)-*/ build/ *.deb *.changes *.dsc *.tar.?z *.buildinfo
+       $(CARGO) clean
+       rm -rf $(DEB_SOURCE)-[0-9]*/ build/ *.deb *.changes *.dsc *.tar.* *.buildinfo *.build .do-cargo-build
 
 .PHONY: dinstall
 dinstall: deb
index 02d4e95a2421217af1a242b948205a3f59033d6a..6049291ea4dbeba4fbaa2d2eeb226cd3f7edf9a4 100755 (executable)
@@ -3,11 +3,25 @@
 include /usr/share/dpkg/pkg-info.mk
 include /usr/share/rustc/architecture.mk
 
+export BUILD_MODE=release
+
+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=termproxy_$(DEB_VERSION_UPSTREAM)
+export DEB_CARGO_PACKAGE=pve-xtermjs
+
 %:
-       dh $@ --buildsystem cargo
+       dh $@
 
 override_dh_auto_build:
        dh_auto_build
        sed -e 's/@VERSION@/$(DEB_VERSION)/' src/www/index.html.tpl.in > src/www/index.html.tpl
        sed -e 's/@VERSION@/$(DEB_VERSION)/' src/www/index.html.hbs.in > src/www/index.html.hbs
        rm src/www/index.html.tpl.in src/www/index.html.hbs.in
+
+override_dh_auto_configure:
+       rm -f Cargo.lock
+       /usr/share/cargo/bin/cargo prepare-debian $(CURDIR)/debian/cargo_registry --link-from-system
+       dh_auto_configure