File: rules

package info (click to toggle)
rust-hstr 0%2B20250327-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,592 kB
  • sloc: makefile: 24; sh: 1
file content (36 lines) | stat: -rwxr-xr-x 1,247 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/usr/bin/make -f

# resolve DEB_VERSION DEB_VERSION_UPSTREAM DEB_VERSION_UPSTREAM_REVISION
include /usr/share/dpkg/pkg-info.mk

# resolve crate version
# * get topmost version except prerelease suffix
#   from Cargo.toml file in dir passed as argument
# * source package version if matching upstream part modulo prerelease
# * otherwise append source package version
crate_version = \
 $(shell perl -n \
 -E '/version\W+\K\d+\.\d+\.\d+/ ' \
 -E 'and say "$(DEB_VERSION_UPSTREAM)" =~ /^\Q$$&\E(?:~[a-z]+\d*)?$$/ \
 ? "$(DEB_VERSION)" \
 : "$$&+$(DEB_VERSION_UPSTREAM_REVISION)" and exit' \
 $1/Cargo.toml)

%:
	dh $@

# declare version for virtually provided embedded crates
packages = $(patsubst %,librust-%-dev,\
 default-from-serde is-macro st-map)
packages_virtual = $(patsubst %,librust-%-dev,\
 derive-default-from-serde static-map-macro)
override_dh_gencontrol:
	$(foreach p,$(packages) $(packages_virtual),\
	  $(foreach q,$(patsubst librust-%-dev,%,$p),\
	   $(eval $p_version = $(call crate_version,crates/$q))))
	set -e; $(foreach p,$(packages),\
	 dh_gencontrol -p$p -- \
	 -v'$($p_version)' \
	 $(foreach q,$(filter-out $p,$(packages) $(packages_virtual)),\
	 -V'rust:Version:$q=$($q_version)');)
	dh_gencontrol --remaining-packages