From 983017838c6756fb97e080f82853e317a8eff17d Mon Sep 17 00:00:00 2001 From: Marius Tolzmann Date: Mon, 30 Jul 2012 22:00:48 +0200 Subject: [PATCH 1/7] bee-remove: Use function keyword for functions --- src/bee-remove.sh.in | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/bee-remove.sh.in b/src/bee-remove.sh.in index 2d0e546..f8cf71c 100644 --- a/src/bee-remove.sh.in +++ b/src/bee-remove.sh.in @@ -32,13 +32,13 @@ VERSION=${BEE_VERSION} : ${BEE_BINDIR:=@BINDIR@} -pkg_remove_all() { +function pkg_remove_all() { for pkg in "${@}" ; do pkg_remove "${pkg}" done } -pkg_remove() { +function pkg_remove() { search=$1 # pattern is a pkg in BEE_METADIR @@ -57,7 +57,7 @@ function bee-cache() { ${BEE_LIBEXECDIR}/bee/bee.d/bee-cache "${@}" } -do_remove() { +function do_remove() { pkg=${1} mv ${BEE_METADIR}/${pkg}/CONTENT{,.bee-remove} 2>/dev/null @@ -143,7 +143,7 @@ function run_hooks() { done } -usage() { +function usage() { cat <<-EOF bee-remove v${VERSION} 2009-2012 by Marius Tolzmann and Tobias Dreyer <{tolzmann,dreyer}@molgen.mpg.de> From 91ea65121a0493c91ce6a7e5c5beb7e48f103bb8 Mon Sep 17 00:00:00 2001 From: Marius Tolzmann Date: Mon, 30 Jul 2012 22:06:02 +0200 Subject: [PATCH 2/7] bee-remove: Define BEE_LIBEXECDIR if not set --- src/bee-remove.sh.in | 1 + 1 file changed, 1 insertion(+) diff --git a/src/bee-remove.sh.in b/src/bee-remove.sh.in index f8cf71c..4d3ac15 100644 --- a/src/bee-remove.sh.in +++ b/src/bee-remove.sh.in @@ -31,6 +31,7 @@ fi VERSION=${BEE_VERSION} : ${BEE_BINDIR:=@BINDIR@} +: ${BEE_LIBEXECDIR:=@LIBEXECDIR@} function pkg_remove_all() { for pkg in "${@}" ; do From 1cf0cbb0d4dadbaaffdb89a9660aadf9f9972a5f Mon Sep 17 00:00:00 2001 From: Marius Tolzmann Date: Mon, 30 Jul 2012 22:08:24 +0200 Subject: [PATCH 3/7] bee-remove: Add bee-list wrapper function --- src/bee-remove.sh.in | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/bee-remove.sh.in b/src/bee-remove.sh.in index 4d3ac15..744be8f 100644 --- a/src/bee-remove.sh.in +++ b/src/bee-remove.sh.in @@ -33,6 +33,10 @@ VERSION=${BEE_VERSION} : ${BEE_BINDIR:=@BINDIR@} : ${BEE_LIBEXECDIR:=@LIBEXECDIR@} +function bee-list() { + ${BEE_LIBEXECDIR}/bee/bee.d/bee-list "${@}" +} + function pkg_remove_all() { for pkg in "${@}" ; do pkg_remove "${pkg}" @@ -51,7 +55,7 @@ function pkg_remove() { # pattern is no installed pkg # show all pkgs that match pattern echo "${search} matches following packages .." - ${BEE_LIBEXECDIR}/bee/bee.d/bee-list -i "${search}" + bee-list -i "${search}" } function bee-cache() { From a0fd9f1e06a6610a7ce1767f15e57d6a30442d82 Mon Sep 17 00:00:00 2001 From: Marius Tolzmann Date: Mon, 30 Jul 2012 22:08:57 +0200 Subject: [PATCH 4/7] bee-remove: Cleanup: move bee-cache wrapper function to the top --- src/bee-remove.sh.in | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/bee-remove.sh.in b/src/bee-remove.sh.in index 744be8f..e329511 100644 --- a/src/bee-remove.sh.in +++ b/src/bee-remove.sh.in @@ -33,6 +33,10 @@ VERSION=${BEE_VERSION} : ${BEE_BINDIR:=@BINDIR@} : ${BEE_LIBEXECDIR:=@LIBEXECDIR@} +function bee-cache() { + ${BEE_LIBEXECDIR}/bee/bee.d/bee-cache "${@}" +} + function bee-list() { ${BEE_LIBEXECDIR}/bee/bee.d/bee-list "${@}" } @@ -58,10 +62,6 @@ function pkg_remove() { bee-list -i "${search}" } -function bee-cache() { - ${BEE_LIBEXECDIR}/bee/bee.d/bee-cache "${@}" -} - function do_remove() { pkg=${1} From 7a6f3632c90146bd8b465db684982bde9d2a7b79 Mon Sep 17 00:00:00 2001 From: Marius Tolzmann Date: Mon, 30 Jul 2012 22:09:20 +0200 Subject: [PATCH 5/7] bee-remove: Add bee-query wrapper function --- src/bee-remove.sh.in | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/bee-remove.sh.in b/src/bee-remove.sh.in index e329511..b20a59d 100644 --- a/src/bee-remove.sh.in +++ b/src/bee-remove.sh.in @@ -41,6 +41,10 @@ function bee-list() { ${BEE_LIBEXECDIR}/bee/bee.d/bee-list "${@}" } +function bee-query() { + ${BEE_LIBEXECDIR}/bee/bee.d/bee-query "${@}" +} + function pkg_remove_all() { for pkg in "${@}" ; do pkg_remove "${pkg}" @@ -126,7 +130,7 @@ function do_remove() { # this may be fixed automatically once bee query doesn't scan the # filesystem anymore and we have an index db 8) # using bee dep here is currently to slow 8( - if [ -z "$(${BEE_LIBEXECDIR}/bee/bee.d/bee-query ${dir} | head -1)" ] ; then + if [ -z "$(bee-query ${dir} | head -1)" ] ; then ${NOOP:+echo} rmdir ${OPT_VERBOSE:+-v} ${dir} fi done From 090e555cd471203bf5eafd708a0de766db24cf43 Mon Sep 17 00:00:00 2001 From: Marius Tolzmann Date: Mon, 30 Jul 2012 22:28:27 +0200 Subject: [PATCH 6/7] bee-remove: Use BEE_VERSION in usage --- src/bee-remove.sh.in | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/bee-remove.sh.in b/src/bee-remove.sh.in index b20a59d..f4a9094 100644 --- a/src/bee-remove.sh.in +++ b/src/bee-remove.sh.in @@ -28,8 +28,6 @@ if [ -z "${BEE_VERSION}" ] ; then exit 1 fi -VERSION=${BEE_VERSION} - : ${BEE_BINDIR:=@BINDIR@} : ${BEE_LIBEXECDIR:=@LIBEXECDIR@} @@ -154,7 +152,7 @@ function run_hooks() { function usage() { cat <<-EOF - bee-remove v${VERSION} 2009-2012 + bee-remove v${BEE_VERSION} 2009-2012 by Marius Tolzmann and Tobias Dreyer <{tolzmann,dreyer}@molgen.mpg.de> Max Planck Institute for Molecular Genetics Berlin Dahlem From c236e290a87b510cf3516f1bd5d818a94ee8bff8 Mon Sep 17 00:00:00 2001 From: Marius Tolzmann Date: Mon, 30 Jul 2012 22:29:07 +0200 Subject: [PATCH 7/7] bee-remove: Remove --noop option.. --noop does not work with bee-cache and probably never worked since bee-dep was used. --- src/bee-remove.sh.in | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/src/bee-remove.sh.in b/src/bee-remove.sh.in index f4a9094..99ecd0c 100644 --- a/src/bee-remove.sh.in +++ b/src/bee-remove.sh.in @@ -78,22 +78,20 @@ function do_remove() { exit 1 fi - [ "${NOOP}" != "yes" ] && \ - run_hooks pre-remove ${pkg} ${BEE_METADIR}/${pkg}/CONTENT.bee-remove + run_hooks pre-remove ${pkg} ${BEE_METADIR}/${pkg}/CONTENT.bee-remove FILES=( $(bee-cache --tmpinstall "${pkg}" print-uniq-files "${pkg}") ) # removing files for f in "${FILES[@]}" ; do if [ -d "${f}" -a ! -h "$f" ] ; then - ${NOOP:+echo} rmdir ${OPT_VERBOSE:+-v} ${f} + rmdir ${OPT_VERBOSE:+-v} ${f} else - ${NOOP:+echo} rm -f ${OPT_VERBOSE:+-v} ${f} + rm -f ${OPT_VERBOSE:+-v} ${f} fi done - [ "${NOOP}" != "yes" ] && \ - run_hooks post-remove ${pkg} ${BEE_METADIR}/${pkg}/CONTENT.bee-remove + run_hooks post-remove ${pkg} ${BEE_METADIR}/${pkg}/CONTENT.bee-remove if [ -r "${BEE_METADIR}/${pkg}/META" ] ; then . "${BEE_METADIR}/${pkg}/META" @@ -129,13 +127,13 @@ function do_remove() { # filesystem anymore and we have an index db 8) # using bee dep here is currently to slow 8( if [ -z "$(bee-query ${dir} | head -1)" ] ; then - ${NOOP:+echo} rmdir ${OPT_VERBOSE:+-v} ${dir} + rmdir ${OPT_VERBOSE:+-v} ${dir} fi done fi #cleanup meta directory - ${NOOP:+echo} rm -fr ${OPT_VERBOSE:+-v} ${BEE_METADIR}/${pkg} + rm -fr ${OPT_VERBOSE:+-v} ${BEE_METADIR}/${pkg} bee-cache update ${pkg} } @@ -160,14 +158,12 @@ function usage() { Options: -h, --help display this help - -n, --noop do not actually remove; just print -v, --verbose print removed files and directories EOF } options=$(${BEE_BINDIR}/beegetopt --name bee-remove \ - --option noop/n \ --option verbose/v \ --option help/h \ -- "$@") @@ -180,10 +176,6 @@ eval set -- "${options}" while true ; do case "$1" in - --noop) - shift - NOOP="yes" - ;; --help) usage exit