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
|
#!/usr/bin/env python3
from argparse import ArgumentParser
from pathlib import Path
from subprocess import run
def prepare_package() -> None:
"""Prepare a package
"""
install_file = Path('./debian/install')
install_data = 'obj-*-linux-gnu/gwlbtun usr/sbin'
install_file.touch()
install_file.write_text(install_data)
def build_package(package_name: str, package_ver: str) -> bool:
"""Build a package using commands from external file
Args:
package_name (str): package name
package_ver (str): package version
Returns:
bool: build status
"""
# prepare sources
debmake_cmd = [
'debmake', '-e', 'support@vyos.io', '-f', 'VyOS Support', '-p',
package_name, '-u', package_ver, '-t'
]
run(debmake_cmd)
prepare_package()
# build a package
run('debuild')
return True
# build a package
if __name__ == '__main__':
# prepare argument parser
arg_parser = ArgumentParser()
arg_parser.add_argument('--package',
required=True,
help='Package name to build')
arg_parser.add_argument('--version',
required=True,
help='Version for the package')
args = arg_parser.parse_args()
if not build_package(args.package, args.version):
exit(1)
exit()
|