Merge "Fix hanging mount points issues"

This commit is contained in:
Jenkins 2014-11-20 13:38:19 +00:00 committed by Gerrit Code Review
commit cb8ae0aa99
3 changed files with 10 additions and 6 deletions

View File

@ -8,8 +8,6 @@ clean_centos_image:
-sudo umount $(BUILD_DIR)/image/centos/SANDBOX/mirror
-sudo umount $(BUILD_DIR)/image/centos/SANDBOX/proc
-sudo umount $(BUILD_DIR)/image/centos/SANDBOX/dev
-sudo umount $(BUILD_DIR)/image/centos/image_boot
-sudo umount $(BUILD_DIR)/image/centos/image_root
sudo rm -rf $(BUILD_DIR)/image/centos
$(ARTS_DIR)/$(TARGET_CENTOS_IMG_ART_NAME): $(BUILD_DIR)/images/$(TARGET_CENTOS_IMG_ART_NAME)
@ -37,6 +35,7 @@ $(BUILD_DIR)/images/$(TARGET_CENTOS_IMG_ART_NAME):
sudo mkdir -p $(SANDBOX)/mirror
sudo mount -o bind $(LOCAL_MIRROR_CENTOS_OS_BASEURL) $(SANDBOX)/mirror
sudo chroot $(SANDBOX) python build_centos_image.py -k centos.ks -n centos_$(CENTOS_IMAGE_RELEASE)_$(CENTOS_ARCH) -s "$(SEPARATE_IMAGES)"
sudo umount $(SANDBOX)/mirror
sudo mv $(SANDBOX)/profile.yaml $(BUILD_DIR)/image/centos/
sudo mv $(SANDBOX)/centos_$(CENTOS_IMAGE_RELEASE)_$(CENTOS_ARCH)*.img $(BUILD_DIR)/image/centos/
gzip -f $(BUILD_DIR)/image/centos/centos_$(CENTOS_IMAGE_RELEASE)_$(CENTOS_ARCH)*.img

View File

@ -56,7 +56,10 @@ if [ ! -d "$TMP_CHROOT_DIR" ]; then
mkdir -p "$TMP_CHROOT_DIR" || die "Couldn't create directory"
fi
# try to remove stale files
# try to remove stale files and mount points
if mount | grep -q "${TMP_CHROOT_DIR}/tmp/mirror"; then
sudo umount ${TMP_CHROOT_DIR}/tmp/mirror
fi
for idx in $(seq $((${#MOUNTPOINTS[@]} - 1)) -1 0); do
MOUNT_POINT=${MOUNTPOINTS[$idx]}
@ -68,14 +71,15 @@ for idx in $(seq $((${#MOUNTPOINTS[@]} - 1)) -1 0); do
SPARSE_FILE_NAME=${IMG_FILE_NAME}.${SPARSE_IMG_FILE_SUFFIX}
LOOP_DEV=/dev/${FUEL_DEVICE_PREFIX}${idx}
if mount | grep -q "${TMP_CHROOT_DIR}${MOUNT_POINT}"; then
sudo umount ${TMP_CHROOT_DIR}${MOUNT_POINT} || echo "Couldn't umnount old loop-device file, trying to perform lazy umnount"
sudo umount ${TMP_CHROOT_DIR}${MOUNT_POINT}
if [ $? -ne 0 ]; then
echo "Couldn't umnount old loop-device file, trying to perform lazy umnount"
sudo umount -l ${TMP_CHROOT_DIR}${MOUNT_POINT} || echo "Couldn't unmount old loop-device file"
fi
fi
if [ -e "$LOOP_DEV" ]; then
# try to remove if it exists
sudo losetup -d $LOOP_DEV || die "Couldn't dissociate old loop-device file"
# try to remove if it exists, just dissociate first, ignore the errors.
sudo losetup -d $LOOP_DEV
sudo rm -f $LOOP_DEV || die "Couldn't remove old loop-device file"
sudo rm -f ${SPARSE_FILE_NAME} || die "Could remove old sparce image"
fi

View File

@ -5,6 +5,7 @@ target_ubuntu_image: $(ARTS_DIR)/$(TARGET_UBUNTU_IMG_ART_NAME)
clean: clean_ubuntu_image
clean_ubuntu_image:
-sudo umount $(TMP_CHROOT)/tmp/mirror
-sudo umount $(TMP_CHROOT)/proc
-sudo umount $(TMP_CHROOT)/dev
-sudo umount $(TMP_CHROOT)/sys