naming fixes, terminal title fixes
[feisty_meow.git] / scripts / rev_control / getem.sh
index f31a86caaf62f9631785fd23642d8b9952291eb3..e0fcdef372f7f5d3e2310d36b08f5340855f1f58 100644 (file)
 
 # gets any updates for the repository folders present in the REPOSITORY_LIST variable.
 
-source "$FEISTY_MEOW_SCRIPTS/core/functions.sh"
-source "$FEISTY_MEOW_SCRIPTS/rev_control/rev_control.sh"
-
-# trickery to ensure we can always update this file, even when the operating system has some
-# rude behavior with regard to file locking (ahem, windows...).
-# and even more rudeness is that the pwd and $TMP may not always be in the same form,
-# which causes endless confusion and badness.  that's why we get the pwd reading for TMP
-# first so we can do an orange-to-orange compare.
+source "$FEISTY_MEOW_SCRIPTS/core/launch_feisty_meow.sh"
+source "$FEISTY_MEOW_SCRIPTS/rev_control/version_control.sh"
+
+save_terminal_title
+
+##############
+
+# trickery to ensure we can always update feisty meow, including this specific
+# file, even when the operating system has some rude behavior with regard to
+# file locking (ahem, windoze).  and even more rudeness is that the pwd and
+# $TMP may not always be in the same form, which causes endless confusion and
+# badness.  that's why we get the pwd reading for TMP first so we can do an
+# oranges-to-oranges compare.
 tmpdir="$(cd $TMP; \pwd)"
 if [ "$(\pwd)" != "$tmpdir" ]; then
-  if [ ! -z "$SHELL_DEBUG" ]; then
-    echo "Moving to the TMP directory to avoid file access conflicts..."
+  if [ ! -z "$DEBUG_FEISTY_MEOW" ]; then
+    echo "moving to the TMP directory to avoid file access conflicts..."
   fi
   new_name="$TMP/zz_$(basename $0)"
-  cp -f "$0" "$new_name"
-  if [ $? -ne 0 ]; then
-    echo "failed to copy this script up to the TMP directory.  exploit attempted?"
-    exit 1
-  fi
-  cd "$TMP"
+  \cp -f "$0" "$new_name"
+  exit_on_error "failed to copy this script up to the TMP directory.  exploit attempted?"
+  pushd "$TMP" &>/dev/null
+  exit_on_error "changing to TMP directory: $TMP"
   chmod a+x "$new_name"
+  exit_on_error "chmodding of file: $new_name"
   exec "$new_name"
+  exit_on_error "execing cloned getemscript"
+  popd &>/dev/null
 fi
 
-# takes out the first few carriage returns that are in the input.
-function squash_first_few_crs()
-{
-  i=0
-  while read line; do
-    i=$((i+1))
-    if [ $i -le 3 ]; then
-      echo -n "$line  "
-    else
-      echo $line
-    fi
-  done
-  if [ $i -le 3 ]; then
-    # if we're still squashing eols, make sure we don't leave them hanging.
-    echo
-  fi
-}
-
-# selects the checkout method based on where we are (the host the script runs on).
-function do_update()
-{
-  directory="$1"; shift
-  if [ -d "CVS" ]; then
-    cvs update . | squash_first_few_crs
-  elif [ -d ".svn" ]; then
-    svn update . | squash_first_few_crs
-  elif [ -d ".git" ]; then
-    git pull 2>&1 | grep -v "X11 forwarding request failed" | squash_first_few_crs
-  else
-    echo unknown repository for $directory...
-  fi
-}
-
-# gets all the updates for a list of folders under revision control.
-function checkout_list {
-  list=$*
-  for i in $list; do
-    # turn repo list back into an array.
-    eval "repository_list=( ${REPOSITORY_LIST[*]} )"
-    for j in "${repository_list[@]}"; do
-      # add in the directory for our purposes here.
-      j="$i/$j"
-      if [ ! -d $j ]; then
-        if [ ! -z "$SHELL_DEBUG" ]; then
-          echo "No directory called $j exists."
-        fi
-        continue
-      fi
-
-      pushd $j &>/dev/null
-      echo -n "retrieving '$j'...  "
-      do_update $j
-      popd &>/dev/null
-    done
-  done
-}
-
 ##############
 
 export TMPO_CHK=$TMP/zz_chk.log
 
 rm -f "$TMPO_CHK"
+exit_on_error "removing file: $TMPO_CHK"
 
-echo "Getting repositories at: $(date)"
+echo "getting repositories at: $(date)"
 
 # perform the checkouts as appropriate per OS.
-if [ "$OS" != "Windows_NT" ]; then
-  checkout_list $HOME 2>&1 | tee -a "$TMPO_CHK"
-else
-  checkout_list $HOME c:/ d:/ e:/ 2>&1 | tee -a "$TMPO_CHK"
+FULL_LIST="$(dirname $FEISTY_MEOW_APEX) $HOME"
+if [ "$OS" == "Windows_NT" ]; then
+  FULL_LIST+="c:/ d:/ e:/"
 fi
+checkout_list $FULL_LIST 2>&1 | tee -a "$TMPO_CHK"
+exit_on_error "checking out list: $FULL_LIST"
+
+echo
 
 ##############
 
-# we now regenerate the scripts after getme, to ensure it's done automatically.
-bash "$FEISTY_MEOW_SCRIPTS/core/bootstrap_shells.sh"
-perl "$FEISTY_MEOW_SCRIPTS/core/generate_aliases.pl"
-echo
-nechung
+# regenerate the scripts after getting latest version of feisty meow.
+regenerate
 
 ##############
 
+restore_terminal_title
+