]> git.proxmox.com Git - proxmox-backup.git/blob - Makefile
docs: troubleshooting: reformat & adapt
[proxmox-backup.git] / Makefile
1 include /usr/share/dpkg/default.mk
2 include defines.mk
3
4 PACKAGE := proxmox-backup
5 ARCH := $(DEB_BUILD_ARCH)
6
7 SUBDIRS := etc www docs
8
9 # Binaries usable by users
10 USR_BIN := \
11 proxmox-backup-client \
12 proxmox-file-restore \
13 pxar \
14 proxmox-tape \
15 pmtx \
16 pmt
17
18 # Binaries usable by admins
19 USR_SBIN := \
20 proxmox-backup-manager \
21 proxmox-backup-debug \
22
23 # Binaries for services:
24 SERVICE_BIN := \
25 proxmox-backup-api \
26 proxmox-backup-banner \
27 proxmox-backup-proxy \
28 proxmox-daily-update
29
30 # Single file restore daemon
31 RESTORE_BIN := \
32 proxmox-restore-daemon
33
34 SUBCRATES := \
35 pbs-api-types \
36 pbs-buildcfg \
37 pbs-client \
38 pbs-config \
39 pbs-datastore \
40 pbs-fuse-loop \
41 pbs-runtime \
42 proxmox-rest-server \
43 proxmox-systemd \
44 pbs-tape \
45 pbs-tools \
46 proxmox-backup-banner \
47 proxmox-backup-client \
48 proxmox-file-restore \
49 proxmox-restore-daemon \
50 pxar-bin
51
52 ifeq ($(BUILD_MODE), release)
53 CARGO_BUILD_ARGS += --release
54 COMPILEDIR := target/release
55 else
56 COMPILEDIR := target/debug
57 endif
58
59 ifeq ($(valgrind), yes)
60 CARGO_BUILD_ARGS += --features valgrind
61 endif
62
63 CARGO ?= cargo
64
65 COMPILED_BINS := \
66 $(addprefix $(COMPILEDIR)/,$(USR_BIN) $(USR_SBIN) $(SERVICE_BIN) $(RESTORE_BIN))
67
68 export DEB_VERSION DEB_VERSION_UPSTREAM
69
70 SERVER_DEB=${PACKAGE}-server_${DEB_VERSION}_${ARCH}.deb
71 SERVER_DBG_DEB=${PACKAGE}-server-dbgsym_${DEB_VERSION}_${ARCH}.deb
72 CLIENT_DEB=${PACKAGE}-client_${DEB_VERSION}_${ARCH}.deb
73 CLIENT_DBG_DEB=${PACKAGE}-client-dbgsym_${DEB_VERSION}_${ARCH}.deb
74 RESTORE_DEB=proxmox-backup-file-restore_${DEB_VERSION}_${ARCH}.deb
75 RESTORE_DBG_DEB=proxmox-backup-file-restore-dbgsym_${DEB_VERSION}_${ARCH}.deb
76 DOC_DEB=${PACKAGE}-docs_${DEB_VERSION}_all.deb
77
78 DEBS=${SERVER_DEB} ${SERVER_DBG_DEB} ${CLIENT_DEB} ${CLIENT_DBG_DEB} \
79 ${RESTORE_DEB} ${RESTORE_DBG_DEB} ${DEBUG_DEB} ${DEBUG_DBG_DEB}
80
81 DSC = rust-${PACKAGE}_${DEB_VERSION}.dsc
82
83 DESTDIR=
84
85 tests ?= --workspace
86
87 all: $(SUBDIRS)
88
89 .PHONY: $(SUBDIRS)
90 $(SUBDIRS):
91 $(MAKE) -C $@
92
93 test:
94 #cargo test test_broadcast_future
95 #cargo test $(CARGO_BUILD_ARGS)
96 $(CARGO) test $(tests) $(CARGO_BUILD_ARGS)
97
98 doc:
99 $(CARGO) doc --workspace --no-deps $(CARGO_BUILD_ARGS)
100
101 # always re-create this dir
102 .PHONY: build
103 build:
104 @echo "Setting pkg-buildcfg version to: $(DEB_VERSION_UPSTREAM)"
105 sed -i -e 's/^version =.*$$/version = "$(DEB_VERSION_UPSTREAM)"/' \
106 pbs-buildcfg/Cargo.toml
107 rm -rf build
108 mkdir build
109 cp -a debian \
110 Cargo.toml src \
111 $(SUBCRATES) \
112 docs etc examples tests www zsh-completions \
113 defines.mk Makefile \
114 ./build/
115 rm -f build/Cargo.lock
116 find build/debian -name "*.hint" -delete
117 $(foreach i,$(SUBDIRS), \
118 $(MAKE) -C build/$(i) clean ;)
119
120
121 .PHONY: proxmox-backup-docs
122 $(DOC_DEB) $(DEBS): proxmox-backup-docs
123 proxmox-backup-docs: build
124 cd build; dpkg-buildpackage -b -us -uc --no-pre-clean
125 lintian $(DOC_DEB)
126
127 # copy the local target/ dir as a build-cache
128 .PHONY: deb
129 $(DEBS): deb
130 deb: build
131 cd build; dpkg-buildpackage -b -us -uc --no-pre-clean --build-profiles=nodoc
132 lintian $(DEBS)
133
134 .PHONY: deb-all
135 deb-all: build
136 cd build; dpkg-buildpackage -b -us -uc --no-pre-clean
137 lintian $(DEBS) $(DOC_DEB)
138
139 .PHONY: dsc
140 dsc: $(DSC)
141 $(DSC): build
142 cd build; dpkg-buildpackage -S -us -uc -d -nc
143 lintian $(DSC)
144
145 .PHONY: clean distclean deb clean
146 distclean: clean
147 clean: clean-deb
148 $(foreach i,$(SUBDIRS), \
149 $(MAKE) -C $(i) clean ;)
150 $(CARGO) clean
151 rm -f .do-cargo-build
152 find . -name '*~' -exec rm {} ';'
153
154 # allows one to avoid running cargo clean when one just wants to tidy up after a packgae build
155 clean-deb:
156 rm -rf *.deb *.dsc *.tar.gz *.buildinfo *.changes build/
157
158 .PHONY: dinstall
159 dinstall: ${SERVER_DEB} ${SERVER_DBG_DEB} ${CLIENT_DEB} ${CLIENT_DBG_DEB} \
160 ${DEBUG_DEB} ${DEBUG_DBG_DEB}
161 dpkg -i $^
162
163 # make sure we build binaries before docs
164 docs: $(COMPILEDIR)/dump-catalog-shell-cli $(COMPILEDIR)/docgen
165
166 .PHONY: cargo-build
167 cargo-build:
168 rm -f .do-cargo-build
169 $(MAKE) $(COMPILED_BINS)
170
171 $(COMPILED_BINS) $(COMPILEDIR)/dump-catalog-shell-cli $(COMPILEDIR)/docgen: .do-cargo-build
172 .do-cargo-build:
173 $(CARGO) build $(CARGO_BUILD_ARGS) \
174 --bin proxmox-backup-api \
175 --bin proxmox-backup-proxy \
176 --bin proxmox-backup-manager \
177 --bin docgen \
178 --package proxmox-backup-banner \
179 --bin proxmox-backup-banner \
180 --package proxmox-backup-client \
181 --bin proxmox-backup-client \
182 --bin proxmox-backup-debug \
183 --package proxmox-file-restore \
184 --bin proxmox-file-restore \
185 --package pxar-bin \
186 --bin pxar \
187 --package pbs-tape \
188 --bin pmt \
189 --bin pmtx \
190 --package proxmox-restore-daemon \
191 --bin proxmox-restore-daemon \
192 --package proxmox-backup \
193 --bin dump-catalog-shell-cli \
194 --bin proxmox-daily-update \
195 --bin proxmox-file-restore \
196 --bin proxmox-tape \
197 --bin sg-tape-cmd
198 touch "$@"
199
200
201 .PHONY: lint
202 lint:
203 cargo clippy -- -A clippy::all -D clippy::correctness
204
205 install: $(COMPILED_BINS)
206 install -dm755 $(DESTDIR)$(BINDIR)
207 install -dm755 $(DESTDIR)$(ZSH_COMPL_DEST)
208 $(foreach i,$(USR_BIN), \
209 install -m755 $(COMPILEDIR)/$(i) $(DESTDIR)$(BINDIR)/ ; \
210 install -m644 zsh-completions/_$(i) $(DESTDIR)$(ZSH_COMPL_DEST)/ ;)
211 install -dm755 $(DESTDIR)$(SBINDIR)
212 $(foreach i,$(USR_SBIN), \
213 install -m755 $(COMPILEDIR)/$(i) $(DESTDIR)$(SBINDIR)/ ; \
214 install -m644 zsh-completions/_$(i) $(DESTDIR)$(ZSH_COMPL_DEST)/ ;)
215 install -dm755 $(DESTDIR)$(LIBEXECDIR)/proxmox-backup
216 install -dm755 $(DESTDIR)$(LIBEXECDIR)/proxmox-backup/file-restore
217 $(foreach i,$(RESTORE_BIN), \
218 install -m755 $(COMPILEDIR)/$(i) $(DESTDIR)$(LIBEXECDIR)/proxmox-backup/file-restore/ ;)
219 # install sg-tape-cmd as setuid binary
220 install -m4755 -o root -g root $(COMPILEDIR)/sg-tape-cmd $(DESTDIR)$(LIBEXECDIR)/proxmox-backup/sg-tape-cmd
221 $(foreach i,$(SERVICE_BIN), \
222 install -m755 $(COMPILEDIR)/$(i) $(DESTDIR)$(LIBEXECDIR)/proxmox-backup/ ;)
223 $(MAKE) -C www install
224 $(MAKE) -C docs install
225 ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
226 $(MAKE) test # HACK, only test now to avoid clobbering build files with wrong config
227 endif
228
229 .PHONY: upload
230 upload: ${SERVER_DEB} ${CLIENT_DEB} ${RESTORE_DEB} ${DOC_DEB} ${DEBUG_DEB}
231 # check if working directory is clean
232 git diff --exit-code --stat && git diff --exit-code --stat --staged
233 tar cf - ${SERVER_DEB} ${SERVER_DBG_DEB} ${DOC_DEB} ${CLIENT_DEB} \
234 ${CLIENT_DBG_DEB} ${DEBUG_DEB} ${DEBUG_DBG_DEB} \
235 | ssh -X repoman@repo.proxmox.com upload --product pbs --dist bullseye
236 tar cf - ${CLIENT_DEB} ${CLIENT_DBG_DEB} | ssh -X repoman@repo.proxmox.com upload --product "pve,pmg,pbs-client" --dist bullseye
237 tar cf - ${RESTORE_DEB} ${RESTORE_DBG_DEB} | ssh -X repoman@repo.proxmox.com upload --product "pve" --dist bullseye