1*c8dee2aaSAndroid Build Coastguard Worker# Copyright 2013 Google Inc. All rights reserved. 2*c8dee2aaSAndroid Build Coastguard Worker# Use of this source code is governed by a BSD-style license that can be 3*c8dee2aaSAndroid Build Coastguard Worker# found in the LICENSE file. 4*c8dee2aaSAndroid Build Coastguard Worker 5*c8dee2aaSAndroid Build Coastguard Worker # For each installed *-dev package DEV 6*c8dee2aaSAndroid Build Coastguard Worker for DEV in $(dpkg --list | grep '^ii [^ ]' | cut -d ' ' -f 3 | grep -P '\-dev($|\:amd64$)') 7*c8dee2aaSAndroid Build Coastguard Worker do 8*c8dee2aaSAndroid Build Coastguard Worker # For each multi-arch *.so SO installed by DEV 9*c8dee2aaSAndroid Build Coastguard Worker for DEV_64_SO in $(dpkg -L $DEV | grep '/lib/x86_64-linux-gnu/.*\.so$') 10*c8dee2aaSAndroid Build Coastguard Worker do 11*c8dee2aaSAndroid Build Coastguard Worker # Skip if DEV_64_SO is not a symlink 12*c8dee2aaSAndroid Build Coastguard Worker if ! test -L $DEV_64_SO 13*c8dee2aaSAndroid Build Coastguard Worker then 14*c8dee2aaSAndroid Build Coastguard Worker echo "$DEV installed $DEV_64_SO which is real." 15*c8dee2aaSAndroid Build Coastguard Worker continue 16*c8dee2aaSAndroid Build Coastguard Worker fi 17*c8dee2aaSAndroid Build Coastguard Worker 18*c8dee2aaSAndroid Build Coastguard Worker DEV_64_TARGET=$(readlink $DEV_64_SO) 19*c8dee2aaSAndroid Build Coastguard Worker DEV_64_TARGET_FULL=$(readlink -f $DEV_64_SO) 20*c8dee2aaSAndroid Build Coastguard Worker 21*c8dee2aaSAndroid Build Coastguard Worker DEV_32_SO=$(echo $DEV_64_SO | sed -e 's@/lib/x86_64-linux-gnu/@/lib/i386-linux-gnu/@') 22*c8dee2aaSAndroid Build Coastguard Worker DEV_32_TARGET=$(echo $DEV_64_TARGET | sed -e 's@/lib/x86_64-linux-gnu/@/lib/i386-linux-gnu/@') 23*c8dee2aaSAndroid Build Coastguard Worker DEV_32_TARGET_FULL=$(echo $DEV_64_TARGET_FULL | sed -e 's@/lib/x86_64-linux-gnu/@/lib/i386-linux-gnu/@') 24*c8dee2aaSAndroid Build Coastguard Worker 25*c8dee2aaSAndroid Build Coastguard Worker # Error if DEV_32_TARGET does not exist. 26*c8dee2aaSAndroid Build Coastguard Worker if ! test -e $DEV_32_TARGET_FULL 27*c8dee2aaSAndroid Build Coastguard Worker then 28*c8dee2aaSAndroid Build Coastguard Worker DEV_64_TARGET_PKG=$(dpkg -S $DEV_64_TARGET_FULL | cut -d ':' -f 1) 29*c8dee2aaSAndroid Build Coastguard Worker echo "Could not find $DEV_32_TARGET_FULL, probably provided by $DEV_64_TARGET_PKG:i386." 30*c8dee2aaSAndroid Build Coastguard Worker #echo " $DEV_64_SO -> $DEV_64_TARGET ($DEV_64_TARGET_FULL)" 31*c8dee2aaSAndroid Build Coastguard Worker #echo " $DEV_32_SO -> $DEV_32_TARGET ($DEV_32_TARGET_FULL)" 32*c8dee2aaSAndroid Build Coastguard Worker continue 33*c8dee2aaSAndroid Build Coastguard Worker fi 34*c8dee2aaSAndroid Build Coastguard Worker 35*c8dee2aaSAndroid Build Coastguard Worker # Create DEV_32_SO 36*c8dee2aaSAndroid Build Coastguard Worker sudo ln -s $DEV_32_TARGET $DEV_32_SO 37*c8dee2aaSAndroid Build Coastguard Worker done 38*c8dee2aaSAndroid Build Coastguard Worker done 39