-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathcheckpkg
executable file
·126 lines (115 loc) · 3.81 KB
/
checkpkg
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
#!/bin/bash
#
# checkpkg script for the vdr4arch project. Automatically executed by repo-make
# for every new package. Checks packages for common mistakes.
#
# To manually check repository, just call ./checkpkg
if [[ $1 == "--help" ]]; then
echo "Usage: ./checkpkg [PATH]"
exit
fi
if [[ -n $1 ]]; then
PACKAGES=$*
else
PACKAGES=$(find -name "*.pkg.tar.xz" -not -name "*-debug-*")
fi
echo "$PACKAGES" | while read PKG; do
#
# Namcap checks (optional). Some messages are filtered out for vdr4arch.
# Only namcap *Errors* make the script return with error status.
#
if which namcap >/dev/null 2>/dev/null; then
REPORT=$(namcap "$PKG" | grep -v \
-e "E: Symlink .*fonts.* points to non-existing" \
-e "W: Dependency included and not needed ('vdr-api')" \
-e "W: Dependency included and not needed ('linux')" \
-e "W: File name .* contains non standard characters" \
-e "E: File .* is owned by .*:\(vdr\|666\|kodi\|420\)" \
-e "E: Dependency .* detected .*/plugins/libxineliboutput-" \
-e "xineliboutput-frontends" \
-e "kodi-addon-graphlcd E: ELF file .* outside of a valid path" \
-e "dkms W: File (usr/src.* exists in a non-standard directory" \
-e "E: .* is not a valid SPDX license identifier.")
echo "$REPORT" >&2
if grep -q 'E:' <<<"$REPORT"; then
echo "namcap error in $PKG!" >&2
exit 1
fi
else
echo "WARNING: You should install namcap for automated package checks!" >&2
fi
#
# Prepare some variables for faster access in the following checks
#
FILELIST=$(bsdtar -tf "$PKG");
if [[ $? != 0 ]]; then exit 1; fi
INSTALL=$(bsdtar -xOf "$PKG" .INSTALL 2>/dev/null)
#
# If we package "var/lib/vdr" then we *have to* chown it to vdr:vdr!
#
bsdtar --numeric-owner -tvf "$PKG" | tr -s ' ' ' ' \
| grep -e 'var/lib/vdr' \
-e 'srv/vdr' \
-e 'var/cache/vdr' \
| grep -ve '666 666' \
| while read i; do
NAME=$(echo ${i} | cut -d' ' -f9)
UIDGID=$(echo ${i} | cut -d' ' -f3-4)
if grep -q \
-e 'var/lib/vdr' \
-e 'srv/vdr' \
-e 'var/cache/vdr' <<<"$NAME" &&
! [ ${UIDGID} = '666 666' ]; then
echo "chown for $NAME missing in $PKG!" >&2
exit 1
fi
done
#
# If a theme doesn't deliver its "default.theme", then we have to delete
# the auto-generated file while installation, so VDR creates an updated one.
#
if grep -q '^var/lib/vdr/themes/' <<<"$FILELIST" &&
! grep -q '^var/lib/vdr/themes/.*-default\.theme' <<<"$FILELIST" &&
! grep -q 'rm -f var/lib/vdr/themes/.*-default\.theme' <<<"$INSTALL"; then
echo "rm for default.theme missing in $PKG" >&2
exit 1
fi
#
# "Cache stuff" shouldn't be packaged
#
if grep -v '/$' <<<"$FILELIST" | grep -q '^var/cache/'; then
echo "Cache files shouldn't be part of $PKG!" >&2
exit 1
fi
#
# VDR plugin config file check
#
PLUGINLIST=$(sed -n 's#^usr/lib/vdr/plugins/libvdr-\(.*\)\.so\..*#\1#p' <<<"$FILELIST")
if [[ -n "$PLUGINLIST" ]]; then
while read PLUGIN; do
PLGCFGPATH=$(grep '^etc/vdr/conf.avail/[0-9]\+-'"$PLUGIN"'.conf$' <<<"$FILELIST")
if [[ -z "$PLGCFGPATH" ]]; then
echo "Config file for plugin $PLUGIN missing in $PKG!" >&2
exit 1
fi
PLGCFG=$(bsdtar -xOf "$PKG" "$PLGCFGPATH")
if ! grep -q '\['"$PLUGIN"'\]' <<<"$PLGCFG"; then
echo "Plugin name missing in config file for $PLUGIN in $PKG!" >&2
exit 1
fi
done <<<"$PLUGINLIST"
fi
#
# Backup array needed
#
PKGINFO=$(bsdtar -xOf "$PKG" .PKGINFO 2>/dev/null)
echo $FILELIST | grep -e '^etc' -e '^var/lib/vdr' \
| grep -v '/$' | grep -v '.theme$' \
| grep -v '.png$' \
| while read FILE; do
if ! grep -q ${FILE} <<<${PKGINFO}; then
echo "Backup entry needed for file $FILE";
exit 1
fi
done
done;