blob: 47786de2bcc1ecb2baf45d01c5a2c508abb64558 [file] [log] [blame]
Ben Wagner63fd7602017-10-09 15:45:33 -04001# Copyright 2013 Google Inc. All rights reserved.
2# Use of this source code is governed by a BSD-style license that can be
3# found in the LICENSE file.
4
Mike Klein7e80c882015-02-03 10:43:28 -05005 # For each installed *-dev package DEV
Ben Wagner22499b02017-11-09 16:47:13 -05006 for DEV in $(dpkg --list | grep '^ii [^ ]' | cut -d ' ' -f 3 | grep -P '\-dev($|\:amd64$)')
Mike Klein7e80c882015-02-03 10:43:28 -05007 do
8 # For each multi-arch *.so SO installed by DEV
9 for DEV_64_SO in $(dpkg -L $DEV | grep '/lib/x86_64-linux-gnu/.*\.so$')
10 do
11 # Skip if DEV_64_SO is not a symlink
12 if ! test -L $DEV_64_SO
13 then
14 echo "$DEV installed $DEV_64_SO which is real."
15 continue
16 fi
Ben Wagner63fd7602017-10-09 15:45:33 -040017
Mike Klein7e80c882015-02-03 10:43:28 -050018 DEV_64_TARGET=$(readlink $DEV_64_SO)
Ben Wagner63fd7602017-10-09 15:45:33 -040019 DEV_64_TARGET_FULL=$(readlink -f $DEV_64_SO)
20
Mike Klein7e80c882015-02-03 10:43:28 -050021 DEV_32_SO=$(echo $DEV_64_SO | sed -e 's@/lib/x86_64-linux-gnu/@/lib/i386-linux-gnu/@')
22 DEV_32_TARGET=$(echo $DEV_64_TARGET | sed -e 's@/lib/x86_64-linux-gnu/@/lib/i386-linux-gnu/@')
23 DEV_32_TARGET_FULL=$(echo $DEV_64_TARGET_FULL | sed -e 's@/lib/x86_64-linux-gnu/@/lib/i386-linux-gnu/@')
Ben Wagner63fd7602017-10-09 15:45:33 -040024
Mike Klein7e80c882015-02-03 10:43:28 -050025 # Error if DEV_32_TARGET does not exist.
26 if ! test -e $DEV_32_TARGET_FULL
27 then
28 DEV_64_TARGET_PKG=$(dpkg -S $DEV_64_TARGET_FULL | cut -d ':' -f 1)
29 echo "Could not find $DEV_32_TARGET_FULL, probably provided by $DEV_64_TARGET_PKG:i386."
30 #echo " $DEV_64_SO -> $DEV_64_TARGET ($DEV_64_TARGET_FULL)"
31 #echo " $DEV_32_SO -> $DEV_32_TARGET ($DEV_32_TARGET_FULL)"
32 continue
33 fi
Ben Wagner63fd7602017-10-09 15:45:33 -040034
Mike Klein7e80c882015-02-03 10:43:28 -050035 # Create DEV_32_SO
36 sudo ln -s $DEV_32_TARGET $DEV_32_SO
37 done
38 done