fixed really old way of thinking about home on windows.
[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         if [ ! -z "$SHELL_DEBUG" ]; then
51           echo "No directory called $j exists."
52         fi
53         continue
54       fi
55
56       pushd $j &>/dev/null
57       echo -n "retrieving '$j'...  "
58       do_update $j
59       popd &>/dev/null
60     done
61   done
62 }
63
64 ##############
65
66 export TMPO_CHK=$TMP/zz_chk.log
67
68 rm -f "$TMPO_CHK"
69
70 # perform the checkouts as appropriate per OS.
71 if [ "$OS" != "Windows_NT" ]; then
72   checkout_list $HOME 2>&1 | tee -a "$TMPO_CHK"
73 else
74   checkout_list $HOME c:/ d:/ e:/ f:/ g:/ h:/ i:/ 2>&1 | tee -a "$TMPO_CHK"
75 fi
76
77 less $TMPO_CHK
78
79 ##############
80
81 # we now regenerate the scripts after getme, to ensure it's done automatically.
82 bash "$FEISTY_MEOW_SCRIPTS/core/bootstrap_shells.sh"
83 perl "$FEISTY_MEOW_SCRIPTS/core/generate_aliases.pl"
84 echo
85 nechung
86
87 ##############
88