2023-01-22 18:11:10 +00:00
|
|
|
# Copyright 2023 Oliver Smith
|
2020-02-20 20:07:28 +00:00
|
|
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
new action: 'pmbootstrap repo_missing'
Add a new action that lists all aports, for which no binary packages
exist. Only list packages that can be built for the relevant arch
(specified with --arch). This works recursively: when a package can be
built for a certain arch, but one of its dependencies
(or their depends) can not be built for that arch, then don't list it.
This action will be used for the new sr.ht based build infrastructure,
to figure out which packages need to be built ahead of time (so we can
trigger each of them as single build job). Determining the order of the
packages to be built is not determined with pmbootstrap, the serverside
code of build.postmarketos.org takes care of that.
For testing purposes, a single package can also be specified and the
action will list if it can be built for that arch with its
dependencies, and what needs to be built exactly.
Add pmb/helpers/package.py to hold functions that work on both pmaports
and (binary package) repos - in contrary to the existing
pmb/helpers/pmaports.py (see previous commit) and pmb/helpers/repo.py,
which only work with one of those.
Refactoring:
* pmb/helpers/pmaports.py: add a get_list() function, which lists all
aports and use it instead of writing the same glob loop over and over
* add pmb.helpers.pmaports.get(), which finds an APKBUILD and parses it
in one step.
* rename pmb.build._package.check_arch to ...check_arch_abort to
distinguish it from the other check_arch function
2018-11-15 07:36:39 +00:00
|
|
|
import pytest
|
|
|
|
import sys
|
|
|
|
|
2020-02-20 19:14:38 +00:00
|
|
|
import pmb_test # noqa
|
new action: 'pmbootstrap repo_missing'
Add a new action that lists all aports, for which no binary packages
exist. Only list packages that can be built for the relevant arch
(specified with --arch). This works recursively: when a package can be
built for a certain arch, but one of its dependencies
(or their depends) can not be built for that arch, then don't list it.
This action will be used for the new sr.ht based build infrastructure,
to figure out which packages need to be built ahead of time (so we can
trigger each of them as single build job). Determining the order of the
packages to be built is not determined with pmbootstrap, the serverside
code of build.postmarketos.org takes care of that.
For testing purposes, a single package can also be specified and the
action will list if it can be built for that arch with its
dependencies, and what needs to be built exactly.
Add pmb/helpers/package.py to hold functions that work on both pmaports
and (binary package) repos - in contrary to the existing
pmb/helpers/pmaports.py (see previous commit) and pmb/helpers/repo.py,
which only work with one of those.
Refactoring:
* pmb/helpers/pmaports.py: add a get_list() function, which lists all
aports and use it instead of writing the same glob loop over and over
* add pmb.helpers.pmaports.get(), which finds an APKBUILD and parses it
in one step.
* rename pmb.build._package.check_arch to ...check_arch_abort to
distinguish it from the other check_arch function
2018-11-15 07:36:39 +00:00
|
|
|
import pmb.build.other
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture
|
|
|
|
def args(request):
|
|
|
|
import pmb.parse
|
|
|
|
sys.argv = ["pmbootstrap", "init"]
|
|
|
|
args = pmb.parse.arguments()
|
|
|
|
args.log = args.work + "/log_testsuite.txt"
|
|
|
|
pmb.helpers.logging.init(args)
|
2021-09-20 10:00:13 +00:00
|
|
|
request.addfinalizer(pmb.helpers.logging.logfd.close)
|
new action: 'pmbootstrap repo_missing'
Add a new action that lists all aports, for which no binary packages
exist. Only list packages that can be built for the relevant arch
(specified with --arch). This works recursively: when a package can be
built for a certain arch, but one of its dependencies
(or their depends) can not be built for that arch, then don't list it.
This action will be used for the new sr.ht based build infrastructure,
to figure out which packages need to be built ahead of time (so we can
trigger each of them as single build job). Determining the order of the
packages to be built is not determined with pmbootstrap, the serverside
code of build.postmarketos.org takes care of that.
For testing purposes, a single package can also be specified and the
action will list if it can be built for that arch with its
dependencies, and what needs to be built exactly.
Add pmb/helpers/package.py to hold functions that work on both pmaports
and (binary package) repos - in contrary to the existing
pmb/helpers/pmaports.py (see previous commit) and pmb/helpers/repo.py,
which only work with one of those.
Refactoring:
* pmb/helpers/pmaports.py: add a get_list() function, which lists all
aports and use it instead of writing the same glob loop over and over
* add pmb.helpers.pmaports.get(), which finds an APKBUILD and parses it
in one step.
* rename pmb.build._package.check_arch to ...check_arch_abort to
distinguish it from the other check_arch function
2018-11-15 07:36:39 +00:00
|
|
|
return args
|
|
|
|
|
|
|
|
|
|
|
|
def test_filter_missing_packages_invalid(args):
|
|
|
|
""" Test ...repo_missing.filter_missing_packages(): invalid package """
|
|
|
|
func = pmb.helpers.repo_missing.filter_missing_packages
|
|
|
|
with pytest.raises(RuntimeError) as e:
|
|
|
|
func(args, "armhf", ["invalid-package-name"])
|
|
|
|
assert str(e.value).startswith("Could not find aport")
|
|
|
|
|
|
|
|
|
|
|
|
def test_filter_missing_packages_binary_exists(args):
|
|
|
|
""" Test ...repo_missing.filter_missing_packages(): binary exists """
|
|
|
|
func = pmb.helpers.repo_missing.filter_missing_packages
|
|
|
|
assert func(args, "armhf", ["busybox"]) == []
|
|
|
|
|
|
|
|
|
|
|
|
def test_filter_missing_packages_pmaports(args, monkeypatch):
|
|
|
|
""" Test ...repo_missing.filter_missing_packages(): pmaports """
|
|
|
|
build_is_necessary = None
|
|
|
|
func = pmb.helpers.repo_missing.filter_missing_packages
|
|
|
|
|
|
|
|
def stub(args, arch, pmaport):
|
|
|
|
return build_is_necessary
|
|
|
|
monkeypatch.setattr(pmb.build, "is_necessary", stub)
|
|
|
|
|
|
|
|
build_is_necessary = True
|
|
|
|
assert func(args, "x86_64", ["busybox", "hello-world"]) == ["hello-world"]
|
|
|
|
|
|
|
|
build_is_necessary = False
|
|
|
|
assert func(args, "x86_64", ["busybox", "hello-world"]) == []
|
|
|
|
|
|
|
|
|
|
|
|
def test_filter_aport_packages(args):
|
|
|
|
""" Test ...repo_missing.filter_aport_packages() """
|
|
|
|
func = pmb.helpers.repo_missing.filter_aport_packages
|
|
|
|
assert func(args, "armhf", ["busybox", "hello-world"]) == ["hello-world"]
|
|
|
|
|
|
|
|
|
|
|
|
def test_filter_arch_packages(args, monkeypatch):
|
|
|
|
""" Test ...repo_missing.filter_arch_packages() """
|
|
|
|
func = pmb.helpers.repo_missing.filter_arch_packages
|
|
|
|
check_arch = None
|
|
|
|
|
2019-10-01 08:42:31 +00:00
|
|
|
def stub(args, arch, pmaport, binary=True):
|
new action: 'pmbootstrap repo_missing'
Add a new action that lists all aports, for which no binary packages
exist. Only list packages that can be built for the relevant arch
(specified with --arch). This works recursively: when a package can be
built for a certain arch, but one of its dependencies
(or their depends) can not be built for that arch, then don't list it.
This action will be used for the new sr.ht based build infrastructure,
to figure out which packages need to be built ahead of time (so we can
trigger each of them as single build job). Determining the order of the
packages to be built is not determined with pmbootstrap, the serverside
code of build.postmarketos.org takes care of that.
For testing purposes, a single package can also be specified and the
action will list if it can be built for that arch with its
dependencies, and what needs to be built exactly.
Add pmb/helpers/package.py to hold functions that work on both pmaports
and (binary package) repos - in contrary to the existing
pmb/helpers/pmaports.py (see previous commit) and pmb/helpers/repo.py,
which only work with one of those.
Refactoring:
* pmb/helpers/pmaports.py: add a get_list() function, which lists all
aports and use it instead of writing the same glob loop over and over
* add pmb.helpers.pmaports.get(), which finds an APKBUILD and parses it
in one step.
* rename pmb.build._package.check_arch to ...check_arch_abort to
distinguish it from the other check_arch function
2018-11-15 07:36:39 +00:00
|
|
|
return check_arch
|
2019-10-01 08:42:31 +00:00
|
|
|
monkeypatch.setattr(pmb.helpers.package, "check_arch", stub)
|
new action: 'pmbootstrap repo_missing'
Add a new action that lists all aports, for which no binary packages
exist. Only list packages that can be built for the relevant arch
(specified with --arch). This works recursively: when a package can be
built for a certain arch, but one of its dependencies
(or their depends) can not be built for that arch, then don't list it.
This action will be used for the new sr.ht based build infrastructure,
to figure out which packages need to be built ahead of time (so we can
trigger each of them as single build job). Determining the order of the
packages to be built is not determined with pmbootstrap, the serverside
code of build.postmarketos.org takes care of that.
For testing purposes, a single package can also be specified and the
action will list if it can be built for that arch with its
dependencies, and what needs to be built exactly.
Add pmb/helpers/package.py to hold functions that work on both pmaports
and (binary package) repos - in contrary to the existing
pmb/helpers/pmaports.py (see previous commit) and pmb/helpers/repo.py,
which only work with one of those.
Refactoring:
* pmb/helpers/pmaports.py: add a get_list() function, which lists all
aports and use it instead of writing the same glob loop over and over
* add pmb.helpers.pmaports.get(), which finds an APKBUILD and parses it
in one step.
* rename pmb.build._package.check_arch to ...check_arch_abort to
distinguish it from the other check_arch function
2018-11-15 07:36:39 +00:00
|
|
|
|
|
|
|
check_arch = False
|
|
|
|
assert func(args, "armhf", ["hello-world"]) == []
|
|
|
|
|
|
|
|
check_arch = True
|
|
|
|
assert func(args, "armhf", []) == []
|
|
|
|
|
|
|
|
|
|
|
|
def test_get_relevant_packages(args, monkeypatch):
|
|
|
|
""" Test ...repo_missing.get_relevant_packages() """
|
|
|
|
|
|
|
|
# Set up fake return values
|
2019-10-01 08:42:31 +00:00
|
|
|
stub_data = {"check_arch": False,
|
new action: 'pmbootstrap repo_missing'
Add a new action that lists all aports, for which no binary packages
exist. Only list packages that can be built for the relevant arch
(specified with --arch). This works recursively: when a package can be
built for a certain arch, but one of its dependencies
(or their depends) can not be built for that arch, then don't list it.
This action will be used for the new sr.ht based build infrastructure,
to figure out which packages need to be built ahead of time (so we can
trigger each of them as single build job). Determining the order of the
packages to be built is not determined with pmbootstrap, the serverside
code of build.postmarketos.org takes care of that.
For testing purposes, a single package can also be specified and the
action will list if it can be built for that arch with its
dependencies, and what needs to be built exactly.
Add pmb/helpers/package.py to hold functions that work on both pmaports
and (binary package) repos - in contrary to the existing
pmb/helpers/pmaports.py (see previous commit) and pmb/helpers/repo.py,
which only work with one of those.
Refactoring:
* pmb/helpers/pmaports.py: add a get_list() function, which lists all
aports and use it instead of writing the same glob loop over and over
* add pmb.helpers.pmaports.get(), which finds an APKBUILD and parses it
in one step.
* rename pmb.build._package.check_arch to ...check_arch_abort to
distinguish it from the other check_arch function
2018-11-15 07:36:39 +00:00
|
|
|
"depends_recurse": ["a", "b", "c", "d"],
|
|
|
|
"filter_arch_packages": ["a", "b", "c"],
|
|
|
|
"filter_aport_packages": ["b", "a"],
|
|
|
|
"filter_missing_packages": ["a"]}
|
|
|
|
|
2019-10-01 08:42:31 +00:00
|
|
|
def stub(args, arch, pmaport, binary=True):
|
|
|
|
return stub_data["check_arch"]
|
|
|
|
monkeypatch.setattr(pmb.helpers.package, "check_arch", stub)
|
new action: 'pmbootstrap repo_missing'
Add a new action that lists all aports, for which no binary packages
exist. Only list packages that can be built for the relevant arch
(specified with --arch). This works recursively: when a package can be
built for a certain arch, but one of its dependencies
(or their depends) can not be built for that arch, then don't list it.
This action will be used for the new sr.ht based build infrastructure,
to figure out which packages need to be built ahead of time (so we can
trigger each of them as single build job). Determining the order of the
packages to be built is not determined with pmbootstrap, the serverside
code of build.postmarketos.org takes care of that.
For testing purposes, a single package can also be specified and the
action will list if it can be built for that arch with its
dependencies, and what needs to be built exactly.
Add pmb/helpers/package.py to hold functions that work on both pmaports
and (binary package) repos - in contrary to the existing
pmb/helpers/pmaports.py (see previous commit) and pmb/helpers/repo.py,
which only work with one of those.
Refactoring:
* pmb/helpers/pmaports.py: add a get_list() function, which lists all
aports and use it instead of writing the same glob loop over and over
* add pmb.helpers.pmaports.get(), which finds an APKBUILD and parses it
in one step.
* rename pmb.build._package.check_arch to ...check_arch_abort to
distinguish it from the other check_arch function
2018-11-15 07:36:39 +00:00
|
|
|
|
|
|
|
def stub(args, arch, pmaport):
|
|
|
|
return stub_data["depends_recurse"]
|
|
|
|
monkeypatch.setattr(pmb.helpers.package, "depends_recurse", stub)
|
|
|
|
|
|
|
|
def stub(args, arch, pmaport):
|
|
|
|
return stub_data["filter_arch_packages"]
|
|
|
|
monkeypatch.setattr(pmb.helpers.repo_missing, "filter_arch_packages", stub)
|
|
|
|
|
|
|
|
def stub(args, arch, pmaport):
|
|
|
|
return stub_data["filter_aport_packages"]
|
|
|
|
monkeypatch.setattr(pmb.helpers.repo_missing, "filter_aport_packages",
|
|
|
|
stub)
|
|
|
|
|
|
|
|
def stub(args, arch, pmaport):
|
|
|
|
return stub_data["filter_missing_packages"]
|
|
|
|
monkeypatch.setattr(pmb.helpers.repo_missing, "filter_missing_packages",
|
|
|
|
stub)
|
|
|
|
|
|
|
|
# No given package
|
|
|
|
func = pmb.helpers.repo_missing.get_relevant_packages
|
|
|
|
assert func(args, "armhf") == ["a"]
|
|
|
|
assert func(args, "armhf", built=True) == ["a", "b"]
|
|
|
|
|
|
|
|
# Package can't be built for given arch
|
|
|
|
with pytest.raises(RuntimeError) as e:
|
|
|
|
func(args, "armhf", "a")
|
|
|
|
assert "can't be built" in str(e.value)
|
|
|
|
|
|
|
|
# Package can be built for given arch
|
2019-10-01 08:42:31 +00:00
|
|
|
stub_data["check_arch"] = True
|
new action: 'pmbootstrap repo_missing'
Add a new action that lists all aports, for which no binary packages
exist. Only list packages that can be built for the relevant arch
(specified with --arch). This works recursively: when a package can be
built for a certain arch, but one of its dependencies
(or their depends) can not be built for that arch, then don't list it.
This action will be used for the new sr.ht based build infrastructure,
to figure out which packages need to be built ahead of time (so we can
trigger each of them as single build job). Determining the order of the
packages to be built is not determined with pmbootstrap, the serverside
code of build.postmarketos.org takes care of that.
For testing purposes, a single package can also be specified and the
action will list if it can be built for that arch with its
dependencies, and what needs to be built exactly.
Add pmb/helpers/package.py to hold functions that work on both pmaports
and (binary package) repos - in contrary to the existing
pmb/helpers/pmaports.py (see previous commit) and pmb/helpers/repo.py,
which only work with one of those.
Refactoring:
* pmb/helpers/pmaports.py: add a get_list() function, which lists all
aports and use it instead of writing the same glob loop over and over
* add pmb.helpers.pmaports.get(), which finds an APKBUILD and parses it
in one step.
* rename pmb.build._package.check_arch to ...check_arch_abort to
distinguish it from the other check_arch function
2018-11-15 07:36:39 +00:00
|
|
|
assert func(args, "armhf", "a") == ["a"]
|
|
|
|
assert func(args, "armhf", "a", True) == ["a", "b"]
|
|
|
|
|
|
|
|
|
|
|
|
def test_generate_output_format(args, monkeypatch):
|
|
|
|
""" Test ...repo_missing.generate_output_format() """
|
|
|
|
|
2019-02-19 07:56:17 +00:00
|
|
|
def stub(args, pkgname, arch, replace_subpkgnames=False):
|
new action: 'pmbootstrap repo_missing'
Add a new action that lists all aports, for which no binary packages
exist. Only list packages that can be built for the relevant arch
(specified with --arch). This works recursively: when a package can be
built for a certain arch, but one of its dependencies
(or their depends) can not be built for that arch, then don't list it.
This action will be used for the new sr.ht based build infrastructure,
to figure out which packages need to be built ahead of time (so we can
trigger each of them as single build job). Determining the order of the
packages to be built is not determined with pmbootstrap, the serverside
code of build.postmarketos.org takes care of that.
For testing purposes, a single package can also be specified and the
action will list if it can be built for that arch with its
dependencies, and what needs to be built exactly.
Add pmb/helpers/package.py to hold functions that work on both pmaports
and (binary package) repos - in contrary to the existing
pmb/helpers/pmaports.py (see previous commit) and pmb/helpers/repo.py,
which only work with one of those.
Refactoring:
* pmb/helpers/pmaports.py: add a get_list() function, which lists all
aports and use it instead of writing the same glob loop over and over
* add pmb.helpers.pmaports.get(), which finds an APKBUILD and parses it
in one step.
* rename pmb.build._package.check_arch to ...check_arch_abort to
distinguish it from the other check_arch function
2018-11-15 07:36:39 +00:00
|
|
|
return {"pkgname": "hello-world", "version": "1.0-r0",
|
|
|
|
"depends": ["depend1", "depend2"]}
|
|
|
|
monkeypatch.setattr(pmb.helpers.package, "get", stub)
|
|
|
|
|
|
|
|
def stub(args, pkgname):
|
|
|
|
return "main"
|
|
|
|
monkeypatch.setattr(pmb.helpers.pmaports, "get_repo", stub)
|
|
|
|
|
|
|
|
func = pmb.helpers.repo_missing.generate_output_format
|
|
|
|
ret = [{"pkgname": "hello-world",
|
|
|
|
"repo": "main",
|
|
|
|
"version": "1.0-r0",
|
|
|
|
"depends": ["depend1", "depend2"]}]
|
|
|
|
assert func(args, "armhf", ["hello-world"]) == ret
|