first check-in of feisty meow codebase. many things broken still due to recent
[feisty_meow.git] / scripts / rev_control / getme.sh
1 #!/bin/bash
2
3 # gets all of fred's revision control folders out.
4
5 source "$SHELLDIR/rev_control/rev_control.sh"
6
7 if [ "$(pwd)" != "$TMP" ]; then
8 #  echo "Moving to the TMP directory to avoid file access conflicts..."
9   new_name="$TMP/zz_$(basename $0)"
10   cp -f "$0" "$new_name"
11   if [ $? -ne 0 ]; then
12     echo "failed to copy this script up to the TMP directory.  exploit attempted?"
13     exit 1
14   fi
15   cd "$TMP"
16   chmod a+x "$new_name"
17   exec "$new_name"
18 fi
19
20 export TMPO_CHK=$TMP/zz_chk.log
21
22 # selects the checkout method based on where we are (the host the script runs on).
23 function do_update()
24 {
25   directory="$1"; shift
26
27   # get the right modifier for the directory name.
28   compute_modifier "$directory" "out"
29
30   is_svn=1
31   checkout_cmd="echo unknown repository for $directory...  "
32
33   if [ "$home_system" == "true" ]; then
34     checkout_cmd="svn update ."
35   fi
36
37   # then we pretty much ignore what we guessed, and just use the
38   # appropriate command for what we see inside the directory.
39   if [ -d "$directory/CVS" ]; then
40     checkout_cmd="cvs co -P -kb "
41     modifier=  # reset the modifier, since we know we have cvs.
42     is_svn=0
43   elif [ -d "$directory/.svn" ]; then
44     checkout_cmd="svn update ."
45   fi
46
47   if [ $is_svn -eq 1 ]; then
48     pushd "$directory" &>/dev/null
49     $checkout_cmd
50     popd &>/dev/null
51   else
52     $checkout_cmd "$modifier$directory"
53   fi
54 }
55
56 function checkout_list {
57   list=$*
58   for i in $list; do
59 #this list should be part of the configuration file, not part of script.
60     for j in $i/feisty_meow $i/hoople $i/hoople2 $i/quartz $i/web $i/yeti $i/xsede/xsede_tests $i/xsede/code/cak0l/trunk ; do
61       if [ ! -d $j ]; then
62 #        echo no directory called $j exists
63         continue
64       fi
65
66       pushd $i &>/dev/null
67       echo -n "retrieving '$j'...  "
68       do_update $j
69 #$(basename $j)
70       popd &>/dev/null
71     done
72   done
73 }
74
75 rm -f "$TMPO_CHK"
76
77 # perform the checkouts as appropriate per OS.
78 if [ "$OS" != "Windows_NT" ]; then
79   checkout_list $HOME 2>&1 | tee -a "$TMPO_CHK"
80 else
81   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"
82 fi
83
84 less $TMPO_CHK
85
86 # we now regenerate the scripts after getme, to ensure it's done automatically.
87 bash "$SHELLDIR/core/bootstrap_shells.sh"
88 perl "$SHELLDIR/core/generate_aliases.pl"
89 echo
90 nechung
91