Github messages for voidlinux
 help / color / mirror / Atom feed
From: sgn <sgn@users.noreply.github.com>
To: ml@inbox.vuxu.org
Subject: [PR PATCH] Attempt to track private API
Date: Sun, 26 Feb 2023 17:50:28 +0100	[thread overview]
Message-ID: <gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-42462@inbox.vuxu.org> (raw)

[-- Attachment #1: Type: text/plain, Size: 1252 bytes --]

There is a new pull request by sgn against master on the void-packages repository

https://github.com/sgn/void-packages attempt-to-track-private-api
https://github.com/void-linux/void-packages/pull/42462

Attempt to track private API
<!-- Uncomment relevant sections and delete options which are not applicable -->

#### Testing the changes
- I tested the changes in this PR: **NO**

<!--
#### New package
- This new package conforms to the [package requirements](https://github.com/void-linux/void-packages/blob/master/CONTRIBUTING.md#package-requirements): **YES**|**NO**
-->

<!-- Note: If the build is likely to take more than 2 hours, please add ci skip tag as described in
https://github.com/void-linux/void-packages/blob/master/CONTRIBUTING.md#continuous-integration
and test at least one native build and, if supported, at least one cross build.
Ignore this section if this PR is not skipping CI.
-->
<!--
#### Local build testing
- I built this PR locally for my native architecture, (ARCH-LIBC)
- I built this PR locally for these architectures (if supported. mark crossbuilds):
  - aarch64-musl
  - armv7l
  - armv6l-musl
-->


A patch file from https://github.com/void-linux/void-packages/pull/42462.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-attempt-to-track-private-api-42462.patch --]
[-- Type: text/x-diff, Size: 13178 bytes --]

From 0dc784539897ffc6dff65dc2b7459e9721072d94 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?=
 <congdanhqx@gmail.com>
Date: Sun, 26 Feb 2023 22:59:31 +0700
Subject: [PATCH 1/5] pre-pkg: shlib-provides virtual SONAME for private API

---
 common/hooks/pre-pkg/06-shlib-provides.sh | 23 +++++++++++++++++++----
 1 file changed, 19 insertions(+), 4 deletions(-)

diff --git a/common/hooks/pre-pkg/06-shlib-provides.sh b/common/hooks/pre-pkg/06-shlib-provides.sh
index a09eb6f5c3b3..2b7e0d77af4c 100644
--- a/common/hooks/pre-pkg/06-shlib-provides.sh
+++ b/common/hooks/pre-pkg/06-shlib-provides.sh
@@ -1,6 +1,16 @@
 # This hook executes the following tasks:
 #	- generates shlib-provides file for xbps-create(1)
 
+has_private_shlib() {
+	local f="$1" _soname="$2"
+	${OBJDUMP} -p "$f" | awk '
+		/^Version definitions:/{v=1}
+		!v{next}
+		/_PRIVATE_API/{ print "yes"; exit}
+		/^$/{exit}
+	'
+}
+
 collect_sonames() {
 	local _destdir="$1" f _soname _fname _pattern
 	local _pattern="^[[:alnum:]]+(.*)+\.so(\.[0-9]+)*$"
@@ -13,6 +23,7 @@ collect_sonames() {
 	fi
 
 	# real pkg
+	{
 	find ${_destdir} -type f -name "*.so*" | while read f; do
 		_fname="${f##*/}"
 		case "$(file -bi "$f")" in
@@ -25,19 +36,23 @@ collect_sonames() {
 			   [[ ${_soname} =~ ${_pattern} &&
 			   	( -e ${_destdir}/usr/lib/${_fname} ||
 				  -e ${_destdir}/usr/lib32/${_fname} ) ]]; then
-				echo "${_soname}" >> ${_tmpfile}
+				echo "${_soname}" >&3
 				echo "   SONAME ${_soname} from ${f##${_destdir}}"
+				if [ "$(has_private_shlib "$f")" ]; then
+					_private="private:$_soname:${libprivate:-${version}}"
+					echo "$_private" >&3
+				fi
 			fi
 			;;
 		esac
 	done
 
 	for f in ${shlib_provides}; do
-		echo "$f" >> ${_tmpfile}
+		echo "$f" >&3
 	done
+	} 3>${_tmpfile}
 	if [ -s "${_tmpfile}" ]; then
-		tr '\n' ' ' < "${_tmpfile}" > ${_destdir}/shlib-provides
-		echo >> ${_destdir}/shlib-provides
+		sort <${_tmpfile} | xargs >${_destdir}/shlib-provides
 	fi
 	rm -f ${_tmpfile}
 }

From 22fb2ba82d84cad5e9efeda0667ac1c68882ecbe Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?=
 <congdanhqx@gmail.com>
Date: Sun, 26 Feb 2023 23:01:50 +0700
Subject: [PATCH 2/5] pre-pkg/gen-runtime-deps: change TAB to 4 spaces

---
 common/hooks/pre-pkg/04-generate-runtime-deps.sh | 8 ++++----
 1 file changed, 4 insertions(+), 4 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..1eb18d9a92e5 100644
--- a/common/hooks/pre-pkg/04-generate-runtime-deps.sh
+++ b/common/hooks/pre-pkg/04-generate-runtime-deps.sh
@@ -71,10 +71,10 @@ hook() {
     exec < $depsftmp
     while read f; do
         lf=${f#${PKGDESTDIR}}
-	    if [ "${skiprdeps/${lf}/}" != "${skiprdeps}" ]; then
-		    msg_normal "Skipping dependency scan for ${lf}\n"
-		    continue
-	    fi
+        if [ "${skiprdeps/${lf}/}" != "${skiprdeps}" ]; then
+            msg_normal "Skipping dependency scan for ${lf}\n"
+            continue
+        fi
         read -n4 elfmagic < "$f"
         if [ "$elfmagic" = $'\177ELF' ]; then
             for nlib in $($OBJDUMP -p "$f"|awk '/NEEDED/{print $2}'); do

From 2835ebe5ca252d56ba8cc388c4f593815509ccfb Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?=
 <congdanhqx@gmail.com>
Date: Sun, 26 Feb 2023 23:28:12 +0700
Subject: [PATCH 3/5] pre-pkg/99-pkglint: factor out check_shlib function

---
 common/hooks/pre-pkg/99-pkglint.sh | 106 ++++++++++++++++-------------
 1 file changed, 57 insertions(+), 49 deletions(-)

diff --git a/common/hooks/pre-pkg/99-pkglint.sh b/common/hooks/pre-pkg/99-pkglint.sh
index a3ed816ed6ec..5c228ff3a4d7 100644
--- a/common/hooks/pre-pkg/99-pkglint.sh
+++ b/common/hooks/pre-pkg/99-pkglint.sh
@@ -1,8 +1,63 @@
 # This hook checks for common issues related to void.
 
+pkg_lint_check_shlib() {
+	local rev libname _shlib _pkgname _pattern
+	local filename="$1"
+	local mapshlibs=$XBPS_COMMONDIR/shlibs
+
+	rev=${filename#*.so.}
+	libname=${filename%.so*}
+	_shlib=$(echo "$libname"|sed -E 's|\+|\\+|g')
+	_pkgname=$(echo "$pkgname"|sed -E 's|\+|\\+|g')
+	if [ "$rev" = "$filename" ]; then
+		_pattern="^${_shlib}\.so[[:blank:]]+${_pkgname}-[^-]+_[0-9]+"
+	else
+		_pattern="^${_shlib}\.so\.[0-9]+(.*)[[:blank:]]+${_pkgname}-[^-]+_[0-9]+"
+	fi
+	grep -E "${_pattern}" $mapshlibs | { \
+		while read conflictFile conflictPkg ignore; do
+			found=1
+			conflictRev=${conflictFile#*.so.}
+			if [ -n "$ignore" -a "$ignore" != "$XBPS_TARGET_MACHINE" ]; then
+				continue
+			elif [ "$rev" = "$conflictRev" ]; then
+				continue
+			elif [[ ${rev}.* =~ $conflictRev ]]; then
+				continue
+			fi
+			msg_red "${pkgver}: SONAME bump detected: ${libname}.so.${conflictRev} -> ${libname}.so.${rev}\n"
+			msg_red "${pkgver}: please update common/shlibs with this line: \"${libname}.so.${rev} ${pkgver}\"\n"
+			msg_red "${pkgver}: all reverse dependencies should also be revbumped to be rebuilt against ${libname}.so.${rev}:\n"
+			_revdeps=$($XBPS_QUERY_XCMD -Rs ${libname}.so -p shlib-requires|cut -d ' ' -f1)
+			for x in ${_revdeps}; do
+				msg_red "   ${x%:}\n"
+			done
+			msg_error "${pkgver}: cannot continue with installation!\n"
+		done
+		# Try to match provided shlibs in virtual packages.
+		for f in ${provides}; do
+			_vpkgname="$($XBPS_UHELPER_CMD getpkgname ${f} 2>/dev/null)"
+			_spkgname="$(grep "^${filename}" $mapshlibs | cut -d ' ' -f2)"
+			_libpkgname="$($XBPS_UHELPER_CMD getpkgname ${_spkgname} 2>/dev/null)"
+			if [ -z "${_spkgname}" -o  -z "${_libpkgname}" ]; then
+				continue
+			fi
+			if [ "${_vpkgname}" = "${_libpkgname}" ]; then
+				found=1
+				break
+			fi
+		done;
+		if [ -z "$found" ]; then
+			_myshlib="${libname}.so"
+			[ "${_myshlib}" != "${rev}" ] && _myshlib+=".${rev}"
+			msg_normal "${pkgver}: ${_myshlib} not found in common/shlibs.\n"
+		fi;
+	}
+}
+
 hook() {
 	local error=0 filename= rev= libname= conflictPkg= conflictFile=
-	local conflictRev= ignore= found= mapshlibs=$XBPS_COMMONDIR/shlibs
+	local conflictRev= ignore= found=
 	local emptypkg=yes
 
 	set +E
@@ -161,53 +216,6 @@ hook() {
 	fi
 
 	for filename in $(<${PKGDESTDIR}/shlib-provides); do
-		rev=${filename#*.so.}
-		libname=${filename%.so*}
-		_shlib=$(echo "$libname"|sed -E 's|\+|\\+|g')
-		_pkgname=$(echo "$pkgname"|sed -E 's|\+|\\+|g')
-		if [ "$rev" = "$filename" ]; then
-			_pattern="^${_shlib}\.so[[:blank:]]+${_pkgname}-[^-]+_[0-9]+"
-		else
-			_pattern="^${_shlib}\.so\.[0-9]+(.*)[[:blank:]]+${_pkgname}-[^-]+_[0-9]+"
-		fi
-		grep -E "${_pattern}" $mapshlibs | { \
-			while read conflictFile conflictPkg ignore; do
-				found=1
-				conflictRev=${conflictFile#*.so.}
-				if [ -n "$ignore" -a "$ignore" != "$XBPS_TARGET_MACHINE" ]; then
-					continue
-				elif [ "$rev" = "$conflictRev" ]; then
-					continue
-				elif [[ ${rev}.* =~ $conflictRev ]]; then
-					continue
-				fi
-				msg_red "${pkgver}: SONAME bump detected: ${libname}.so.${conflictRev} -> ${libname}.so.${rev}\n"
-				msg_red "${pkgver}: please update common/shlibs with this line: \"${libname}.so.${rev} ${pkgver}\"\n"
-				msg_red "${pkgver}: all reverse dependencies should also be revbumped to be rebuilt against ${libname}.so.${rev}:\n"
-				_revdeps=$($XBPS_QUERY_XCMD -Rs ${libname}.so -p shlib-requires|cut -d ' ' -f1)
-				for x in ${_revdeps}; do
-					msg_red "   ${x%:}\n"
-				done
-				msg_error "${pkgver}: cannot continue with installation!\n"
-			done
-			# Try to match provided shlibs in virtual packages.
-			for f in ${provides}; do
-				_vpkgname="$($XBPS_UHELPER_CMD getpkgname ${f} 2>/dev/null)"
-				_spkgname="$(grep "^${filename}" $mapshlibs | cut -d ' ' -f2)"
-				_libpkgname="$($XBPS_UHELPER_CMD getpkgname ${_spkgname} 2>/dev/null)"
-				if [ -z "${_spkgname}" -o  -z "${_libpkgname}" ]; then
-					continue
-				fi
-				if [ "${_vpkgname}" = "${_libpkgname}" ]; then
-					found=1
-					break
-				fi
-			done;
-			if [ -z "$found" ]; then
-				_myshlib="${libname}.so"
-				[ "${_myshlib}" != "${rev}" ] && _myshlib+=".${rev}"
-				msg_normal "${pkgver}: ${_myshlib} not found in common/shlibs.\n"
-			fi;
-		}
+		pkg_lint_check_shlib "$filename"
 	done
 }

From 8db0d9f1212de66ebb349d3c04d79bd18b6652e3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?=
 <congdanhqx@gmail.com>
Date: Sun, 26 Feb 2023 23:44:45 +0700
Subject: [PATCH 4/5] pre-pkg/99-pkglint: check Private API changed

---
 common/hooks/pre-pkg/99-pkglint.sh | 34 +++++++++++++++++++++++++++++-
 1 file changed, 33 insertions(+), 1 deletion(-)

diff --git a/common/hooks/pre-pkg/99-pkglint.sh b/common/hooks/pre-pkg/99-pkglint.sh
index 5c228ff3a4d7..b08b2f4bf560 100644
--- a/common/hooks/pre-pkg/99-pkglint.sh
+++ b/common/hooks/pre-pkg/99-pkglint.sh
@@ -1,5 +1,32 @@
 # This hook checks for common issues related to void.
 
+pkg_lint_check_private_shlib() {
+	local _prefix _myshlib filename libname _failure
+	local mapshlibs=$XBPS_COMMONDIR/shlibs.private
+	local _shlib="$1"
+
+	filename="${_shlib%:*}"
+	libname=${filename%.so*}
+	_myshlib=$(grep "^${filename}:" "$XBPS_COMMONDIR/shlibs.private")
+	if [ -z "$_myshlib" ]; then
+		msg_normal "${pkgver}: ${_myshlib} not found in common/shlibs.private.\n"
+	elif [ "$_shlib" != "$_myshlib" ]; then
+		_failure=yes
+		_prefix="private:${libname}.so"
+		msg_red "${pkgver}: Private API change detected.\n"
+		msg_red "${pkgver}: Please update common/shlibs.private with:\n"
+		msg_red "${pkgver}:     ${filename}:${_shlib#*:}\n"
+		msg_red "${pkgver}: All reverse dependencies should also be revbumped to be rebuilt:\n"
+		_revdeps=$($XBPS_QUERY_XCMD -Rs ${_prefix} -p shlib-requires|cut -d: -f1)
+		for x in ${_revdeps}: do
+			msg_red "    ${x}\n"
+		done
+	fi
+	if [ "$_failure" ]; then
+		msg_error "${pkgver}: cannot continue with installation!\n"
+	fi
+}
+
 pkg_lint_check_shlib() {
 	local rev libname _shlib _pkgname _pattern
 	local filename="$1"
@@ -216,6 +243,11 @@ hook() {
 	fi
 
 	for filename in $(<${PKGDESTDIR}/shlib-provides); do
-		pkg_lint_check_shlib "$filename"
+		case "$filename" in
+		private:*)
+			pkg_lint_check_private_shlib "${filename#private:}" ;;
+		*)
+			pkg_lint_check_shlib "$filename" ;;
+		esac
 	done
 }

From 94bde55e854e2c849baf81dff4fc97bdbdc4253a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?=
 <congdanhqx@gmail.com>
Date: Sun, 26 Feb 2023 23:47:02 +0700
Subject: [PATCH 5/5] pre-pkg/gen-runtime-deps: generate private shlib requires
 too

---
 .../hooks/pre-pkg/04-generate-runtime-deps.sh | 36 +++++++++++++++++--
 common/shlibs.private                         |  2 ++
 2 files changed, 36 insertions(+), 2 deletions(-)
 create mode 100644 common/shlibs.private

diff --git a/common/hooks/pre-pkg/04-generate-runtime-deps.sh b/common/hooks/pre-pkg/04-generate-runtime-deps.sh
index 1eb18d9a92e5..1419a62a264e 100644
--- a/common/hooks/pre-pkg/04-generate-runtime-deps.sh
+++ b/common/hooks/pre-pkg/04-generate-runtime-deps.sh
@@ -45,8 +45,21 @@ store_pkgdestdir_rundeps() {
         fi
 }
 
+get_private_shlib() {
+    local f="$1"
+    $OBJDUMP -p "$f" |
+    awk '
+        /^Version References:/{ vr=1; next }
+        !vr { next }
+        /required from/{ lname=substr($NF, 1, length($NF)-1) }
+        /_PRIVATE_API/{ print lname }
+    '
+}
+
 hook() {
-    local depsftmp f lf j mapshlibs sorequires _curdep elfmagic broken_shlibs verify_deps
+    local depsftmp f lf j mapshlibs sorequires _curdep elfmagic
+    local nlib broken_shlibs verify_deps
+    local napi private_deps
 
     # 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
@@ -85,6 +98,10 @@ hook() {
                 done
                 [[ $found -eq 0 ]] && verify_deps="$verify_deps $nlib"
             done
+            napi="$(get_private_shlib "$f")"
+            if [ "$napi" ]; then
+                private_deps="$private_deps $napi"
+            fi
         fi
     done
     exec 0<&3 # restore stdin
@@ -165,7 +182,22 @@ hook() {
 
     store_pkgdestdir_rundeps
 
+    if [ -n "${private_deps}" ]; then
+        for x in ${private_deps}; do
+            if _rdep=$(grep "^${x}" "$XBPS_COMMONDIR/shlibs.private"); then
+                msg_red_nochroot " Untracked Private API: $_rdep\n"
+                broken_shlibs=1
+            else
+                _rdep="private:$_rdep"
+                sorequires="$sorequires $_rdep"
+            fi
+        done
+        if [ -n "$broken_shlibs" ]; then
+            msg_error "$pkgver: uses unknown private API, aborting!\n"
+        fi
+    fi
     if [ -n "${sorequires}" ]; then
-        echo "${sorequires}" | xargs -n1 | sort | xargs > ${PKGDESTDIR}/shlib-requires
+        echo "${sorequires}" |
+        xargs -n1 | sort | xargs > ${PKGDESTDIR}/shlib-requires
     fi
 }
diff --git a/common/shlibs.private b/common/shlibs.private
new file mode 100644
index 000000000000..e64f4954c481
--- /dev/null
+++ b/common/shlibs.private
@@ -0,0 +1,2 @@
+libQt5Core.so.5:5.15.7
+libQt6Core.so.6:6.4.2

             reply	other threads:[~2023-02-26 16:50 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-26 16:50 sgn [this message]
2023-02-27  6:46 ` [PR PATCH] [Updated] " sgn
2023-02-27 15:22 ` sgn
2023-03-05  8:23 ` classabbyamp
2023-03-09 16:18 ` [PR PATCH] [Updated] " sgn
2023-03-09 16:28 ` sgn
2023-03-09 16:55 ` sgn
2023-03-12 12:28 ` sgn
2023-03-16 11:25 ` sgn
2023-06-15  1:58 ` github-actions
2023-06-29  2:04 ` [PR PATCH] [Closed]: " github-actions

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-42462@inbox.vuxu.org \
    --to=sgn@users.noreply.github.com \
    --cc=ml@inbox.vuxu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).