All of lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [RFC PATCH] package/libcamera: remove rpath and strip debug symbols before signing IPA libs
@ 2022-05-05 12:01 Quentin Schulz
  2022-05-05 20:57 ` Arnout Vandecappelle
  0 siblings, 1 reply; 6+ messages in thread
From: Quentin Schulz @ 2022-05-05 12:01 UTC (permalink / raw)
  To: buildroot
  Cc: Quentin Schulz, Quentin Schulz, Kieran Bingham, Laurent Pinchart

From: Quentin Schulz <quentin.schulz@theobroma-systems.com>

Open-Source IPA shlibs need to be signed in order to be runnable within
the same process, otherwise they are deemed Closed-Source and run in
another process and communicate over IPC.
Buildroot strips debug symbols and sanitizes RPATH in a post build
process. We need to do the same before signing the IPA shlibs otherwise
the signature won't match the shlib on the rootfs.

meson gets rid of rpath while installing so we don't need to do it
manually.
However the signing process is also part of the meson install target, so
we have a chicken and the egg problem. Let's install the libs in the
target directory (and do a useless signing) to get rid of rpath, then
strip debug symbols the same way Buildroot does in post build step, then
re-sign shlibs directly in TARGET_DIR with signing script from
libcamera.

Cc: Quentin Schulz <foss+buildroot@0leil.net>
Signed-off-by: Quentin Schulz <quentin.schulz@theobroma-systems.com>
---
 package/libcamera/libcamera.mk | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/package/libcamera/libcamera.mk b/package/libcamera/libcamera.mk
index 77381ab3ca..d1303a2ff5 100644
--- a/package/libcamera/libcamera.mk
+++ b/package/libcamera/libcamera.mk
@@ -104,4 +104,25 @@ LIBCAMERA_DEPENDENCIES += libexecinfo
 LIBCAMERA_LDFLAGS = $(TARGET_LDFLAGS) -lexecinfo
 endif
 
+# Open-Source IPA shlibs need to be signed in order to be runnable within the
+# same process, otherwise they are deemed Closed-Source and run in another
+# process and communicate over IPC.
+# Buildroot strips debug symbols and sanitizes RPATH in a post build process. We
+# need to do the same before signing the IPA shlibs otherwise the signature
+# won't match the shlib on the rootfs.
+#
+# meson gets rid of rpath while installing so we don't need to do it manually.
+# However the signing process is also part of the meson install target, so we
+# have a chicken and the egg problem. Let's install the libs in the target
+# directory (and do a useless signing) to get rid of rpath, then strip debug
+# symbols the same way Buildroot does in post build step, then re-sign shlibs
+# directly in TARGET_DIR with signing script from libcamera.
+define LIBCAMERA_INSTALL_TARGET_CMDS
+	$(TARGET_MAKE_ENV) $(LIBCAMERA_NINJA_ENV) DESTDIR=$(TARGET_DIR) \
+		$(NINJA) $(NINJA_OPTS) -C $(LIBCAMERA_SRCDIR)/build install
+	find $(TARGET_DIR) -type f -name "ipa_*.so" -print0 | xargs -0 $(STRIPCMD) 2>/dev/null || true
+	MESON_INSTALL_DESTDIR_PREFIX=$(TARGET_DIR)/usr/lib/libcamera/ $(@D)/src/ipa/ipa-sign-install.sh $(@D)/build/src/ipa-priv-key.pem $(addprefix ipa_,$(addsuffix .so,$(LIBCAMERA_PIPELINES-y)))
+	MESON_INSTALL_DESTDIR_PREFIX=$(TARGET_DIR)/usr/lib64/libcamera/ $(@D)/src/ipa/ipa-sign-install.sh $(@D)/build/src/ipa-priv-key.pem $(addprefix ipa_,$(addsuffix .so,$(LIBCAMERA_PIPELINES-y)))
+endef
+
 $(eval $(meson-package))
-- 
2.35.1

_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2022-05-09 11:00 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-05 12:01 [Buildroot] [RFC PATCH] package/libcamera: remove rpath and strip debug symbols before signing IPA libs Quentin Schulz
2022-05-05 20:57 ` Arnout Vandecappelle
2022-05-06  8:56   ` Quentin Schulz
2022-05-06  9:04     ` Kieran Bingham
2022-05-06  9:24       ` Quentin Schulz
2022-05-09 11:00         ` Arnout Vandecappelle

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.