chiark / gitweb /
php: Update from 7.2.4 to 7.2.5
[termux-packages] / scripts / lint-packages.py
1 #!/usr/bin/env python3
2
3 import os
4 import re
5 import sys
6
7 def main():
8     package_dir = 'packages'
9     for pkgdir_name in sorted(os.listdir(package_dir)):
10         dir_path = package_dir + '/' + pkgdir_name
11         build_sh_path = dir_path + '/build.sh'
12         if not os.path.isfile(build_sh_path):
13             sys.exit('No build.sh file in: ' + pkgdir_name)
14         with open(build_sh_path) as build_sh:
15             lines = build_sh.readlines()
16         validate_package(pkgdir_name, lines)
17
18 def validate_package(package_name, lines):
19     if len(lines) < 3:
20         print('Too few lines in package: ' + package_name)
21         return
22     if not lines[0].startswith('TERMUX_PKG_HOMEPAGE='):
23         print('The first line is not TERMUX_PKG_HOMEPAGE: ' + package_name)
24     if not lines[1].startswith('TERMUX_PKG_DESCRIPTION='):
25         print('The second line is not TERMUX_PKG_DESCRIPTION: ' + package_name)
26
27     line_number = 1
28     for line in lines:
29         if line.endswith(' \n'):
30             print(package_name + ': Line ' + str(line_number) + ' has trailing whitespace')
31         if line.startswith('TERMUX_PKG_REVISION='):
32             value = line[len('TERMUX_PKG_REVISION='):].strip()
33             if not re.match('[0-9]+', value):
34                 print(package_name + ': strange TERMUX_PKG_REVISION value "' + value + '"')
35
36         line_number += 1
37
38 if __name__ == '__main__':
39     main()