From: Don Armstrong Date: Mon, 23 Jan 2012 19:02:50 +0000 (-0800) Subject: start allowing for local user cache configuration X-Git-Url: https://git.donarmstrong.com/?p=cran2deb.git;a=commitdiff_plain;h=HEAD start allowing for local user cache configuration --- diff --git a/trunk/exec/cran2deb b/trunk/exec/cran2deb index e47543d..5e5e240 100755 --- a/trunk/exec/cran2deb +++ b/trunk/exec/cran2deb @@ -3,6 +3,13 @@ umask 002 root=$(r -e 'suppressMessages(library(cran2deb));cat(system.file(package="cran2deb"),file=stdout())') cmd=$1 +if [ -e /etc/cran2deb/config ]; then + . /etc/cran2deb/config; +elif [ -r ~/.cran2deb_config ]; then + . ~/.cran2deb_config; +fi; + + if [ "x" = "x$cmd" ]; then cmd="help" fi @@ -14,10 +21,11 @@ fi shift -precmd="" -if [ "$(id -un)" != c2d ]; then - precmd="sudo -u c2d -E" -fi +# there's no reason not to run cran2deb as a local user +# precmd="" +# if [ "$(id -un)" != c2d ]; then +# precmd="sudo -u c2d -E" +# fi if [ "web" = "$cmd" ]; then # web uses getopt and would be irritated by the "$root" argument diff --git a/trunk/exec/repopulate b/trunk/exec/repopulate index 08862db..72e23cc 100755 --- a/trunk/exec/repopulate +++ b/trunk/exec/repopulate @@ -7,6 +7,13 @@ set -e dir=/etc/cran2deb +if [ -e /etc/cran2deb/config ]; then + . /etc/cran2deb/config; +elif [ -r ~/.cran2deb/config ]; then + dir=~/.cran2deb/ + . ~/.cran2deb/config; +fi; + if [ ! -d "$dir" ]; then echo "Dir $dir not existing." exit -1 @@ -16,7 +23,7 @@ umask 002 echo "Setting 'root' var to '$1'." root=$1 shift -for x in $(find /etc/cran2deb/ -type f -name '*.in'); do +for x in $(find "${dir}" -type f -name '*.in'); do #echo "x=$x" y=$(echo $x | sed -e 's,.in$,,') sed -e "s:@ROOT@:$root:g" <"$x" >"$y" diff --git a/trunk/exec/update b/trunk/exec/update index d02ece2..ee1bd7b 100755 --- a/trunk/exec/update +++ b/trunk/exec/update @@ -7,6 +7,14 @@ ## DOC: set -e +cachedir="/var/cache/cran2deb/results/" +pbuildercache="/var/cache/pbuilder/" + +if [ -e /etc/cran2deb/config ]; then + . /etc/cran2deb/config; +elif [ -r ~/.cran2deb_config ]; then + . ~/.cran2deb_config; +fi; umask 002 root=$1 @@ -17,23 +25,24 @@ fi shift sys=$(cran2deb which_system) -mkdir -p /var/cache/cran2deb/results/$sys +mkdir -p $(cachedir)/$sys #update_period=10800 update_period=108 -if [ ! $1 = full ] || [ ! -e /var/cache/cran2deb/cache.rda ]; then +cache_rda="${cachedir}/cache.rda" +if [ ! $1 = full ] || [ ! -e "${cache_rda}" ]; then delta=$(($update_period+1)) echo Forcing cache update else seconds_time=$(date +%s) - seconds_file=$(stat -c '%Y' /var/cache/cran2deb/cache.rda) + seconds_file=$(stat -c '%Y' "${cache_rda}") delta=$(($seconds_time-$seconds_file)) echo Cache is $delta seconds out of date, auto-update after $update_period seconds. fi -if [ ! -e /var/cache/cran2deb/cache.rda ] || [ $delta -gt $update_period ]; then +if [ ! -e "${cache_rda}" ] || [ $delta -gt $update_period ]; then mode=create - if [ -e /var/cache/pbuilder/base-cran2deb-$sys.tgz ]; then + if [ -e "${pbuilder_cache}"/base-cran2deb-$sys.tgz ]; then mode=update fi echo C: sudo pbuilder $mode --override-config --configfile /etc/cran2deb/sys/$sys/pbuilderrc