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