Skip to content

Commit

Permalink
Devel (#102)
Browse files Browse the repository at this point in the history
* ensure install command failures are non-fatal

installation from a non-privilege account is unable to change file ownership

* sanitize DESTDIR usage #1

Don't use DESTDIR in other directory definition, keep it for
installation paths only.

* sanitize DESTDIR usage #2

Don't use DESTDIR into final executable, this is an installation-time
only variable.

* let installation process define full pathes

instead of having the final executable compute those pathes using only
an installation-specified prefix.

* a single sed command is enough
  • Loading branch information
guillomovitch authored and kissifrot committed Sep 14, 2017
1 parent 848c391 commit fe10fc3
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 44 deletions.
72 changes: 37 additions & 35 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,16 @@ PREFIX?=/usr/local

# Overwrite that variable with the Perl vendorlib Config value if
# you package Backup Manager
PERL5DIR?="$(DESTDIR)$(shell perl -MConfig -e 'print "$$Config{sitelib}"')"
PERL5DIR?="$(shell perl -MConfig -e 'print "$$Config{sitelib}"')"

# Some static paths, specific to backup-manager
BINDIR=$(PREFIX)/bin
SBINDIR=$(PREFIX)/sbin
VARDIR=$(PREFIX)/var

LIBDIR=$(DESTDIR)/$(PREFIX)/lib/backup-manager
LIBDIR=$(PREFIX)/lib/backup-manager
CONTRIB=$(LIBDIR)/contrib
SHAREDIR=$(DESTDIR)/$(PREFIX)/share/backup-manager
SHAREDIR=$(PREFIX)/share/backup-manager
SHFILES=\
lib/externals.sh \
lib/dialog.sh \
Expand All @@ -58,7 +58,7 @@ SHFILES=\
lib/md5sum.sh

# For the backup-manager-doc package
DOCDIR = $(DESTDIR)/$(PREFIX)/share/doc/backup-manager
DOCDIR = $(PREFIX)/share/doc/backup-manager
DOCHTMLDIR = $(DOCDIR)/user-guide.html
DOCPDF = doc/user-guide.pdf
DOCHTMLFILES = doc/user-guide.html/*.html
Expand All @@ -75,18 +75,18 @@ install_binary: build install_lib install_bin

install_contrib:
@echo -e "*** Contrib files ***\n"
install -d $(CONTRIB)
install -m0755 contrib/*.sh $(CONTRIB)
install -d $(DESTDIR)/$(CONTRIB)
install -m0755 contrib/*.sh $(DESTDIR)/$(CONTRIB)

# The backup-manager-doc package
install_doc:
@echo -e "\n*** Building the User Guide ***\n"
$(MAKE) -C doc DESTDIR=$(DESTDIR)
install -d $(DOCDIR)
install -o root -g 0 -m 0644 $(DOCPDF) $(DOCDIR)
install -o root -g 0 -m 0644 $(DOCTXT) $(DOCDIR)
install -d $(DOCHTMLDIR)
install -o root -g 0 -m 0644 $(DOCHTMLFILES) $(DOCHTMLDIR)
install -d $(DESTDIR)/$(DOCDIR)
-install -o root -g 0 -m 0644 $(DOCPDF) $(DESTDIR)/$(DOCDIR)
-install -o root -g 0 -m 0644 $(DOCTXT) $(DESTDIR)/$(DOCDIR)
install -d $(DESTDIR)/$(DOCHTMLDIR)
-install -o root -g 0 -m 0644 $(DOCHTMLFILES) $(DESTDIR)/$(DOCHTMLDIR)

# The translation stuff
install_po:
Expand All @@ -95,42 +95,44 @@ install_po:
# The backup-manager libraries
install_lib:
@echo -e "\n*** Installing libraries ***\n"
install -d $(LIBDIR)
install -o root -g 0 -m 0644 $(SHFILES) $(LIBDIR)
install -d $(DESTDIR)/$(LIBDIR)
-install -o root -g 0 -m 0644 $(SHFILES) $(DESTDIR)/$(LIBDIR)

# The main stuff to build the backup-manager package
install_bin:
@echo -e "\n*** Installing scripts ***\n"
mkdir -p $(DESTDIR)/$(SBINDIR)
mkdir -p $(DESTDIR)/$(BINDIR)
mkdir -p $(SHAREDIR)
install -o root -g 0 -m 0755 backup-manager $(DESTDIR)/$(SBINDIR)
install -o root -g 0 -m 0755 backup-manager-purge $(DESTDIR)/$(BINDIR)
install -o root -g 0 -m 0755 backup-manager-upload $(DESTDIR)/$(BINDIR)
install -o root -g 0 -m 0644 backup-manager.conf.tpl $(SHAREDIR)
mkdir -p $(DESTDIR)$(SHAREDIR)
-install -o root -g 0 -m 0755 backup-manager $(DESTDIR)/$(SBINDIR)
-install -o root -g 0 -m 0755 backup-manager-purge $(DESTDIR)/$(BINDIR)
-install -o root -g 0 -m 0755 backup-manager-upload $(DESTDIR)/$(BINDIR)
-install -o root -g 0 -m 0644 backup-manager.conf.tpl $(DESTDIR)$(SHAREDIR)

# Set PREFIX to backup-manager binary
sed "s#^BIN_PREFIX=.*#BIN_PREFIX=$(DESTDIR)/$(BINDIR)#" -i $(DESTDIR)/$(SBINDIR)/backup-manager
sed "s#^LIB_PREFIX=.*#LIB_PREFIX=$(DESTDIR)/$(PREFIX)/lib#" -i $(DESTDIR)/$(SBINDIR)/backup-manager
sed "s#^VAR_PREFIX=.*#VAR_PREFIX=$(VARDIR)#" -i $(DESTDIR)/$(SBINDIR)/backup-manager
sed \
-e "s#^bindir=.*#bindir=$(BINDIR)#" \
-e "s#^libdir=.*#libdir=$(LIBDIR)#" \
-e "s#^vardir=.*#vardir=$(VARDIR)#" \
-i $(DESTDIR)/$(SBINDIR)/backup-manager

mkdir -p $(PERL5DIR)
mkdir -p $(PERL5DIR)/BackupManager
install -o root -g 0 -m 0644 BackupManager/*.pm $(PERL5DIR)/BackupManager
mkdir -p $(DESTDIR)/$(PERL5DIR)
mkdir -p $(DESTDIR)/$(PERL5DIR)/BackupManager
-install -o root -g 0 -m 0644 BackupManager/*.pm $(DESTDIR)/$(PERL5DIR)/BackupManager

# Uninstall
uninstall:
@echo -e "\n*** Unsinstalling Backup-Manager ***\n"
@rm -fv $(DESTDIR)$(SBINDIR)/backup-manager
@rm -fv $(DESTDIR)$(BINDIR)/backup-manager-purge
@rm -fv $(DESTDIR)$(BINDIR)/backup-manager-upload
@rm -fv $(SHAREDIR)/backup-manager.conf.tpl
@rm -fv $(DESTDIR)$(PREFIX)/share/man/man8/backup-manager*.8
@rm -Rfv $(LIBDIR)
@rm -Rfv $(PERL5DIR)/BackupManager
@rm -Rfv $(SHAREDIR)
@rm -Rfv $(DESTDIR)$(PREFIX)/share/doc/backup-manager
@rm -fv $(DESTDIR)$(PREFIX)/share/locale/*/LC_MESSAGES/backup-manager.mo
@rm -fv $(DESTDIR)/$(SBINDIR)/backup-manager
@rm -fv $(DESTDIR)/$(BINDIR)/backup-manager-purge
@rm -fv $(DESTDIR)/$(BINDIR)/backup-manager-upload
@rm -fv $(DESTDIR)/$(SHAREDIR)/backup-manager.conf.tpl
@rm -fv $(DESTDIR)/$(PREFIX)/share/man/man8/backup-manager*.8
@rm -Rfv $(DESTDIR)/$(LIBDIR)
@rm -Rfv $(DESTDIR)/$(PERL5DIR)/BackupManager
@rm -Rfv $(DESTDIR)/$(SHAREDIR)
@rm -Rfv $(DESTDIR)/$(PREFIX)/share/doc/backup-manager
@rm -fv $(DESTDIR)/$(PREFIX)/share/locale/*/LC_MESSAGES/backup-manager.mo

# Building manpages
man/backup-manager-upload.8:
Expand All @@ -148,7 +150,7 @@ manpages-stamp: man/backup-manager-upload.8 man/backup-manager-purge.8
install_man: manpages-stamp
@echo -e "\n*** Installing man pages ***\n"
install -d $(DESTDIR)/$(PREFIX)/share/man/man8/
install -o root -g 0 -m 0644 man/*.8 $(DESTDIR)/$(PREFIX)/share/man/man8/
-install -o root -g 0 -m 0644 man/*.8 $(DESTDIR)/$(PREFIX)/share/man/man8/

testperldir:
@echo "PERL5DIR: $(PERL5DIR)"
Expand Down
14 changes: 5 additions & 9 deletions backup-manager
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,12 @@ set -e
RELEASE="true"
VERSION="0.7.13"

#Set prefix for paths
BIN_PREFIX=/usr/bin
LIB_PREFIX=/usr/lib
VAR_PREFIX=/var/lib

# All the paths we provide
libdir="$LIB_PREFIX/backup-manager"
vardir="$VAR_PREFIX/backup-manager"
bmu="$BIN_PREFIX/backup-manager-upload"
bmp="$BIN_PREFIX/backup-manager-purge"
libdir="/usr/lib/backup-manager"
vardir="/var/lib/backup-manager"
bindir="/usr/bin"
bmu="$bindir/backup-manager-upload"
bmp="$bindir/backup-manager-purge"
export BM_BMP_PATH=$bmp

# Find which lockfile to use
Expand Down

0 comments on commit fe10fc3

Please sign in to comment.