Skip to content

Commit

Permalink
Merge branch 'bee-remove'
Browse files Browse the repository at this point in the history
* bee-remove:
  bee-remove: Check exit-status of first pipe command
  bee-remove: Skip non-existent directories
  bee-install: Remove redundant output (from bee-remove)
  bee-remove: Do not remove symlinks or directories on other mountpoints
  bee-remove: Change output.
  bee-remove: Skip symlinks when removing prefix directories
  bee-remove: Remove prefix directories recursive
  • Loading branch information
mariux committed Aug 28, 2012
2 parents 1588267 + d85905d commit 404fb61
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 10 deletions.
1 change: 0 additions & 1 deletion src/bee-install.sh.in
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,6 @@ function do_remove() {
echo "REMOVE ${p}"
continue
fi
echo "removing ${p} .."
${BEE_LIBEXECDIR}/bee/bee.d/bee-remove ${p}
done
}
Expand Down
52 changes: 43 additions & 9 deletions src/bee-remove.sh.in
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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."
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 404fb61

Please sign in to comment.