diff --git a/src/bee-install.sh.in b/src/bee-install.sh.in index ceeffb1..ec16979 100644 --- a/src/bee-install.sh.in +++ b/src/bee-install.sh.in @@ -196,7 +196,6 @@ function do_remove() { echo "REMOVE ${p}" continue fi - echo "removing ${p} .." ${BEE_LIBEXECDIR}/bee/bee.d/bee-remove ${p} done } diff --git a/src/bee-remove.sh.in b/src/bee-remove.sh.in index 99ecd0c..9418c46 100644 --- a/src/bee-remove.sh.in +++ b/src/bee-remove.sh.in @@ -60,8 +60,45 @@ function pkg_remove() { # pattern is no installed pkg # show all pkgs that match pattern - echo "${search} matches following packages .." - bee-list -i "${search}" + echo >&2 "bee-remove: FAILED to remove '${search}': No such package." + echo >&2 "bee-remove: List of installed packages matching '${search}':" + bee-list -i "${search}" | sed -e 's,^, ,' >&2 + if [ ${PIPESTATUS[0]} != 0 ] ; then + echo >&2 " No packages found." + fi +} + + +# for each argument +# recursive get all dirnames that are directories on same mountpoint +# +# /path/to/somewhere -> /path/to/somewhere /path/to /path +# +function subdirs() { + local last + + for path in "${@}" ; do + last="" + while [ "${path:0:1}" = '/' -a "${path}" != "" ] ; do + if [ ! -d "${path}" ] ; then + continue 2 + fi + + this=$(stat "${path}" --printf "%F%m") + if [ -n "${last}" -a "${last}" != "${this}" ] ; then + continue 2 + else + last="${this}" + fi + + if [ "${this:0:9}" != 'directory' ] ; then + continue 2 + fi + + echo ${path} + path=${path%/*} + done + done } function do_remove() { @@ -72,6 +109,8 @@ function do_remove() { return 1 fi + echo "removing ${pkg} .." + bee-cache update ${pkg} if [ $? -ne 0 ] ; then echo >&2 "bee-remove: ${pkg}: bee-cache update failed." @@ -102,13 +141,8 @@ function do_remove() { vars=( PREFIX EPREFIX BINDIR SBINDIR LIBEXECDIR SYSCONFDIR \ SHAREDSTATEDIR LOCALSTATEDIR LIBDIR INCLUDEDIR \ DATAROOTDIR DATADIR INFODIR LOCALEDIR MANDIR DOCDIR ) - dirs=( $(for var in ${vars[@]} ; do eval echo \${PKG_${var}} ; done | sort -ur) ) - for dir in "${dirs[@]}" ; do - # if dir does not exist -> skip it - if [ ! -d "${dir}" ] ; then - continue - fi - + dirs=( $(for var in ${vars[@]} ; do eval echo \${PKG_${var}} ; done) ) + for dir in $( subdirs ${dirs[@]} | sort -ur ) ; do # if dir does is not part of package -> skip it content_file="${BEE_METADIR}/${pkg}/CONTENT.bee-remove" if ! grep -q -l -E ":file=${dir}(/|$)" "${content_file}" ; then