-include /usr/share/dpkg/pkg-info.mk
-include /usr/share/dpkg/architecture.mk
-
-PACKAGE=proxmox-apt
-BUILDDIR ?= $(PACKAGE)-$(DEB_VERSION_UPSTREAM)
-BUILDDIR_TMP ?= $(BUILDDIR).tmp
-
-DEB=librust-$(PACKAGE)-dev_$(DEB_VERSION_UPSTREAM_REVISION)_$(DEB_BUILD_ARCH).deb
-DSC=rust-$(PACKAGE)_$(DEB_VERSION_UPSTREAM_REVISION).dsc
-
-ifeq ($(BUILD_MODE), release)
-CARGO_BUILD_ARGS += --release
-COMPILEDIR := target/release
-else
-COMPILEDIR := target/debug
-endif
-
-all: cargo-build $(SUBDIRS)
-
-.PHONY: cargo-build
-cargo-build:
- cargo build $(CARGO_BUILD_ARGS)
-
-.PHONY: build
-build:
- rm -rf $(BUILDDIR) $(BUILDDIR_TMP); mkdir $(BUILDDIR_TMP)
- rm -f debian/control
- debcargo package \
- --config debian/debcargo.toml \
- --changelog-ready \
- --no-overlay-write-back \
- --directory $(BUILDDIR_TMP) \
- $(PACKAGE) \
- $(shell dpkg-parsechangelog -l debian/changelog -SVersion | sed -e 's/-.*//')
- cp $(BUILDDIR_TMP)/debian/control debian/control
- rm -f $(BUILDDIR_TMP)/Cargo.lock
- find $(BUILDDIR_TMP)/debian -name "*.hint" -delete
- mv $(BUILDDIR_TMP) $(BUILDDIR)
+# Shortcut for common operations:
+
+CRATES != /usr/bin/cargo metadata --no-deps --format-version=1 | jq -r .workspace_members'[]' | awk '{ print $$1 }'
+
+# By default we just run checks:
+.PHONY: all
+all: check
.PHONY: deb
-deb: $(DEB)
-$(DEB): build
- cd $(BUILDDIR); dpkg-buildpackage -b -us -uc --no-pre-clean
- lintian $(DEB)
+deb: $(foreach c,$(CRATES), $c-deb)
+ echo $(foreach c,$(CRATES), $c-deb)
+ lintian build/*.deb
.PHONY: dsc
-dsc: $(DSC)
-$(DSC): build
- cd $(BUILDDIR); dpkg-buildpackage -S -us -uc -d -nc
- lintian $(DSC)
+dsc: $(foreach c,$(CRATES), $c-dsc)
+ echo $(foreach c,$(CRATES), $c-dsc)
+ lintian build/*.dsc
+
+.PHONY: autopkgtest
+autopkgtest: $(foreach c,$(CRATES), $c-autopkgtest)
.PHONY: dinstall
-dinstall: $(DEB)
- dpkg -i $(DEB)
+dinstall:
+ $(MAKE) clean
+ $(MAKE) deb
+ sudo -k dpkg -i build/librust-*.deb
+
+%-deb:
+ ./build.sh $*
+ touch $@
+
+%-dsc:
+ BUILDCMD='dpkg-buildpackage -S -us -uc -d' ./build.sh $*
+ touch $@
-.PHONY: upload
-upload: $(DEB) $(DBG_DEB)
- tar cf - $(DEB) $(DBG_DEB) | ssh -X repoman@repo.proxmox.com -- upload --product pbs,pmg,pve --dist buster --arch $(DEB_BUILD_ARCH)
+%-autopkgtest:
+ autopkgtest build/$* build/*.deb -- null
+ touch $@
-.PHONY: distclean
-distclean: clean
+.PHONY: check
+check:
+ cargo test
+
+# Run the api-test server, serving the api-test/www/ subdir as 'www' dir over
+# http:
+.PHONY: apitest
+apitest:
+ cargo run -p api-test -- api-test/www/
+
+# Prints a diff between the current code and the one rustfmt would produce
+.PHONY: fmt
+fmt:
+ cargo +nightly fmt -- --check
+
+# Doc without dependencies
+.PHONY: doc
+doc:
+ cargo doc --no-deps
.PHONY: clean
clean:
cargo clean
- rm -rf *.deb *.buildinfo *.changes *.dsc rust-$(PACKAGE)_*.tar.?z $(BUILDDIR) $(BUILDDIR_TMP)
- find . -name '*~' -exec rm {} ';'
+ rm -rf build/
+ rm -f -- *-deb *-dsc *-autopkgtest *.build *.buildinfo *.changes
+
+.PHONY: update
+update:
+ cargo update
+
+%-upload: %-deb
+ cd build; \
+ dcmd --deb rust-$*_*.changes \
+ | grep -v '.changes$$' \
+ | tar -cf "$@.tar" -T-; \
+ cat "$@.tar" | ssh -X repoman@repo.proxmox.com upload --product devel --dist bookworm