2020-02-20 20:07:28 +00:00
|
|
|
# Copyright 2020 Oliver Smith
|
|
|
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
2017-05-26 20:08:45 +00:00
|
|
|
import fnmatch
|
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
|
|
|
import logging
|
2018-12-30 00:03:39 +00:00
|
|
|
import re
|
2019-09-12 19:20:08 +00:00
|
|
|
import glob
|
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
|
|
|
import pmb.helpers.git
|
2017-05-26 20:08:45 +00:00
|
|
|
|
|
|
|
|
2018-12-30 00:03:39 +00:00
|
|
|
def indent_size(line):
|
|
|
|
"""
|
|
|
|
Number of spaces at the beginning of a string.
|
|
|
|
"""
|
|
|
|
matches = re.findall("^[ ]*", line)
|
|
|
|
if len(matches) == 1:
|
|
|
|
return len(matches[0])
|
|
|
|
return 0
|
|
|
|
|
|
|
|
|
2017-05-26 20:08:45 +00:00
|
|
|
def format_function(name, body, remove_indent=4):
|
|
|
|
"""
|
|
|
|
Format the body of a shell function passed to rewrite() below, so it fits
|
|
|
|
the format of the original APKBUILD.
|
2018-12-30 00:03:39 +00:00
|
|
|
:param remove_indent: Maximum number of spaces to remove from the
|
|
|
|
beginning of each line of the function body.
|
2017-05-26 20:08:45 +00:00
|
|
|
"""
|
2018-12-30 00:03:39 +00:00
|
|
|
tab_width = 4
|
2017-05-26 20:08:45 +00:00
|
|
|
ret = ""
|
|
|
|
lines = body.split("\n")
|
|
|
|
for i in range(len(lines)):
|
|
|
|
line = lines[i]
|
|
|
|
if not line.strip():
|
|
|
|
if not ret or i == len(lines) - 1:
|
|
|
|
continue
|
2018-12-30 00:03:39 +00:00
|
|
|
|
|
|
|
# Remove indent
|
|
|
|
spaces = min(indent_size(line), remove_indent)
|
|
|
|
line = line[spaces:]
|
|
|
|
|
|
|
|
# Convert spaces to tabs
|
|
|
|
spaces = indent_size(line)
|
|
|
|
tabs = int(spaces / tab_width)
|
|
|
|
line = ("\t" * tabs) + line[spaces:]
|
|
|
|
|
|
|
|
ret += line + "\n"
|
2017-05-26 20:08:45 +00:00
|
|
|
return name + "() {\n" + ret + "}\n"
|
|
|
|
|
|
|
|
|
2019-09-13 23:27:20 +00:00
|
|
|
def rewrite(args, pkgname, path_original="", fields={}, replace_pkgname=None,
|
2018-12-30 00:03:39 +00:00
|
|
|
replace_functions={}, replace_simple={}, below_header="",
|
|
|
|
remove_indent=4):
|
2017-05-26 20:08:45 +00:00
|
|
|
"""
|
|
|
|
Append a header to $WORK/aportgen/APKBUILD, delete maintainer/contributor
|
|
|
|
lines (so they won't be bugged with issues regarding our generated aports),
|
|
|
|
and add reference to the original aport.
|
|
|
|
|
2019-09-13 23:27:20 +00:00
|
|
|
:param path_original: The original path of the automatically generated aport
|
2017-05-26 20:08:45 +00:00
|
|
|
:param fields: key-value pairs of fields, that shall be changed in the
|
|
|
|
APKBUILD. For example: {"pkgdesc": "my new package", "subpkgs": ""}
|
|
|
|
:param replace_pkgname: When set, $pkgname gets replaced with that string in
|
|
|
|
every line.
|
|
|
|
:param replace_functions: Function names and new bodies, for example:
|
|
|
|
{"build": "return 0"}
|
|
|
|
The body can also be None (deletes the function)
|
|
|
|
:param replace_simple: Lines, that fnmatch the pattern, get
|
|
|
|
replaced/deleted. Example: {"*test*": "# test", "*mv test.bin*": None}
|
|
|
|
:param below_header: String, that gets directly placed below the header.
|
2018-12-30 00:03:39 +00:00
|
|
|
:param remove_indent: Number of spaces to remove from function body provided
|
|
|
|
to replace_functions.
|
2017-05-26 20:08:45 +00:00
|
|
|
|
|
|
|
"""
|
|
|
|
# Header
|
2019-09-13 23:27:20 +00:00
|
|
|
if path_original:
|
|
|
|
lines_new = [
|
|
|
|
"# Automatically generated aport, do not edit!\n",
|
|
|
|
"# Generator: pmbootstrap aportgen " + pkgname + "\n",
|
|
|
|
"# Based on: " + path_original + "\n",
|
|
|
|
"\n",
|
|
|
|
]
|
|
|
|
else:
|
|
|
|
lines_new = [
|
|
|
|
"# Forked from Alpine INSERT-REASON-HERE (CHANGEME!)\n",
|
|
|
|
"\n",
|
|
|
|
]
|
2019-09-13 23:26:49 +00:00
|
|
|
|
|
|
|
if below_header:
|
|
|
|
for line in below_header.split("\n"):
|
|
|
|
if not line[:8].strip():
|
|
|
|
line = line[8:]
|
|
|
|
lines_new += line.rstrip() + "\n"
|
2017-05-26 20:08:45 +00:00
|
|
|
|
|
|
|
# Copy/modify lines, skip Maintainer/Contributor
|
|
|
|
path = args.work + "/aportgen/APKBUILD"
|
|
|
|
with open(path, "r+", encoding="utf-8") as handle:
|
|
|
|
skip_in_func = False
|
|
|
|
for line in handle.readlines():
|
|
|
|
# Skip maintainer/contributor
|
|
|
|
if line.startswith("# Maintainer") or line.startswith(
|
|
|
|
"# Contributor"):
|
|
|
|
continue
|
|
|
|
|
|
|
|
# Replace functions
|
|
|
|
if skip_in_func:
|
|
|
|
if line.startswith("}"):
|
|
|
|
skip_in_func = False
|
|
|
|
continue
|
|
|
|
else:
|
|
|
|
for func, body in replace_functions.items():
|
|
|
|
if line.startswith(func + "() {"):
|
|
|
|
skip_in_func = True
|
|
|
|
if body:
|
2018-12-30 00:03:39 +00:00
|
|
|
lines_new += format_function(func, body,
|
|
|
|
remove_indent=remove_indent)
|
2017-05-26 20:08:45 +00:00
|
|
|
break
|
|
|
|
if skip_in_func:
|
|
|
|
continue
|
|
|
|
|
|
|
|
# Replace fields
|
|
|
|
for key, value in fields.items():
|
|
|
|
if line.startswith(key + "="):
|
2020-05-12 18:13:38 +00:00
|
|
|
if value:
|
2020-05-12 18:20:16 +00:00
|
|
|
if key in ["pkgname", "pkgver", "pkgrel"]:
|
|
|
|
# No quotes to avoid lint error
|
|
|
|
line = f"{key}={value}\n"
|
|
|
|
else:
|
|
|
|
line = f'{key}="{value}"\n'
|
2020-05-12 18:13:38 +00:00
|
|
|
else:
|
|
|
|
# Remove line without value to avoid lint error
|
|
|
|
line = ""
|
2017-05-26 20:08:45 +00:00
|
|
|
break
|
|
|
|
|
|
|
|
# Replace $pkgname
|
|
|
|
if replace_pkgname and "$pkgname" in line:
|
|
|
|
line = line.replace("$pkgname", replace_pkgname)
|
|
|
|
|
|
|
|
# Replace simple
|
|
|
|
for pattern, replacement in replace_simple.items():
|
2018-05-13 18:30:02 +00:00
|
|
|
if fnmatch.fnmatch(line, pattern + "\n"):
|
2017-05-26 20:08:45 +00:00
|
|
|
line = replacement
|
|
|
|
if replacement:
|
|
|
|
line += "\n"
|
|
|
|
break
|
|
|
|
if line is None:
|
|
|
|
continue
|
|
|
|
|
|
|
|
lines_new.append(line)
|
|
|
|
|
|
|
|
# Write back
|
|
|
|
handle.seek(0)
|
|
|
|
handle.write("".join(lines_new))
|
|
|
|
handle.truncate()
|
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
|
|
|
|
|
|
|
|
2019-09-12 19:20:08 +00:00
|
|
|
def get_upstream_aport(args, pkgname):
|
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
|
|
|
"""
|
|
|
|
Perform a git checkout of Alpine's aports and get the path to the aport.
|
|
|
|
|
2019-09-12 19:20:08 +00:00
|
|
|
:param pkgname: package name
|
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
|
|
|
:returns: absolute path on disk where the Alpine aport is checked out
|
|
|
|
example: /opt/pmbootstrap_work/cache_git/aports/upstream/main/gcc
|
|
|
|
"""
|
|
|
|
# APKBUILD
|
|
|
|
pmb.helpers.git.clone(args, "aports_upstream")
|
2019-09-12 19:20:08 +00:00
|
|
|
aports_upstream_path = args.work + "/cache_git/aports_upstream"
|
|
|
|
|
2020-05-12 18:55:08 +00:00
|
|
|
# Checkout branch
|
|
|
|
channel_cfg = pmb.config.pmaports.read_config_channel(args)
|
|
|
|
branch = channel_cfg["branch_aports"]
|
|
|
|
logging.info(f"Checkout aports.git branch: {branch}")
|
|
|
|
if pmb.helpers.run.user(args, ["git", "checkout", branch],
|
|
|
|
aports_upstream_path, check=False):
|
|
|
|
logging.info("NOTE: run 'pmbootstrap pull' and try again")
|
|
|
|
logging.info("NOTE: if it still fails, your aports.git was cloned with"
|
|
|
|
" an older version of pmbootstrap, as shallow clone."
|
|
|
|
" Unshallow it, or remove it and let pmbootstrap clone it"
|
|
|
|
f" again: {aports_upstream_path}")
|
|
|
|
raise RuntimeError("Branch checkout failed.")
|
|
|
|
|
2019-09-12 19:20:08 +00:00
|
|
|
# Search package
|
|
|
|
paths = glob.glob(aports_upstream_path + "/*/" + pkgname)
|
|
|
|
if len(paths) > 1:
|
|
|
|
raise RuntimeError("Package " + pkgname + " found in multiple"
|
|
|
|
" aports subfolders.")
|
|
|
|
elif len(paths) == 0:
|
|
|
|
raise RuntimeError("Package " + pkgname + " not found in alpine"
|
|
|
|
" aports repository.")
|
|
|
|
aport_path = paths[0]
|
|
|
|
|
|
|
|
# Parse APKBUILD
|
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 = pmb.parse.apkbuild(args, aport_path + "/APKBUILD",
|
|
|
|
check_pkgname=False)
|
|
|
|
apkbuild_version = apkbuild["pkgver"] + "-r" + apkbuild["pkgrel"]
|
|
|
|
|
|
|
|
# Binary package
|
2019-09-12 19:20:08 +00:00
|
|
|
split = aport_path.split("/")
|
|
|
|
repo = split[-2]
|
|
|
|
pkgname = split[-1]
|
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
|
|
|
index_path = pmb.helpers.repo.alpine_apkindex_path(args, repo)
|
|
|
|
package = pmb.parse.apkindex.package(args, pkgname, indexes=[index_path])
|
|
|
|
|
|
|
|
# Compare version (return when equal)
|
|
|
|
compare = pmb.parse.version.compare(apkbuild_version, package["version"])
|
|
|
|
if compare == 0:
|
|
|
|
return aport_path
|
|
|
|
|
|
|
|
# Different version message
|
|
|
|
logging.error("ERROR: Package '" + pkgname + "' has a different version in"
|
|
|
|
" local checkout of Alpine's aports (" + apkbuild_version +
|
|
|
|
") compared to Alpine's binary package (" +
|
|
|
|
package["version"] + ")!")
|
|
|
|
|
|
|
|
# APKBUILD < binary
|
|
|
|
if compare == -1:
|
2020-02-16 17:23:06 +00:00
|
|
|
raise RuntimeError("You can update your local checkout with: "
|
|
|
|
"'pmbootstrap pull'")
|
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 > binary
|
|
|
|
raise RuntimeError("You can force an update of your binary package"
|
|
|
|
" APKINDEX files with: 'pmbootstrap update'")
|