don't hardcode /usr/share paths
Add a defines.mk file defining the standard default layout for installation (PREFIX, DATAROOTDIR, LIBDIR etc.). Add a $(JSDIR) variable and use env!("JSDIR") in place of the hardcoded /usr/share/javascript/proxmox-backup path. Have defines.mk include an *optional* local.mak to override JSDIR to www/ during local development. Add `make install` targets and remove debian/install. Note that service files are now in $libdir/proxmox-backup/ as there's usually no point in starting them from the command line, so /usr/sbin makes no sense. Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
parent
9fa03fa2d3
commit
6285b251e7
47
Makefile
47
Makefile
@ -1,14 +1,31 @@
|
||||
PACKAGE=proxmox-backup
|
||||
PKGVER=0.1
|
||||
PKGREL=1
|
||||
include defines.mk
|
||||
|
||||
ARCH:=$(shell dpkg-architecture -qDEB_BUILD_ARCH)
|
||||
GITVERSION:=$(shell git rev-parse HEAD)
|
||||
|
||||
# Binaries usable by users
|
||||
USR_BIN := \
|
||||
proxmox-backup-client \
|
||||
catar
|
||||
|
||||
# Binaries usable by admins
|
||||
USR_SBIN := proxmox-backup-manager
|
||||
|
||||
# Binaries for services:
|
||||
SERVICE_BIN := \
|
||||
proxmox-backup-api \
|
||||
proxmox-backup-proxy
|
||||
|
||||
COMPILEDIR := target/release
|
||||
COMPILED_BINS := \
|
||||
$(addprefix $(COMPILEDIR)/,$(USR_BIN) $(USR_SBIN) $(SERVICE_BIN))
|
||||
|
||||
export PROXMOX_PKG_VERSION=${PKGVER}
|
||||
export PROXMOX_PKG_RELEASE=${PKGREL}
|
||||
export PROXMOX_PKG_REPOID=${GITVERSION}
|
||||
|
||||
export PROXMOX_JSDIR := $(JSDIR)
|
||||
|
||||
DEB=${PACKAGE}_${PKGVER}-${PKGREL}_${ARCH}.deb
|
||||
|
||||
DESTDIR=
|
||||
@ -24,15 +41,15 @@ deb ${DEB}:
|
||||
rm -rf build
|
||||
# build here to cache results
|
||||
cargo build --release
|
||||
make -C www
|
||||
rsync -a debian Cargo.lock Cargo.toml src www target build
|
||||
$(MAKE) -C www
|
||||
rsync -a debian Cargo.toml src www etc target build
|
||||
cd build; dpkg-buildpackage -b -us -uc
|
||||
|
||||
|
||||
distclean: clean
|
||||
|
||||
clean:
|
||||
make -C www clean
|
||||
$(MAKE) -C www clean
|
||||
cargo clean
|
||||
rm -rf *.deb *.buildinfo *.changes build
|
||||
find . -name '*~' -exec rm {} ';'
|
||||
@ -40,3 +57,21 @@ clean:
|
||||
.PHONY: dinstall
|
||||
dinstall: ${DEB}
|
||||
dpkg -i ${DEB}
|
||||
|
||||
.PHONY: build-release
|
||||
build-release:
|
||||
cargo build --release
|
||||
|
||||
$(COMPILED_BINS): build-release
|
||||
|
||||
install: $(COMPILED_BINS)
|
||||
install -dm755 $(DESTDIR)$(BINDIR)
|
||||
$(foreach i,$(USR_BIN), \
|
||||
install -m755 $(COMPILEDIR)/$(i) $(DESTDIR)$(BINDIR)/ ;)
|
||||
install -dm755 $(DESTDIR)$(SBINDIR)
|
||||
$(foreach i,$(USR_SBIN), \
|
||||
install -m755 $(COMPILEDIR)/$(i) $(DESTDIR)$(SBINDIR)/ ;)
|
||||
install -dm755 $(DESTDIR)$(LIBDIR)/proxmox-backup
|
||||
$(foreach i,$(SERVICE_BIN), \
|
||||
install -m755 $(COMPILEDIR)/$(i) $(DESTDIR)$(LIBDIR)/proxmox-backup/ ;)
|
||||
$(MAKE) -C www install
|
||||
|
10
debian/install
vendored
10
debian/install
vendored
@ -1,8 +1,2 @@
|
||||
target/release/proxmox-backup-api /usr/sbin
|
||||
target/release/proxmox-backup-proxy /usr/bin
|
||||
target/release/proxmox-backup-manager /usr/sbin
|
||||
target/release/proxmox-backup-client /usr/sbin
|
||||
target/release/catar /usr/sbin
|
||||
www/images/logo-128.png /usr/share/javascript/proxmox-backup/images/
|
||||
www/images/proxmox_logo.png /usr/share/javascript/proxmox-backup/images/
|
||||
www/js/proxmox-backup-gui.js /usr/share/javascript/proxmox-backup/js/
|
||||
etc/proxmox-backup.service /lib/systemd/system/
|
||||
etc/proxmox-backup-proxy.service /lib/systemd/system/
|
||||
|
16
debian/proxmox-backup-proxy.service
vendored
16
debian/proxmox-backup-proxy.service
vendored
@ -1,16 +0,0 @@
|
||||
[Unit]
|
||||
Description=Proxmox API Proxy Server
|
||||
ConditionPathExists=/usr/bin/proxmox-backup-proxy
|
||||
Wants=proxmox-backup.service
|
||||
After=syslog.service
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
User=www-data
|
||||
Group=www-data
|
||||
ExecStart=/usr/bin/proxmox-backup-proxy start
|
||||
Type=simple
|
||||
Restart=on-failure
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
13
debian/proxmox-backup.service
vendored
13
debian/proxmox-backup.service
vendored
@ -1,13 +0,0 @@
|
||||
[Unit]
|
||||
Description=Proxmox API Test Server
|
||||
ConditionPathExists=/usr/sbin/proxmox-backup-api
|
||||
After=syslog.service
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
ExecStart=/usr/sbin/proxmox-backup-api start
|
||||
Type=simple
|
||||
Restart=on-failure
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
2
debian/rules
vendored
2
debian/rules
vendored
@ -7,6 +7,8 @@
|
||||
%:
|
||||
dh $@ --with=systemd --with=bash-completion
|
||||
|
||||
override_dh_autobuild:
|
||||
make PROXY_USER=www-data
|
||||
|
||||
override_dh_installinit:
|
||||
dh_installinit
|
||||
|
13
defines.mk
Normal file
13
defines.mk
Normal file
@ -0,0 +1,13 @@
|
||||
PACKAGE := proxmox-backup
|
||||
PKGVER := 0.1
|
||||
PKGREL := 1
|
||||
|
||||
PREFIX := /usr
|
||||
BINDIR := $(PREFIX)/bin
|
||||
SBINDIR := $(PREFIX)/sbin
|
||||
LIBDIR := $(PREFIX)/lib
|
||||
DATAROOTDIR := $(PREFIX)/share
|
||||
JSDIR := $(DATAROOTDIR)/javascript/proxmox-backup
|
||||
|
||||
# For local overrides
|
||||
-include local.mak
|
18
etc/Makefile
Normal file
18
etc/Makefile
Normal file
@ -0,0 +1,18 @@
|
||||
include ../defines.mk
|
||||
|
||||
UNITS := \
|
||||
proxmox-backup.service \
|
||||
proxmox-backup-proxy.service
|
||||
|
||||
all: $(UNITS)
|
||||
|
||||
clean:
|
||||
rm -f $(UNITS)
|
||||
|
||||
.SUFFIXES: .service.in .service
|
||||
.service.in.service:
|
||||
sed \
|
||||
-e 's!%LIBDIR%!$(LIBDIR)!g' \
|
||||
-e 's!%PROXY_USER%!$(PROXY_USER)!g' \
|
||||
$< >$@.tmp
|
||||
mv $@.tmp $@
|
15
etc/proxmox-backup-proxy.service.in
Normal file
15
etc/proxmox-backup-proxy.service.in
Normal file
@ -0,0 +1,15 @@
|
||||
[Unit]
|
||||
Description=Proxmox Backup API Proxy Server
|
||||
Wants=network-online.target
|
||||
After=network.target syslog.service
|
||||
Requires=proxmox-backup.service
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
ExecStart=%LIBDIR%/proxmox-backup/proxmox-backup-proxy
|
||||
Restart=on-failure
|
||||
User=%PROXY_USER%
|
||||
Group=%PROXY_USER%
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
12
etc/proxmox-backup.service.in
Normal file
12
etc/proxmox-backup.service.in
Normal file
@ -0,0 +1,12 @@
|
||||
[Unit]
|
||||
Description=Proxmox Backup API Server
|
||||
Wants=network-online.target
|
||||
After=network.target syslog.target
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
ExecStart=%LIBDIR%/proxmox-backup/proxmox-backup-api
|
||||
Restart=on-failure
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
@ -41,7 +41,7 @@ fn main() {
|
||||
}
|
||||
|
||||
let config = ApiConfig::new(
|
||||
"/usr/share/javascript/proxmox-backup", &ROUTER, RpcEnvironmentType::PRIVILEDGED);
|
||||
env!("PROXMOX_JSDIR"), &ROUTER, RpcEnvironmentType::PRIVILEDGED);
|
||||
|
||||
let rest_server = RestServer::new(config);
|
||||
|
||||
|
@ -32,7 +32,7 @@ fn main() {
|
||||
}
|
||||
|
||||
let mut config = ApiConfig::new(
|
||||
"/usr/share/javascript/proxmox-backup", &ROUTER, RpcEnvironmentType::PUBLIC);
|
||||
env!("PROXMOX_JSDIR"), &ROUTER, RpcEnvironmentType::PUBLIC);
|
||||
|
||||
// add default dirs which includes jquery and bootstrap
|
||||
// my $base = '/usr/share/libpve-http-server-perl';
|
||||
|
14
www/Makefile
14
www/Makefile
@ -1,3 +1,9 @@
|
||||
include ../defines.mk
|
||||
|
||||
IMAGES := \
|
||||
images/logo-128.png \
|
||||
images/proxmox_logo.png
|
||||
|
||||
JSSRC= \
|
||||
Utils.js \
|
||||
Logo.js \
|
||||
@ -24,3 +30,11 @@ js/proxmox-backup-gui.js: js OnlineHelpInfo.js ${JSSRC}
|
||||
clean:
|
||||
find . -name '*~' -exec rm {} ';'
|
||||
rm -rf js
|
||||
|
||||
install: js/proxmox-backup-gui.js
|
||||
install -dm755 $(DESTDIR)$(JSDIR)
|
||||
install -dm755 $(DESTDIR)$(JSDIR)/js
|
||||
install -m644 js/proxmox-backup-gui.js $(DESTDIR)$(JSDIR)/js/
|
||||
install -dm755 $(DESTDIR)$(JSDIR)/images
|
||||
$(foreach i,$(IMAGES), \
|
||||
install -m644 $(i) $(DESTDIR)$(JSDIR)/images/ ;)
|
||||
|
Loading…
Reference in New Issue
Block a user