-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcheck_pkgdiff.sh
executable file
·56 lines (40 loc) · 1.15 KB
/
check_pkgdiff.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
#!/bin/bash
pkgloc=${1:-new-packages}
function check_diff(){
pkgfile=$1
pkgname=`pacman -Qp $1 | cut -f 1 -d ' '`
cat <<EOF >> filediff.report.md
## Package \`$pkgname\`
`pacman -Qpl $1 | grep -v "$pkgname \." | wc -l` files and directories.
EOF
if pacman -Si $pkgname 2>/dev/null > /dev/null ; then
pacman -Qpl $1 | grep -v "$pkgname \." | sed "s@$pkgname /@@" | sort > .$pkgname.new.list
pacman -Fl $pkgname | grep -v -e "$pkgname \." | sed "s@$pkgname @@" | sort > .$pkgname.old.list
diff -dN .$pkgname.old.list .$pkgname.new.list > .$pkgname.changes
if [ -s .$pkgname.changes ]; then
cat <<EOF >> filediff.report.md
<details>
<summary>view diff (`tail -n+4 .$pkgname.changes | grep -e "^+" -e "^-" | wc -l` changes)</summary>
\`\`\`diff
`cat .$pkgname.changes`
\`\`\`
</details>
EOF
else
cat <<EOF >> filediff.report.md
No changes, no diff reported.
EOF
fi
else
cat <<EOF >> filediff.report.md
New package, no diff reported.
EOF
fi
}
export -f check_diff
cat <<EOF > filediff.report.md
# Package files diff check report
EOF
pacman -Fy --noconfirm
pacman -Sy --noconfirm
find $pkgloc | grep '.pkg.' | xargs -I @ bash -c "check_diff @"