15e986ef106a18a1e5eeff60e2f6b24834370ace
[feisty_meow.git] / scripts / rev_control / getme.sh
1 #!/bin/bash
2
3 # gets any updates for the repository folders present in the REPOSITORY_LIST variable.
4
5 source "$FEISTY_MEOW_SCRIPTS/rev_control/rev_control.sh"
6
7 # trickery to ensure we can always update this file, even when the operating system has some
8 # rude behavior with regard to file locking (ahem, windows...).
9 if [ "$(pwd)" != "$TMP" ]; then
10   if [ ! -z "$SHELL_DEBUG" ]; then
11     echo "Moving to the TMP directory to avoid file access conflicts..."
12   fi
13   new_name="$TMP/zz_$(basename $0)"
14   cp -f "$0" "$new_name"
15   if [ $? -ne 0 ]; then
16     echo "failed to copy this script up to the TMP directory.  exploit attempted?"
17     exit 1
18   fi
19   cd "$TMP"
20   chmod a+x "$new_name"
21   exec "$new_name"
22 fi
23
24 # selects the checkout method based on where we are (the host the script runs on).
25 function do_update()
26 {
27   directory="$1"; shift
28
29   if [ -d "CVS" ]; then
30     cvs update .
31   elif [ -d ".svn" ]; then
32     svn update .
33   elif [ -d ".git" ]; then
34     git pull
35   else
36     echo unknown repository for $directory...
37   fi
38 }
39
40 # gets all the updates for a list of folders under revision control.
41 function checkout_list {
42   list=$*
43   for i in $list; do
44     # turn repo list back into an array.
45     eval "repository_list=( ${REPOSITORY_LIST[*]} )"
46     for j in "${repository_list[@]}"; do
47       # add in the directory for our purposes here.
48       j="$i/$j"
49       if [ ! -d $j ]; then
50         echo no directory called $j exists
51         continue
52       fi
53
54       pushd $j &>/dev/null
55       echo -n "retrieving '$j'...  "
56       do_update $j
57       popd &>/dev/null
58     done
59   done
60 }
61
62 ##############
63
64 export TMPO_CHK=$TMP/zz_chk.log
65
66 rm -f "$TMPO_CHK"
67
68 # perform the checkouts as appropriate per OS.
69 if [ "$OS" != "Windows_NT" ]; then
70   checkout_list $HOME 2>&1 | tee -a "$TMPO_CHK"
71 else
72   checkout_list c:/ c:/home d:/ d:/home e:/ e:/home f:/ f:/home g:/ g:/home h:/ h:/home i:/ i:/home 2>&1 | tee -a "$TMPO_CHK"
73 fi
74
75 less $TMPO_CHK
76
77 ##############
78
79 # we now regenerate the scripts after getme, to ensure it's done automatically.
80 bash "$FEISTY_MEOW_SCRIPTS/core/bootstrap_shells.sh"
81 perl "$FEISTY_MEOW_SCRIPTS/core/generate_aliases.pl"
82 echo
83 nechung
84
85 ##############
86