gl-system-install: optional 4th arg to help packagers

(buildroot in RPM-speak, DESTDIR in DEB-speak)

based on a patch sent by Francis Galiegue (fgaliegue at gmail)
This commit is contained in:
Sitaram Chamarty 2011-04-03 20:16:36 +05:30
parent 1006eba2fc
commit 78444c2e76

View file

@ -11,7 +11,11 @@ usage() { echo "
$0 /usr/local/bin /var/gitolite/conf /var/gitolite/hooks $0 /usr/local/bin /var/gitolite/conf /var/gitolite/hooks
In this example, all the binaries go to /usr/local/bin, and the shared In this example, all the binaries go to /usr/local/bin, and the shared
conf and hooks files/directories go to the other 2 directories given conf and hooks files/directories go to the other 2 directories given. All
the 3 paths supplied MUST be absolute.
[RPM packagers: you can supply a 4th argument to specify a 'buildroot'
directory. DEB folks would call this a 'DESTDIR', I believe.]
" "
exit 1; exit 1;
} }
@ -20,19 +24,25 @@ die() { echo "$@"; echo; usage; exit 1; } >&2
[ -z "$3" ] && usage [ -z "$3" ] && usage
gl_bin_dir=$1 validate_dir() {
[ -d $gl_bin_dir ] || die "$gl_bin_dir not found" echo $1 | grep ^/ >/dev/null || die "$1 should be an absolute path"
gl_conf_dir=$2 [ -d $1 ] || mkdir -p $1 || die "$1 does not exist and could not be created"
[ -d $gl_conf_dir ] || die "$gl_conf_dir not found" }
gl_hooks_dir=$3
[ -d $gl_hooks_dir ] || die "$gl_hooks_dir not found" # if we have a buildroot, set that up first
buildroot=$4;
[ -n "$buildroot" ] && validate_dir $buildroot
[ -n "$buildroot" ] && buildroot=$buildroot/
gl_bin_dir=$1; validate_dir $buildroot$gl_bin_dir
gl_conf_dir=$2; validate_dir $buildroot$gl_conf_dir
gl_hooks_dir=$3; validate_dir $buildroot$gl_hooks_dir
bindir=`echo $0 | perl -lpe 's/^/$ENV{PWD}\// unless /^\//; s/\/[^\/]+$//;'` bindir=`echo $0 | perl -lpe 's/^/$ENV{PWD}\// unless /^\//; s/\/[^\/]+$//;'`
cd $bindir/.. # we assume the standard gitolite source tree is here! cd $bindir/.. # we assume the standard gitolite source tree is here!
cp src/* $gl_bin_dir || die "cp src/* to $gl_bin_dir failed" cp src/* $buildroot$gl_bin_dir || die "cp src/* to $buildroot$gl_bin_dir failed"
rm $gl_bin_dir/gl-easy-install rm $buildroot$gl_bin_dir/gl-easy-install
perl -lpi -e "s(^GL_PACKAGE_CONF=.*)(GL_PACKAGE_CONF=$gl_conf_dir)" $gl_bin_dir/gl-setup perl -lpi -e "s(^GL_PACKAGE_CONF=.*)(GL_PACKAGE_CONF=$gl_conf_dir)" $buildroot$gl_bin_dir/gl-setup
# record which version is being sent across; we assume it's HEAD # record which version is being sent across; we assume it's HEAD
if git rev-parse --is-inside-work-tree >/dev/null 2>&1 if git rev-parse --is-inside-work-tree >/dev/null 2>&1
@ -42,12 +52,12 @@ else
[ -f conf/VERSION ] || echo '(unknown)' > conf/VERSION [ -f conf/VERSION ] || echo '(unknown)' > conf/VERSION
fi fi
cp -R conf/* $gl_conf_dir || die "cp conf/* to $gl_conf_dir failed" cp -R conf/* $buildroot$gl_conf_dir || die "cp conf/* to $buildroot$gl_conf_dir failed"
perl -lpi \ perl -lpi \
-e "s(^#\s*\\\$GL_PACKAGE_CONF\s*=.*)(\\\$GL_PACKAGE_CONF = '$gl_conf_dir';)" \ -e "s(^#\s*\\\$GL_PACKAGE_CONF\s*=.*)(\\\$GL_PACKAGE_CONF = '$gl_conf_dir';)" \
$gl_conf_dir/example.gitolite.rc $buildroot$gl_conf_dir/example.gitolite.rc
perl -lpi \ perl -lpi \
-e "s(^#\s*\\\$GL_PACKAGE_HOOKS\s*=.*)(\\\$GL_PACKAGE_HOOKS = '$gl_hooks_dir';)" \ -e "s(^#\s*\\\$GL_PACKAGE_HOOKS\s*=.*)(\\\$GL_PACKAGE_HOOKS = '$gl_hooks_dir';)" \
$gl_conf_dir/example.gitolite.rc $buildroot$gl_conf_dir/example.gitolite.rc
cp -R hooks/* $gl_hooks_dir || die "cp hooks/* to $gl_hooks_dir failed" cp -R hooks/* $buildroot$gl_hooks_dir || die "cp hooks/* to $buildroot$gl_hooks_dir failed"