2019-12-20 11:34:14 +03:00
i n c l u d e / u s r / s h a r e / d p k g / d e f a u l t . m k
2019-01-31 15:43:09 +03:00
i n c l u d e d e f i n e s . m k
2018-11-30 15:39:40 +03:00
2020-01-15 12:29:57 +03:00
PACKAGE := proxmox-backup
2019-12-20 11:34:14 +03:00
ARCH := $( DEB_BUILD_ARCH)
2018-12-01 15:44:13 +03:00
2024-04-23 14:51:56 +03:00
SUBDIRS := etc www docs templates
2019-01-31 17:42:47 +03:00
2019-01-31 15:43:09 +03:00
# Binaries usable by users
USR_BIN := \
2021-01-27 13:31:26 +03:00
proxmox-backup-client \
2021-03-31 13:21:48 +03:00
proxmox-file-restore \
2021-01-27 13:31:26 +03:00
pxar \
2021-03-03 10:30:22 +03:00
proxmox-tape \
2021-02-05 13:12:52 +03:00
pmtx \
pmt
2019-01-31 15:43:09 +03:00
# Binaries usable by admins
2020-02-10 16:43:26 +03:00
USR_SBIN := \
2021-08-30 11:53:37 +03:00
proxmox-backup-manager \
2023-07-14 13:10:24 +03:00
proxmox-backup-debug
2019-01-31 15:43:09 +03:00
# Binaries for services:
SERVICE_BIN := \
proxmox-backup-api \
2020-02-10 16:43:26 +03:00
proxmox-backup-banner \
2020-10-31 23:27:06 +03:00
proxmox-backup-proxy \
2020-12-28 13:10:25 +03:00
proxmox-daily-update
2019-01-31 15:43:09 +03:00
2021-03-31 13:21:52 +03:00
# Single file restore daemon
RESTORE_BIN := \
proxmox-restore-daemon
2023-05-21 14:32:43 +03:00
SUBCRATES != cargo metadata --no-deps --format-version= 1 \
| jq -r .workspace_members'[]' \
2024-06-19 18:47:37 +03:00
| grep " $$ PWD/ " \
| sed -e " s!.* $$ PWD/!!g " -e 's/\#.*$$//g' -e 's/)$$//g'
2021-07-06 15:45:55 +03:00
2019-01-31 17:42:47 +03:00
i f e q ( $( BUILD_MODE ) , r e l e a s e )
CARGO_BUILD_ARGS += --release
2024-06-19 17:38:05 +03:00
COMPILEDIR := target/$( DEB_HOST_RUST_TYPE) /release
2019-01-31 17:42:47 +03:00
e l s e
2024-06-19 17:38:05 +03:00
COMPILEDIR := target/$( DEB_HOST_RUST_TYPE) /debug
2019-01-31 17:42:47 +03:00
e n d i f
2019-05-22 16:41:20 +03:00
i f e q ( $( valgrind ) , y e s )
CARGO_BUILD_ARGS += --features valgrind
e n d i f
2019-12-20 11:34:14 +03:00
CARGO ?= cargo
2019-01-31 15:43:09 +03:00
COMPILED_BINS := \
2021-03-31 13:21:52 +03:00
$( addprefix $( COMPILEDIR) /,$( USR_BIN) $( USR_SBIN) $( SERVICE_BIN) $( RESTORE_BIN) )
2019-01-31 15:43:09 +03:00
2020-07-04 18:51:56 +03:00
export DEB_VERSION DEB_VERSION_UPSTREAM
2023-05-21 14:57:47 +03:00
SERVER_DEB = $( PACKAGE) -server_$( DEB_VERSION) _$( ARCH) .deb
SERVER_DBG_DEB = $( PACKAGE) -server-dbgsym_$( DEB_VERSION) _$( ARCH) .deb
CLIENT_DEB = $( PACKAGE) -client_$( DEB_VERSION) _$( ARCH) .deb
CLIENT_DBG_DEB = $( PACKAGE) -client-dbgsym_$( DEB_VERSION) _$( ARCH) .deb
RESTORE_DEB = proxmox-backup-file-restore_$( DEB_VERSION) _$( ARCH) .deb
RESTORE_DBG_DEB = proxmox-backup-file-restore-dbgsym_$( DEB_VERSION) _$( ARCH) .deb
DOC_DEB = $( PACKAGE) -docs_$( DEB_VERSION) _all.deb
2019-11-11 10:35:33 +03:00
2023-05-21 14:57:47 +03:00
DEBS = $( SERVER_DEB) $( SERVER_DBG_DEB) $( CLIENT_DEB) $( CLIENT_DBG_DEB) \
2023-10-03 12:18:25 +03:00
$( RESTORE_DEB) $( RESTORE_DBG_DEB)
2020-03-03 12:56:07 +03:00
2023-05-21 14:57:47 +03:00
DSC = rust-$( PACKAGE) _$( DEB_VERSION) .dsc
2018-12-01 15:44:13 +03:00
DESTDIR =
2018-11-30 15:39:40 +03:00
2021-07-07 13:15:21 +03:00
tests ?= --workspace
2021-07-12 14:15:17 +03:00
all : $( SUBDIRS )
2019-01-31 17:42:47 +03:00
.PHONY : $( SUBDIRS )
$(SUBDIRS) :
$( MAKE) -C $@
2018-11-30 15:39:40 +03:00
2019-03-07 13:44:48 +03:00
test :
2019-05-21 18:54:49 +03:00
#cargo test test_broadcast_future
2019-04-27 11:56:49 +03:00
#cargo test $(CARGO_BUILD_ARGS)
2020-07-20 11:22:13 +03:00
$( CARGO) test $( tests) $( CARGO_BUILD_ARGS)
2018-12-19 15:54:22 +03:00
2019-03-07 13:44:48 +03:00
doc :
2021-07-07 13:15:21 +03:00
$( CARGO) doc --workspace --no-deps $( CARGO_BUILD_ARGS)
2019-02-12 15:27:11 +03:00
2019-01-31 17:42:47 +03:00
# always re-create this dir
.PHONY : build
build :
2018-11-30 15:39:40 +03:00
rm -rf build
2021-07-06 15:45:55 +03:00
mkdir build
2023-01-04 17:13:09 +03:00
git rev-parse HEAD > build/.repoid
2021-07-06 15:45:55 +03:00
cp -a debian \
2021-07-19 16:54:53 +03:00
Cargo.toml src \
2021-07-06 15:45:55 +03:00
$( SUBCRATES) \
2024-04-23 14:51:56 +03:00
docs etc examples tests www zsh-completions templates \
2021-07-06 15:45:55 +03:00
defines.mk Makefile \
./build/
rm -f build/Cargo.lock
2020-01-15 12:29:57 +03:00
find build/debian -name "*.hint" -delete
2019-02-01 13:08:36 +03:00
$( foreach i,$( SUBDIRS) , \
$( MAKE) -C build/$( i) clean ; )
2018-11-30 15:39:40 +03:00
2020-01-15 12:29:57 +03:00
2019-12-13 16:14:28 +03:00
.PHONY : proxmox -backup -docs
2020-07-14 13:31:17 +03:00
$(DOC_DEB) $(DEBS) : proxmox -backup -docs
proxmox-backup-docs : build
2019-12-13 16:14:28 +03:00
cd build; dpkg-buildpackage -b -us -uc --no-pre-clean
lintian $( DOC_DEB)
2024-06-27 11:33:39 +03:00
.PHONY : deb dsc deb -nodoc deb -nostrip
2023-05-21 14:35:55 +03:00
deb-nodoc : build
2019-12-13 16:14:28 +03:00
cd build; dpkg-buildpackage -b -us -uc --no-pre-clean --build-profiles= nodoc
2019-11-11 10:35:33 +03:00
lintian $( DEBS)
2019-02-01 12:07:22 +03:00
2024-06-27 11:33:39 +03:00
deb-nostrip : build
cd build; DEB_BUILD_OPTIONS = nostrip dpkg-buildpackage -b -us -uc
lintian $( DEBS) $( DOC_DEB)
2023-05-21 14:35:55 +03:00
$(DEBS) : deb
deb : build
2023-05-21 14:42:19 +03:00
cd build; dpkg-buildpackage -b -us -uc
2021-06-28 20:07:10 +03:00
lintian $( DEBS) $( DOC_DEB)
2020-07-14 13:31:17 +03:00
2019-02-01 12:07:22 +03:00
.PHONY : dsc
2023-05-27 18:03:32 +03:00
dsc :
rm -rf $( DSC) build/
$( MAKE) $( DSC)
lintian $( DSC)
2019-02-01 12:07:22 +03:00
$(DSC) : build
2023-05-21 14:42:19 +03:00
cd build; dpkg-buildpackage -S -us -uc -d
2023-05-27 18:03:32 +03:00
sbuild : $( DSC )
sbuild $<
2018-11-30 15:39:40 +03:00
2021-07-11 14:25:39 +03:00
.PHONY : clean distclean deb clean
2018-12-01 15:44:13 +03:00
distclean : clean
2021-07-12 09:08:25 +03:00
clean : clean -deb
2019-02-01 13:08:36 +03:00
$( foreach i,$( SUBDIRS) , \
$( MAKE) -C $( i) clean ; )
2019-12-20 11:34:14 +03:00
$( CARGO) clean
2021-07-12 14:15:17 +03:00
rm -f .do-cargo-build
2018-11-30 19:09:50 +03:00
2023-05-21 14:56:43 +03:00
# allows one to avoid running cargo clean when one just wants to tidy up after a package build
2021-07-11 14:25:39 +03:00
clean-deb :
2023-05-21 14:56:43 +03:00
rm -rf build/
rm -f *.deb *.dsc *.tar.* *.buildinfo *.build *.changes
2021-07-11 14:25:39 +03:00
2018-12-01 15:44:13 +03:00
.PHONY : dinstall
2023-10-03 12:18:25 +03:00
dinstall : $( SERVER_DEB ) $( SERVER_DBG_DEB ) $( CLIENT_DEB ) $( CLIENT_DBG_DEB )
2021-04-09 11:08:55 +03:00
dpkg -i $^
2019-01-31 15:43:09 +03:00
2019-02-24 11:51:10 +03:00
# make sure we build binaries before docs
2021-07-12 14:15:17 +03:00
docs : $( COMPILEDIR ) /dump -catalog -shell -cli $( COMPILEDIR ) /docgen
2019-02-24 11:51:10 +03:00
2019-01-31 17:42:47 +03:00
.PHONY : cargo -build
2019-03-07 13:44:48 +03:00
cargo-build :
2021-07-12 14:15:17 +03:00
rm -f .do-cargo-build
$( MAKE) $( COMPILED_BINS)
$(COMPILED_BINS) $(COMPILEDIR)/dump-catalog-shell-cli $(COMPILEDIR)/docgen : .do -cargo -build
.do-cargo-build :
2021-09-21 08:58:53 +03:00
$( CARGO) build $( CARGO_BUILD_ARGS) \
2021-07-12 11:45:09 +03:00
--package proxmox-backup-banner \
--bin proxmox-backup-banner \
2021-08-26 12:00:37 +03:00
--package proxmox-backup-client \
--bin proxmox-backup-client \
2021-09-22 17:25:07 +03:00
--bin dump-catalog-shell-cli \
2021-08-31 15:45:48 +03:00
--bin proxmox-backup-debug \
2021-09-01 13:21:51 +03:00
--package proxmox-file-restore \
--bin proxmox-file-restore \
2021-07-19 16:53:43 +03:00
--package pxar-bin \
--bin pxar \
2021-09-13 12:54:24 +03:00
--package pbs-tape \
--bin pmt \
--bin pmtx \
2021-09-21 08:58:52 +03:00
--package proxmox-restore-daemon \
--bin proxmox-restore-daemon \
2021-07-12 11:45:09 +03:00
--package proxmox-backup \
2021-09-22 17:27:37 +03:00
--bin docgen \
2024-06-03 15:04:50 +03:00
--bin pbs2to3 \
2021-09-22 17:27:37 +03:00
--bin proxmox-backup-api \
--bin proxmox-backup-manager \
--bin proxmox-backup-proxy \
2021-07-12 07:16:28 +03:00
--bin proxmox-daily-update \
--bin proxmox-file-restore \
--bin proxmox-tape \
--bin sg-tape-cmd
2021-07-12 14:15:17 +03:00
touch " $@ "
2019-01-31 15:43:09 +03:00
2019-09-11 14:59:56 +03:00
.PHONY : lint
lint :
cargo clippy -- -A clippy::all -D clippy::correctness
2019-01-31 15:43:09 +03:00
install : $( COMPILED_BINS )
install -dm755 $( DESTDIR) $( BINDIR)
2020-02-25 15:56:39 +03:00
install -dm755 $( DESTDIR) $( ZSH_COMPL_DEST)
2019-01-31 15:43:09 +03:00
$( foreach i,$( USR_BIN) , \
2020-02-25 15:56:39 +03:00
install -m755 $( COMPILEDIR) /$( i) $( DESTDIR) $( BINDIR) / ; \
install -m644 zsh-completions/_$( i) $( DESTDIR) $( ZSH_COMPL_DEST) / ; )
2019-01-31 15:43:09 +03:00
install -dm755 $( DESTDIR) $( SBINDIR)
$( foreach i,$( USR_SBIN) , \
2020-02-25 15:56:39 +03:00
install -m755 $( COMPILEDIR) /$( i) $( DESTDIR) $( SBINDIR) / ; \
install -m644 zsh-completions/_$( i) $( DESTDIR) $( ZSH_COMPL_DEST) / ; )
2023-07-14 13:10:24 +03:00
install -m755 $( COMPILEDIR) /pbs2to3 $( DESTDIR) $( SBINDIR) /
2019-02-01 12:05:14 +03:00
install -dm755 $( DESTDIR) $( LIBEXECDIR) /proxmox-backup
2021-03-31 13:21:52 +03:00
install -dm755 $( DESTDIR) $( LIBEXECDIR) /proxmox-backup/file-restore
$( foreach i,$( RESTORE_BIN) , \
install -m755 $( COMPILEDIR) /$( i) $( DESTDIR) $( LIBEXECDIR) /proxmox-backup/file-restore/ ; )
2020-12-28 13:10:25 +03:00
# install sg-tape-cmd as setuid binary
2020-12-28 15:22:17 +03:00
install -m4755 -o root -g root $( COMPILEDIR) /sg-tape-cmd $( DESTDIR) $( LIBEXECDIR) /proxmox-backup/sg-tape-cmd
2019-01-31 15:43:09 +03:00
$( foreach i,$( SERVICE_BIN) , \
2019-02-01 12:05:14 +03:00
install -m755 $( COMPILEDIR) /$( i) $( DESTDIR) $( LIBEXECDIR) /proxmox-backup/ ; )
2019-01-31 15:43:09 +03:00
$( MAKE) -C www install
2019-02-24 11:51:10 +03:00
$( MAKE) -C docs install
2024-04-23 14:51:56 +03:00
$( MAKE) -C templates install
2019-12-13 12:35:43 +03:00
.PHONY : upload
2023-05-21 16:27:55 +03:00
upload : UPLOAD_DIST ?= $( DEB_DISTRIBUTION )
2023-10-03 12:18:25 +03:00
upload : $( SERVER_DEB ) $( CLIENT_DEB ) $( RESTORE_DEB ) $( DOC_DEB )
2019-12-13 12:35:43 +03:00
# check if working directory is clean
git diff --exit-code --stat && git diff --exit-code --stat --staged
2023-10-03 12:18:25 +03:00
tar cf - $( SERVER_DEB) $( SERVER_DBG_DEB) $( DOC_DEB) $( CLIENT_DEB) $( CLIENT_DBG_DEB) \
2023-05-21 16:27:55 +03:00
| ssh -X repoman@repo.proxmox.com upload --product pbs --dist $( UPLOAD_DIST)
tar cf - $( CLIENT_DEB) $( CLIENT_DBG_DEB) | ssh -X repoman@repo.proxmox.com upload --product "pve,pmg,pbs-client" --dist $( UPLOAD_DIST)
tar cf - $( RESTORE_DEB) $( RESTORE_DBG_DEB) | ssh -X repoman@repo.proxmox.com upload --product "pve" --dist $( UPLOAD_DIST)