Properly account for pipefail during cleanup

Due to a bug in how we were running some of our phases we were not
detecting some nonzero exit's. When this is fixed, dib fails early during
cleanup (leaving some resources attatched) due to not propertly
accounting for pipefail.

Change-Id: Icc0b35acbe035cac12a9291e2d07b6c690c3a6ad
This commit is contained in:
Gregory Haynes 2015-12-31 19:41:11 +00:00
parent f389b3a04d
commit 966f12dc4c

View File

@ -208,8 +208,9 @@ function detach_loopback() {
# If setup on a rhel or derivative the map was created with kpartx not losetup
# and subsequently needs to be removed.
loopdev_name=$(echo $loopdev | sed 's/\/dev\///g')
if sudo dmsetup ls | grep $loopdev_name; then
mapper_name=$(sudo dmsetup ls | grep $loopdev_name | awk '{ print $1 }')
if [ "$mapper_name" ]; then
sudo dmsetup --noudevsync remove $mapper_name
fi
@ -282,7 +283,7 @@ function mount_proc_dev_sys () {
function unmount_dir () {
local pattern="$1" mnts=""
if [ -n "$pattern" ]; then
if [ -n "$pattern" ] && awk '{print $2}' < /proc/mounts | grep "^$pattern"; then
mnts=`awk '{print $2}' < /proc/mounts | grep "^$pattern" | sort -r`
fi
if [ -n "$mnts" ]; then