Blob Blame Raw
From 3ad950799e2640e06f487c2de214f16247e6e4a0 Mon Sep 17 00:00:00 2001
From: Stephen Gallagher <sgallagh@redhat.com>
Date: Wed, 13 Jun 2018 09:09:26 -0400
Subject: [PATCH] Add DESTDIR support for `make install`

When packaging for distributions (particularly RPM), it is common
for the packaging tool to install all of the files into a chroot-
style directory structure as a non-privileged user. This is done
to avoid requiring root privileges for packaging (particularly to
avoid issues where the attempt to package causes changes to be
made to the packaging host.

The standard variable used for this (from autotools) is DESTDIR.
This patch adds DESTDIR before the prefix in install.sh to ensure
that when `make install` is run, it will direct output to the
proper location.

Signed-off-by: Stephen Gallagher <sgallagh@redhat.com>
---
 script/install.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/script/install.sh b/script/install.sh
index 55ebe96f3d9b2186828a7a4c6d20fe9d4607bd71..8bdff41f9fb2bfc01db870945d0bbccaa9a85abf 100644
--- a/script/install.sh
+++ b/script/install.sh
@@ -15,10 +15,10 @@ fi
 
 prefix="${PREFIX:-$prefix}"
 prefix="${prefix:-/usr/local}"
 
 for src in bin/hub share/man/*/*.1; do
-  dest="${prefix}/${src}"
+  dest="${DESTDIR}${prefix}/${src}"
   mkdir -p "${dest%/*}"
   [[ $src == share/* ]] && mode="644" || mode=755
   install -m "$mode" "$src" "$dest"
 done
-- 
2.17.1