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

[Xen-devel] [XTF PATCH v3] Correct the usage of $(DESTDIR) and $(PREFIX)



The GNU coding standards expect $(DESTDIR) to be the root of everything
installed, and for $(PREFIX) to then be added to the path.  This is not how
XTF previously behaved.

XTF is not a typical package, and doesn't meet the usual semantics; it expects
to arrange all files in a single directory.  Drop the use of $(PREFIX)
entirely (to avoid the expectation that it behaves as $(prefix) usually
behaves) and introduce $(xtfdir) instead.

$(DESTDIR) now works as intended for staged installes, and $(xtfdir) is the
single selected directy containing all installed content, typically expected
to be /opt/xtf or similar.

The intended way to install XTF now:

  $ make install DESTDIR=/path/to/staging/area xtfdir=/opt/xtf

Reported-by: Wei Liu <wei.liu2@xxxxxxxxxx>
Signed-off-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
---
CC: Ian Jackson <Ian.Jackson@xxxxxxxxxxxxx>
CC: Wei Liu <wei.liu2@xxxxxxxxxx>

v3:
 * Drop $(PREFIX) entirely, as the semantics don't match.  Use $(xtfdir)
   instead to make it obvious that it is different.
v2:
 * Add an explicit subdirectory, to avoid prefix=/usr putting a number of
   files and directories straight in /usr
---
 Makefile                  | 23 +++++++++++++++++++----
 build/gen.mk              | 14 +++++++-------
 config/default-hvm.cfg.in |  2 +-
 config/default-pv.cfg.in  |  2 +-
 docs/introduction.dox     |  2 +-
 docs/mainpage.dox         |  4 ++--
 6 files changed, 31 insertions(+), 16 deletions(-)

diff --git a/Makefile b/Makefile
index 45f3846..8c36da0 100644
--- a/Makefile
+++ b/Makefile
@@ -2,9 +2,24 @@ MAKEFLAGS += -r
 ROOT := $(abspath $(CURDIR))
 export ROOT
 
+# $(xtfdir) defaults to $(ROOT) so development and testing can be done
+# straight out of the working tree.
+xtfdir  ?= $(ROOT)
 DESTDIR ?= $(ROOT)/dist
-PREFIX ?= $(ROOT)
-export DESTDIR PREFIX
+
+ifeq ($(filter /%,$(xtfdir)),)
+$(error $$(xtfdir) must be absolute, not '$(xtfdir)')
+endif
+
+ifneq ($(DESTDIR),)
+ifeq ($(filter /%,$(DESTDIR)),)
+$(error $$(DESTDIR) must be absolute, not '$(DESTDIR)')
+endif
+endif
+
+xtftestdir := $(xtfdir)/tests
+
+export DESTDIR xtfdir xtftestdir
 
 # Programs used
 CC              ?= $(CROSS_COMPILE)gcc
@@ -28,8 +43,8 @@ all:
 
 .PHONY: install
 install:
-       @$(INSTALL_DIR) $(DESTDIR)
-       $(INSTALL_PROGRAM) xtf-runner $(DESTDIR)
+       @$(INSTALL_DIR) $(DESTDIR)$(xtfdir)
+       $(INSTALL_PROGRAM) xtf-runner $(DESTDIR)$(xtfdir)
        @set -e; for D in $(wildcard tests/*); do \
                [ ! -e $$D/Makefile ] && continue; \
                $(MAKE) -C $$D install; \
diff --git a/build/gen.mk b/build/gen.mk
index 0a172b3..aeac2a6 100644
--- a/build/gen.mk
+++ b/build/gen.mk
@@ -31,8 +31,8 @@ test-info.json: $(ROOT)/build/mkinfo.py FORCE
 
 .PHONY: install install-each-env
 install: install-each-env test-info.json
-       @$(INSTALL_DIR) $(DESTDIR)/tests/$(NAME)
-       $(INSTALL_DATA) test-info.json $(DESTDIR)/tests/$(NAME)
+       @$(INSTALL_DIR) $(DESTDIR)$(xtftestdir)/$(NAME)
+       $(INSTALL_DATA) test-info.json $(DESTDIR)$(xtftestdir)/$(NAME)
 
 define PERENV_build
 
@@ -54,7 +54,7 @@ test-$(1)-$(NAME).cfg: $$(cfg-$(1)) FORCE
        @{ cat $$< $(TEST-EXTRA-CFG) ;} | \
        sed -e "s/@@NAME@@/$$(NAME)/g" \
                -e "s/@@ENV@@/$(1)/g" \
-               -e "s!@@PREFIX@@!$$(PREFIX)!g" \
+               -e "s!@@XTFDIR@@!$$(xtfdir)!g" \
                > $$@.tmp
        @if ! cmp -s $$@ $$@.tmp; then mv -f $$@.tmp $$@; else rm -f $$@.tmp; fi
 
@@ -63,12 +63,12 @@ test-$(1)-$(NAME).cfg: $$(cfg-$(1)) FORCE
 
 .PHONY: install-$(1) install-$(1).cfg
 install-$(1): test-$(1)-$(NAME)
-       @$(INSTALL_DIR) $(DESTDIR)/tests/$(NAME)
-       $(INSTALL_PROGRAM) $$< $(DESTDIR)/tests/$(NAME)
+       @$(INSTALL_DIR) $(DESTDIR)$(xtftestdir)/$(NAME)
+       $(INSTALL_PROGRAM) $$< $(DESTDIR)$(xtftestdir)/$(NAME)
 
 install-$(1).cfg: test-$(1)-$(NAME).cfg
-       @$(INSTALL_DIR) $(DESTDIR)/tests/$(NAME)
-       $(INSTALL_DATA) $$< $(DESTDIR)/tests/$(NAME)
+       @$(INSTALL_DIR) $(DESTDIR)$(xtftestdir)/$(NAME)
+       $(INSTALL_DATA) $$< $(DESTDIR)$(xtftestdir)/$(NAME)
 
 install-each-env: install-$(1) install-$(1).cfg
 
diff --git a/config/default-hvm.cfg.in b/config/default-hvm.cfg.in
index 2a395a5..7d29e0c 100644
--- a/config/default-hvm.cfg.in
+++ b/config/default-hvm.cfg.in
@@ -1,7 +1,7 @@
 name="test-@@ENV@@-@@NAME@@"
 builder="hvm"
 memory=128
-firmware_override="@@PREFIX@@/tests/@@NAME@@/test-@@ENV@@-@@NAME@@"
+firmware_override="@@XTFDIR@@/tests/@@NAME@@/test-@@ENV@@-@@NAME@@"
 
 # The framework doesn't reboot.  A reboot signal is almost certainly a triple
 # fault instead.  Prevent it turning into a runaway domain.
diff --git a/config/default-pv.cfg.in b/config/default-pv.cfg.in
index 044e50e..166e464 100644
--- a/config/default-pv.cfg.in
+++ b/config/default-pv.cfg.in
@@ -1,4 +1,4 @@
 name="test-@@ENV@@-@@NAME@@"
 loader="generic"
 memory=128
-kernel="@@PREFIX@@/tests/@@NAME@@/test-@@ENV@@-@@NAME@@"
+kernel="@@XTFDIR@@/tests/@@NAME@@/test-@@ENV@@-@@NAME@@"
diff --git a/docs/introduction.dox b/docs/introduction.dox
index e9a0777..3151fbf 100644
--- a/docs/introduction.dox
+++ b/docs/introduction.dox
@@ -131,7 +131,7 @@ If XTF in being built in dom0, all paths should be set up 
to run correctly.
 
 If XTF is built elsewhere, it should be installed:
 
-    $ make install PREFIX=/path DESTDIR=/path
+    $ make install xtfdir=/path DESTDIR=/path
 
 with paths appropriate for the system under test.
 
diff --git a/docs/mainpage.dox b/docs/mainpage.dox
index 2639423..942929e 100644
--- a/docs/mainpage.dox
+++ b/docs/mainpage.dox
@@ -62,9 +62,9 @@ To run tests on a Xen host: (see @ref errata first)
 
 - For the paths of binaries, `xl` accepts either an absolute path, or certain
   relative paths (`/etc/xen/` or `$CWD` for `kernel=`, `$libdir/xen/boot` for
-  `firmware_override=`).  The default `PREFIX=` is configured correctly for
+  `firmware_override=`).  The default `xtfdir=` is configured correctly for
   running the tests out of the build working tree.  If the tests are running
-  elsewhere, use `make install DESTDIR=$X PREFIX=$Y` to configure absolute
+  elsewhere, use `make install DESTDIR=$X xtfdir=$Y` to configure absolute
   paths appropriately for the test system.
 
 
-- 
2.1.4


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
https://lists.xen.org/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.