summary refs log tree commit diff
path: root/xlint
blob: acbe3d20f2e3546f56e4384669e245725bf3e725 (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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
#!/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/" |
		grep . && ret=1
}

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_debug
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_target
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' '|')

ret=0
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=.*[^L]GPL[^-]' "license GPL without version"
	scan 'license=.*LGPL[^-]' "license LGPL 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
	scan 'distfiles=.*sourceforge\.net' 'use $SOURCEFORGE_SITE'
	scan 'distfiles=.*savannah.nongnu\.org' 'use $NONGNU_SITE'
	scan 'distfiles=.*archive\.ubuntu\.com' 'use $UBUNTU_SITE'
	scan 'distfiles=.*xorg\.freedesktop\.org' 'use $XORG_SITE'
	scan 'distfiles=.*debian\.org' 'use $DEBIAN_SITE'
	scan 'distfiles=.*gnome\.org/pub' 'use $GNOME_SITE'
	scan 'distfiles=.*www\.kernel\.org' 'use $KERNEL_SITE'
	scan 'distfiles=.*cpan\.org' 'use $CPAN_SITE'
	scan 'distfiles=.*pypi\.python\.org' 'use $PYPI_SITE'
	scan 'distfiles=.*ftp\.mozilla\.org' 'use $MOZILLA_SITE'
	scan 'distfiles=.*ftp\.gnu\.org/(pub/)?gnu' 'use $GNU_SITE'
	scan 'distfiles=.*freedesktop\.org/software' 'use $FREEDESKTOP_SITE'
done
exit $ret