summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'dev-lang/rust/rust-1.81.0-r100.ebuild')
-rw-r--r--dev-lang/rust/rust-1.81.0-r100.ebuild37
1 files changed, 37 insertions, 0 deletions
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