ia64/xen-unstable

view tools/security/Makefile @ 19527:0e24e9674ded

tools: Always use sane upstream (`native') python paths

Previously, by default we would install our python modules into
/usr/lib/python/xen, for example /usr/lib/python/xen/__init__.py.
Upstream python's standard install location (a) includes the Python
version number and (b) puts things in site-packages by default.

Our best conjecture for the reason for this was an attempt to make the
installs portable between different python versions. However, that
doesn't work because compiled python modules (.pyc), and C python
extensions corresponding to one version of python, are not compatible
across different versions of python.

This is why upstream include the version number.

site-packages is the standard location for locally-installed packages
and is automatically included on the python search path.

In this change, we abandon our own unusual python path setup:

* Invoke setup.py in an entirely standard manner. We pass
PREFIX and DESTDIR using the appropriate options provided by
setup.py for those purposes (adding them to setup.py calls
which were previously lacking them).

* Since the installation locations are now on the standard
python path, we no longer need to add anything to the path
in any of our python utilities. Therefore remove all that
code from every python script. (Many of these scripts
unconditionally added /usr/lib/python and /usr/lib64/python which
is wrong even in the old world.)

* There is no longer any special `Xen python path'. xen-python-path
is no longer needed. It is no longer called by anything in our
tree. However since out-of-tree callers may still invoke it, we
retain it. It now prints a fixed string referring to a directory
which does not to exist; callers (who use it to augment their
python path) will thus add a nonexistent directory to their python
path which is harmless.

* Remove various workarounds including use of setup.py --home
(which is intended for something completely different).

* Remove tests for the XEN_PYTHON_NATIVE_INSTALL build-time
environment variable. The new behaviour is the behaviour which we
should have had if this variable had been set. That is, it is now
as if this variable was always set but also bugs in the resulting
install have been fixed.

This should be a proper fix for the bug addressed by c/s 19515.

Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
author Keir Fraser <keir.fraser@citrix.com>
date Wed Apr 08 19:13:04 2009 +0100 (2009-04-08)
parents e52bf1822059
children bf946cc3008b
line source
1 XEN_ROOT = ../..
2 include $(XEN_ROOT)/tools/Rules.mk
4 CFLAGS += -Werror
5 CFLAGS += -fno-strict-aliasing
6 CFLAGS += -I. $(CFLAGS_libxenctrl)
8 CPPFLAGS += -MMD -MF .$*.d
9 PROG_DEPS = .*.d
11 XML2VERSION = $(shell xml2-config --version )
12 CFLAGS += $(shell xml2-config --cflags )
13 CFLAGS += $(shell if [[ $(XML2VERSION) < 2.6.20 ]]; then echo ""; else echo "-DVALIDATE_SCHEMA"; fi )
14 LDFLAGS += $(shell xml2-config --libs ) # if this does not work, try -L/usr/lib -lxml2 -lz -lpthread -lm
16 SRCS_TOOL = secpol_tool.c
17 OBJS_TOOL := $(patsubst %.c,%.o,$(filter %.c,$(SRCS_TOOL)))
19 ACM_INST_TOOLS = xensec_tool xensec_gen
20 ACM_EZPOLICY = xensec_ezpolicy
21 ACM_OBJS = $(OBJS_TOOL) $(OBJS_GETD)
22 ACM_SCRIPTS = python/xensec_tools/acm_getlabel
24 ACM_CONFIG_DIR = /etc/xen/acm-security
25 ACM_POLICY_DIR = $(ACM_CONFIG_DIR)/policies
26 ACM_SCRIPT_DIR = $(ACM_CONFIG_DIR)/scripts
28 ACM_INST_HTML = python/xensec_gen/index.html
29 ACM_INST_CGI = python/xensec_gen/cgi-bin/policy.cgi
30 ACM_SECGEN_HTMLDIR= /var/lib/xensec_gen
31 ACM_SECGEN_CGIDIR = $(ACM_SECGEN_HTMLDIR)/cgi-bin
33 ACM_SCHEMA = security_policy.xsd
34 ACM_EXAMPLES = client_v1 test
35 ACM_DEF_POLICIES =
36 ACM_POLICY_SUFFIX = security_policy.xml
38 ifeq ($(ACM_SECURITY),y)
39 .PHONY: all
40 all: build
42 .PHONY: install
43 install: all $(ACM_CONFIG_FILE)
44 $(INSTALL_DIR) $(DESTDIR)$(SBINDIR)
45 $(INSTALL_PROG) $(ACM_INST_TOOLS) $(DESTDIR)$(SBINDIR)
46 $(INSTALL_PROG) $(ACM_EZPOLICY) $(DESTDIR)$(SBINDIR)
47 $(INSTALL_DIR) $(DESTDIR)$(ACM_CONFIG_DIR)
48 $(INSTALL_DIR) $(DESTDIR)$(ACM_POLICY_DIR)
49 $(INSTALL_DATA) policies/$(ACM_SCHEMA) $(DESTDIR)$(ACM_POLICY_DIR)
50 $(INSTALL_DIR) $(DESTDIR)$(ACM_POLICY_DIR)/example
51 set -e; for i in $(ACM_EXAMPLES); do \
52 $(INSTALL_DATA) policies/example/$$i-$(ACM_POLICY_SUFFIX) $(DESTDIR)$(ACM_POLICY_DIR)/example/; \
53 done
54 set -e; for i in $(ACM_DEF_POLICIES); do \
55 $(INSTALL_DATA) policies/$$i-$(ACM_POLICY_SUFFIX) $(DESTDIR)$(ACM_POLICY_DIR); \
56 done
57 $(INSTALL_DIR) $(DESTDIR)$(ACM_SCRIPT_DIR)
58 $(INSTALL_PROG) $(ACM_SCRIPTS) $(DESTDIR)$(ACM_SCRIPT_DIR)
59 $(INSTALL_DIR) $(DESTDIR)$(ACM_SECGEN_HTMLDIR)
60 $(INSTALL_DATA) $(ACM_INST_HTML) $(DESTDIR)$(ACM_SECGEN_HTMLDIR)
61 $(INSTALL_DIR) $(DESTDIR)$(ACM_SECGEN_CGIDIR)
62 $(INSTALL_PROG) $(ACM_INST_CGI) $(DESTDIR)$(ACM_SECGEN_CGIDIR)
63 python python/setup.py install \
64 --prefix="$(PREFIX)" --root="$(DESTDIR)" --force
65 else
66 .PHONY: all
67 all:
69 .PHONY: install
70 install:
71 endif
73 .PHONY: build
74 build: $(ACM_INST_TOOLS) $(ACM_NOINST_TOOLS)
75 python python/setup.py build
76 chmod 700 $(ACM_SCRIPTS)
78 xensec_tool: $(OBJS_TOOL)
79 $(CC) -g $(CFLAGS) $(LDFLAGS) -O0 -o $@ $^ $(LDFLAGS_libxenctrl)
81 xensec_gen: xensec_gen.py
82 cp -f $^ $@
84 .PHONY: clean
85 clean:
86 $(RM) $(ACM_INST_TOOLS) $(ACM_NOINST_TOOLS)
87 $(RM) $(ACM_OBJS)
88 $(RM) $(PROG_DEPS)
89 $(RM) -r build
91 .PHONY: mrproper
92 mrproper: clean
94 -include $(PROG_DEPS)