blob: dc483518599516d64a476f086e45f230fdb29812 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
|
#!/usr/bin/sh
# remove rpath specified
rpathSuffix=(
"/home/abuild/rpmbuild/BUILD",
"/home/lkp/rpmbuild/BUILD"
)
rpath=(
"/usr/lib64",
"/lib64",
"/usr/lib",
"/lib",
"/usr/lib/../lib64"
)
buildroot=$1
function rpathChange()
{
localSrcPath=$1
localDstPath=""
rpathArr=(`echo $localSrcPath | tr ':' ' '`)
for path in ${rpathArr[*]}
do
localflag=0
for suffix in ${rpathSuffix[*]}
do
if echo "$path" | grep $suffix &> /dev/null; then
localflag=1
break
fi
done
# Is the suffix path, delete
if [ $localflag -eq 1 ]; then
continue;
fi
#Is the standard path, delete
if echo "${rpath[@]}" | grep -w $path &> /dev/null; then
continue
fi
if [ x"$localDstPath" == x"" ]; then
localDstPath=$path
else
localDstPath=$localDstPath:$path
fi
done
echo $localDstPath
}
function removeRpathOrRunpath()
{
localfile=$1
rpathInfo=$(chrpath -l $localfile | grep "RPATH=")
runpathInfo=$(chrpath -l $localfile | grep "RUNPATH=")
currPath=""
realPath=""
needCh=0
if [ x"$rpathInfo" != x"" ]; then
needCh=1
currPath=$(echo $rpathInfo | awk -F "RPATH=" '{print $2}')
realPath=$(rpathChange $currPath)
fi
if [ x"$runpathInfo" != x"" ]; then
needCh=1
currPath=$(echo $runpathInfo | awk -F "RUNPATH=" '{print $2}')
realPath=$(rpathChange $currPath)
fi
if [ $needCh -eq 0 ]; then
return 0
fi
if [ x"$realPath" == x"" ]; then
chrpath -d $localfile
else
chrpath -r $realPath $localfile
fi
return 0
}
for file in $(find $buildroot/ -executable -type f -exec file {} ';' | grep "\<ELF\>" | awk -F ':' '{print $1}')
do
test -u $file
if [ $? -eq 0 ]; then
continue
fi
if [ -w "$file" ]; then
removeRpathOrRunpath $file
fi
done
exit 0
|