[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[Libguestfs] [PATCH] build: Choose a virtual directory for the daemon which is not a symlink.



From: "Richard W.M. Jones" <rjones redhat com>

Check /sbin, /usr/sbin, /bin and /usr/bin to ensure that neither the
directory nor the parent (eg. /usr) is a symlink, and use this
directory for the virtual directory used to store guestfsd in the
appliance.
---
 appliance/Makefile.am |    9 +++++----
 configure.ac          |   20 ++++++++++++++++++++
 2 files changed, 25 insertions(+), 4 deletions(-)

diff --git a/appliance/Makefile.am b/appliance/Makefile.am
index 99896be..fcf6422 100644
--- a/appliance/Makefile.am
+++ b/appliance/Makefile.am
@@ -67,10 +67,11 @@ stamp-supermin: make.sh packagelist excludelist
 supermin.d/daemon.img: ../daemon/guestfsd
 	mkdir -p supermin.d
 	rm -f $@ $ -t
-	mkdir sbin
-	cd sbin && ln ../../daemon/guestfsd
-	echo -e "sbin\nsbin/guestfsd" | cpio --quiet -o -H newc > $ -t
-	rm -r sbin
+	rm -rf tmp
+	mkdir -p tmp/$(DAEMON_SUPERMIN_DIR)
+	cd tmp/$(DAEMON_SUPERMIN_DIR) && ln $(abs_top_builddir)/daemon/guestfsd
+	( cd tmp && find | cpio --quiet -o -H newc ) > $ -t
+	rm -rf tmp
 	mv $ -t $@
 
 supermin.d/init.img: init
diff --git a/configure.ac b/configure.ac
index 5caca32..3712d19 100644
--- a/configure.ac
+++ b/configure.ac
@@ -278,6 +278,26 @@ if test "x$enable_daemon" = "xyes"; then
             AC_DEFINE([VALGRIND_DAEMON],[1],[Define to 1 to run the daemon under valgrind])
             AC_DEFINE_UNQUOTED([VALGRIND_LOG_PATH],["$(pwd)"],[Path to save valgrind log files])
         fi
+
+        dnl Which directory should we put the daemon in?  NOTE: This
+        dnl is the "virtual" directory inside the appliance, not the
+        dnl install directory for libguestfs live.  Since Fedora 17
+        dnl /sbin is a symlink to /usr/sbin.  We have to put the
+        dnl daemon into a real (non-symlink) directory.
+        dirs="/sbin /usr/sbin /bin /usr/bin"
+        AC_MSG_CHECKING([which of $dirs is a real directory])
+        for dir in $dirs; do
+            parent=`dirname $dir`
+            if test -d $parent && test -d $dir; then
+                DAEMON_SUPERMIN_DIR=$dir
+                break
+            fi
+        done
+        if test "x$DAEMON_SUPERMIN_DIR" = "x"; then
+            AC_MSG_ERROR([non-symlink binary directory not found])
+        fi
+        AC_MSG_RESULT([$DAEMON_SUPERMIN_DIR])
+        AC_SUBST([DAEMON_SUPERMIN_DIR])
 fi
 AM_CONDITIONAL([INSTALL_DAEMON],[test "x$enable_install_daemon" = "xyes"])
 AM_CONDITIONAL([VALGRIND_DAEMON],[test "x$enable_valgrind_daemon" = "xyes"])
-- 
1.7.6


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]