-
Notifications
You must be signed in to change notification settings - Fork 0
/
check_symdiff.sh
executable file
·81 lines (58 loc) · 2.45 KB
/
check_symdiff.sh
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
#!/bin/bash
pkgloc=${1:-new-packages}
function check_diff(){
pkgfile=$1
pkgname=`pacman -Qp $1 | cut -f 1 -d ' '`
cat <<EOF >> symdiff.report.md
## Package \`$pkgname\`
EOF
if pacman -Si $pkgname 2>/dev/null > /dev/null ; then
oldpkg=$(mktemp)
oldpkgdir=$(mktemp -d)
newpkgdir=$(mktemp -d)
pacman -Sy
oldpkgurl=$(pacman -Sp $pkgname --noconfirm)
curl -sL "$oldpkgurl" --output $oldpkg
tar -C $newpkgdir -xf $1
tar -C $oldpkgdir -xf $oldpkg
echo "===================="
echo "newpkgdir: "
find $newpkgdir -name "*.so" -o -name "*.so.*" | sed "s@^$newpkgdir@@"
echo "oldpkgdir: "
find $oldpkgdir -name "*.so" -o -name "*.so.*" | sed "s@^$oldpkgdir@@"
echo "===================="
mkdir -p .$pkgname.sodiff.new .$pkgname.sodiff.old
for sofile in $(comm -12 <(find $newpkgdir -name "*.so" -o -name "*.so.*" | sed "s@^$newpkgdir@@") <(find $oldpkgdir -name "*.so" -o -name "*.so.*" | sed "s@^$oldpkgdir@@")); do
soname=`basename $newpkgdir/$sofile`
readelf -s $newpkgdir/$sofile | grep -v -e " UND " -e "^$" | tail -n "+3" | tr -s ' ' | cut -f 5,6,7,9 -d ' ' | sort > .$pkgname.sodiff.new/$soname.symlist
readelf -s $oldpkgdir/$sofile | grep -v -e " UND " -e "^S" | tail -n "+3" | tr -s ' ' | cut -f 5,6,7,9 -d ' ' | sort > .$pkgname.sodiff.old/$soname.symlist
echo "- $soname" >> symdiff.report.md
done
diff -rdN .$pkgname.sodiff.old .$pkgname.sodiff.new > .$pkgname.symchanges
if [ -s .$pkgname.symchanges ]; then
cat <<EOF >> symdiff.report.md
<details>
<summary>view diff (`tail -n+4 .$pkgname.symchanges | grep -e "^+" -e "^-" | wc -l` changes)</summary>
\`\`\`diff
`cat .$pkgname.symchanges`
\`\`\`
</details>
EOF
else
cat <<EOF >> symdiff.report.md
No changes, no symdiff reported.
EOF
fi
else
cat <<EOF >> symdiff.report.md
New package, no symdiff reported.
EOF
fi
}
export -f check_diff
cat <<EOF > symdiff.report.md
# Package symbols diff check report
EOF
pacman -Fy --noconfirm
pacman -Sy --noconfirm
find $pkgloc | grep '.pkg.' | xargs -I @ bash -c "check_diff @"