def merge_licenses()

in tools/build-release.py [0:0]


def merge_licenses(base_dir, repo_list):
    start = 202  # Apache License is 202 lines
    lic = os.path.join(base_dir, "LICENSE")
    if not os.path.isfile(lic):
        fail("license does not exist at top level staging directory")
    with open(lic, 'a') as lp:
        for repo_meta in repo_list:
            alias = repo_meta["alias"]
            lic_repo = os.path.join(os.path.join(base_dir, alias), "LICENSE")
            if not os.path.isfile(lic_repo):
                fail("license does not exist in '%s' repository" % alias)
            with open(lic_repo, 'r') as fp:
                lines = fp.readlines()
                if len(lines) <= start:
                    continue
                print("copying license details from: %s\n" % alias)
                i = start
                while i < len(lines):
                    lp.write(lines[i])
                    i += 1