-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcheck
More file actions
executable file
·69 lines (62 loc) · 2.13 KB
/
Copy pathcheck
File metadata and controls
executable file
·69 lines (62 loc) · 2.13 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
#!/bin/bash
# ACR policy checks. Run from the repo root: ./check
# Validates every pkgs/<name>/PKGBUILD against the repository rules.
# 1. tracked-upstream source, by suffix (an optional trailing -sys is allowed):
# *-git[-sys] -> source must be a git+ VCS source
# *-rel[-sys] -> source must be a releases/download/ URL (a published git tag)
# any other pkgname suffix is rejected.
# 2. no .install pre/post scriptlets (no install= line, no *.install file)
# UNLESS the pkgname ends in -sys, which opts in to allowing them.
# 3. at least one '# Maintainer:' line
set -u
shopt -s nullglob
source "$(dirname "$0")/acrlib"
fail=0
checked=0
for pkgbuild in pkgs/*/PKGBUILD; do
dir=$(dirname "$pkgbuild")
name=$(basename "$dir")
[[ "$name" == "template" ]] && continue
checked=$((checked + 1))
# Rule 1: tracked-upstream source, validated against the pkgname suffix
pkgname=$(sed -n "s/^pkgname=//p" "$pkgbuild" | tr -d "'\"" | head -1)
case "$(acr_tier "$pkgname")" in
git)
if ! grep -qE '^[[:space:]]*source.*=.*git\+' "$pkgbuild"; then
echo "FAIL [$name]: -git package has no git+ VCS source"
fail=1
fi
;;
rel)
if ! grep -qE '^[[:space:]]*source.*=.*releases/download/' "$pkgbuild"; then
echo "FAIL [$name]: -rel package has no releases/download/ source"
fail=1
fi
;;
*)
echo "FAIL [$name]: pkgname '$pkgname' must end in -git or -rel (optionally + -sys)"
fail=1
;;
esac
# Rule 2: no install scriptlets, unless the pkgname opts in with a -sys suffix
if ! acr_is_sys "$pkgname"; then
if grep -qE '^[[:space:]]*install=' "$pkgbuild"; then
echo "FAIL [$name]: install= scriptlet declared in PKGBUILD (use a -sys suffix to allow)"
fail=1
fi
installs=("$dir"/*.install)
if (( ${#installs[@]} > 0 )); then
echo "FAIL [$name]: .install file present in recipe dir (use a -sys suffix to allow)"
fail=1
fi
fi
# Rule 3: at least one Maintainer line
if ! grep -qE '^#[[:space:]]*Maintainer:' "$pkgbuild"; then
echo "FAIL [$name]: missing '# Maintainer:' line"
fail=1
fi
done
if [[ $fail -eq 0 ]]; then
echo "ok: $checked package(s) pass ACR policy"
fi
exit $fail