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
|
2017-05-26 20:08:45 +00:00
|
|
|
import os
|
|
|
|
import sys
|
|
|
|
import pytest
|
2019-11-10 10:20:00 +00:00
|
|
|
import shutil
|
2017-05-26 20:08:45 +00:00
|
|
|
import filecmp
|
|
|
|
|
2020-02-20 19:14:38 +00:00
|
|
|
import pmb_test
|
|
|
|
import pmb_test.const
|
2017-05-26 20:08:45 +00:00
|
|
|
import pmb.aportgen
|
2018-09-05 05:57:38 +00:00
|
|
|
import pmb.aportgen.core
|
2017-06-15 00:26:32 +00:00
|
|
|
import pmb.config
|
Properly rebuild/install packages when something changed (Fix #120, #108, #131) (#129)
TLDR: Always rebuild/install packages when something changed when executing "pmbootstrap install/initfs/flash", more speed in dependency resolution.
---
pmbootstrap has already gotten some support for "timestamp based rebuilds", which modifies the logic for when packages should be rebuilt. It doesn't only consider packages outdated with old pkgver/pkgrel combinations, but also packages, where a source file has a newer timestamp, than the built package has.
I've found out, that this can lead to more rebuilds than expected. For example, when you check out the pmbootstrap git repository again into another folder, although you have already built packages. Then all files have the timestamp of the checkout, and the packages will appear to be outdated. While this is not largely a concern now, this will become a problem once we have a binary package repository, because then the packages from the binary repo will always seem to be outdated, if you just freshly checked out the repository.
To combat this, git gets asked if the files from the aport we're looking at are in sync with upstream, or not. Only when the files are not in sync with upstream and the timestamps of the sources are newer, a rebuild gets triggered from now on.
In case this logic should fail, I've added an option during "pmbootstrap init" where you can enable or disable the "timestamp based rebuilds" option.
In addition to that, this commit also works on fixing #120: packages do not get updated in "pmbootstrap install" after they have been rebuilt. For this to work, we specify all packages explicitly for abuild, instead of letting abuild do the resolving. This feature will also work with the "timestamp based rebuilds".
This commit also fixes the working_dir argument in pmb.helpers.run.user, which was simply ignored before.
Finally, the performance of the dependency resolution is faster again (when compared to the current version in master), because the parsed apkbuilds and finding the aport by pkgname gets cached during one pmbootstrap call (in args.cache, which also makes it easy to put fake data there in testcases).
The new dependency resolution code can output lots of verbose messages for debugging by specifying the `-v` parameter. The meaning of that changed, it used to output the file names where log messages come from, but no one seemed to use that anyway.
2017-07-10 15:23:43 +00:00
|
|
|
import pmb.helpers.logging
|
2017-05-26 20:08:45 +00:00
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture
|
Debian Jessie/Python 3.4 support for the most part (#6)
* automatically find the chroot binary on Debian, even if it is not
in the user's PATH
* don't use subprocess.run anymore (remove related testcase, that explicitly
checked for subprocess.run usage, and used recursive globbing, another
post 3.4 Python feature, for the checks. A similar case can be added in the
future, but right now it's more important to get Debian 3.4 working and all
PRs are reviewed anyway.)
* pytest fixtures: don't use the newer "yield" feature, as this is only
supported in a newer version of pytest, than provided on Debian Jessie
From manually testing, most stuff works in Debian Jessie. However, the
testsuite does not run through - creating an empty .tar.gz with Python
fails for some reason (this is done in test_apk_static.py).
2017-05-29 18:38:11 +00:00
|
|
|
def args(tmpdir, request):
|
2017-05-26 20:08:45 +00:00
|
|
|
import pmb.parse
|
2020-04-10 08:56:34 +00:00
|
|
|
cfg = f"{pmb_test.const.testdata}/channels.cfg"
|
|
|
|
sys.argv = ["pmbootstrap.py", "--config-channels", cfg, "chroot"]
|
2017-05-26 20:08:45 +00:00
|
|
|
args = pmb.parse.arguments()
|
Properly rebuild/install packages when something changed (Fix #120, #108, #131) (#129)
TLDR: Always rebuild/install packages when something changed when executing "pmbootstrap install/initfs/flash", more speed in dependency resolution.
---
pmbootstrap has already gotten some support for "timestamp based rebuilds", which modifies the logic for when packages should be rebuilt. It doesn't only consider packages outdated with old pkgver/pkgrel combinations, but also packages, where a source file has a newer timestamp, than the built package has.
I've found out, that this can lead to more rebuilds than expected. For example, when you check out the pmbootstrap git repository again into another folder, although you have already built packages. Then all files have the timestamp of the checkout, and the packages will appear to be outdated. While this is not largely a concern now, this will become a problem once we have a binary package repository, because then the packages from the binary repo will always seem to be outdated, if you just freshly checked out the repository.
To combat this, git gets asked if the files from the aport we're looking at are in sync with upstream, or not. Only when the files are not in sync with upstream and the timestamps of the sources are newer, a rebuild gets triggered from now on.
In case this logic should fail, I've added an option during "pmbootstrap init" where you can enable or disable the "timestamp based rebuilds" option.
In addition to that, this commit also works on fixing #120: packages do not get updated in "pmbootstrap install" after they have been rebuilt. For this to work, we specify all packages explicitly for abuild, instead of letting abuild do the resolving. This feature will also work with the "timestamp based rebuilds".
This commit also fixes the working_dir argument in pmb.helpers.run.user, which was simply ignored before.
Finally, the performance of the dependency resolution is faster again (when compared to the current version in master), because the parsed apkbuilds and finding the aport by pkgname gets cached during one pmbootstrap call (in args.cache, which also makes it easy to put fake data there in testcases).
The new dependency resolution code can output lots of verbose messages for debugging by specifying the `-v` parameter. The meaning of that changed, it used to output the file names where log messages come from, but no one seemed to use that anyway.
2017-07-10 15:23:43 +00:00
|
|
|
args.log = args.work + "/log_testsuite.txt"
|
2019-09-13 23:27:20 +00:00
|
|
|
args.fork_alpine = False
|
Properly rebuild/install packages when something changed (Fix #120, #108, #131) (#129)
TLDR: Always rebuild/install packages when something changed when executing "pmbootstrap install/initfs/flash", more speed in dependency resolution.
---
pmbootstrap has already gotten some support for "timestamp based rebuilds", which modifies the logic for when packages should be rebuilt. It doesn't only consider packages outdated with old pkgver/pkgrel combinations, but also packages, where a source file has a newer timestamp, than the built package has.
I've found out, that this can lead to more rebuilds than expected. For example, when you check out the pmbootstrap git repository again into another folder, although you have already built packages. Then all files have the timestamp of the checkout, and the packages will appear to be outdated. While this is not largely a concern now, this will become a problem once we have a binary package repository, because then the packages from the binary repo will always seem to be outdated, if you just freshly checked out the repository.
To combat this, git gets asked if the files from the aport we're looking at are in sync with upstream, or not. Only when the files are not in sync with upstream and the timestamps of the sources are newer, a rebuild gets triggered from now on.
In case this logic should fail, I've added an option during "pmbootstrap init" where you can enable or disable the "timestamp based rebuilds" option.
In addition to that, this commit also works on fixing #120: packages do not get updated in "pmbootstrap install" after they have been rebuilt. For this to work, we specify all packages explicitly for abuild, instead of letting abuild do the resolving. This feature will also work with the "timestamp based rebuilds".
This commit also fixes the working_dir argument in pmb.helpers.run.user, which was simply ignored before.
Finally, the performance of the dependency resolution is faster again (when compared to the current version in master), because the parsed apkbuilds and finding the aport by pkgname gets cached during one pmbootstrap call (in args.cache, which also makes it easy to put fake data there in testcases).
The new dependency resolution code can output lots of verbose messages for debugging by specifying the `-v` parameter. The meaning of that changed, it used to output the file names where log messages come from, but no one seemed to use that anyway.
2017-07-10 15:23:43 +00:00
|
|
|
pmb.helpers.logging.init(args)
|
2021-09-20 10:00:13 +00:00
|
|
|
request.addfinalizer(pmb.helpers.logging.logfd.close)
|
Debian Jessie/Python 3.4 support for the most part (#6)
* automatically find the chroot binary on Debian, even if it is not
in the user's PATH
* don't use subprocess.run anymore (remove related testcase, that explicitly
checked for subprocess.run usage, and used recursive globbing, another
post 3.4 Python feature, for the checks. A similar case can be added in the
future, but right now it's more important to get Debian 3.4 working and all
PRs are reviewed anyway.)
* pytest fixtures: don't use the newer "yield" feature, as this is only
supported in a newer version of pytest, than provided on Debian Jessie
From manually testing, most stuff works in Debian Jessie. However, the
testsuite does not run through - creating an empty .tar.gz with Python
fails for some reason (this is done in test_apk_static.py).
2017-05-29 18:38:11 +00:00
|
|
|
return args
|
2017-05-26 20:08:45 +00:00
|
|
|
|
|
|
|
|
2018-09-05 05:57:38 +00:00
|
|
|
def test_aportgen_compare_output(args, tmpdir, monkeypatch):
|
2019-09-13 23:27:20 +00:00
|
|
|
# Fake aports folder in tmpdir
|
2019-11-10 10:20:00 +00:00
|
|
|
tmpdir = str(tmpdir)
|
|
|
|
shutil.copytree(args.aports + "/.git", tmpdir + "/.git")
|
|
|
|
args.aports = tmpdir
|
2019-09-13 23:27:20 +00:00
|
|
|
os.mkdir(tmpdir + "/cross")
|
2020-02-20 19:14:38 +00:00
|
|
|
testdata = pmb_test.const.testdata + "/aportgen"
|
2018-09-05 05:57:38 +00:00
|
|
|
|
|
|
|
# Override get_upstream_aport() to point to testdata
|
2021-06-12 22:43:15 +00:00
|
|
|
def func(args, upstream_path, arch=None):
|
2019-09-12 19:20:08 +00:00
|
|
|
return testdata + "/aports/main/" + upstream_path
|
2018-09-05 05:57:38 +00:00
|
|
|
monkeypatch.setattr(pmb.aportgen.core, "get_upstream_aport", func)
|
|
|
|
|
|
|
|
# Run aportgen and compare output
|
|
|
|
pkgnames = ["binutils-armhf", "gcc-armhf"]
|
|
|
|
for pkgname in pkgnames:
|
|
|
|
pmb.aportgen.generate(args, pkgname)
|
|
|
|
path_new = args.aports + "/cross/" + pkgname + "/APKBUILD"
|
|
|
|
path_old = testdata + "/pmaports/cross/" + pkgname + "/APKBUILD"
|
|
|
|
assert os.path.exists(path_new)
|
|
|
|
assert filecmp.cmp(path_new, path_old, False)
|
|
|
|
|
|
|
|
|
2019-09-13 23:27:20 +00:00
|
|
|
def test_aportgen_fork_alpine_compare_output(args, tmpdir, monkeypatch):
|
|
|
|
# Fake aports folder in tmpdir
|
2019-11-10 10:20:00 +00:00
|
|
|
tmpdir = str(tmpdir)
|
|
|
|
shutil.copytree(args.aports + "/.git", tmpdir + "/.git")
|
|
|
|
args.aports = tmpdir
|
2019-09-13 23:27:20 +00:00
|
|
|
os.mkdir(tmpdir + "/temp")
|
2020-02-20 19:14:38 +00:00
|
|
|
testdata = pmb_test.const.testdata + "/aportgen"
|
2019-09-13 23:27:20 +00:00
|
|
|
args.fork_alpine = True
|
|
|
|
|
|
|
|
# Override get_upstream_aport() to point to testdata
|
2021-06-12 22:43:15 +00:00
|
|
|
def func(args, upstream_path, arch=None):
|
2019-09-13 23:27:20 +00:00
|
|
|
return testdata + "/aports/main/" + upstream_path
|
|
|
|
monkeypatch.setattr(pmb.aportgen.core, "get_upstream_aport", func)
|
|
|
|
|
|
|
|
# Run aportgen and compare output
|
|
|
|
pkgname = "binutils"
|
|
|
|
pmb.aportgen.generate(args, pkgname)
|
|
|
|
path_new = args.aports + "/temp/" + pkgname + "/APKBUILD"
|
|
|
|
path_old = testdata + "/pmaports/temp/" + pkgname + "/APKBUILD"
|
|
|
|
assert os.path.exists(path_new)
|
|
|
|
assert filecmp.cmp(path_new, path_old, False)
|
|
|
|
|
|
|
|
|
aportgen: Gracefully handle old aports_upstream (#1291)
In order to get cross-compilers, we generate a few aports (e.g.
binutils-armhf, gcc-armhf) automatically from Alpine's aports.
pmbootstrap was already able to perform a git checkout of Alpine's
aports repository. But it needed to be manually updated. Otherwise
the `pmbootstrap aportgen` command could actually downgrade the aport
instead of updating it to the current version.
After thinking about adding a dedicated pmbootstrap command for
updating git repositories, I thought it would be better to not open
that can of worms (pmbootstrap as general git wrapper? no thanks).
The solution implemented here compares the upstream aport version of
the git checkout of a certain package (e.g. gcc for gcc-armhf) with the
version in Alpine's binary package APKINDEX. When the aport version is
lower than the binary package version, it shows the user how to update
the git repository with just one command:
pmbootstrap chroot --add=git --user -- \
git -C /mnt/pmbootstrap-git/aports_upstream pull
Changes:
* `pmb.aportgen.core.get_upstream_aport()`: new function, that returns
the absolute path to the upstream aport on disk, after checking the
version of the aport against the binary package.
* Use that new function in pmb.aportgen.gcc and pmb.aportgen.binutils
* New function `pmb.helpers.repo.alpine_apkindex_path()`: updates the
APKINDEX if necessary and returns the absolute path to the APKINDEX.
This code was basically present already, but not as function, so now
we have a bit less overhead there.
* `pmbootstrap chroot`: new `--user` argument
* `pmb.parse.apkbuild`: make pkgname check optional, as it fails with
the official gcc APKBUILD before we modify it (the current APKBUILD
parser is not meant to be perfect, as this would require a full shell
parsing implementation).
* Extended `test_aportgen.py` and enabled it by default in
`testcases_fast.sh`. Previously it was disabled due to traffic
concerns (cloning the aports repo, but then again we do a full KDE
plasma mobile installation in Travis now, so that shouldn't matter
too much).
* `testcases_fast.sh`: With "test_aport_in_sync_with_git" removed
from the disabled-by-default list (left over from timestamp based
rebuilds), there were no more test cases disabled by default. I've
changed it, so now the qemu_running_processes test case is disabled,
and added an `--all` parameter to the script to disable no test
cases. Travis runs with the `--all` parameter while it's useful to
do a quick local test without `--all` in roughly 2 minutes instead of
10.
* `aports/cross/binutils-*`: Fix `_mirror` variable to point to current
default Alpine mirror (so the aportgen testcase runs through).
2018-03-11 14:18:21 +00:00
|
|
|
def test_aportgen(args, tmpdir):
|
|
|
|
# Fake aports folder in tmpdir
|
2020-04-10 08:56:34 +00:00
|
|
|
testdata = pmb_test.const.testdata
|
2019-11-10 10:20:00 +00:00
|
|
|
tmpdir = str(tmpdir)
|
|
|
|
shutil.copytree(args.aports + "/.git", tmpdir + "/.git")
|
|
|
|
args.aports = tmpdir
|
2020-04-10 08:56:34 +00:00
|
|
|
shutil.copy(f"{testdata}/pmaports.cfg", args.aports)
|
2018-09-05 05:57:38 +00:00
|
|
|
os.mkdir(tmpdir + "/cross")
|
aportgen: Gracefully handle old aports_upstream (#1291)
In order to get cross-compilers, we generate a few aports (e.g.
binutils-armhf, gcc-armhf) automatically from Alpine's aports.
pmbootstrap was already able to perform a git checkout of Alpine's
aports repository. But it needed to be manually updated. Otherwise
the `pmbootstrap aportgen` command could actually downgrade the aport
instead of updating it to the current version.
After thinking about adding a dedicated pmbootstrap command for
updating git repositories, I thought it would be better to not open
that can of worms (pmbootstrap as general git wrapper? no thanks).
The solution implemented here compares the upstream aport version of
the git checkout of a certain package (e.g. gcc for gcc-armhf) with the
version in Alpine's binary package APKINDEX. When the aport version is
lower than the binary package version, it shows the user how to update
the git repository with just one command:
pmbootstrap chroot --add=git --user -- \
git -C /mnt/pmbootstrap-git/aports_upstream pull
Changes:
* `pmb.aportgen.core.get_upstream_aport()`: new function, that returns
the absolute path to the upstream aport on disk, after checking the
version of the aport against the binary package.
* Use that new function in pmb.aportgen.gcc and pmb.aportgen.binutils
* New function `pmb.helpers.repo.alpine_apkindex_path()`: updates the
APKINDEX if necessary and returns the absolute path to the APKINDEX.
This code was basically present already, but not as function, so now
we have a bit less overhead there.
* `pmbootstrap chroot`: new `--user` argument
* `pmb.parse.apkbuild`: make pkgname check optional, as it fails with
the official gcc APKBUILD before we modify it (the current APKBUILD
parser is not meant to be perfect, as this would require a full shell
parsing implementation).
* Extended `test_aportgen.py` and enabled it by default in
`testcases_fast.sh`. Previously it was disabled due to traffic
concerns (cloning the aports repo, but then again we do a full KDE
plasma mobile installation in Travis now, so that shouldn't matter
too much).
* `testcases_fast.sh`: With "test_aport_in_sync_with_git" removed
from the disabled-by-default list (left over from timestamp based
rebuilds), there were no more test cases disabled by default. I've
changed it, so now the qemu_running_processes test case is disabled,
and added an `--all` parameter to the script to disable no test
cases. Travis runs with the `--all` parameter while it's useful to
do a quick local test without `--all` in roughly 2 minutes instead of
10.
* `aports/cross/binutils-*`: Fix `_mirror` variable to point to current
default Alpine mirror (so the aportgen testcase runs through).
2018-03-11 14:18:21 +00:00
|
|
|
|
2017-05-26 20:08:45 +00:00
|
|
|
# Create aportgen folder -> code path where it still exists
|
|
|
|
pmb.helpers.run.user(args, ["mkdir", "-p", args.work + "/aportgen"])
|
|
|
|
|
aportgen: Gracefully handle old aports_upstream (#1291)
In order to get cross-compilers, we generate a few aports (e.g.
binutils-armhf, gcc-armhf) automatically from Alpine's aports.
pmbootstrap was already able to perform a git checkout of Alpine's
aports repository. But it needed to be manually updated. Otherwise
the `pmbootstrap aportgen` command could actually downgrade the aport
instead of updating it to the current version.
After thinking about adding a dedicated pmbootstrap command for
updating git repositories, I thought it would be better to not open
that can of worms (pmbootstrap as general git wrapper? no thanks).
The solution implemented here compares the upstream aport version of
the git checkout of a certain package (e.g. gcc for gcc-armhf) with the
version in Alpine's binary package APKINDEX. When the aport version is
lower than the binary package version, it shows the user how to update
the git repository with just one command:
pmbootstrap chroot --add=git --user -- \
git -C /mnt/pmbootstrap-git/aports_upstream pull
Changes:
* `pmb.aportgen.core.get_upstream_aport()`: new function, that returns
the absolute path to the upstream aport on disk, after checking the
version of the aport against the binary package.
* Use that new function in pmb.aportgen.gcc and pmb.aportgen.binutils
* New function `pmb.helpers.repo.alpine_apkindex_path()`: updates the
APKINDEX if necessary and returns the absolute path to the APKINDEX.
This code was basically present already, but not as function, so now
we have a bit less overhead there.
* `pmbootstrap chroot`: new `--user` argument
* `pmb.parse.apkbuild`: make pkgname check optional, as it fails with
the official gcc APKBUILD before we modify it (the current APKBUILD
parser is not meant to be perfect, as this would require a full shell
parsing implementation).
* Extended `test_aportgen.py` and enabled it by default in
`testcases_fast.sh`. Previously it was disabled due to traffic
concerns (cloning the aports repo, but then again we do a full KDE
plasma mobile installation in Travis now, so that shouldn't matter
too much).
* `testcases_fast.sh`: With "test_aport_in_sync_with_git" removed
from the disabled-by-default list (left over from timestamp based
rebuilds), there were no more test cases disabled by default. I've
changed it, so now the qemu_running_processes test case is disabled,
and added an `--all` parameter to the script to disable no test
cases. Travis runs with the `--all` parameter while it's useful to
do a quick local test without `--all` in roughly 2 minutes instead of
10.
* `aports/cross/binutils-*`: Fix `_mirror` variable to point to current
default Alpine mirror (so the aportgen testcase runs through).
2018-03-11 14:18:21 +00:00
|
|
|
# Generate all valid packages (gcc twice -> different code path)
|
2020-06-21 09:47:35 +00:00
|
|
|
pkgnames = ["binutils-armv7", "musl-armv7", "busybox-static-armv7",
|
|
|
|
"gcc-armv7", "gcc-armv7"]
|
2017-06-14 17:10:21 +00:00
|
|
|
for pkgname in pkgnames:
|
2017-05-26 20:08:45 +00:00
|
|
|
pmb.aportgen.generate(args, pkgname)
|
|
|
|
|
|
|
|
|
|
|
|
def test_aportgen_invalid_generator(args):
|
|
|
|
with pytest.raises(ValueError) as e:
|
|
|
|
pmb.aportgen.generate(args, "pkgname-with-no-generator")
|
|
|
|
assert "No generator available" in str(e.value)
|
aportgen: Gracefully handle old aports_upstream (#1291)
In order to get cross-compilers, we generate a few aports (e.g.
binutils-armhf, gcc-armhf) automatically from Alpine's aports.
pmbootstrap was already able to perform a git checkout of Alpine's
aports repository. But it needed to be manually updated. Otherwise
the `pmbootstrap aportgen` command could actually downgrade the aport
instead of updating it to the current version.
After thinking about adding a dedicated pmbootstrap command for
updating git repositories, I thought it would be better to not open
that can of worms (pmbootstrap as general git wrapper? no thanks).
The solution implemented here compares the upstream aport version of
the git checkout of a certain package (e.g. gcc for gcc-armhf) with the
version in Alpine's binary package APKINDEX. When the aport version is
lower than the binary package version, it shows the user how to update
the git repository with just one command:
pmbootstrap chroot --add=git --user -- \
git -C /mnt/pmbootstrap-git/aports_upstream pull
Changes:
* `pmb.aportgen.core.get_upstream_aport()`: new function, that returns
the absolute path to the upstream aport on disk, after checking the
version of the aport against the binary package.
* Use that new function in pmb.aportgen.gcc and pmb.aportgen.binutils
* New function `pmb.helpers.repo.alpine_apkindex_path()`: updates the
APKINDEX if necessary and returns the absolute path to the APKINDEX.
This code was basically present already, but not as function, so now
we have a bit less overhead there.
* `pmbootstrap chroot`: new `--user` argument
* `pmb.parse.apkbuild`: make pkgname check optional, as it fails with
the official gcc APKBUILD before we modify it (the current APKBUILD
parser is not meant to be perfect, as this would require a full shell
parsing implementation).
* Extended `test_aportgen.py` and enabled it by default in
`testcases_fast.sh`. Previously it was disabled due to traffic
concerns (cloning the aports repo, but then again we do a full KDE
plasma mobile installation in Travis now, so that shouldn't matter
too much).
* `testcases_fast.sh`: With "test_aport_in_sync_with_git" removed
from the disabled-by-default list (left over from timestamp based
rebuilds), there were no more test cases disabled by default. I've
changed it, so now the qemu_running_processes test case is disabled,
and added an `--all` parameter to the script to disable no test
cases. Travis runs with the `--all` parameter while it's useful to
do a quick local test without `--all` in roughly 2 minutes instead of
10.
* `aports/cross/binutils-*`: Fix `_mirror` variable to point to current
default Alpine mirror (so the aportgen testcase runs through).
2018-03-11 14:18:21 +00:00
|
|
|
|
|
|
|
|
|
|
|
def test_aportgen_get_upstream_aport(args, monkeypatch):
|
|
|
|
# Fake pmb.parse.apkbuild()
|
|
|
|
def fake_apkbuild(*args, **kwargs):
|
|
|
|
return apkbuild
|
|
|
|
monkeypatch.setattr(pmb.parse, "apkbuild", fake_apkbuild)
|
|
|
|
|
|
|
|
# Fake pmb.parse.apkindex.package()
|
|
|
|
def fake_package(*args, **kwargs):
|
|
|
|
return package
|
|
|
|
monkeypatch.setattr(pmb.parse.apkindex, "package", fake_package)
|
|
|
|
|
|
|
|
# Equal version
|
|
|
|
func = pmb.aportgen.core.get_upstream_aport
|
2019-09-12 19:20:08 +00:00
|
|
|
upstream = "gcc"
|
|
|
|
upstream_full = args.work + "/cache_git/aports_upstream/main/" + upstream
|
aportgen: Gracefully handle old aports_upstream (#1291)
In order to get cross-compilers, we generate a few aports (e.g.
binutils-armhf, gcc-armhf) automatically from Alpine's aports.
pmbootstrap was already able to perform a git checkout of Alpine's
aports repository. But it needed to be manually updated. Otherwise
the `pmbootstrap aportgen` command could actually downgrade the aport
instead of updating it to the current version.
After thinking about adding a dedicated pmbootstrap command for
updating git repositories, I thought it would be better to not open
that can of worms (pmbootstrap as general git wrapper? no thanks).
The solution implemented here compares the upstream aport version of
the git checkout of a certain package (e.g. gcc for gcc-armhf) with the
version in Alpine's binary package APKINDEX. When the aport version is
lower than the binary package version, it shows the user how to update
the git repository with just one command:
pmbootstrap chroot --add=git --user -- \
git -C /mnt/pmbootstrap-git/aports_upstream pull
Changes:
* `pmb.aportgen.core.get_upstream_aport()`: new function, that returns
the absolute path to the upstream aport on disk, after checking the
version of the aport against the binary package.
* Use that new function in pmb.aportgen.gcc and pmb.aportgen.binutils
* New function `pmb.helpers.repo.alpine_apkindex_path()`: updates the
APKINDEX if necessary and returns the absolute path to the APKINDEX.
This code was basically present already, but not as function, so now
we have a bit less overhead there.
* `pmbootstrap chroot`: new `--user` argument
* `pmb.parse.apkbuild`: make pkgname check optional, as it fails with
the official gcc APKBUILD before we modify it (the current APKBUILD
parser is not meant to be perfect, as this would require a full shell
parsing implementation).
* Extended `test_aportgen.py` and enabled it by default in
`testcases_fast.sh`. Previously it was disabled due to traffic
concerns (cloning the aports repo, but then again we do a full KDE
plasma mobile installation in Travis now, so that shouldn't matter
too much).
* `testcases_fast.sh`: With "test_aport_in_sync_with_git" removed
from the disabled-by-default list (left over from timestamp based
rebuilds), there were no more test cases disabled by default. I've
changed it, so now the qemu_running_processes test case is disabled,
and added an `--all` parameter to the script to disable no test
cases. Travis runs with the `--all` parameter while it's useful to
do a quick local test without `--all` in roughly 2 minutes instead of
10.
* `aports/cross/binutils-*`: Fix `_mirror` variable to point to current
default Alpine mirror (so the aportgen testcase runs through).
2018-03-11 14:18:21 +00:00
|
|
|
apkbuild = {"pkgver": "2.0", "pkgrel": "0"}
|
|
|
|
package = {"version": "2.0-r0"}
|
|
|
|
assert func(args, upstream) == upstream_full
|
|
|
|
|
|
|
|
# APKBUILD < binary
|
|
|
|
apkbuild = {"pkgver": "1.0", "pkgrel": "0"}
|
|
|
|
package = {"version": "2.0-r0"}
|
|
|
|
with pytest.raises(RuntimeError) as e:
|
|
|
|
func(args, upstream)
|
|
|
|
assert str(e.value).startswith("You can update your local checkout with")
|
|
|
|
|
|
|
|
# APKBUILD > binary
|
|
|
|
apkbuild = {"pkgver": "3.0", "pkgrel": "0"}
|
|
|
|
package = {"version": "2.0-r0"}
|
2022-11-02 16:58:26 +00:00
|
|
|
assert func(args, upstream) == upstream_full
|