xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Andrew Cooper <andrew.cooper3@citrix.com>
To: Xen-devel <xen-devel@lists.xen.org>
Cc: Andrew Cooper <andrew.cooper3@citrix.com>,
	Ian Jackson <Ian.Jackson@eu.citrix.com>,
	Wei Liu <wei.liu2@citrix.com>
Subject: [XTF PATCH v3] Correct the usage of $(DESTDIR) and $(PREFIX)
Date: Mon, 25 Jul 2016 17:23:18 +0100	[thread overview]
Message-ID: <1469463798-11632-1-git-send-email-andrew.cooper3@citrix.com> (raw)
In-Reply-To: <1469015759-18516-1-git-send-email-wei.liu2@citrix.com>

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@citrix.com>
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
CC: Ian Jackson <Ian.Jackson@eu.citrix.com>
CC: Wei Liu <wei.liu2@citrix.com>

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@lists.xen.org
https://lists.xen.org/xen-devel

  parent reply	other threads:[~2016-07-25 16:23 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-20 11:55 [PATCH XTF] build: introduce a dist target Wei Liu
2016-07-20 12:52 ` Andrew Cooper
2016-07-20 13:10   ` Wei Liu
2016-07-20 13:15     ` Andrew Cooper
2016-07-20 18:21 ` [PATCH XTF] Correct the usage of $(DESTDIR) and $(prefix) Andrew Cooper
2016-07-20 18:28   ` Doug Goldstein
2016-07-20 18:31   ` Wei Liu
2016-07-21 10:43   ` Ian Jackson
2016-07-21 10:57     ` Andrew Cooper
2016-07-21 11:10       ` Ian Jackson
2016-07-25 16:23 ` Andrew Cooper [this message]
2016-07-26  9:09   ` [XTF PATCH v3] Correct the usage of $(DESTDIR) and $(PREFIX) Wei Liu
2016-07-26 10:14   ` Ian Jackson
2016-07-26 10:17     ` Andrew Cooper

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1469463798-11632-1-git-send-email-andrew.cooper3@citrix.com \
    --to=andrew.cooper3@citrix.com \
    --cc=Ian.Jackson@eu.citrix.com \
    --cc=wei.liu2@citrix.com \
    --cc=xen-devel@lists.xen.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).