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