case "$ARCH" in
	armv7hf|armv6hf)
		SPIRALARCH="armhf"
		;;
	armv4)
		SPIRALARCH="armel"
		;;
	i486)
		SPIRALARCH="i386"
		;;
	loongarch64|loongarch64_nosimd)
		# Well ...
		SPIRALARCH="loong64 loongarch64"
		;;
	loongson2f|loongson3)
		SPIRALARCH="mips64el"
		;;
	*)
		SPIRALARCH="$ARCH"
		;;
esac

abinfo "Finding libraries to create Sprial provides for ..."
declare -A __SONAMES
for file in $(find "$PKGDIR"/usr/lib -type l) ; do
	p=/usr/lib/"$(readlink $file)"
	_soname="$(objdump -p "$p" | grep SONAME | awk '{ print $2 }')"
	if [ -z "$_soname" ] ; then
		# This library does not have sonames
		continue
	fi
	# Use a hash table to easily dedup
	__SONAMES[$_soname]="$_soname"
done

for soname in "${__SONAMES[@]}" ; do
	# Do NOT add quotes here.
	# We need to add two Spiral provides for LoongArch64, for
	# obvious reasons.
	for arch in $SPIRALARCH ; do
		__AB_SONAMES_MANUADD+=("$soname:$arch")
	done
done

IFS=$'\n'
abinfo "Collected SONAMEs:"
echo "${__SONAMES[*]}"
unset IFS

# Set to __AB_SONAMES_MANUADD for later processing.
__AB_SONAMES_MANUADD=("${__SONAMES[@]}")
