r15897 - gnucash/trunk/packaging/win32 - Improve win32/reset.sh.
Andreas Köhler
andi5 at cvs.gnucash.org
Sun Apr 15 10:48:43 EDT 2007
Author: andi5
Date: 2007-04-15 10:48:42 -0400 (Sun, 15 Apr 2007)
New Revision: 15897
Trac: http://svn.gnucash.org/trac/changeset/15897
Modified:
gnucash/trunk/packaging/win32/custom.sh
gnucash/trunk/packaging/win32/functions
gnucash/trunk/packaging/win32/reset.sh
Log:
Improve win32/reset.sh.
The script uses the paths from custom.sh now. Certain paths can be
added as precious by reset.sh or the user to avoid their deletion. All
planned actions are presented before confirmation to make them more
transparent.
Modified: gnucash/trunk/packaging/win32/custom.sh
===================================================================
--- gnucash/trunk/packaging/win32/custom.sh 2007-04-15 10:17:59 UTC (rev 15896)
+++ gnucash/trunk/packaging/win32/custom.sh 2007-04-15 14:48:42 UTC (rev 15897)
@@ -2,6 +2,9 @@
#
# all directories should be without spaces!
+[ "$__SOURCED_CUSTOM_SH" ] && return
+__SOURCED_CUSTOM_SH=1
+
GLOBAL_DIR=c:\\soft
TMP_DIR=$GLOBAL_DIR\\tmp
DOWNLOAD_DIR=$GLOBAL_DIR\\downloads
Modified: gnucash/trunk/packaging/win32/functions
===================================================================
--- gnucash/trunk/packaging/win32/functions 2007-04-15 10:17:59 UTC (rev 15896)
+++ gnucash/trunk/packaging/win32/functions 2007-04-15 14:48:42 UTC (rev 15897)
@@ -1,3 +1,6 @@
+[ "$__SOURCED_FUNCTIONS" ] && return
+__SOURCED_FUNCTIONS=1
+
function add_step() { steps=("${steps[@]}" "$@"); }
function quiet() { "$@" &>/dev/null; }
Modified: gnucash/trunk/packaging/win32/reset.sh
===================================================================
--- gnucash/trunk/packaging/win32/reset.sh 2007-04-15 10:17:59 UTC (rev 15896)
+++ gnucash/trunk/packaging/win32/reset.sh 2007-04-15 14:48:42 UTC (rev 15897)
@@ -2,42 +2,123 @@
set -e
-echo ""
-echo "This will reset your installation of gnucash."
-echo -n "Are you sure you want to do this? [y/N] "
-read resp
-case "$resp" in
- y*|Y*)
- ;;
- *)
- exit 0;
- ;;
-esac
-
#### Load Custom.sh
-function add_step() { echo "" >/dev/null; }
function qpushd() { pushd "$@" >/dev/null; }
function qpopd() { popd >/dev/null; }
+function unix_path() { echo "$*" | sed 's,^\([A-Za-z]\):,/\1,;s,\\,/,g'; }
-# /c/dir/sub
-function unix_path() {
- echo "$*" | sed 's,^\([A-Za-z]\):,/\1,;s,\\,/,g'
-}
-
qpushd "$(dirname $(unix_path "$0"))"
+. functions
. custom.sh
-#### Now clear out the install
+## too bad, bash 2.04 has no real support for arrays
-basedir=`unix_path $GLOBAL_DIR`
-qpushd $basedir
+# 0 = get confirmation
+# 1 = delete
+_phase=0
-rm -rf regex readline guile pexports gnome swig autotools
-rm -rf libgsf goffice glade gnucash tmp
+# usage: add_precious_path <step> <path>
+function add_precious_path() {
+ _precious_paths="${_precious_paths} $1|$2"
+}
-rm -f /etc/profile.d/installer.sh
+add_precious_path msys $MSYS_DIR
+add_precious_path wget $WGET_DIR
+add_precious_path svn $SVN_DIR
+add_precious_path repos $REPOS_DIR
+add_precious_path docs $DOCS_DIR
+# usage: eval_path <path> <force>
+function eval_path() {
+ if [ "$2" != "force" ]; then
+ for _precious in $_precious_paths; do
+ _prec_step="${_precious%%|*}"
+ _prec_path="${_precious##*|}"
+ _preclen="${#_prec_path}"
+ _dirss="${1:0:${_preclen}}"
+ _dirlen="${#1}"
+ _precss="${_prec_path:0:${_dirlen}}"
+ if [ "$_dirss" = "$_prec_path" -o "$_precss" = "$1" ]; then
+ if [ "$_phase" != "1" ]; then
+ echo " - will not remove $1 to save $_prec_path ($_prec_step)"
+ fi
+ return
+ fi
+ done
+ fi
+ if [ "$_phase" = "1" ]; then
+ echo rm -rf $1
+ rm -rf $1
+ else
+ echo " * rm -rf $1"
+ fi
+}
+
+function eval_all() {
+ eval_path $UNZIP_DIR
+ eval_path $REGEX_DIR
+ eval_path $READLINE_DIR
+ eval_path $ACTIVE_PERL_DIR
+ eval_path $AUTOTOOLS_DIR
+ eval_path $GUILE_DIR
+ eval_path $OPENSSL_DIR
+ eval_path $MINGW_UTILS_DIR
+ eval_path $EXETYPE_DIR
+ eval_path $LIBXML2_DIR
+ eval_path $GNOME_DIR
+ eval_path $SWIG_DIR
+ eval_path $PCRE_DIR
+ eval_path $LIBGSF_DIR
+ eval_path $GOFFICE_DIR
+ eval_path $GLADE_DIR
+ eval_path $INNO_DIR
+ eval_path $HH_DIR
+ eval_path $OPENSP_DIR
+ eval_path $LIBOFX_DIR
+ eval_path $GWENHYWFAR_DIR
+ eval_path $AQBANKING_DIR
+ eval_path $BUILD_DIR
+ eval_path $INSTALL_DIR
+ eval_path $GNUCASH_DIR\\dist
+ eval_path $TMP_DIR
+ eval_path $MSYS_DIR\\etc\\profile.d\\installer.sh force
+}
+
+echo
+echo "This will reset your installation of gnucash."
+echo "The following tasks will be executed:"
+
+while true; do
+ echo
+ eval_all
+ echo
+ echo -n "Are you sure you want to do this: Yes, first add safe paths or no? [y/s/N] "
+ read resp
+ case "$resp" in
+ y*|Y*)
+ _phase=1
+ break
+ ;;
+ s*|S*)
+ echo
+ echo -n "Add safe path (e.g. c:\\\\soft\\\\tmp): "
+ read path
+ [ "$path" ] && add_precious_path user_defined $path
+ ;;
+ *)
+ exit 0
+ ;;
+ esac
+done
+
+#### Now clear out the install
+
+echo
+qpushd $GLOBAL_DIR
+ eval_all
+qpopd
+
echo "Done"
exit 0
More information about the gnucash-changes
mailing list