From 3dfeefe2f6ebeb55fd5d0016a7e9134247306c2a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20K=C3=B6hler?= Date: Sun, 15 Apr 2007 14:48:42 +0000 Subject: [PATCH] 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. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@15897 57a11ea4-9604-0410-9ed3-97b8803252fd --- packaging/win32/custom.sh | 3 + packaging/win32/functions | 3 + packaging/win32/reset.sh | 131 ++++++++++++++++++++++++++++++-------- 3 files changed, 112 insertions(+), 25 deletions(-) diff --git a/packaging/win32/custom.sh b/packaging/win32/custom.sh index c0884f9465..ee21fb2ef5 100644 --- a/packaging/win32/custom.sh +++ b/packaging/win32/custom.sh @@ -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 diff --git a/packaging/win32/functions b/packaging/win32/functions index 9c5094c02a..05f9ceb33a 100644 --- a/packaging/win32/functions +++ b/packaging/win32/functions @@ -1,3 +1,6 @@ +[ "$__SOURCED_FUNCTIONS" ] && return +__SOURCED_FUNCTIONS=1 + function add_step() { steps=("${steps[@]}" "$@"); } function quiet() { "$@" &>/dev/null; } diff --git a/packaging/win32/reset.sh b/packaging/win32/reset.sh index 05c1d19842..cdddc58a08 100644 --- a/packaging/win32/reset.sh +++ b/packaging/win32/reset.sh @@ -2,41 +2,122 @@ 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; } - -# /c/dir/sub -function unix_path() { - echo "$*" | sed 's,^\([A-Za-z]\):,/\1,;s,\\,/,g' -} +function unix_path() { echo "$*" | sed 's,^\([A-Za-z]\):,/\1,;s,\\,/,g'; } qpushd "$(dirname $(unix_path "$0"))" +. functions . custom.sh +## too bad, bash 2.04 has no real support for arrays + +# 0 = get confirmation +# 1 = delete +_phase=0 + +# usage: add_precious_path +function add_precious_path() { + _precious_paths="${_precious_paths} $1|$2" +} + +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 +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 -basedir=`unix_path $GLOBAL_DIR` -qpushd $basedir - -rm -rf regex readline guile pexports gnome swig autotools -rm -rf libgsf goffice glade gnucash tmp - -rm -f /etc/profile.d/installer.sh +echo +qpushd $GLOBAL_DIR + eval_all +qpopd echo "Done" exit 0