media-sound/apulse: Fix ebuild and script to support all ABIs
authorDaniel Campbell <zlg@gentoo.org>
Thu, 27 Aug 2015 07:25:49 +0000 (00:25 -0700)
committerDaniel Campbell <zlg@gentoo.org>
Thu, 27 Aug 2015 07:25:49 +0000 (00:25 -0700)
Prior solution was over-engineered and didn't cover all cases.
Thanks mgorny and jcallen for the assistance.

Gentoo-Bug: 547524

Package-Manager: portage-2.2.20.1

media-sound/apulse/apulse-0.1.6-r1.ebuild
media-sound/apulse/files/apulse

index 2f68179ace9df4a54d05ce8eb72624d0455e58ed..8324b905461999750de5e18f4a2fcbfee9673281 100644 (file)
@@ -25,9 +25,15 @@ multilib_src_configure() {
        local mycmakeargs="-DAPULSEPATH=${EPREFIX}/usr/$(get_libdir)/apulse"
 
        cmake-utils_src_configure
+
+       # Ensure all relevant libdirs are added
+       DIRS=
+       _add_dir() { DIRS="${EPREFIX}/usr/$(get_libdir)/apulse${DIRS:+:${DIRS}}"; }
+       multilib_foreach_abi _add_dir
+       sed -e "s#@@DIRS@@#${DIRS}#g" "${FILESDIR}"/apulse > "${T}"/apulse
 }
 
 multilib_src_install() {
        cmake-utils_src_install
-       dobin "${FILESDIR}"/apulse
+       dobin "${T}"/apulse
 }
index f4195651bc92cc95c10ca6751cea28aad3d69f6b..32633b2d9a5004f3828628059512084c6a15463d 100755 (executable)
@@ -9,32 +9,6 @@ if [ $# -lt 1 ]; then
        exit
 fi
 
-# Get the full path of our application
-app_path=$(which ${1} 2>/dev/null)
-
-# The app might not be picked up by `which`, so let's use realpath as a backup
-[ -z ${app_path} ] && app_path=$(realpath ${1})
-
-# Then make sure it's executable
-[ ! -x ${app_path} ] && echo "${app_path} is not executable!" && exit 8
-
-# Fetch the app's ABI
-app_abi=$(file -L ${app_path} | sed 's/\([^,]*\), \([^,]*\), \(.*\)/\2/')
-
-# Determine libdir based on app_abi
-# Applications that don't have a header will default to native libdir
-case $app_abi in
-       Intel\ 80386)
-               APULSE_ABI="32"
-               ;;
-       x86-64)
-               APULSE_ABI="64"
-               ;;
-       *)
-               APULSE_ABI=$(readlink /usr/lib)
-               APULSE_ABI=${APULSE_ABI#lib}
-               ;;
-esac
-
-# Set library path for the application so it'll use apulse
-LD_LIBRARY_PATH=/usr/lib${APULSE_ABI}/apulse${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH} exec "$@"
+# Set library path for the application so it'll use apulse. DIRS is
+# replaced by the ebuild to include the correct paths
+LD_LIBRARY_PATH=@@DIRS@@${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH} exec "$@"