]> git.donarmstrong.com Git - cran2deb.git/blob - trunk/exec/update
* fix wrong right bracket
[cran2deb.git] / trunk / exec / update
1 #!/bin/bash
2
3 ## DOC: cran2deb update
4 ## DOC:     update the cran2deb cache and database
5 ## DOC: cran2deb update full
6 ## DOC:     force a full update of the cran2deb cache and database
7 ## DOC:
8
9 set -e
10 cachedir="${CRAN2DEB_CACHE:-/var/cache/cran2deb}/results/"
11 pbuildercache="${CRAN2DEB_PBUILDER_CACHE:-/var/cache/pbuilder/}"
12
13 umask 002
14 root=$1
15 if [ -z "$root" ]; then
16        echo "You need to specify the root of your installation, i.e. the folder in which to find the exec subdirectory."
17        exit 1
18 fi
19
20 shift
21 sys=$(cran2deb which_system)
22 mkdir -p "${cachedir}"/"$sys"
23 #update_period=10800
24 update_period=108
25
26 cache_rda="${cachedir}/cache.rda"
27 if [ ! $1 = full ] || [ ! -e "${cache_rda}" ]; then
28     delta=$(($update_period+1))
29     echo Forcing cache update
30 else
31     seconds_time=$(date +%s)
32     seconds_file=$(stat -c '%Y' "${cache_rda}")
33     delta=$(($seconds_time-$seconds_file))
34     echo Cache is $delta seconds out of date, auto-update after $update_period seconds.
35 fi
36
37 if [ ! -e "${cache_rda}" ] || [ $delta -gt $update_period ]; then
38     if [ "${CRAN2DEB_BUILD}" == "yes" ]; then
39         mode=create
40         if [ -e "${pbuilder_cache}"/base-cran2deb-$sys.tgz ]; then
41             mode=update
42         fi
43         echo C: sudo pbuilder $mode --override-config --configfile "${CRAN2DEB_CONFDIR:-/etc/cran2deb}"/sys/"$sys"/pbuilderrc
44         echo "Executing sudo pbuilder $mode --override-config --configfile ${CRAN2DEB_CONFDIR:-/etc/cran2deb}/sys/$sys/pbuilderrc"
45         sudo pbuilder $mode --override-config --configfile "${CRAN2DEB_CONFDIR:-/etc/cran2deb}"/sys/"$sys"/pbuilderrc
46     fi;
47     echo "Executing $root/exec/update_cache $root"
48     $root/exec/update_cache $root
49 fi
50