buildsys: Makefile and build.sh like in proxmox crate

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
Wolfgang Bumiller 2020-11-20 09:43:04 +01:00
parent 46d6d8fa6e
commit 54fd53e1f7
2 changed files with 69 additions and 0 deletions

52
Makefile Normal file
View File

@ -0,0 +1,52 @@
# Shortcut for common operations:
CRATES=perlmod perlmod-macro
# By default we just run checks:
.PHONY: all
all: check
.PHONY: deb
deb: $(foreach c,$(CRATES), $c-deb)
echo $(foreach c,$(CRATES), $c-deb)
lintian build/*.deb
.PHONY: dinstall
dinstall:
$(MAKE) clean
$(MAKE) deb
sudo -k dpkg -i build/librust-*.deb
%-deb:
./build.sh $*
touch $@
.PHONY: check
check:
cargo test
# 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 build *-deb
.PHONY: update
update:
cargo update
%-upload: %-deb
cd build; \
dcmd --deb rust-$*_*.changes \
| grep -v '.changes$$' \
| tar -cf- -T- \
| ssh -X repoman@repo.proxmox.com upload --product devel --dist buster

17
build.sh Executable file
View File

@ -0,0 +1,17 @@
#!/bin/sh
set -e
export CARGO=/usr/bin/cargo
export RUSTC=/usr/bin/rustc
CRATE=$1
BUILDCMD=${BUILDCMD:-"dpkg-buildpackage -b -uc -us"}
mkdir -p build
echo system >build/rust-toolchain
rm -rf "build/${CRATE}"
debcargo package --config "$PWD/${CRATE}/debian/debcargo.toml" --changelog-ready --no-overlay-write-back --directory "$PWD/build/${CRATE}" "${CRATE}" "$(dpkg-parsechangelog -l "${CRATE}/debian/changelog" -SVersion | sed -e 's/-.*//')"
cd "build/${CRATE}"
${BUILDCMD}