[PATCH v3 08/14] python: build: follow standard semantics for DESTDIR and PREFIX
Signed-off-by: Marcus Folkesson --- python/audit2allow/Makefile | 17 ++--- python/chcat/Makefile | 8 python/semanage/Makefile | 11 +-- python/sepolgen/src/sepolgen/Makefile | 3 ++- python/sepolicy/Makefile | 18 +- 5 files changed, 30 insertions(+), 27 deletions(-) diff --git a/python/audit2allow/Makefile b/python/audit2allow/Makefile index 8db8075f..d1d4ca8d 100644 --- a/python/audit2allow/Makefile +++ b/python/audit2allow/Makefile @@ -1,19 +1,22 @@ PYTHON ?= python # Installation directories. -PREFIX ?= $(DESTDIR)/usr -BINDIR ?= $(PREFIX)/bin -LIBDIR ?= $(PREFIX)/lib -MANDIR ?= $(PREFIX)/share/man -LOCALEDIR ?= /usr/share/locale -INCLUDEDIR ?= $(PREFIX)/include -LIBSEPOLA ?= $(LIBDIR)/libsepol.a +PREFIX ?= /usr +BINDIR ?= $(DESTDIR)$(PREFIX)/bin +LIBDIR ?= $(DESTDIR)$(PREFIX)/lib +MANDIR ?= $(DESTDIR)$(PREFIX)/share/man CFLAGS ?= -Werror -Wall -W +# If no specific libsepol.a is specified, fall back on LDFLAGS search path +ifeq ($(LIBSEPOLA),) + LDFLAGS += -l:libsepol.a +endif + all: audit2why sepolgen-ifgen-attr-helper sepolgen-ifgen-attr-helper: sepolgen-ifgen-attr-helper.o $(LIBSEPOLA) + $(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS) audit2why: ln -sf audit2allow audit2why diff --git a/python/chcat/Makefile b/python/chcat/Makefile index 0fd12d6d..947734a0 100644 --- a/python/chcat/Makefile +++ b/python/chcat/Makefile @@ -1,8 +1,8 @@ # Installation directories. -PREFIX ?= $(DESTDIR)/usr -BINDIR ?= $(PREFIX)/bin -MANDIR ?= $(PREFIX)/share/man -LOCALEDIR ?= $(PREFIX)/share/locale +PREFIX ?= /usr +BINDIR ?= $(DESTDIR)$(PREFIX)/bin +MANDIR ?= $(DESTDIR)$(PREFIX)/share/man +LOCALEDIR ?= $(DESTDIR)$(PREFIX)/share/locale .PHONY: all all: chcat diff --git a/python/semanage/Makefile b/python/semanage/Makefile index 132162bc..0218222d 100644 --- a/python/semanage/Makefile +++ b/python/semanage/Makefile @@ -1,13 +1,12 @@ PYTHON ?= python # Installation directories. -PREFIX ?= $(DESTDIR)/usr -LIBDIR ?= $(PREFIX)/lib -SBINDIR ?= $(PREFIX)/sbin -MANDIR = $(PREFIX)/share/man -PYTHONLIBDIR ?= $(shell $(PYTHON) -c "from distutils.sysconfig import *; print(get_python_lib(1))") +PREFIX ?= /usr +SBINDIR ?= $(DESTDIR)$(PREFIX)/sbin +MANDIR = $(DESTDIR)$(PREFIX)/share/man +PYTHONLIBDIR ?= $(shell $(PYTHON) -c "from distutils.sysconfig import *; print(get_python_lib(prefix='$(PREFIX)'))") PACKAGEDIR ?= $(DESTDIR)/$(PYTHONLIBDIR) -BASHCOMPLETIONDIR ?= $(DESTDIR)/usr/share/bash-completion/completions +BASHCOMPLETIONDIR ?= $(DESTDIR)$(PREFIX)/share/bash-completion/completions TARGETS=semanage diff --git a/python/sepolgen/src/sepolgen/Makefile b/python/sepolgen/src/sepolgen/Makefile index d3aa7715..2121a955 100644 --- a/python/sepolgen/src/sepolgen/Makefile +++ b/python/sepolgen/src/sepolgen/Makefile @@ -1,5 +1,6 @@ +PREFIX ?= /usr PYTHON ?= python -PYTHONLIBDIR ?= $(shell $(PYTHON) -c "from distutils.sysconfig import *; print(get_python_lib(1))") +PYTHONLIBDIR ?= $(shell $(PYTHON) -c "from distutils.sysconfig import *; print(get_python_lib(prefix='$(PREFIX)'))") PACKAGEDIR ?= $(DESTDIR)/$(PYTHONLIBDIR)/sepolgen all: diff --git a/python/sepolicy/Makefile b/python/sepolicy/Makefile index 5a56e6c8..1c02ee06 100644 --- a/python/sepolicy/Makefile +++ b/python/sepolicy/Makefile @@ -1,14 +1,14 @@ PYTHON ?= python # Installation directories. -PREFIX ?= $(DESTDIR)/usr -LIBDIR ?= $(PREFIX)/lib -BINDIR ?= $(PREFIX)/bin -DATADIR ?= $(PREFIX)/share -MANDIR ?= $(PREFIX)/share/man -LOCALEDIR ?= /usr/share/locale -BASHCOMPLETIONDIR ?= $(DESTDIR)/usr/share/bash-completion/completions -SHAREDIR ?= $(PREFIX)/share/sandbox +PREFIX ?= /usr +LIBDIR ?= $(DESTDIR)$(PREFIX)/lib +BINDIR ?= $(DESTDIR)$(PREFIX)/bin +DATADIR ?= $(DESTDIR)$(PREFIX)/share +MANDIR ?= $(DESTDIR)$(PREFIX)/share/man +LOCALEDIR ?= $(DESTDIR)$(PREFIX)/share/locale +BASHCOMPLETIONDIR ?= $(DESTDIR)$(PREFIX)/share/bash-completion/completions +SHAREDIR ?= $(DESTDIR)$(PREFIX)/share/sandbox CFLAGS ?= -Wall -Werror -Wextra -W override CFLAGS += -DPACKAGE="policycoreutils" -DSHARED -shared @@ -30,7 +30,7 @@ test: @$(PYTHON) test_sepolicy.py -v install: - $(PYTHON) setup.py install `test -n "$(DESTDIR)" && echo --root $(DESTDIR)` + $(PYTHON) setup.py install --prefix=$(PREFIX) `test -n "$(DESTDIR)" && echo --root $(DESTDIR)` [ -d $(BINDIR) ] || mkdir -p $(BINDIR) install -m 755 sepolicy.py $(BINDIR)/sepolicy (cd $(BINDIR); ln -sf sepolicy sepolgen) -- 2.15.1
Re: [PATCH v3 08/14] python: build: follow standard semantics for DESTDIR and PREFIX
On Sun, Jan 21, 2018 at 10:46:11PM +0100, Marcus Folkesson wrote: > Signed-off-by: Marcus Folkesson > --- > python/audit2allow/Makefile | 17 ++--- > python/chcat/Makefile | 8 > python/semanage/Makefile | 11 +-- > python/sepolgen/src/sepolgen/Makefile | 3 ++- > python/sepolicy/Makefile | 18 +- > 5 files changed, 30 insertions(+), 27 deletions(-) > > diff --git a/python/audit2allow/Makefile b/python/audit2allow/Makefile > index 8db8075f..d1d4ca8d 100644 > --- a/python/audit2allow/Makefile > +++ b/python/audit2allow/Makefile > @@ -1,19 +1,22 @@ > PYTHON ?= python > > # Installation directories. > -PREFIX ?= $(DESTDIR)/usr > -BINDIR ?= $(PREFIX)/bin > -LIBDIR ?= $(PREFIX)/lib > -MANDIR ?= $(PREFIX)/share/man > -LOCALEDIR ?= /usr/share/locale > -INCLUDEDIR ?= $(PREFIX)/include > -LIBSEPOLA ?= $(LIBDIR)/libsepol.a > +PREFIX ?= /usr > +BINDIR ?= $(DESTDIR)$(PREFIX)/bin > +LIBDIR ?= $(DESTDIR)$(PREFIX)/lib > +MANDIR ?= $(DESTDIR)$(PREFIX)/share/man > > CFLAGS ?= -Werror -Wall -W > > +# If no specific libsepol.a is specified, fall back on LDFLAGS search path > +ifeq ($(LIBSEPOLA),) > + LDFLAGS += -l:libsepol.a > +endif > + > all: audit2why sepolgen-ifgen-attr-helper > > sepolgen-ifgen-attr-helper: sepolgen-ifgen-attr-helper.o $(LIBSEPOLA) > + $(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS) > > audit2why: > ln -sf audit2allow audit2why > diff --git a/python/chcat/Makefile b/python/chcat/Makefile > index 0fd12d6d..947734a0 100644 > --- a/python/chcat/Makefile > +++ b/python/chcat/Makefile > @@ -1,8 +1,8 @@ > # Installation directories. > -PREFIX ?= $(DESTDIR)/usr > -BINDIR ?= $(PREFIX)/bin > -MANDIR ?= $(PREFIX)/share/man > -LOCALEDIR ?= $(PREFIX)/share/locale > +PREFIX ?= /usr > +BINDIR ?= $(DESTDIR)$(PREFIX)/bin > +MANDIR ?= $(DESTDIR)$(PREFIX)/share/man > +LOCALEDIR ?= $(DESTDIR)$(PREFIX)/share/locale > > .PHONY: all > all: chcat > diff --git a/python/semanage/Makefile b/python/semanage/Makefile > index 132162bc..0218222d 100644 > --- a/python/semanage/Makefile > +++ b/python/semanage/Makefile > @@ -1,13 +1,12 @@ > PYTHON ?= python > > # Installation directories. > -PREFIX ?= $(DESTDIR)/usr > -LIBDIR ?= $(PREFIX)/lib > -SBINDIR ?= $(PREFIX)/sbin > -MANDIR = $(PREFIX)/share/man > -PYTHONLIBDIR ?= $(shell $(PYTHON) -c "from distutils.sysconfig import *; > print(get_python_lib(1))") > +PREFIX ?= /usr > +SBINDIR ?= $(DESTDIR)$(PREFIX)/sbin > +MANDIR = $(DESTDIR)$(PREFIX)/share/man > +PYTHONLIBDIR ?= $(shell $(PYTHON) -c "from distutils.sysconfig import *; > print(get_python_lib(prefix='$(PREFIX)'))") Note that this change move paths for modules from platform-specific to platform-shared: - /home/vagrant/build/usr/lib64/python3.6/site-packages/seobject.py + /home/vagrant/build/usr/lib/python3.6/site-packages/seobject.py I think it's a good change given that there's only pure python modules, but it would be good to document it in the commit message. > PACKAGEDIR ?= $(DESTDIR)/$(PYTHONLIBDIR) > -BASHCOMPLETIONDIR ?= $(DESTDIR)/usr/share/bash-completion/completions > +BASHCOMPLETIONDIR ?= $(DESTDIR)$(PREFIX)/share/bash-completion/completions > > TARGETS=semanage > > diff --git a/python/sepolgen/src/sepolgen/Makefile > b/python/sepolgen/src/sepolgen/Makefile > index d3aa7715..2121a955 100644 > --- a/python/sepolgen/src/sepolgen/Makefile > +++ b/python/sepolgen/src/sepolgen/Makefile > @@ -1,5 +1,6 @@ > +PREFIX ?= /usr > PYTHON ?= python > -PYTHONLIBDIR ?= $(shell $(PYTHON) -c "from distutils.sysconfig import *; > print(get_python_lib(1))") > +PYTHONLIBDIR ?= $(shell $(PYTHON) -c "from distutils.sysconfig import *; > print(get_python_lib(prefix='$(PREFIX)'))") > PACKAGEDIR ?= $(DESTDIR)/$(PYTHONLIBDIR)/sepolgen > > all: > diff --git a/python/sepolicy/Makefile b/python/sepolicy/Makefile > index 5a56e6c8..1c02ee06 100644 > --- a/python/sepolicy/Makefile > +++ b/python/sepolicy/Makefile > @@ -1,14 +1,14 @@ > PYTHON ?= python > > # Installation directories. > -PREFIX ?= $(DESTDIR)/usr > -LIBDIR ?= $(PREFIX)/lib > -BINDIR ?= $(PREFIX)/bin > -DATADIR ?= $(PREFIX)/share > -MANDIR ?= $(PREFIX)/share/man > -LOCALEDIR ?= /usr/share/locale > -BASHCOMPLETIONDIR ?= $(DESTDIR)/usr/share/bash-completion/completions > -SHAREDIR ?= $(PREFIX)/share/sandbox > +PREFIX ?= /usr > +LIBDIR ?= $(DESTDIR)$(PREFIX)/lib > +BINDIR ?= $(DESTDIR)$(PREFIX)/bin > +DATADIR ?= $(DESTDIR)$(PREFIX)/share > +MANDIR ?= $(DESTDIR)$(PREFIX)/share/man > +LOCALEDIR ?= $(DESTDIR)$(PREFIX)/share/locale > +BASHCOMPLETIONDIR ?= $(DESTDIR)$(PREFIX)/share/bash-completion/completions > +SHAREDIR ?= $(DESTDIR)$(PREFIX)/share/sandbox > CFLAGS ?= -Wall -Werror -Wextra -W > override CFLAGS += -DPACKAGE="policycoreutils" -DSHARED -shared > > @@ -30,7 +30,7 @@ test: > @$(PYTHON) test_sepolicy.py -v > > install: > - $(PYTHON) setup.py install `test -n "$(DESTDIR)" && echo --root > $(DESTDIR)` > + $(PYT
Re: [PATCH v3 08/14] python: build: follow standard semantics for DESTDIR and PREFIX
Hi Petr, On Tue, Jan 23, 2018 at 11:24:47AM +0100, Petr Lautrbach wrote: > On Sun, Jan 21, 2018 at 10:46:11PM +0100, Marcus Folkesson wrote: > > Signed-off-by: Marcus Folkesson > > --- > > python/audit2allow/Makefile | 17 ++--- > > python/chcat/Makefile | 8 > > python/semanage/Makefile | 11 +-- > > python/sepolgen/src/sepolgen/Makefile | 3 ++- > > python/sepolicy/Makefile | 18 +- > > 5 files changed, 30 insertions(+), 27 deletions(-) > > > > diff --git a/python/audit2allow/Makefile b/python/audit2allow/Makefile > > index 8db8075f..d1d4ca8d 100644 > > --- a/python/audit2allow/Makefile > > +++ b/python/audit2allow/Makefile > > @@ -1,19 +1,22 @@ > > PYTHON ?= python > > > > # Installation directories. > > -PREFIX ?= $(DESTDIR)/usr > > -BINDIR ?= $(PREFIX)/bin > > -LIBDIR ?= $(PREFIX)/lib > > -MANDIR ?= $(PREFIX)/share/man > > -LOCALEDIR ?= /usr/share/locale > > -INCLUDEDIR ?= $(PREFIX)/include > > -LIBSEPOLA ?= $(LIBDIR)/libsepol.a > > +PREFIX ?= /usr > > +BINDIR ?= $(DESTDIR)$(PREFIX)/bin > > +LIBDIR ?= $(DESTDIR)$(PREFIX)/lib > > +MANDIR ?= $(DESTDIR)$(PREFIX)/share/man > > > > CFLAGS ?= -Werror -Wall -W > > > > +# If no specific libsepol.a is specified, fall back on LDFLAGS search path > > +ifeq ($(LIBSEPOLA),) > > + LDFLAGS += -l:libsepol.a > > +endif > > + > > all: audit2why sepolgen-ifgen-attr-helper > > > > sepolgen-ifgen-attr-helper: sepolgen-ifgen-attr-helper.o $(LIBSEPOLA) > > + $(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS) > > > > audit2why: > > ln -sf audit2allow audit2why > > diff --git a/python/chcat/Makefile b/python/chcat/Makefile > > index 0fd12d6d..947734a0 100644 > > --- a/python/chcat/Makefile > > +++ b/python/chcat/Makefile > > @@ -1,8 +1,8 @@ > > # Installation directories. > > -PREFIX ?= $(DESTDIR)/usr > > -BINDIR ?= $(PREFIX)/bin > > -MANDIR ?= $(PREFIX)/share/man > > -LOCALEDIR ?= $(PREFIX)/share/locale > > +PREFIX ?= /usr > > +BINDIR ?= $(DESTDIR)$(PREFIX)/bin > > +MANDIR ?= $(DESTDIR)$(PREFIX)/share/man > > +LOCALEDIR ?= $(DESTDIR)$(PREFIX)/share/locale > > > > .PHONY: all > > all: chcat > > diff --git a/python/semanage/Makefile b/python/semanage/Makefile > > index 132162bc..0218222d 100644 > > --- a/python/semanage/Makefile > > +++ b/python/semanage/Makefile > > @@ -1,13 +1,12 @@ > > PYTHON ?= python > > > > # Installation directories. > > -PREFIX ?= $(DESTDIR)/usr > > -LIBDIR ?= $(PREFIX)/lib > > -SBINDIR ?= $(PREFIX)/sbin > > -MANDIR = $(PREFIX)/share/man > > -PYTHONLIBDIR ?= $(shell $(PYTHON) -c "from distutils.sysconfig import *; > > print(get_python_lib(1))") > > +PREFIX ?= /usr > > +SBINDIR ?= $(DESTDIR)$(PREFIX)/sbin > > +MANDIR = $(DESTDIR)$(PREFIX)/share/man > > +PYTHONLIBDIR ?= $(shell $(PYTHON) -c "from distutils.sysconfig import *; > > print(get_python_lib(prefix='$(PREFIX)'))") > > Note that this change move paths for modules from platform-specific to > platform-shared: > > - /home/vagrant/build/usr/lib64/python3.6/site-packages/seobject.py > + /home/vagrant/build/usr/lib/python3.6/site-packages/seobject.py > > I think it's a good change given that there's only pure python > modules, but it would be good to document it in the commit message. > > I will split up the logical changes and make it to a seperate commit in v4. Thanks you! > > PACKAGEDIR ?= $(DESTDIR)/$(PYTHONLIBDIR) > > -BASHCOMPLETIONDIR ?= $(DESTDIR)/usr/share/bash-completion/completions > > +BASHCOMPLETIONDIR ?= $(DESTDIR)$(PREFIX)/share/bash-completion/completions > > > > TARGETS=semanage > > > > diff --git a/python/sepolgen/src/sepolgen/Makefile > > b/python/sepolgen/src/sepolgen/Makefile > > index d3aa7715..2121a955 100644 > > --- a/python/sepolgen/src/sepolgen/Makefile > > +++ b/python/sepolgen/src/sepolgen/Makefile > > @@ -1,5 +1,6 @@ > > +PREFIX ?= /usr > > PYTHON ?= python > > -PYTHONLIBDIR ?= $(shell $(PYTHON) -c "from distutils.sysconfig import *; > > print(get_python_lib(1))") > > +PYTHONLIBDIR ?= $(shell $(PYTHON) -c "from distutils.sysconfig import *; > > print(get_python_lib(prefix='$(PREFIX)'))") > > PACKAGEDIR ?= $(DESTDIR)/$(PYTHONLIBDIR)/sepolgen > > > > all: > > diff --git a/python/sepolicy/Makefile b/python/sepolicy/Makefile > > index 5a56e6c8..1c02ee06 100644 > > --- a/python/sepolicy/Makefile > > +++ b/python/sepolicy/Makefile > > @@ -1,14 +1,14 @@ > > PYTHON ?= python > > > > # Installation directories. > > -PREFIX ?= $(DESTDIR)/usr > > -LIBDIR ?= $(PREFIX)/lib > > -BINDIR ?= $(PREFIX)/bin > > -DATADIR ?= $(PREFIX)/share > > -MANDIR ?= $(PREFIX)/share/man > > -LOCALEDIR ?= /usr/share/locale > > -BASHCOMPLETIONDIR ?= $(DESTDIR)/usr/share/bash-completion/completions > > -SHAREDIR ?= $(PREFIX)/share/sandbox > > +PREFIX ?= /usr > > +LIBDIR ?= $(DESTDIR)$(PREFIX)/lib > > +BINDIR ?= $(DESTDIR)$(PREFIX)/bin > > +DATADIR ?= $(DESTDIR)$(PREFIX)/share > > +MANDIR ?= $(DESTDIR)$(PREFIX)/share/man > > +LOCALEDIR ?= $(DESTDIR)$(PREFIX)/s