aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/obs/build_srcpkg.py
blob: 86655f593af047f7922283673f84cc422df047a0 (plain)
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
#!/usr/bin/env python3
# SPDX-License-Identifier: GPL-2.0-or-later
# Copyright 2022 sysmocom - s.f.m.c. GmbH <info@sysmocom.de>
import argparse
import sys
import lib
import lib.config
import lib.docker
import lib.git
import lib.metapkg
import lib.srcpkg


def main():
    parser = argparse.ArgumentParser(
        description="Clone the git repository and build the debian source"
                    " package as well as an rpm .spec file. This is the same"
                    " code that runs to generate source packages which we"
                    " upload to https://obs.osmocom.org."
                    f" Output dir: {lib.config.path_temp}/srcpkgs")
    groups = lib.add_shared_arguments(parser)
    groups["git"].add_argument("-g", "--gerrit-id", type=int, default=0,
        help="clone particular revision from gerrit using given ID")
    parser.add_argument("package", nargs="?",
                        help="package name, e.g. libosmocore or open5gs")
    args = parser.parse_args()

    if not args.meta and not args.package:
        print("ERROR: specify -m and/or a package. See -h for help.")
        sys.exit(1)

    lib.set_args(args)

    if args.docker:
        lib.docker.run_in_docker_and_exit("build_srcpkg.py")

    if not args.ignore_req:
        lib.check_required_programs()

    if args.package:
        args.package = lib.set_proper_package_name(args.package)
    lib.remove_temp()

    if args.meta:
        lib.metapkg.build()

    if args.package:
        lib.srcpkg.build(args.package, args.gerrit_id)


if __name__ == "__main__":
    main()