From 9907fc4f835889e69bcfa81b59ad607cb284d0eb Mon Sep 17 00:00:00 2001
From: Christopher Spinrath <christopher.spinrath@rwth-aachen.de>
Date: Sat, 26 Sep 2015 16:22:11 +0200
Subject: [PATCH] image_(u)mount_if: handle relative paths correctly

findmnt always returns the absolute path to a mount point, so
we have to compare the result with an absolute path.
But $(IMAGE_DIR) may be a relative path; thus, convert it to an
absolute path first.
---
 Makefile                      | 6 ++++--
 config/Makefile.conf.defaults | 1 -
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/Makefile b/Makefile
index 21070a5..593b427 100644
--- a/Makefile
+++ b/Makefile
@@ -97,6 +97,8 @@ define archdir =
 $(WORKSPACE)/$(call to_arch,$1)
 endef
 
+IMAGE_DIR=$(WORKSPACE)/image_files
+
 ARCH_DIR=$(call archdir,$(ARCH))
 PRIMARY_ARCH_DIR=$(call archdir,$(PRIMARY_ARCH))
 SECONDARY_ARCH_DIR=$(call archdir,$(SECONDARY_ARCH))
@@ -511,12 +513,12 @@ $(IMAGE_DIR)$(GRUB_INSTALL_DIR)/lipinfo.cfg : | $(WORKSPACE)
 
 image_mount_if : $(IMAGE_PART_FILE)
 	mkdir -p "$(IMAGE_DIR)"
-	[ "$$(findmnt --target "$(IMAGE_DIR)" -f -n --output=target)" = "$(IMAGE_DIR)" ] \
+	[ "$$(findmnt --target "$(IMAGE_DIR)" -f -n --output=target)" = "$(shell readlink -f "$(IMAGE_DIR)")" ] \
 		|| mount "$(IMAGE_PART_FILE)" "$(IMAGE_DIR)"
 
 image_umount_if :
 	#if something is mounted then umount
-	[ "$$(findmnt --target "$(IMAGE_DIR)" -f -n --output=target)" != "$(IMAGE_DIR)" ] \
+	[ "$$(findmnt --target "$(IMAGE_DIR)" -f -n --output=target)" != "$(shell readlink -f "$(IMAGE_DIR)")" ] \
 		|| umount -d "$(IMAGE_DIR)"
 
 $(call ensure_mount,image) : image_content $(GRUB_ASSEMBLE_DIR)/mbr.img
diff --git a/config/Makefile.conf.defaults b/config/Makefile.conf.defaults
index 128f386..6fb4e34 100644
--- a/config/Makefile.conf.defaults
+++ b/config/Makefile.conf.defaults
@@ -29,7 +29,6 @@ ISO_PATTERN_FLAGS=
 
 APT_SOURCE_URL_OVERRIDE=http://ftp.halifax.rwth-aachen.de/ubuntu/
 
-IMAGE_DIR=$(WORKSPACE)/image_files
 IMAGE_GIT_URL=https://www.fsmpi.rwth-aachen.de/git/lipstick
 IMAGE_GIT_BRANCH=ss15
 IMAGE_EXTRA_INFO=
-- 
GitLab