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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
|
#!/usr/bin/make -f
include /usr/share/dpkg/default.mk
include /usr/share/dpkg/buildflags.mk
include /usr/share/rustc/architecture.mk
export CFLAGS CXXFLAGS CPPFLAGS LDFLAGS
export DEB_HOST_RUST_TYPE DEB_HOST_GNU_TYPE
# Honor user-provided PATH and cargo binary so as to avoid possibly
# ancient system rust installations
export CARGO=cargo
export CARGO_HOME=$(CURDIR)/debian/cargo_home
export CARGO_TARGET_DIR=$(CURDIR)/debian/target
export RUSTFLAGS=-C debuginfo=2 -C strip=none
# Rust binaries to build and install, space separated
CARGO_BUILD_BINS = arti
# Extra target flags, passed to all cargo invocations
CARGO_TARGET_FLAGS =
# Crates to exclude from testing, space separated (by default the
# entire workspace is tested)
CARGO_TEST_EXCLUDED = arti-bench arti-config
CARGO_TEST_EXCLUDED += tor-events tor-hspow
# If the build profile contains 'debug', a debug build is triggered
# (note: no separate dbgsym package is built in that case)
ifeq ($(filter debug,$(DEB_BUILD_PROFILES)),)
RELEASE = 1
CARGO_TARGET_FLAGS += --release
else
DEB_BUILD_OPTIONS += nostrip noautodbgsym
endif
# If the build profile contains 'full', a full build is triggered
ifneq ($(filter full,$(DEB_BUILD_PROFILES)),)
CARGO_TARGET_FLAGS += --features full
endif
CARGO_BIN_DIR := $(CARGO_TARGET_DIR)
ifneq ($(DEB_BUILD_GNU_TYPE),$(DEB_HOST_GNU_TYPE))
CROSS_BUILD = 1
CARGO_TARGET_FLAGS += --target $(DEB_HOST_RUST_TYPE)
CARGO_BIN_DIR := $(CARGO_BIN_DIR)/$(DEB_HOST_RUST_TYPE)
export PKG_CONFIG=$(DEB_HOST_GNU_TYPE)-pkgconf
endif
ifeq ($(RELEASE),1)
CARGO_BIN_DIR := $(CARGO_BIN_DIR)/release
else
CARGO_BIN_DIR := $(CARGO_BIN_DIR)/debug
endif
ifneq ($(CARGO_TEST_EXCLUDED),)
CARGO_TEST_EXCLUDE_FLAGS = $(addprefix --exclude ,$(CARGO_TEST_EXCLUDED))
endif
CARGO_BUILD_FLAGS = $(CARGO_TARGET_FLAGS) --locked --verbose
CARGO_BUILD_FLAGS += $(addprefix -p ,$(CARGO_BUILD_BINS))
CARGO_TEST_FLAGS = $(CARGO_TARGET_FLAGS) --workspace --locked --no-fail-fast --verbose
CARGO_TEST_FLAGS += --lib --bins $(CARGO_TEST_EXCLUDE_FLAGS)
ifeq ($(DEB_HOST_ARCH_OS),linux)
dhoptions += --with systemd
endif
%:
dh $@ $(dhoptions)
override_dh_auto_clean:
dh_auto_clean
rm -rf $(CURDIR)/target $(CARGO_HOME) $(CARGO_TARGET_DIR) debian/arti.toml
override_dh_auto_configure:
install -D -m 0644 $(CURDIR)/debian/config.toml $(CARGO_HOME)/config.toml
ifeq ($(CROSS_BUILD),1)
printf "\n[target.$(DEB_HOST_RUST_TYPE)]\n" >> $(CARGO_HOME)/config.toml
printf "linker = \"$(DEB_HOST_GNU_TYPE)-gcc\"\n" >> $(CARGO_HOME)/config.toml
endif
dh_auto_configure
override_dh_auto_build-arch:
$(CARGO) build $(CARGO_BUILD_FLAGS)
# TODO: `cargo test` triggers rebuilds which may or may not be necessary. Binaries
# are not rebuilt though (same hashes, same creation/modification/etc. times)
# TODO: tests must currently be disabled when cross compiling. However, one could
# define a 'cross-test' build profile to optionally execute tests using qemu
override_dh_auto_test-arch:
ifeq ($(filter nocheck,$(DEB_BUILD_PROFILES)),)
$(CARGO) test $(CARGO_TEST_FLAGS)
endif
override_dh_auto_install:
for bin in $(CARGO_BUILD_BINS); do \
install -D -m 0755 $(CARGO_BIN_DIR)/$$bin $(CURDIR)/debian/$(DEB_SOURCE)/usr/bin/$$bin; \
done
cp crates/arti/src/arti-example-config.toml debian/arti.toml
sed -ri 's/^#state_dir.+/state_dir = "\~\/data"/' debian/arti.toml
sed -ri 's/^#cache_dir.+/cache_dir = "\~\/cache"/' debian/arti.toml
dh_auto_install
override_dh_compress:
dh_compress -Xarti-example-config.toml
override_dh_strip:
ifeq ($(filter nostrip,$(DEB_BUILD_OPTIONS)),)
dh_strip
endif
|