Skip to contentSkip to conversation

libselinux: set PREFIX to generate proper .pc file

PATCH New Marcus Folkesson 3 participants 7 messages Jan 6, 2018 – Jan 7, 2018

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 libselinux: set PREFIX to generate proper .pc file

---
 package/libselinux/libselinux.mk | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
package/libselinux/libselinux.mk +3 -1
index 8ac8000de5..bf33da7f75 100644
@@ -43,17 +43,19 @@ LIBSELINUX_MAKE_INSTALL_TARGETS += install-pywrap
 # dependencies are broken and result in file truncation errors at link
 # time if the Python bindings are built through the same make
 # invocation as the rest of the library.
+# DESTDIR is needed during the compile to compute library and header paths.
 define LIBSELINUX_BUILD_PYTHON_BINDINGS
 	$(TARGET_MAKE_ENV) $(MAKE) -C $(@D) \
 		$(LIBSELINUX_MAKE_OPTS) DESTDIR=$(STAGING_DIR) swigify pywrap
 endef
 endif # python || python3
 
+# DESTDIR is needed during the compile to compute library and header paths.
 define LIBSELINUX_BUILD_CMDS
 	# DESTDIR is needed during the compile to compute library and
 	# header paths.
 	$(TARGET_MAKE_ENV) $(MAKE) -C $(@D) \
-		$(LIBSELINUX_MAKE_OPTS) DESTDIR=$(STAGING_DIR) all
+		$(LIBSELINUX_MAKE_OPTS) DESTDIR=$(STAGING_DIR) PREFIX=/usr all
 	$(LIBSELINUX_BUILD_PYTHON_BINDINGS)
 endef
 
Signature · 1 line
2.15.1
#1 lore raw

PATCH 1/1 libselinux: set PREFIX to generate proper .pc file

Marcus,

On Sat, Jan 6, 2018 at 8:52 AM, Marcus Folkesson
<[email protected]> wrote:

Please add a link to the autobuilder failure for libostree that this resolves.

I tested both one of the build failures and test-pkg with the following as checkpolicy depends on libsepol/libselinux:
BR2_PACKAGE_HOST_CHECKPOLICY=y BR2_PACKAGE_CHECKPOLICY=y
BR2_PACKAGE_LIBSEMANAGE=y

#2 lore raw

PATCH 1/1 libselinux: set PREFIX to generate proper .pc file

In reply to Marcus Folkesson

Hello,

Thanks for continuing the work on this topic!

Quoted 19 lines · Marcus Folkesson
---
 package/libselinux/libselinux.mk | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
package/libselinux/libselinux.mk +1 -0
index 8ac8000de5..bf33da7f75 100644
@@ -43,17 +43,19 @@ LIBSELINUX_MAKE_INSTALL_TARGETS += install-pywrap
 # dependencies are broken and result in file truncation errors at link
 # time if the Python bindings are built through the same make
 # invocation as the rest of the library.
+# DESTDIR is needed during the compile to compute library and header paths.
 define LIBSELINUX_BUILD_PYTHON_BINDINGS
 	$(TARGET_MAKE_ENV) $(MAKE) -C $(@D) \
 		$(LIBSELINUX_MAKE_OPTS) DESTDIR=$(STAGING_DIR) swigify pywrap
 endef
 endif # python || python3

package/libselinux/libselinux.mk LIBSELINUX_MAKE_INSTALL_TARGETS += install-pywrap · line 60

Quoted 10 lines
package/libselinux/libselinux.mk +2 -1
 
+# DESTDIR is needed during the compile to compute library and header paths.
 define LIBSELINUX_BUILD_CMDS
 	# DESTDIR is needed during the compile to compute library and
 	# header paths.
 	$(TARGET_MAKE_ENV) $(MAKE) -C $(@D) \
-		$(LIBSELINUX_MAKE_OPTS) DESTDIR=$(STAGING_DIR) all
+		$(LIBSELINUX_MAKE_OPTS) DESTDIR=$(STAGING_DIR) PREFIX=/usr all
 	$(LIBSELINUX_BUILD_PYTHON_BINDINGS)
 endef

How can this work without passing PREFIX=/usr also at install time ? (Same question for libsemanage and libsepol).

Thanks,

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
#3 lore raw

PATCH 1/1 libselinux: set PREFIX to generate proper .pc file

Hi Thomas,

Quoted 25 lines · Thomas Petazzoni

Hello,

Thanks for continuing the work on this topic!

Quoted 20 lines · Marcus Folkesson
---
 package/libselinux/libselinux.mk | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
package/libselinux/libselinux.mk +1 -0
index 8ac8000de5..bf33da7f75 100644
@@ -43,17 +43,19 @@ LIBSELINUX_MAKE_INSTALL_TARGETS += install-pywrap
 # dependencies are broken and result in file truncation errors at link
 # time if the Python bindings are built through the same make
 # invocation as the rest of the library.
+# DESTDIR is needed during the compile to compute library and header paths.
 define LIBSELINUX_BUILD_PYTHON_BINDINGS
 	$(TARGET_MAKE_ENV) $(MAKE) -C $(@D) \
 		$(LIBSELINUX_MAKE_OPTS) DESTDIR=$(STAGING_DIR) swigify pywrap
 endef
 endif # python || python3
 
Quoted 12 lines

package/libselinux/libselinux.mk LIBSELINUX_MAKE_INSTALL_TARGETS += install-pywrap · line 60

Quoted 9 lines
package/libselinux/libselinux.mk +2 -1
+# DESTDIR is needed during the compile to compute library and header paths.
 define LIBSELINUX_BUILD_CMDS
 	# DESTDIR is needed during the compile to compute library and
 	# header paths.
 	$(TARGET_MAKE_ENV) $(MAKE) -C $(@D) \
-		$(LIBSELINUX_MAKE_OPTS) DESTDIR=$(STAGING_DIR) all
+		$(LIBSELINUX_MAKE_OPTS) DESTDIR=$(STAGING_DIR) PREFIX=/usr all
 	$(LIBSELINUX_BUILD_PYTHON_BINDINGS)
 endef

How can this work without passing PREFIX=/usr also at install time ? (Same question for libsemanage and libsepol).

If not PREFIX is passed, it get the value of $(DESTDIR)/usr, which I think is correct?

If PREFIX=/usr at install time, it tries to install on the host system.

I guess autotools would have done a better job with DESTDIR and PREFIX.

What I can tell, the libselinux.pc is the only target that make use of PREFIX during compile time.

But maybe I should set PREFIX explicitly to $(XXXXX_DIR)/usr during installation just for clarity?

From libselinux/src/Makefile:
PREFIX ?= $(DESTDIR)/usr

Quoted 8 lines

Thanks,

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com

Best regards
Marcus Folkesson

#4 lore raw

PATCH 1/1 libselinux: set PREFIX to generate proper .pc file

Hello,

Quoted 5 lines · Marcus Folkesson
Quoted 2 lines

How can this work without passing PREFIX=/usr also at install time ? (Same question for libsemanage and libsepol).

If not PREFIX is passed, it get the value of $(DESTDIR)/usr, which I think is correct?

No, in the standard semantic of DESTDIR and PREFIX:

- PREFIX should be /usr, and DESTDIR $(TARGET_DIR) or $(STAGING_DIR) for target installation

- PREFIX should be $(HOST_DIR) for host installation, DESTDIR is not used

PREFIX is where the software is going to be executed from. So the software is going to be executed from /usr for target software, from $(HOST_DIR) for host software. PREFIX potentially has an effect on the stuff being built: PREFIX might end up being hardcoded into the binaries being compiled.

DESTDIR is used to divert the installation. It is only meaningful during installation. It has no effect on the stuff being built: DESTDIR is never going to be hardcoded in a binary.

Quoted 2 lines

If PREFIX=/usr at install time, it tries to install on the host system.

That's bogus.

Quoted 1 line

I guess autotools would have done a better job with DESTDIR and PREFIX.

Yes.

Quoted 5 lines

What I can tell, the libselinux.pc is the only target that make use of PREFIX during compile time.

But maybe I should set PREFIX explicitly to $(XXXXX_DIR)/usr during installation just for clarity?

In the standard (autotools) semantic of PREFIX,
PREFIX=$(TARGET_DIR)/usr is wrong, see above.

Quoted 2 lines

From libselinux/src/Makefile:
PREFIX ?= $(DESTDIR)/usr

Yes that's just plain wrong.

So, two options:

- We fix libselinux Makefile to have a more standard DESTDIR/PREFIX usage.

- We keep libselinux Makefile as-is, but we had some comments in libselinux.mk that explain the weird PREFIX/DESTDIR usage.

Thanks!

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
#5 lore raw

PATCH 1/1 libselinux: set PREFIX to generate proper .pc file

Hi Thomas,

Quoted 24 lines · Thomas Petazzoni

Hello,

Quoted 5 lines · Marcus Folkesson
Quoted 2 lines

How can this work without passing PREFIX=/usr also at install time ? (Same question for libsemanage and libsepol).

If not PREFIX is passed, it get the value of $(DESTDIR)/usr, which I think is correct?

No, in the standard semantic of DESTDIR and PREFIX:

- PREFIX should be /usr, and DESTDIR $(TARGET_DIR) or $(STAGING_DIR) for target installation

- PREFIX should be $(HOST_DIR) for host installation, DESTDIR is not used

PREFIX is where the software is going to be executed from. So the software is going to be executed from /usr for target software, from $(HOST_DIR) for host software. PREFIX potentially has an effect on the stuff being built: PREFIX might end up being hardcoded into the binaries being compiled.

Quoted 4 lines

DESTDIR is used to divert the installation. It is only meaningful during installation. It has no effect on the stuff being built: DESTDIR is never going to be hardcoded in a binary.

You are right.

Quoted 4 lines
Quoted 2 lines

If PREFIX=/usr at install time, it tries to install on the host system.

That's bogus.

Just to make clear - *this* package will try to install on the host system.

Quoted 17 lines
Quoted 2 lines

I guess autotools would have done a better job with DESTDIR and PREFIX.

Yes.

Quoted 5 lines

What I can tell, the libselinux.pc is the only target that make use of PREFIX during compile time.

But maybe I should set PREFIX explicitly to $(XXXXX_DIR)/usr during installation just for clarity?

In the standard (autotools) semantic of PREFIX,
PREFIX=$(TARGET_DIR)/usr is wrong, see above.

Quoted 2 lines

From libselinux/src/Makefile:
PREFIX ?= $(DESTDIR)/usr

Quoted 6 lines

Yes that's just plain wrong.

So, two options:

- We fix libselinux Makefile to have a more standard DESTDIR/PREFIX usage.

I think we should go for this one in the long run.
I will try to come up with something and get it upstreams for the selinux project.

Should we keep libselinux Makefile as-is in meanwhile or add patches?

I can take responsibility for the packages being fixed when it is upstreams.

Quoted 12 lines

- We keep libselinux Makefile as-is, but we had some comments in libselinux.mk that explain the weird PREFIX/DESTDIR usage.

Thanks!

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com

Best regards
Marcus Folkesson

#6 lore raw

PATCH 1/1 libselinux: set PREFIX to generate proper .pc file

Hello,

Quoted 7 lines · Marcus Folkesson
Quoted 4 lines
Quoted 2 lines

If PREFIX=/usr at install time, it tries to install on the host system.

That's bogus.

Just to make clear - *this* package will try to install on the host system.

I don't follow you here.

Quoted 8 lines
Quoted 2 lines

- We fix libselinux Makefile to have a more standard DESTDIR/PREFIX usage.

I think we should go for this one in the long run.
I will try to come up with something and get it upstreams for the selinux project.

Should we keep libselinux Makefile as-is in meanwhile or add patches?

We can add patches, especially if you are pushing them upstream.

Thanks!

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com