about summary refs log tree commit diff
path: root/xlint
blob: 13033402892669b204ab739c5abd0d9a1d22962b (plain) (blame)
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
#!/bin/sh
# xlint TEMPLATE - scan XBPS template for common mistakes

scan() {
	local rx=$1 msg=$2 limit=${3:-1}
	grep -P -Hn -m$limit -e "$rx" "$template" |
		sed "s/^\([^:]*:[^:]*:\)\(.*\)/\1 $msg/"
}

variables=$(echo -n "#.*
_.*
.*_descr
.*_homedir
.*_shell
CFLAGS
CPPFLAGS
CXXFLAGS
LDFLAGS
XBPS_FETCH_COMMAND
bootstrap
broken
build_options
build_style
build_wrksrc
checksum
conf_files
configure_args
configure_script
conflicts
create_wrksrc
depends
desc_option_.*
disable_parallel_build
distfiles
dkms_modules
force_debug_pkgs
font_dirs
homepage
hostmakedepends
keep_libtool_archives
lib32disabled
lib32mode
license
maintainer
make_build_args
make_build_args
make_dirs
make_install_args
make_install_target
makedepends
mutable_files
noarch
nocross
nonfree
nostrip
nostrip_files
noverifyrdeps
only_for_archs
patch_args
pkgname
provides
pycompile_dirs
pycompile_module
pycompile_version
python_versions
register_shell
replaces
revision
sgml_entries
short_desc
skip_extraction
subpackages
system_accounts
system_groups
systemd_services
triggers
version
wrksrc
xml_entries" | tr '\n' '|')

for template; do
	scan 'short_desc=.*\."' "unwanted trailing dot in short_desc"
	scan 'short_desc=["'\''][a-z]' "short_desc should start uppercase"
	scan 'short_desc=["'\''].{72}' "short_desc should be less than 72 chars"
	scan 'license=.*GPL[^-]' "license GPL without version"
	scan 'vinstall.* usr/bin' "use vbin" -1
	scan 'vinstall.* usr/share/man' "use vman" -1
	scan 'vinstall.* usr/share/licenses' "use vlicense" -1
	scan '^  ' "indent with tabs"
	scan '[\t ]$' "trailing whitespace" -1
	scan '`' "use \$() instead of backticks" -1
	scan 'replaces=[^<>]*$' "replaces needs depname with version"
	scan 'conflicts=[^<>]*$' "conflicts needs depname with version"
	scan 'maintainer=(?!.*<.*@.*>).*' "maintainer needs email address"
	scan '^(?!\s*('"$variables"'))[^\s=-]+=' \
		"custom variables should use _ prefix: \2" -1
	scan '^[^ =]*=(""|''|)$' "variable set to empty string: \2" -1
done