From f37c64523aab80d6314faf6b7456ecec91836a12 Mon Sep 17 00:00:00 2001 From: Michal Vasilek Date: Tue, 22 Nov 2022 19:33:18 +0100 Subject: [PATCH 01/10] common/hooks: move provided shlibs to templates shlibs are now in individual packages and not in a centralized common/shlibs file. The third optional column was used to restrict the shlib to a specific arch which is now not required, the shlibs list can be easily modified with shell code just like any other variable. TODO: * how much slower is this? xbps-query -o is slow when a lot of packages are installed * adjust pkglint rules * add a pkglint rule that checks that an shlib actually exists in the pkg * currently every shlib has to be on its own line which can easily break with += and there can not be a whitespace at the beginning of the line * one limitation is that the package template can not be fully sourced, so it's not possible to for example have different shlibs when an option is enabled, but that was not possible now either --- .../hooks/pre-pkg/04-generate-runtime-deps.sh | 25 ++++++++++++++----- 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/common/hooks/pre-pkg/04-generate-runtime-deps.sh b/common/hooks/pre-pkg/04-generate-runtime-deps.sh index a291f2ccc872..bd012e1b0ee1 100644 --- a/common/hooks/pre-pkg/04-generate-runtime-deps.sh +++ b/common/hooks/pre-pkg/04-generate-runtime-deps.sh @@ -46,15 +46,13 @@ store_pkgdestdir_rundeps() { } hook() { - local depsftmp f lf j mapshlibs sorequires _curdep elfmagic broken_shlibs verify_deps + local depsftmp f lf j sorequires _curdep elfmagic verify_rdeps # Disable trap on ERR, xbps-uhelper cmd might return error... but not something # to be worried about because if there are broken shlibs this hook returns # error via msg_error(). trap - ERR - mapshlibs=$XBPS_COMMONDIR/shlibs - if [ -n "$noverifyrdeps" ]; then store_pkgdestdir_rundeps return 0 @@ -95,10 +93,25 @@ hook() { # above, the mapping is done thru the common/shlibs file. # for f in ${verify_deps}; do - unset _f j rdep _rdep rdepcnt soname _pkgname _rdepver found + unset _f j rdep rdepver _rdep rdepcurrent rdepcnt soname _pkgname _rdepver found _f=$(echo "$f"|sed -E 's|\+|\\+|g') - rdep="$(grep -E "^${_f}[[:blank:]]+.*$" $mapshlibs|cut -d ' ' -f2)" - rdepcnt="$(grep -E "^${_f}[[:blank:]]+.*$" $mapshlibs|cut -d ' ' -f2|wc -l)" + # get rdep pkgname in current version + rdepcurrent="$(xbps-query -o "/usr/lib/${_f}" | cut -d: -f1)" + # extract just pkgname + rdepname="$($XBPS_UHELPER_CMD getpkgname "$rdepcurrent")" + # look into the template of the rdep to figure out which version + # should be used for the shlib dependency + shlibs=$( + shlibs= + source_file $XBPS_SRCPKGDIR/$rdepname/template + if type ${rdepname}_package >/dev/null 2>&1; then + ${rdepname}_package + fi + echo "$shlibs" + ); + rdepver="$(echo $shlibs | grep -E "^${_f}[[:blank:]]+.*$" | cut -d ' ' -f2)" + rdep="${rdepname}-${rdepver}" + rdepcnt=1 # FIXME if [ -z "$rdep" ]; then # Ignore libs by current pkg soname=$(find ${PKGDESTDIR} -name "$f") From 64c6d5e73469185fdf4837d7edf9434c98de41d5 Mon Sep 17 00:00:00 2001 From: Michal Vasilek Date: Tue, 22 Nov 2022 19:41:41 +0100 Subject: [PATCH 02/10] glibc: add shlibs to the package --- srcpkgs/glibc/template | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/srcpkgs/glibc/template b/srcpkgs/glibc/template index 452b55c12762..7e6f06e3d863 100644 --- a/srcpkgs/glibc/template +++ b/srcpkgs/glibc/template @@ -59,6 +59,42 @@ if [ "$XBPS_TARGET_LIBC" = musl ]; then broken="no point in building this for musl" fi +shlibs=" +libc.so.6 ${version}_1 +libm.so.6 ${version}_1 +libpthread.so.0 ${version}_1 +librt.so.1 ${version}_1 +libdl.so.2 ${version}_1 +ld-linux-armhf.so.3 ${version}_1 +libresolv.so.2 ${version}_1 +libanl.so.1 ${version}_1 +libthread_db.so.1 ${version}_1 +libutil.so.1 ${version}_1 +libnsl.so.1 ${version}_1 +libnss_db.so.2 ${version}_1 +libnss_files.so.2 ${version}_1 +libnss_compat.so.2 ${version}_1 +libnss_dns.so.2 ${version}_1 +libnss_hesiod.so.2 ${version}_1 +libcrypt.so.1 ${version}_1 +libBrokenLocale.so.1 ${version}_1 +libmemusage.so ${version}_1 +libSegFault.so ${version}_1 +libpcprofile.so ${version}_1 +libcidn.so.1 ${version}_1 +libmvec.so.1 ${version}_1 +" + +case "$XBPS_TARGET_MACHINE" in + x86_64) shlibs+="ld-linux-x86-64.so.2 ${version}_1" ;; + i686) shlibs+="ld-linux.so.2 ${version}_1" ;; + armv5tel) shlibs+="ld-linux.so.3 ${version}_1" ;; + aarch64) shlibs+="ld-linux-aarch64.so.1 ${version}_1" ;; + ppc64) shlibs+="ld64.so.2 ${version}_1" ;; + mips) shlibs+="ld.so.1 ${version}_1" ;; + ppc) shlibs+="ld.so.1 ${version}_1" ;; +esac + do_configure() { mkdir build cd build From ccebcf0a0d76e2295c7a20de77cb9a38ac217ab6 Mon Sep 17 00:00:00 2001 From: Michal Vasilek Date: Tue, 22 Nov 2022 19:41:57 +0100 Subject: [PATCH 03/10] musl: add shlibs to the package --- srcpkgs/musl/template | 2 ++ 1 file changed, 2 insertions(+) diff --git a/srcpkgs/musl/template b/srcpkgs/musl/template index afb33cd868b5..fb6bbc66fb0f 100644 --- a/srcpkgs/musl/template +++ b/srcpkgs/musl/template @@ -17,6 +17,8 @@ checksum=1370c9a812b2cf2a7d92802510cca0058cc37e66a7bedd70051f0a34015022a3 nostrip_files="libc.so" shlib_provides="libc.so" +shlibs="libc.so 1.1.24_7" + post_build() { $CC $CFLAGS $LDFLAGS -fpie ${FILESDIR}/getent.c -o getent $CC $CFLAGS $LDFLAGS -fpie ${FILESDIR}/getconf.c -o getconf From 268640b9a8257483c61a20803df3e7c83c089bbd Mon Sep 17 00:00:00 2001 From: Michal Vasilek Date: Fri, 30 Dec 2022 18:06:30 +0100 Subject: [PATCH 04/10] acl: add shlibs to the package --- srcpkgs/acl/template | 1 + 1 file changed, 1 insertion(+) diff --git a/srcpkgs/acl/template b/srcpkgs/acl/template index 9fa74946a240..4b2aabca60c5 100644 --- a/srcpkgs/acl/template +++ b/srcpkgs/acl/template @@ -13,6 +13,7 @@ license="LGPL-2.1-or-later" homepage="https://savannah.nongnu.org/projects/acl" distfiles="${NONGNU_SITE}/acl/acl-${version}.tar.gz" checksum=760c61c68901b37fdd5eefeeaf4c0c7a26bdfdd8ac747a1edff1ce0e243c11af +shlibs="libacl.so.1 2.2.47_1" if [ -z "$CHROOT_READY" ]; then CFLAGS+=" -I${XBPS_MASTERDIR}/usr/include" From 5198be19c3ce0e3c1bfb780f61e97fcbde188382 Mon Sep 17 00:00:00 2001 From: Michal Vasilek Date: Fri, 30 Dec 2022 17:57:49 +0100 Subject: [PATCH 05/10] search for shlib-provides --- common/hooks/pre-pkg/04-generate-runtime-deps.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/hooks/pre-pkg/04-generate-runtime-deps.sh b/common/hooks/pre-pkg/04-generate-runtime-deps.sh index bd012e1b0ee1..3d530f8ec4fe 100644 --- a/common/hooks/pre-pkg/04-generate-runtime-deps.sh +++ b/common/hooks/pre-pkg/04-generate-runtime-deps.sh @@ -96,7 +96,7 @@ hook() { unset _f j rdep rdepver _rdep rdepcurrent rdepcnt soname _pkgname _rdepver found _f=$(echo "$f"|sed -E 's|\+|\\+|g') # get rdep pkgname in current version - rdepcurrent="$(xbps-query -o "/usr/lib/${_f}" | cut -d: -f1)" + rdepcurrent="$($XBPS_QUERY_CMD -p shlib-provides -s "${_f}" | cut -d: -f1)" # extract just pkgname rdepname="$($XBPS_UHELPER_CMD getpkgname "$rdepcurrent")" # look into the template of the rdep to figure out which version From ecba7b5bd703f7f2f104d3ce7a118764880189ca Mon Sep 17 00:00:00 2001 From: Michal Vasilek Date: Fri, 30 Dec 2022 17:58:54 +0100 Subject: [PATCH 06/10] fix ignoring libs from current pkg --- .../hooks/pre-pkg/04-generate-runtime-deps.sh | 31 ++++++++++--------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/common/hooks/pre-pkg/04-generate-runtime-deps.sh b/common/hooks/pre-pkg/04-generate-runtime-deps.sh index 3d530f8ec4fe..48cd87d76e15 100644 --- a/common/hooks/pre-pkg/04-generate-runtime-deps.sh +++ b/common/hooks/pre-pkg/04-generate-runtime-deps.sh @@ -97,20 +97,23 @@ hook() { _f=$(echo "$f"|sed -E 's|\+|\\+|g') # get rdep pkgname in current version rdepcurrent="$($XBPS_QUERY_CMD -p shlib-provides -s "${_f}" | cut -d: -f1)" - # extract just pkgname - rdepname="$($XBPS_UHELPER_CMD getpkgname "$rdepcurrent")" - # look into the template of the rdep to figure out which version - # should be used for the shlib dependency - shlibs=$( - shlibs= - source_file $XBPS_SRCPKGDIR/$rdepname/template - if type ${rdepname}_package >/dev/null 2>&1; then - ${rdepname}_package - fi - echo "$shlibs" - ); - rdepver="$(echo $shlibs | grep -E "^${_f}[[:blank:]]+.*$" | cut -d ' ' -f2)" - rdep="${rdepname}-${rdepver}" + rdep= + if [ -n "$rdepcurrent" ]; then + # extract just pkgname + rdepname="$($XBPS_UHELPER_CMD getpkgname "$rdepcurrent")" + # look into the template of the rdep to figure out which version + # should be used for the shlib dependency + shlibs=$( + shlibs= + source_file $XBPS_SRCPKGDIR/$rdepname/template + if type ${rdepname}_package >/dev/null 2>&1; then + ${rdepname}_package + fi + echo "$shlibs" + ); + rdepver="$(echo $shlibs | grep -E "^${_f}[[:blank:]]+.*$" | cut -d ' ' -f2)" + rdep="${rdepname}-${rdepver}" + fi rdepcnt=1 # FIXME if [ -z "$rdep" ]; then # Ignore libs by current pkg From e5a1676aa2aeb0d004490c7f36a1c2b095df0e80 Mon Sep 17 00:00:00 2001 From: Michal Vasilek Date: Fri, 30 Dec 2022 18:18:57 +0100 Subject: [PATCH 07/10] use = as the version separator --- common/hooks/pre-pkg/04-generate-runtime-deps.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/hooks/pre-pkg/04-generate-runtime-deps.sh b/common/hooks/pre-pkg/04-generate-runtime-deps.sh index 48cd87d76e15..059d97d6644c 100644 --- a/common/hooks/pre-pkg/04-generate-runtime-deps.sh +++ b/common/hooks/pre-pkg/04-generate-runtime-deps.sh @@ -111,7 +111,7 @@ hook() { fi echo "$shlibs" ); - rdepver="$(echo $shlibs | grep -E "^${_f}[[:blank:]]+.*$" | cut -d ' ' -f2)" + rdepver="$(echo $shlibs | grep -E "^${_f}=.*$" | cut -d '=' -f2)" rdep="${rdepname}-${rdepver}" fi rdepcnt=1 # FIXME From ad42b57508e686a0968197d1321853c2230c259c Mon Sep 17 00:00:00 2001 From: Michal Vasilek Date: Fri, 30 Dec 2022 18:20:19 +0100 Subject: [PATCH 08/10] acl: use = as a version separator --- srcpkgs/acl/template | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/srcpkgs/acl/template b/srcpkgs/acl/template index 4b2aabca60c5..99d3bbfc1990 100644 --- a/srcpkgs/acl/template +++ b/srcpkgs/acl/template @@ -13,7 +13,7 @@ license="LGPL-2.1-or-later" homepage="https://savannah.nongnu.org/projects/acl" distfiles="${NONGNU_SITE}/acl/acl-${version}.tar.gz" checksum=760c61c68901b37fdd5eefeeaf4c0c7a26bdfdd8ac747a1edff1ce0e243c11af -shlibs="libacl.so.1 2.2.47_1" +shlibs="libacl.so.1=2.2.47_1" if [ -z "$CHROOT_READY" ]; then CFLAGS+=" -I${XBPS_MASTERDIR}/usr/include" From 6254e5ce0cb4e97af113cf0172d1e59bdc0ee41d Mon Sep 17 00:00:00 2001 From: Michal Vasilek Date: Fri, 30 Dec 2022 18:20:28 +0100 Subject: [PATCH 09/10] glibc: use = as a version separator --- srcpkgs/glibc/template | 60 +++++++++++++++++++++--------------------- 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/srcpkgs/glibc/template b/srcpkgs/glibc/template index 7e6f06e3d863..177b67f6d7e0 100644 --- a/srcpkgs/glibc/template +++ b/srcpkgs/glibc/template @@ -60,39 +60,39 @@ if [ "$XBPS_TARGET_LIBC" = musl ]; then fi shlibs=" -libc.so.6 ${version}_1 -libm.so.6 ${version}_1 -libpthread.so.0 ${version}_1 -librt.so.1 ${version}_1 -libdl.so.2 ${version}_1 -ld-linux-armhf.so.3 ${version}_1 -libresolv.so.2 ${version}_1 -libanl.so.1 ${version}_1 -libthread_db.so.1 ${version}_1 -libutil.so.1 ${version}_1 -libnsl.so.1 ${version}_1 -libnss_db.so.2 ${version}_1 -libnss_files.so.2 ${version}_1 -libnss_compat.so.2 ${version}_1 -libnss_dns.so.2 ${version}_1 -libnss_hesiod.so.2 ${version}_1 -libcrypt.so.1 ${version}_1 -libBrokenLocale.so.1 ${version}_1 -libmemusage.so ${version}_1 -libSegFault.so ${version}_1 -libpcprofile.so ${version}_1 -libcidn.so.1 ${version}_1 -libmvec.so.1 ${version}_1 +libc.so.6=${version}_1 +libm.so.6=${version}_1 +libpthread.so.0=${version}_1 +librt.so.1=${version}_1 +libdl.so.2=${version}_1 +ld-linux-armhf.so.3=${version}_1 +libresolv.so.2=${version}_1 +libanl.so.1=${version}_1 +libthread_db.so.1=${version}_1 +libutil.so.1=${version}_1 +libnsl.so.1=${version}_1 +libnss_db.so.2=${version}_1 +libnss_files.so.2=${version}_1 +libnss_compat.so.2=${version}_1 +libnss_dns.so.2=${version}_1 +libnss_hesiod.so.2=${version}_1 +libcrypt.so.1=${version}_1 +libBrokenLocale.so.1=${version}_1 +libmemusage.so=${version}_1 +libSegFault.so=${version}_1 +libpcprofile.so=${version}_1 +libcidn.so.1=${version}_1 +libmvec.so.1=${version}_1 " case "$XBPS_TARGET_MACHINE" in - x86_64) shlibs+="ld-linux-x86-64.so.2 ${version}_1" ;; - i686) shlibs+="ld-linux.so.2 ${version}_1" ;; - armv5tel) shlibs+="ld-linux.so.3 ${version}_1" ;; - aarch64) shlibs+="ld-linux-aarch64.so.1 ${version}_1" ;; - ppc64) shlibs+="ld64.so.2 ${version}_1" ;; - mips) shlibs+="ld.so.1 ${version}_1" ;; - ppc) shlibs+="ld.so.1 ${version}_1" ;; + x86_64) shlibs+="ld-linux-x86-64.so.2=${version}_1" ;; + i686) shlibs+="ld-linux.so.2=${version}_1" ;; + armv5tel) shlibs+="ld-linux.so.3=${version}_1" ;; + aarch64) shlibs+="ld-linux-aarch64.so.1=${version}_1" ;; + ppc64) shlibs+="ld64.so.2=${version}_1" ;; + mips) shlibs+="ld.so.1=${version}_1" ;; + ppc) shlibs+="ld.so.1=${version}_1" ;; esac do_configure() { From 50495cf03661066204a906aa449290c94c228331 Mon Sep 17 00:00:00 2001 From: Michal Vasilek Date: Fri, 30 Dec 2022 18:20:37 +0100 Subject: [PATCH 10/10] musl: use = as a version separator --- srcpkgs/musl/template | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/srcpkgs/musl/template b/srcpkgs/musl/template index fb6bbc66fb0f..6aabd3a7e10a 100644 --- a/srcpkgs/musl/template +++ b/srcpkgs/musl/template @@ -17,7 +17,7 @@ checksum=1370c9a812b2cf2a7d92802510cca0058cc37e66a7bedd70051f0a34015022a3 nostrip_files="libc.so" shlib_provides="libc.so" -shlibs="libc.so 1.1.24_7" +shlibs="libc.so=1.1.24_7" post_build() { $CC $CFLAGS $LDFLAGS -fpie ${FILESDIR}/getent.c -o getent