Debian Codegraph @

debian/shuffle-binaries

raw
1 #!/bin/sh
2 set -e
3
4 version="$1"; shift
5
6 # We wrap all of the programs in /usr/bin with a script
7 # (xen-utils-wrapper) which chooses the version corresponding to the
8 # currently-running version of Xen. The actual binaries go
9 # in xen-utils-$version:usr/lib/xen-$version/bin
10 #
11 # We first have to figure out what libraries the binary is linked
12 # against. We then match against the libraries listed for inclusion
13 # here:
14 list=debian/libxenmiscV.install.vsn-in
15
16 t=debian/tmp
17 vd="/usr/lib/xen-$version/bin"
18 cd=/usr/lib/xen-common/bin
19
20 mkdir -p "$t/$vd"
21
22 find "$t"/usr/*bin -type f | while read binary; do
23 # filter for executables (ignore scripts)
24 file "$binary" | grep -q -eELF.\\+version.\\+interpreter || continue
25
26 reason=$(
27 strings "$binary" | grep -e^lib.\\+\\.so\\.\[.0-9\]\\+\$ | \
28 while read lib; do
29 lib=${lib%.so.*}
30 if grep -q -F "usr/lib/*/$lib.so.*" $list; then
31 printf " %s" "$lib"
32 fi
33 done
34 )
35
36 # if no reason, then skip
37 [ -n "$reason" ] || continue
38
39 echo "shuffling $binary$reason"
40
41 mv -v "$binary" "$t/$vd/"
42 ln -vs "$cd/xen-utils-wrapper" "$binary"
43
44 touch "$0.stamp"
45 done
46
47 if [ ! -e "$0.stamp" ]; then
48 echo "Failed to shuffle binaries!" 1>&2
49 exit 1
50 fi