diff --git a/conf/distro/include/musl-ldso-paths.inc b/conf/distro/include/musl-ldso-paths.inc new file mode 100644 index 0000000000000000000000000000000000000000..a76324bf2a5d14dd7b0514eecb2a28fd2d231612 --- /dev/null +++ b/conf/distro/include/musl-ldso-paths.inc @@ -0,0 +1,23 @@ +# SPDX-FileCopyrightText: Huawei Inc. +# +# SPDX-License-Identifier: Apache-2.0 + +MUSL_LDSO_PATHS = " \ + module \ + module/ability \ + module/account \ + module/app \ + module/data \ + module/distributedhardware \ + module/multimedia \ + module/telephony \ +" + +MUSL_LDSO_PATHS:append:openharmony-3.1 = " \ + module/application \ + module/bundle \ + module/events \ + module/multimodalinput \ + module/net \ + module/security \ +" diff --git a/conf/distro/oniro-openharmony-linux.conf b/conf/distro/oniro-openharmony-linux.conf index cb429c6f5e71e91424ffda70cfbbd5d4237685fb..7036ac9a2436b314b497b8b8984d5d3da1a110bb 100644 --- a/conf/distro/oniro-openharmony-linux.conf +++ b/conf/distro/oniro-openharmony-linux.conf @@ -43,6 +43,7 @@ INHERIT += "uninative" require include/openssl.inc require include/java.inc +require include/musl-ldso-paths.inc # Workaround for missing host tools in do_testimage when not adding testimage to # IMAGE_CLASSES, but doing a direct `inherit testimage` in image recipes diff --git a/recipes-core/musl/musl_%.bbappend b/recipes-core/musl/musl_%.bbappend index cc05fd60d9921b303f2d85d9ff62c440cb8733eb..82812d403be5ef0d0adb31bf8d7db50148986caf 100644 --- a/recipes-core/musl/musl_%.bbappend +++ b/recipes-core/musl/musl_%.bbappend @@ -25,20 +25,7 @@ LDFLAGS:append:toolchain-clang = " ${@bb.utils.contains('COMPILER_RT', '-rtlib=c #CFLAGS:append:oniro-openharmony-linux = "-DHOOK_ENABLE" do_install:append:oniro-openharmony-linux () { - cat >> ${D}${sysconfdir}/ld-musl-${MUSL_LDSO_ARCH}.path << EOF -${libdir}/module -${libdir}/module/ability -${libdir}/module/account -${libdir}/module/app -${libdir}/module/application -${libdir}/module/bundle -${libdir}/module/data -${libdir}/module/distributedhardware -${libdir}/module/events -${libdir}/module/multimedia -${libdir}/module/multimodalinput -${libdir}/module/net -${libdir}/module/security -${libdir}/module/telephony -EOF + for folder in ${MUSL_LDSO_PATHS}; do + echo "${libdir}/${folder}" >> ${D}${sysconfdir}/ld-musl-${MUSL_LDSO_ARCH}.path + done } diff --git a/recipes-openharmony/openharmony/musl-ldso-paths-sanity-check.inc b/recipes-openharmony/openharmony/musl-ldso-paths-sanity-check.inc new file mode 100644 index 0000000000000000000000000000000000000000..bfa1971c9c513a75971153421801de55bbfa65eb --- /dev/null +++ b/recipes-openharmony/openharmony/musl-ldso-paths-sanity-check.inc @@ -0,0 +1,29 @@ +# SPDX-FileCopyrightText: Huawei Inc. +# +# SPDX-License-Identifier: Apache-2.0 + +# This post do_install() function checks if all subfloders copied from +# system/lib/module are set in the distro variable MUSL_LDSO_PATHS. +# +# This variable is used to generate the content of the file +# /etc/ld-musl-${MUSL_LDSO_ARCH}.path so this function stops bitbake +# if one of the coipied folder from /system/lib/module/* is not in +# MUSL_LDSO_PATHS. + +musl_ldso_paths_sanity_check() { + cd "${D}/${libdir}" + MODULE_LIB_PATHS="$(find module -type d)" + for folder in ${MODULE_LIB_PATHS}; do + PAT="(^|[[:space:]])${folder}([[:space:]]|$)" + if [[ ! "${MUSL_LDSO_PATHS}" =~ ${PAT} ]]; then + echo + echo "'${folder}' not in MUSL_LDSO_PATHS" + echo "Add it in conf/distro/include/musl-ldso-paths.inc" + echo + + return 1 + fi + done +} + +do_install[postfuncs] += "musl_ldso_paths_sanity_check" diff --git a/recipes-openharmony/openharmony/openharmony-standard_3.0.bb b/recipes-openharmony/openharmony/openharmony-standard_3.0.bb index 22a8fb3439e9b4d6d4fdc7e7b4874d66edc83c9d..64d987d026343348fff6901e45f2abb3b21eedcf 100644 --- a/recipes-openharmony/openharmony/openharmony-standard_3.0.bb +++ b/recipes-openharmony/openharmony/openharmony-standard_3.0.bb @@ -17,6 +17,7 @@ DEPENDS += "bison-native" DEPENDS += "ruby-native" require ${PN}-sources-${OPENHARMONY_VERSION}.inc +require musl-ldso-paths-sanity-check.inc FILESEXTRAPATHS:prepend := "${THISDIR}/openharmony-${OPENHARMONY_VERSION}:" FILESEXTRAPATHS:prepend := "${THISDIR}/openharmony-standard-${OPENHARMONY_VERSION}:" diff --git a/recipes-openharmony/openharmony/openharmony-standard_3.1.bb b/recipes-openharmony/openharmony/openharmony-standard_3.1.bb index 6d79c434dcd29eaf7af583dfc8cc8849c6a2d435..99cd4d145f95c71c6102ef3b78db451e30ee64c4 100644 --- a/recipes-openharmony/openharmony/openharmony-standard_3.1.bb +++ b/recipes-openharmony/openharmony/openharmony-standard_3.1.bb @@ -23,6 +23,7 @@ FILESEXTRAPATHS:prepend := "${THISDIR}/openharmony-standard-${OPENHARMONY_VERSIO require ${PN}-sources-${OPENHARMONY_VERSION}.inc require java-tools.inc +require musl-ldso-paths-sanity-check.inc SRC_URI += "${@bb.utils.contains('PTEST_ENABLED', '1', 'file://run-ptest', '', d)}"