From: Thomas Lamprecht Date: Tue, 23 May 2023 11:44:33 +0000 (+0200) Subject: buildsys: avoid debcargo and dh-cargo on build X-Git-Url: https://git.proxmox.com/?p=pve-xtermjs.git;a=commitdiff_plain;h=11430bcc1f71d90dc374dfb223d9a13ac14a660b buildsys: avoid debcargo and dh-cargo on build 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 --- diff --git a/Makefile b/Makefile index 6512a90..059d32f 100644 --- 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 diff --git a/debian/rules b/debian/rules index 02d4e95..6049291 100755 --- a/debian/rules +++ b/debian/rules @@ -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