Skip to contentSkip to conversation

file: export MAGIC in SDK

PATCH New Chen Qi 1 participant 2 messages Jan 17, 2023

lore
Share & tools
lore

Chen Qi

author
#0 lore raw

PATCH 1/2 file: export MAGIC in SDK

Previously, a wrapper is used for file, which adds '--magic-file' option to it. But other components might use libmagic and in such case, if there's no MAGIC environent variable set correctly, things do not work. For example, rpmbuild makes use of libmagic and it requries MAGIC to be set correctly.

---
 meta/recipes-devtools/file/file_5.44.bb | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
meta/recipes-devtools/file/file_5.44.bb +5 -2
index b3d821518a..d4b49341b7 100644
@@ -32,6 +32,7 @@ EXTRA_OEMAKE:append:class-target = " -e FILE_COMPILE=${STAGING_BINDIR_NATIVE}/fi
 EXTRA_OEMAKE:append:class-nativesdk = " -e FILE_COMPILE=${STAGING_BINDIR_NATIVE}/file-native/file"
 
 FILES:${PN} += "${datadir}/misc/*.mgc"
+FILES:${PN}:append:class-nativesdk = " ${SDKPATHNATIVE}/environment-setup.d/file.sh"
 
 do_compile:append:class-native() {
 	oe_runmake check
@@ -43,8 +44,10 @@ do_install:append:class-native() {
 }
 
 do_install:append:class-nativesdk() {
-	create_cmdline_wrapper ${D}/${bindir}/file \
-		--magic-file ${datadir}/misc/magic.mgc
+	mkdir -p ${D}${SDKPATHNATIVE}/environment-setup.d
+	cat <<- EOF > ${D}${SDKPATHNATIVE}/environment-setup.d/file.sh
+		export MAGIC="$OECORE_NATIVE_SYSROOT${datadir}/misc/magic.mgc"
+	EOF
 }
 
 BBCLASSEXTEND = "native nativesdk"
Signature · 1 line
2.17.1
author
#1 lore raw

PATCH 2/2 rpm: do not export MAGIC in SDK

This MAGIC variable is used by libmagic (file), and should be exported by the file recipe.

As the rpm recipe has 'file' in its DEPENDS, its sub-packages which links to libmagic will be automatically added the 'file' runtime dependency. More specifically, it's the rpm-build package. So in case components in nativesdk-rpm-build package uses libmagic, the nativesdk-file package will be installed and the MAGIC var will be exported.

---
 meta/recipes-devtools/rpm/rpm_4.18.0.bb | 1 -
 1 file changed, 1 deletion(-)
meta/recipes-devtools/rpm/rpm_4.18.0.bb +0 -1
index 8eb0ab207e..61e395a9d0 100644
@@ -123,7 +123,6 @@ do_install:append:class-nativesdk() {
 	cat <<- EOF > ${D}${SDKPATHNATIVE}/environment-setup.d/rpm.sh
 		export RPM_CONFIGDIR="$OECORE_NATIVE_SYSROOT${libdir}/rpm"
 		export RPM_ETCCONFIGDIR="$OECORE_NATIVE_SYSROOT${sysconfdir}"
-		export MAGIC="$OECORE_NATIVE_SYSROOT${datadir}/misc/magic.mgc"
 		export RPM_NO_CHROOT_FOR_SCRIPTS=1
 	EOF
 }
Signature · 1 line
2.17.1