summaryrefslogtreecommitdiff
path: root/dev-lang/rust/rust-1.75.0-r100.ebuild
diff options
context:
space:
mode:
authorMatt Jolly <kangie@gentoo.org>2024-11-23 15:00:48 +1000
committerMatt Jolly <kangie@gentoo.org>2024-11-25 13:39:22 +1000
commit8c365d501a904021cb0bd4b81d4bf7e4380702c5 (patch)
treecd920d01a00b86679f85508f9e48805c715bea83 /dev-lang/rust/rust-1.75.0-r100.ebuild
parent44b2f1af783f3e8b25f85da254ea2d1ed45cbb7e (diff)
downloadgentoo-8c365d501a904021cb0bd4b81d4bf7e4380702c5.tar.gz
gentoo-8c365d501a904021cb0bd4b81d4bf7e4380702c5.tar.bz2
gentoo-8c365d501a904021cb0bd4b81d4bf7e4380702c5.zip
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@gentoo.org>
Diffstat (limited to 'dev-lang/rust/rust-1.75.0-r100.ebuild')
-rw-r--r--dev-lang/rust/rust-1.75.0-r100.ebuild37
1 files changed, 37 insertions, 0 deletions
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