-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathassert_sane_pkgdir.sh
More file actions
executable file
·87 lines (78 loc) · 2.59 KB
/
assert_sane_pkgdir.sh
File metadata and controls
executable file
·87 lines (78 loc) · 2.59 KB
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
#!/usr/bin/env bash
if [ -z "$PACKAGES_DIR" ]; then
PACKAGES_DIR=$(pwd)
echo "PACKAGES_DIR not set, defaulting to $PACKAGES_DIR (working directory)"
fi
FAILED=0
# check that the directory contains a PKGSCRIPT
function check_pkgscript() {
PKGSCRIPT="$PACKAGES_DIR/$1/PKGSCRIPT"
if [ ! -f "$PKGSCRIPT" ]; then
echo "$1: PKGSCRIPT not found!"
FAILED=1
fi
}
# check that the directory name, and the name provided by the PKGSCRIPT match
function check_package_name() {
DIRECTORY="$1"
PKGSCRIPT="$PACKAGES_DIR/$DIRECTORY/PKGSCRIPT"
eval "$(. "$PKGSCRIPT"; echo "NAME=$NAME")"
if [ "$DIRECTORY" != "$NAME" ]; then
echo "$1: directory name and package name (PKGSCRIPT) do not match: $DIRECTORY != $NAME"
FAILED=1
fi
}
# check that the directory contains a PKGINFO
function check_pkginfo() {
PKGINFO="$PACKAGES_DIR/$1/PKGINFO"
if [ ! -f "$PKGINFO" ]; then
echo "$1: PKGINFO not found!"
FAILED=1
fi
}
# check that PKGINFO has the same name as the directory
function check_pkginfo_name() {
DIRECTORY="$1"
PKGINFO="$PACKAGES_DIR/$DIRECTORY/PKGINFO"
GIVEN_NAME=$(cat "$PKGINFO" | grep name | awk '{print $2}' | grep -Po '[^\",]+' | head -n 1)
if [ "$DIRECTORY" != "$GIVEN_NAME" ]; then
echo "$1: directory name and package name (PKGINFO) do not match: $DIRECTORY != $GIVEN_NAME"
FAILED=1
fi
}
# check that the PKGSCRIPT's description isn't the iw description
# (nl80211 based CLI configuration utility for wireless devices.)
function check_iw_description() {
PKGSCRIPT="$PACKAGES_DIR/$1/PKGSCRIPT"
eval "$(. "$PKGSCRIPT"; echo "DESC=\"$DESC\"")"
if [ "$DESC" = "nl80211 based CLI configuration utility for wireless devices." ]; then
echo "$1: description is the iw description, please change it"
FAILED=1
fi
}
# for each directory in the packages directory, run above checks
echo "checking packages directory for sanity"
for DIRECTORY in "$PACKAGES_DIR"/*; do
if [ ! -d "$DIRECTORY" ]; then
continue
fi
DIRECTORY=$(basename "$DIRECTORY")
check_pkgscript "$DIRECTORY"
# make sure there's a PKGSCRIPT before running following checks
if [ -f "$PACKAGES_DIR/$DIRECTORY/PKGSCRIPT" ]; then
check_package_name "$DIRECTORY"
# don't run the iw description check on the iw package
if [ "$DIRECTORY" != "iw" ]; then
check_iw_description "$DIRECTORY"
fi
fi
check_pkginfo "$DIRECTORY"
# make sure there's a PKGINFO before running following checks
if [ -f "$PACKAGES_DIR/$DIRECTORY/PKGINFO" ]; then
check_pkginfo_name "$DIRECTORY"
fi
done
if [ "$FAILED" = "1" ]; then
echo "sanity check failed, please fix the above errors"
exit 1
fi