From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <gentoo-commits+bounces-1693845-garchives=archives.gentoo.org@lists.gentoo.org>
Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature RSA-PSS (4096 bits))
	(No client certificate requested)
	by finch.gentoo.org (Postfix) with ESMTPS id BBEDD1581F3
	for <garchives@archives.gentoo.org>; Mon, 25 Nov 2024 03:41:53 +0000 (UTC)
Received: from pigeon.gentoo.org (localhost [127.0.0.1])
	by pigeon.gentoo.org (Postfix) with SMTP id 03F37E08F0;
	Mon, 25 Nov 2024 03:41:53 +0000 (UTC)
Received: from smtp.gentoo.org (woodpecker.gentoo.org [140.211.166.183])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256)
	(No client certificate requested)
	by pigeon.gentoo.org (Postfix) with ESMTPS id 94EF8E08F0
	for <gentoo-commits@lists.gentoo.org>; Mon, 25 Nov 2024 03:41:52 +0000 (UTC)
Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256)
	(No client certificate requested)
	by smtp.gentoo.org (Postfix) with ESMTPS id 60A2134301E
	for <gentoo-commits@lists.gentoo.org>; Mon, 25 Nov 2024 03:41:51 +0000 (UTC)
Received: from localhost.localdomain (localhost [IPv6:::1])
	by oystercatcher.gentoo.org (Postfix) with ESMTP id A9F42D81
	for <gentoo-commits@lists.gentoo.org>; Mon, 25 Nov 2024 03:41:49 +0000 (UTC)
From: "Matt Jolly" <kangie@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Content-Transfer-Encoding: 8bit
Content-type: text/plain; charset=UTF-8
Reply-To: gentoo-dev@lists.gentoo.org, "Matt Jolly" <kangie@gentoo.org>
Message-ID: <1732505962.8c365d501a904021cb0bd4b81d4bf7e4380702c5.kangie@gentoo>
Subject: [gentoo-commits] repo/gentoo:master commit in: dev-lang/rust/
X-VCS-Repository: repo/gentoo
X-VCS-Files: dev-lang/rust/rust-1.71.1-r100.ebuild dev-lang/rust/rust-1.74.1-r100.ebuild dev-lang/rust/rust-1.75.0-r100.ebuild dev-lang/rust/rust-1.77.1-r100.ebuild dev-lang/rust/rust-1.79.0-r100.ebuild dev-lang/rust/rust-1.80.1-r100.ebuild dev-lang/rust/rust-1.81.0-r100.ebuild dev-lang/rust/rust-1.82.0-r100.ebuild
X-VCS-Directories: dev-lang/rust/
X-VCS-Committer: kangie
X-VCS-Committer-Name: Matt Jolly
X-VCS-Revision: 8c365d501a904021cb0bd4b81d4bf7e4380702c5
X-VCS-Branch: master
Date: Mon, 25 Nov 2024 03:41:49 +0000 (UTC)
Precedence: bulk
List-Post: <mailto:gentoo-commits@lists.gentoo.org>
List-Help: <mailto:gentoo-commits+help@lists.gentoo.org>
List-Unsubscribe: <mailto:gentoo-commits+unsubscribe@lists.gentoo.org>
List-Subscribe: <mailto:gentoo-commits+subscribe@lists.gentoo.org>
List-Id: Gentoo Linux mail <gentoo-commits.gentoo.org>
X-BeenThere: gentoo-commits@lists.gentoo.org
X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply
X-Archives-Salt: c3e1c461-264a-4931-a94e-7127898678b1
X-Archives-Hash: 9f5b0e8d3ca1a44964e10f36756aba5b

commit:     8c365d501a904021cb0bd4b81d4bf7e4380702c5
Author:     Matt Jolly <kangie <AT> gentoo <DOT> org>
AuthorDate: Sat Nov 23 05:00:48 2024 +0000
Commit:     Matt Jolly <kangie <AT> gentoo <DOT> org>
CommitDate: Mon Nov 25 03:39:22 2024 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=8c365d50

dev-lang/rust: -r100: add postinst workaround for --keep-going

A bug in Portage's --keep-going option can cause it to fail to uninstall
non-slotted Rust files when resuming an interrupted upgrade. This results
in a broken Rust installation, preventing compilation and requiring manual
intervention.

We can work around this by deleting duplicate Rust libraries in postinst.

Bug: https://bugs.gentoo.org/943308
Signed-off-by: Matt Jolly <kangie <AT> gentoo.org>

 dev-lang/rust/rust-1.71.1-r100.ebuild | 37 +++++++++++++++++++++++++++++++++++
 dev-lang/rust/rust-1.74.1-r100.ebuild | 37 +++++++++++++++++++++++++++++++++++
 dev-lang/rust/rust-1.75.0-r100.ebuild | 37 +++++++++++++++++++++++++++++++++++
 dev-lang/rust/rust-1.77.1-r100.ebuild | 37 +++++++++++++++++++++++++++++++++++
 dev-lang/rust/rust-1.79.0-r100.ebuild | 37 +++++++++++++++++++++++++++++++++++
 dev-lang/rust/rust-1.80.1-r100.ebuild | 37 +++++++++++++++++++++++++++++++++++
 dev-lang/rust/rust-1.81.0-r100.ebuild | 37 +++++++++++++++++++++++++++++++++++
 dev-lang/rust/rust-1.82.0-r100.ebuild | 37 +++++++++++++++++++++++++++++++++++
 8 files changed, 296 insertions(+)

diff --git a/dev-lang/rust/rust-1.71.1-r100.ebuild b/dev-lang/rust/rust-1.71.1-r100.ebuild
index 18b1b9fe6fc5..78f8d663cf0d 100644
--- a/dev-lang/rust/rust-1.71.1-r100.ebuild
+++ b/dev-lang/rust/rust-1.71.1-r100.ebuild
@@ -624,7 +624,44 @@ src_install() {
 	fi
 }
 
+pkg_preinst() {
+	# 943308 and friends; basically --keep-going can forget to unmerge old rust
+	# but the soft blocker allows us to install conflicting files.
+	# This results in duplicated .{rlib,so} files which confuses rustc and results in
+	# the need for manual intervention.
+	if has_version -b "dev-lang/rust:stable/$(ver_cut 1-2)"; then
+		# we need to find all .{rlib,so} files in the old rust lib directory
+		# and store them in an array for later use
+		readarray -d '' old_rust_libs < <(
+			find "${EROOT}/usr/lib/rust/${PV}/lib/rustlib" \
+			-type f \( -name '*.rlib' -o -name '*.so' \) -print0)
+		export old_rust_libs
+		if [[ ${#old_rust_libs[@]} -gt 0 ]]; then
+			einfo "Found old .rlib and .so files in the old rust lib directory"
+		else
+			die "Found no old .rlib and .so files but old rust version is installed. Bailing!"
+		fi
+	fi
+}
+
 pkg_postinst() {
+
+	if has_version -b "dev-lang/rust:stable/$(ver_cut 1-2)"; then
+		# Be _extra_ careful here as we're removing files from the live filesystem
+		local f
+		for f in "${old_rust_libs[@]}"; do
+			[[ -f ${f} ]] || die "old_rust_libs array contains non-existent file"
+			local base_name="${f%-*}"
+			local ext="${f##*.}"
+			local matching_files=("${base_name}"-*.${ext})
+			if [[ ${#matching_files[@]} -ne 2 ]]; then
+				die "Expected exactly two files matching ${base_name}-\*.rlib, but found ${#matching_files[@]}"
+			fi
+			einfo "Removing old .rlib file ${f}"
+			rm "${f}" || die
+		done
+	fi
+
 	eselect rust update
 
 	if has_version dev-debug/gdb || has_version dev-debug/lldb; then

diff --git a/dev-lang/rust/rust-1.74.1-r100.ebuild b/dev-lang/rust/rust-1.74.1-r100.ebuild
index d446b5263782..7d362a51d3ed 100644
--- a/dev-lang/rust/rust-1.74.1-r100.ebuild
+++ b/dev-lang/rust/rust-1.74.1-r100.ebuild
@@ -654,7 +654,44 @@ src_install() {
 	fi
 }
 
+pkg_preinst() {
+	# 943308 and friends; basically --keep-going can forget to unmerge old rust
+	# but the soft blocker allows us to install conflicting files.
+	# This results in duplicated .{rlib,so} files which confuses rustc and results in
+	# the need for manual intervention.
+	if has_version -b "dev-lang/rust:stable/$(ver_cut 1-2)"; then
+		# we need to find all .{rlib,so} files in the old rust lib directory
+		# and store them in an array for later use
+		readarray -d '' old_rust_libs < <(
+			find "${EROOT}/usr/lib/rust/${PV}/lib/rustlib" \
+			-type f \( -name '*.rlib' -o -name '*.so' \) -print0)
+		export old_rust_libs
+		if [[ ${#old_rust_libs[@]} -gt 0 ]]; then
+			einfo "Found old .rlib and .so files in the old rust lib directory"
+		else
+			die "Found no old .rlib and .so files but old rust version is installed. Bailing!"
+		fi
+	fi
+}
+
 pkg_postinst() {
+
+	if has_version -b "dev-lang/rust:stable/$(ver_cut 1-2)"; then
+		# Be _extra_ careful here as we're removing files from the live filesystem
+		local f
+		for f in "${old_rust_libs[@]}"; do
+			[[ -f ${f} ]] || die "old_rust_libs array contains non-existent file"
+			local base_name="${f%-*}"
+			local ext="${f##*.}"
+			local matching_files=("${base_name}"-*.${ext})
+			if [[ ${#matching_files[@]} -ne 2 ]]; then
+				die "Expected exactly two files matching ${base_name}-\*.rlib, but found ${#matching_files[@]}"
+			fi
+			einfo "Removing old .rlib file ${f}"
+			rm "${f}" || die
+		done
+	fi
+
 	eselect rust update
 
 	if has_version dev-debug/gdb || has_version dev-debug/lldb; then

diff --git a/dev-lang/rust/rust-1.75.0-r100.ebuild b/dev-lang/rust/rust-1.75.0-r100.ebuild
index 40ab20831e94..6a5b34dda65a 100644
--- a/dev-lang/rust/rust-1.75.0-r100.ebuild
+++ b/dev-lang/rust/rust-1.75.0-r100.ebuild
@@ -656,7 +656,44 @@ src_install() {
 	fi
 }
 
+pkg_preinst() {
+	# 943308 and friends; basically --keep-going can forget to unmerge old rust
+	# but the soft blocker allows us to install conflicting files.
+	# This results in duplicated .{rlib,so} files which confuses rustc and results in
+	# the need for manual intervention.
+	if has_version -b "dev-lang/rust:stable/$(ver_cut 1-2)"; then
+		# we need to find all .{rlib,so} files in the old rust lib directory
+		# and store them in an array for later use
+		readarray -d '' old_rust_libs < <(
+			find "${EROOT}/usr/lib/rust/${PV}/lib/rustlib" \
+			-type f \( -name '*.rlib' -o -name '*.so' \) -print0)
+		export old_rust_libs
+		if [[ ${#old_rust_libs[@]} -gt 0 ]]; then
+			einfo "Found old .rlib and .so files in the old rust lib directory"
+		else
+			die "Found no old .rlib and .so files but old rust version is installed. Bailing!"
+		fi
+	fi
+}
+
 pkg_postinst() {
+
+	if has_version -b "dev-lang/rust:stable/$(ver_cut 1-2)"; then
+		# Be _extra_ careful here as we're removing files from the live filesystem
+		local f
+		for f in "${old_rust_libs[@]}"; do
+			[[ -f ${f} ]] || die "old_rust_libs array contains non-existent file"
+			local base_name="${f%-*}"
+			local ext="${f##*.}"
+			local matching_files=("${base_name}"-*.${ext})
+			if [[ ${#matching_files[@]} -ne 2 ]]; then
+				die "Expected exactly two files matching ${base_name}-\*.rlib, but found ${#matching_files[@]}"
+			fi
+			einfo "Removing old .rlib file ${f}"
+			rm "${f}" || die
+		done
+	fi
+
 	eselect rust update
 
 	if has_version dev-debug/gdb || has_version dev-debug/lldb; then

diff --git a/dev-lang/rust/rust-1.77.1-r100.ebuild b/dev-lang/rust/rust-1.77.1-r100.ebuild
index 372322af3e8f..2aa9d06c5418 100644
--- a/dev-lang/rust/rust-1.77.1-r100.ebuild
+++ b/dev-lang/rust/rust-1.77.1-r100.ebuild
@@ -655,7 +655,44 @@ src_install() {
 	fi
 }
 
+pkg_preinst() {
+	# 943308 and friends; basically --keep-going can forget to unmerge old rust
+	# but the soft blocker allows us to install conflicting files.
+	# This results in duplicated .{rlib,so} files which confuses rustc and results in
+	# the need for manual intervention.
+	if has_version -b "dev-lang/rust:stable/$(ver_cut 1-2)"; then
+		# we need to find all .{rlib,so} files in the old rust lib directory
+		# and store them in an array for later use
+		readarray -d '' old_rust_libs < <(
+			find "${EROOT}/usr/lib/rust/${PV}/lib/rustlib" \
+			-type f \( -name '*.rlib' -o -name '*.so' \) -print0)
+		export old_rust_libs
+		if [[ ${#old_rust_libs[@]} -gt 0 ]]; then
+			einfo "Found old .rlib and .so files in the old rust lib directory"
+		else
+			die "Found no old .rlib and .so files but old rust version is installed. Bailing!"
+		fi
+	fi
+}
+
 pkg_postinst() {
+
+	if has_version -b "dev-lang/rust:stable/$(ver_cut 1-2)"; then
+		# Be _extra_ careful here as we're removing files from the live filesystem
+		local f
+		for f in "${old_rust_libs[@]}"; do
+			[[ -f ${f} ]] || die "old_rust_libs array contains non-existent file"
+			local base_name="${f%-*}"
+			local ext="${f##*.}"
+			local matching_files=("${base_name}"-*.${ext})
+			if [[ ${#matching_files[@]} -ne 2 ]]; then
+				die "Expected exactly two files matching ${base_name}-\*.rlib, but found ${#matching_files[@]}"
+			fi
+			einfo "Removing old .rlib file ${f}"
+			rm "${f}" || die
+		done
+	fi
+
 	eselect rust update
 
 	if has_version dev-debug/gdb || has_version dev-debug/lldb; then

diff --git a/dev-lang/rust/rust-1.79.0-r100.ebuild b/dev-lang/rust/rust-1.79.0-r100.ebuild
index e1878c76dba4..392cc8f26840 100644
--- a/dev-lang/rust/rust-1.79.0-r100.ebuild
+++ b/dev-lang/rust/rust-1.79.0-r100.ebuild
@@ -658,7 +658,44 @@ src_install() {
 	fi
 }
 
+pkg_preinst() {
+	# 943308 and friends; basically --keep-going can forget to unmerge old rust
+	# but the soft blocker allows us to install conflicting files.
+	# This results in duplicated .{rlib,so} files which confuses rustc and results in
+	# the need for manual intervention.
+	if has_version -b "dev-lang/rust:stable/$(ver_cut 1-2)"; then
+		# we need to find all .{rlib,so} files in the old rust lib directory
+		# and store them in an array for later use
+		readarray -d '' old_rust_libs < <(
+			find "${EROOT}/usr/lib/rust/${PV}/lib/rustlib" \
+			-type f \( -name '*.rlib' -o -name '*.so' \) -print0)
+		export old_rust_libs
+		if [[ ${#old_rust_libs[@]} -gt 0 ]]; then
+			einfo "Found old .rlib and .so files in the old rust lib directory"
+		else
+			die "Found no old .rlib and .so files but old rust version is installed. Bailing!"
+		fi
+	fi
+}
+
 pkg_postinst() {
+
+	if has_version -b "dev-lang/rust:stable/$(ver_cut 1-2)"; then
+		# Be _extra_ careful here as we're removing files from the live filesystem
+		local f
+		for f in "${old_rust_libs[@]}"; do
+			[[ -f ${f} ]] || die "old_rust_libs array contains non-existent file"
+			local base_name="${f%-*}"
+			local ext="${f##*.}"
+			local matching_files=("${base_name}"-*.${ext})
+			if [[ ${#matching_files[@]} -ne 2 ]]; then
+				die "Expected exactly two files matching ${base_name}-\*.rlib, but found ${#matching_files[@]}"
+			fi
+			einfo "Removing old .rlib file ${f}"
+			rm "${f}" || die
+		done
+	fi
+
 	eselect rust update
 
 	if has_version dev-debug/gdb || has_version dev-debug/lldb; then

diff --git a/dev-lang/rust/rust-1.80.1-r100.ebuild b/dev-lang/rust/rust-1.80.1-r100.ebuild
index 9dbccd98b9a6..72080e2236fe 100644
--- a/dev-lang/rust/rust-1.80.1-r100.ebuild
+++ b/dev-lang/rust/rust-1.80.1-r100.ebuild
@@ -655,7 +655,44 @@ src_install() {
 	fi
 }
 
+pkg_preinst() {
+	# 943308 and friends; basically --keep-going can forget to unmerge old rust
+	# but the soft blocker allows us to install conflicting files.
+	# This results in duplicated .{rlib,so} files which confuses rustc and results in
+	# the need for manual intervention.
+	if has_version -b "dev-lang/rust:stable/$(ver_cut 1-2)"; then
+		# we need to find all .{rlib,so} files in the old rust lib directory
+		# and store them in an array for later use
+		readarray -d '' old_rust_libs < <(
+			find "${EROOT}/usr/lib/rust/${PV}/lib/rustlib" \
+			-type f \( -name '*.rlib' -o -name '*.so' \) -print0)
+		export old_rust_libs
+		if [[ ${#old_rust_libs[@]} -gt 0 ]]; then
+			einfo "Found old .rlib and .so files in the old rust lib directory"
+		else
+			die "Found no old .rlib and .so files but old rust version is installed. Bailing!"
+		fi
+	fi
+}
+
 pkg_postinst() {
+
+	if has_version -b "dev-lang/rust:stable/$(ver_cut 1-2)"; then
+		# Be _extra_ careful here as we're removing files from the live filesystem
+		local f
+		for f in "${old_rust_libs[@]}"; do
+			[[ -f ${f} ]] || die "old_rust_libs array contains non-existent file"
+			local base_name="${f%-*}"
+			local ext="${f##*.}"
+			local matching_files=("${base_name}"-*.${ext})
+			if [[ ${#matching_files[@]} -ne 2 ]]; then
+				die "Expected exactly two files matching ${base_name}-\*.rlib, but found ${#matching_files[@]}"
+			fi
+			einfo "Removing old .rlib file ${f}"
+			rm "${f}" || die
+		done
+	fi
+
 	eselect rust update
 
 	if has_version dev-debug/gdb || has_version dev-debug/lldb; then

diff --git a/dev-lang/rust/rust-1.81.0-r100.ebuild b/dev-lang/rust/rust-1.81.0-r100.ebuild
index 8d7100d336d7..54695b7209d5 100644
--- a/dev-lang/rust/rust-1.81.0-r100.ebuild
+++ b/dev-lang/rust/rust-1.81.0-r100.ebuild
@@ -659,7 +659,44 @@ src_install() {
 	fi
 }
 
+pkg_preinst() {
+	# 943308 and friends; basically --keep-going can forget to unmerge old rust
+	# but the soft blocker allows us to install conflicting files.
+	# This results in duplicated .{rlib,so} files which confuses rustc and results in
+	# the need for manual intervention.
+	if has_version -b "dev-lang/rust:stable/$(ver_cut 1-2)"; then
+		# we need to find all .{rlib,so} files in the old rust lib directory
+		# and store them in an array for later use
+		readarray -d '' old_rust_libs < <(
+			find "${EROOT}/usr/lib/rust/${PV}/lib/rustlib" \
+			-type f \( -name '*.rlib' -o -name '*.so' \) -print0)
+		export old_rust_libs
+		if [[ ${#old_rust_libs[@]} -gt 0 ]]; then
+			einfo "Found old .rlib and .so files in the old rust lib directory"
+		else
+			die "Found no old .rlib and .so files but old rust version is installed. Bailing!"
+		fi
+	fi
+}
+
 pkg_postinst() {
+
+	if has_version -b "dev-lang/rust:stable/$(ver_cut 1-2)"; then
+		# Be _extra_ careful here as we're removing files from the live filesystem
+		local f
+		for f in "${old_rust_libs[@]}"; do
+			[[ -f ${f} ]] || die "old_rust_libs array contains non-existent file"
+			local base_name="${f%-*}"
+			local ext="${f##*.}"
+			local matching_files=("${base_name}"-*.${ext})
+			if [[ ${#matching_files[@]} -ne 2 ]]; then
+				die "Expected exactly two files matching ${base_name}-\*.rlib, but found ${#matching_files[@]}"
+			fi
+			einfo "Removing old .rlib file ${f}"
+			rm "${f}" || die
+		done
+	fi
+
 	eselect rust update
 
 	if has_version dev-debug/gdb || has_version dev-debug/lldb; then

diff --git a/dev-lang/rust/rust-1.82.0-r100.ebuild b/dev-lang/rust/rust-1.82.0-r100.ebuild
index 63c8e27e3eaa..714ff39f1a8e 100644
--- a/dev-lang/rust/rust-1.82.0-r100.ebuild
+++ b/dev-lang/rust/rust-1.82.0-r100.ebuild
@@ -669,7 +669,44 @@ src_install() {
 	fi
 }
 
+pkg_preinst() {
+	# 943308 and friends; basically --keep-going can forget to unmerge old rust
+	# but the soft blocker allows us to install conflicting files.
+	# This results in duplicated .{rlib,so} files which confuses rustc and results in
+	# the need for manual intervention.
+	if has_version -b "dev-lang/rust:stable/$(ver_cut 1-2)"; then
+		# we need to find all .{rlib,so} files in the old rust lib directory
+		# and store them in an array for later use
+		readarray -d '' old_rust_libs < <(
+			find "${EROOT}/usr/lib/rust/${PV}/lib/rustlib" \
+			-type f \( -name '*.rlib' -o -name '*.so' \) -print0)
+		export old_rust_libs
+		if [[ ${#old_rust_libs[@]} -gt 0 ]]; then
+			einfo "Found old .rlib and .so files in the old rust lib directory"
+		else
+			die "Found no old .rlib and .so files but old rust version is installed. Bailing!"
+		fi
+	fi
+}
+
 pkg_postinst() {
+
+	if has_version -b "dev-lang/rust:stable/$(ver_cut 1-2)"; then
+		# Be _extra_ careful here as we're removing files from the live filesystem
+		local f
+		for f in "${old_rust_libs[@]}"; do
+			[[ -f ${f} ]] || die "old_rust_libs array contains non-existent file"
+			local base_name="${f%-*}"
+			local ext="${f##*.}"
+			local matching_files=("${base_name}"-*.${ext})
+			if [[ ${#matching_files[@]} -ne 2 ]]; then
+				die "Expected exactly two files matching ${base_name}-\*.rlib, but found ${#matching_files[@]}"
+			fi
+			einfo "Removing old .rlib file ${f}"
+			rm "${f}" || die
+		done
+	fi
+
 	eselect rust update
 
 	if has_version dev-debug/gdb || has_version dev-debug/lldb; then