Permalink
Browse files

Add --rpgdir option to configure for rpg database and installed packa…

…ges.

Previously rpg would always try to install packages into a ruby
libdir subdirectory. This required rpg to run with root privileges
if there was only one ruby (the system one) installed.

By specifying --rpgdir it is possible to locate rpg database and
installed packages anywhere on the filesystem, allowing rpg to be
run as an unprivileged user on systems with a single ruby.
  • Loading branch information...
1 parent 6e6db9b commit 972d66c6b9c6fb10a8734eefc7369952b6ff1f66 @p p committed Jul 24, 2011
Showing with 26 additions and 5 deletions.
  1. +6 −0 configure
  2. +20 −5 rpg-sh-setup.sh
View
6 configure
@@ -15,6 +15,7 @@
#/ --datarootdir=DIR data file root [PREFIX/share]
#/ --datadir=DIR data files [DATAROOTDIR]
#/ --mandir=DIR man documentation [DATAROOTDIR/man]
+#/ --rpgdir=DIR rpg package and db root [RUBYLIBDIR/rpg]
warn () { echo "$(basename $0):" "$@" 1>&2; }
longarg () { echo "$1" | sed "s/^$2=//"; }
@@ -66,6 +67,8 @@ do
--datadir=*) datadir="$(longarg "$1" --datadir)";shift;;
--mandir) mandir="$2";shift 2;;
--mandir=*) mandir="$(longarg "$1" --mandir)";shift;;
+ --rpgdir) rpgdir="$2";shift 2;;
+ --rpgdir=*) rpgdir="$(longarg "$1" --rpgdir)";shift;;
# Environment variables passed on command line:
[A-Z]*=*) name="${1%%=*}"
@@ -239,6 +242,7 @@ then
: ${datadir:=$(rbconfig datadir "$datarootdir")}
: ${mandir:=$(rbconfig mandir "$datadir/man")}
: ${docdir:=$(rbconfig docdir "$datadir/doc")}
+ : ${rpgdir:=$(rbconfig rubylibdir "/var/lib")/rpg}
else
: ${prefix:="/usr/local"}
: ${exec_prefix:="$prefix"}
@@ -261,6 +265,7 @@ recordconfig sysconfdir "$sysconfdir"
recordconfig datarootdir "$datarootdir"
recordconfig datadir "$datadir"
recordconfig mandir "$mandir"
+recordconfig rpgdir "$rpgdir"
recordconfig develmode "$develmode"
echo writing config.mk...
@@ -289,4 +294,5 @@ printf " libexecdir: %-20s (%s)\n" "$libexecdir" "rpg program executables"
printf " sysconfdir: %-20s (%s)\n" "$sysconfdir" "rpgrc config file"
printf " localstatedir: %-20s (%s)\n" "$localstatedir" "package db, index, and gem cache"
printf " mandir: %-20s (%s)\n" "$mandir" "unix manpages"
+printf " rpgdir: %-20s (%s)\n" "$rpgdir" "rpg files"
echo "run \`make' to build and then \`make install' to install."
View
25 rpg-sh-setup.sh
@@ -266,27 +266,42 @@ eval "${oldrpgenv}"
# no rpg utility targets this directory -- every significant location must
# have a separate path variable so that things stay flexible in
# configuration.
-: ${RPGPATH:=$(
+: ${RPGPATH:=${rpgdir:-$(
if $RUBYMACFRAMEWORK
then echo "/Library/Ruby/RPG/$RUBYVERSION"
else echo "${RUBYLIBDIR:-/var/lib}/rpg"
fi
-)}
+)}}
# `RPGLIB` is the shared Ruby `lib` directory where library files are
# installed. It defaults to the currently active ruby's `vendor_ruby`
# directory (or `site_ruby` when Ruby < 1.8.7). If neither of those
# locations be determined for some reason, `RPGPATH/lib` is assumed.
-: ${RPGLIB:="${RUBYVENDORDIR:-${RUBYSITEDIR:-$RPGPATH/lib}}"}
+if test -n "$rpgdir"
+then
+ : ${RPGLIB:=$rpgdir/lib}
+else
+ : ${RPGLIB:="${RUBYVENDORDIR:-${RUBYSITEDIR:-$RPGPATH/lib}}"}
+fi
# `RPGBIN` is where executable scripts included in packages are installed.
# It defaults to the currently active ruby's `bindir` and falls back to
# `RPGPATH/bin` if no ruby `bindir` can be determined.
-: ${RPGBIN:="${RUBYBINDIR:-$RPGPATH/bin}"}
+if test -n "$rpgdir"
+then
+ : ${RPGBIN:=$rpgdir/bin}
+else
+ : ${RPGBIN:="${RUBYBINDIR:-$RPGPATH/bin}"}
+fi
# `RPGMAN` is where manpages included with packages are installed. This
# is basically the whole reason `rpg` was written in the first place.
-: ${RPGMAN:="${RUBYMANDIR:-$RPGPATH/man}"}
+if test -n "$rpgdir"
+then
+ : ${RPGMAN:=$RPGPATH/man}
+else
+ : ${RPGMAN:="${RUBYMANDIR:-$RPGPATH/man}"}
+fi
# RPG Paths
# ---------

0 comments on commit 972d66c

Please sign in to comment.