• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# 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
5 # For each installed *-dev package DEV
6 for DEV in $(dpkg --list | grep '^ii  [^ ]' | cut -d ' ' -f 3 | grep -P '\-dev($|\:amd64$)')
7 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
17
18        DEV_64_TARGET=$(readlink $DEV_64_SO)
19        DEV_64_TARGET_FULL=$(readlink -f $DEV_64_SO)
20
21        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/@')
24
25        # 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
34
35        # Create DEV_32_SO
36        sudo ln -s $DEV_32_TARGET $DEV_32_SO
37     done
38 done
39