2018-08-30 22:39:24 +00:00
|
|
|
#!/usr/bin/env python3
|
2021-01-07 23:16:08 +00:00
|
|
|
# Copyright 2021 Oliver Smith
|
2018-08-30 22:39:24 +00:00
|
|
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
2020-08-24 13:21:37 +00:00
|
|
|
import sys
|
2018-08-30 22:39:24 +00:00
|
|
|
|
2019-05-19 20:18:12 +00:00
|
|
|
# Same dir
|
|
|
|
import common
|
2018-08-30 22:39:24 +00:00
|
|
|
|
2020-08-24 13:21:37 +00:00
|
|
|
# pmbootstrap
|
|
|
|
import testcases.add_pmbootstrap_to_import_path
|
|
|
|
import pmb.parse
|
|
|
|
import pmb.parse._apkbuild
|
|
|
|
import pmb.helpers.pmaports
|
2018-08-30 22:39:24 +00:00
|
|
|
|
2020-08-24 13:21:37 +00:00
|
|
|
|
|
|
|
def build_strict(packages, arch):
|
2019-05-19 20:18:12 +00:00
|
|
|
common.run_pmbootstrap(["build_init"])
|
2021-03-10 09:08:22 +00:00
|
|
|
common.run_pmbootstrap(["--details-to-stdout", "--no-ccache", "build",
|
|
|
|
"--strict", "--force",
|
|
|
|
"--arch", arch, ] + list(packages))
|
2019-05-19 20:13:06 +00:00
|
|
|
|
2020-08-24 13:21:37 +00:00
|
|
|
|
|
|
|
def verify_checksums(packages, arch):
|
|
|
|
# Only do this with one build-{arch} job
|
|
|
|
arch_verify = "x86_64"
|
|
|
|
if arch != arch_verify:
|
|
|
|
print(f"NOTE: doing checksum verification in build-{arch_verify} job,"
|
|
|
|
" not here.")
|
|
|
|
return
|
|
|
|
|
2020-11-11 13:48:19 +00:00
|
|
|
if len(packages) == 0:
|
|
|
|
print("no packages changed, not doing any checksums verification")
|
|
|
|
return
|
|
|
|
|
2020-08-24 13:21:37 +00:00
|
|
|
common.run_pmbootstrap(["build_init"])
|
|
|
|
common.run_pmbootstrap(["--details-to-stdout", "checksum", "--verify"] +
|
|
|
|
list(packages))
|
2018-08-30 22:39:24 +00:00
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
2020-08-24 13:21:37 +00:00
|
|
|
# Architecture to build for (as in build-{arch})
|
|
|
|
if len(sys.argv) != 2:
|
|
|
|
print("usage: build_changed_aports.py ARCH")
|
|
|
|
sys.exit(1)
|
|
|
|
arch = sys.argv[1]
|
|
|
|
|
2019-02-09 21:22:41 +00:00
|
|
|
# Get and print modified packages
|
2019-05-19 20:18:12 +00:00
|
|
|
common.add_upstream_git_remote()
|
|
|
|
packages = common.get_changed_packages()
|
2019-02-09 21:22:41 +00:00
|
|
|
|
2020-08-24 13:21:37 +00:00
|
|
|
# Package count sanity check
|
2019-05-19 20:18:12 +00:00
|
|
|
common.get_changed_packages_sanity_check(len(packages))
|
2020-08-24 13:21:37 +00:00
|
|
|
|
|
|
|
# [ci:skip-build]: verify checksums and stop
|
|
|
|
verify_only = common.commit_message_has_string("[ci:skip-build]")
|
|
|
|
if verify_only:
|
|
|
|
print("WARNING: not building changed packages ([ci:skip-build])!")
|
|
|
|
print("verifying checksums: " + ", ".join(packages))
|
|
|
|
verify_checksums(packages, arch)
|
|
|
|
sys.exit(0)
|
|
|
|
|
|
|
|
# Prepare "args" to use pmbootstrap code
|
|
|
|
sys.argv = ["pmbootstrap", "chroot"]
|
|
|
|
args = pmb.parse.arguments()
|
|
|
|
|
|
|
|
# Filter out packages that can't be built for given arch
|
|
|
|
# (Iterate over copy of packages, because we modify it in this loop)
|
|
|
|
for package in packages.copy():
|
|
|
|
apkbuild_path = pmb.helpers.pmaports.find(args, package)
|
2021-11-27 14:08:36 +00:00
|
|
|
apkbuild = pmb.parse._apkbuild.apkbuild(f"{apkbuild_path}/APKBUILD")
|
2020-08-24 13:21:37 +00:00
|
|
|
|
|
|
|
if not pmb.helpers.pmaports.check_arches(apkbuild["arch"], arch):
|
|
|
|
print(f"{package}: not enabled for {arch}, skipping")
|
|
|
|
packages.remove(package)
|
|
|
|
|
|
|
|
# No packages: skip build
|
2018-08-30 22:39:24 +00:00
|
|
|
if len(packages) == 0:
|
2020-08-24 13:21:37 +00:00
|
|
|
print(f"no packages changed, which can be built for {arch}")
|
|
|
|
sys.exit(0)
|
|
|
|
|
|
|
|
# Build packages
|
|
|
|
print(f"building in strict mode for {arch}: {', '.join(packages)}")
|
|
|
|
build_strict(packages, arch)
|