]> git.donarmstrong.com Git - cran2deb.git/blob - trunk/exec/update
982fa6c055457b6e3ce309b1abbfac66de28d260
[cran2deb.git] / trunk / exec / update
1 #!/usr/bin/rc
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 umask 002
10 root=$1
11 if ([ -z "$root" ]) {
12        echo "You need to specify the root of your installation, i.e. the folder in which to find the exec subdirectory."
13        exit 1
14 }
15
16 shift
17 sys=`{cran2deb which_system}
18 mkdir -p /var/cache/cran2deb/results/$sys || exit 1
19 #update_period=10800
20 update_period=108
21 if (~ $1 full || ![ -e /var/cache/cran2deb/cache.rda ] ) {
22     delta=`{awk 'END{print '^$update_period^'+1}' </dev/null}
23     echo Forcing cache update
24 } else {
25     delta=`{awk 'END{print '^`{date +%s}^-^`{stat -c '%Y' /var/cache/cran2deb/cache.rda}^'}' </dev/null}
26     echo Cache is $delta seconds out of date, auto-update after $update_period seconds.
27 }
28 if (![ -e /var/cache/cran2deb/cache.rda ] || [ $delta -gt $update_period ]) {
29     mode=create
30     if ([ -e /var/cache/pbuilder/base-cran2deb-$sys.tgz ]) {
31         mode=update
32     }
33     echo C: sudo pbuilder $mode --override-config --configfile /etc/cran2deb/sys/$sys/pbuilderrc
34     echo "Executing sudo pbuilder $mode --override-config --configfile /etc/cran2deb/sys/$sys/pbuilderrc"
35     sudo pbuilder $mode --override-config --configfile /etc/cran2deb/sys/$sys/pbuilderrc
36     echo "Executing $root/exec/update_cache $root"
37     $root/exec/update_cache $root
38 }
39