2019-06-18 18:49:40 +03:00
# Shortcut for common operations:
2024-06-19 17:00:04 +03:00
# see proxmox-backup if we ever want to support other prefixes
CRATES != echo proxmox-*/Cargo.toml | sed -e 's|/Cargo.toml||g'
2020-01-15 10:05:49 +03:00
2019-06-18 18:49:40 +03:00
# By default we just run checks:
.PHONY : all
all : check
2020-01-15 10:05:49 +03:00
.PHONY : deb
deb : $( foreach c ,$ ( CRATES ) , $ c -deb )
echo $( foreach c,$( CRATES) , $c -deb)
lintian build/*.deb
2023-05-23 11:44:18 +03:00
.PHONY : dsc
dsc : $( foreach c ,$ ( CRATES ) , $ c -dsc )
echo $( foreach c,$( CRATES) , $c -dsc)
lintian build/*.dsc
2021-01-14 16:23:45 +03:00
.PHONY : autopkgtest
autopkgtest : $( foreach c ,$ ( CRATES ) , $ c -autopkgtest )
2020-01-21 13:28:15 +03:00
.PHONY : dinstall
2020-01-21 14:30:13 +03:00
dinstall :
$( MAKE) clean
$( MAKE) deb
2020-01-21 13:56:56 +03:00
sudo -k dpkg -i build/librust-*.deb
2020-01-21 13:28:15 +03:00
2020-01-15 10:05:49 +03:00
%-deb :
./build.sh $*
touch $@
2023-05-23 11:44:18 +03:00
%-dsc :
BUILDCMD = 'dpkg-buildpackage -S -us -uc -d' ./build.sh $*
touch $@
2021-01-14 16:23:45 +03:00
%-autopkgtest :
autopkgtest build/$* build/*.deb -- null
touch $@
2024-09-20 09:43:07 +03:00
.PHONY : list -packages
list-packages :
@for p in $( CRATES) ; do \
echo " librust- $$ p-dev " ; \
done
2019-06-18 18:49:40 +03:00
.PHONY : check
check :
cargo test
2019-06-18 18:52:29 +03:00
# 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/
2019-06-18 18:49:40 +03:00
# Prints a diff between the current code and the one rustfmt would produce
.PHONY : fmt
fmt :
2020-03-16 14:21:14 +03:00
cargo +nightly fmt -- --check
2019-06-18 18:49:40 +03:00
# Doc without dependencies
.PHONY : doc
doc :
cargo doc --no-deps
.PHONY : clean
clean :
cargo clean
2023-05-23 11:46:08 +03:00
rm -rf build/
2023-06-04 19:27:46 +03:00
rm -f -- *-deb *-dsc *-autopkgtest *.build *.buildinfo *.changes
2019-06-18 18:49:40 +03:00
.PHONY : update
update :
cargo update
2020-03-03 13:50:28 +03:00
%-upload : %-deb
cd build; \
dcmd --deb rust-$* _*.changes \
| grep -v '.changes$$' \
2021-05-14 13:08:50 +03:00
| tar -cf " $@ .tar " -T-; \
2023-05-23 12:27:56 +03:00
cat " $@ .tar " | ssh -X repoman@repo.proxmox.com upload --product devel --dist bookworm
2024-09-05 12:24:08 +03:00
%-install :
rm -rf build/install/$*
mkdir -p build/install/$*
BUILDDIR = build/install/$* BUILDCMD = /usr/bin/true NOCONTROL = 1 ./build.sh " $* " || true
version = " $$ (dpkg-parsechangelog -l $* /debian/changelog -SVersion | sed -e 's/-.*//') " ; \
install -m755 -Dd " $( DESTDIR) /usr/share/cargo/registry/ $* - $$ {version} " ; \
rm -rf " $( DESTDIR) /usr/share/cargo/registry/ $* - $$ {version} " ; \
mv " build/install/ $* / $* " \
" $( DESTDIR) /usr/share/cargo/registry/ $* - $$ {version} " ; \
mv " $( DESTDIR) /usr/share/cargo/registry/ $* - $$ {version}/debian/cargo-checksum.json " \
" $( DESTDIR) /usr/share/cargo/registry/ $* - $$ {version}/.cargo-checksum.json " ; \
rm -rf " $( DESTDIR) /usr/share/cargo/registry/ $* - $$ {version}/debian " \
.PHONY : install
install : $( foreach c ,$ ( CRATES ) , $ c -install )
%-install-overlay : %-install
version = " $$ (dpkg-parsechangelog -l $* /debian/changelog -SVersion | sed -e 's/-.*//') " ; \
setfattr -n trusted.overlay.opaque -v y \
" $( DESTDIR) /usr/share/cargo/registry/ $* - $$ {version} "
install -m755 -Dd $( DESTDIR) /usr/lib/extension-release.d
echo 'ID=_any' >$( DESTDIR) /usr/lib/extension-release.d/extension-release.$*
.PHONY : install -overlay
install-overlay : $( foreach c ,$ ( CRATES ) , $ c -install -overlay )
# To make sure a sysext *replaces* a crate, rather than "merging" with it, we
# need to be able to set the 'trusted.overlay.opaque' xattr. Since we cannot do
# this as a user, we utilize `fakeroot` which keeps track of this for us, and
# turn the final directory into an 'erofs' file system image.
#
# The reason is that if a crate gets changed like this:
#
# old:
# src/foo.rs
# new:
# src/foo/mod.rs
#
# if its /usr/share/cargo/registry/$crate-$version directory was not marked as
# "opaque", the merged file system would end up with both
#
# src/foo.rs
# src/foo/mod.rs
#
# together.
#
# See https://docs.kernel.org/filesystems/overlayfs.html
%-sysext :
fakeroot $( MAKE) $* -sysext-do
%-sysext-do :
rm -f extensions/$* .raw
2024-11-19 15:58:15 +03:00
rm -rf build/sysext/$*
rm -rf build/install/$*
2024-09-05 12:24:08 +03:00
$( MAKE) DESTDIR = build/sysext/$* $* -install-overlay
mkdir -p extensions
mkfs.erofs extensions/$* .raw build/sysext/$*
sysext :
fakeroot $( MAKE) sysext-do
sysext-do :
rm -f extensions/proxmox-workspace.raw
[ -n " $( NOCLEAN) " ] || rm -rf build/sysext/workspace
$( MAKE) DESTDIR = build/sysext/workspace $( foreach c,$( CRATES) , $c -install)
install -m755 -Dd build/sysext/workspace/usr/lib/extension-release.d
echo 'ID=_any' >build/sysext/workspace/usr/lib/extension-release.d/extension-release.proxmox-workspace
mkdir -p extensions
mkfs.erofs extensions/proxmox-workspace.raw build/sysext/workspace