-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbuildsrc
More file actions
executable file
·65 lines (55 loc) · 1.77 KB
/
buildsrc
File metadata and controls
executable file
·65 lines (55 loc) · 1.77 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
#!/usr/bin/python3
"""Build TurnKey Webmin deb packages from upstream Webmin tarballs"""
import argparse
import sys
from typing import NoReturn
from buildsrc_lib import CTRL_FILE, Webmin, WebminUpdateError
def fatal(msg: str | WebminUpdateError) -> NoReturn:
print(msg, file=sys.stderr)
sys.exit(1)
def main() -> None:
parser = argparse.ArgumentParser()
# TODO
# - support building specific version
# - support building pre-release version
parser.add_argument(
"-c",
"--control-file",
default=CTRL_FILE,
help=f"path to control file (default: {CTRL_FILE})",
)
parser.add_argument(
"-u",
"--update-check",
action="store_true",
help="just check for newer version; if new version exit 0,"
" otherwise exit 100",
)
parser.add_argument(
"-V",
"--build-version",
default="latest",
help="version to build (default: 'latest')",
)
parser.add_argument(
"-f", "--force", action="store_true", help="force actions"
)
parser.add_argument(
"-q", "--quiet", action="store_true", help="minimise output"
)
args = parser.parse_args()
try:
webmin = Webmin(force=args.force, quiet=args.quiet)
if args.update_check:
# if check_only=True, method will exit with appropriate exit code
webmin.new_version(check_only=True)
else:
updated = webmin.update(version=args.build_version)
if updated:
webmin.write_control(control_file=args.control_file)
if not args.quiet:
print("Double check changes, commit and rebuild packages")
except WebminUpdateError as e:
fatal(e)
if __name__ == "__main__":
main()