build: use get_pkgver() again (MR 2353)

During rework this got lost, re-incorporate it so packages built with
--src have a relevant pkgver.

Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
This commit is contained in:
Caleb Connolly 2024-07-08 18:21:57 +02:00 committed by Oliver Smith
parent 319d9681f3
commit c5135ac62a
No known key found for this signature in database
GPG key ID: 5AE7F5513E0885CB
2 changed files with 11 additions and 5 deletions

View file

@ -94,7 +94,7 @@ def get_depends(context: Context, apkbuild):
return ret
def get_pkgver(original_pkgver, original_source=False, now=None):
def get_pkgver(original_pkgver: str, original_source=False):
"""Get the original pkgver when using the original source.
Otherwise, get the pkgver with an appended suffix of current date and time.
@ -112,7 +112,7 @@ def get_pkgver(original_pkgver, original_source=False, now=None):
# Append current date
no_suffix = original_pkgver.split("_", 1)[0]
now = now if now else datetime.datetime.now()
now = datetime.datetime.now()
new_suffix = "_p" + now.strftime("%Y%m%d%H%M%S")
return no_suffix + new_suffix
@ -194,6 +194,7 @@ class BuildQueueItem(TypedDict):
arch: Arch # Arch to build for
aports: str
apkbuild: dict[str, Any]
pkgver: str
output_path: Path
channel: str
depends: list[str]
@ -353,14 +354,16 @@ def packages(
pkg_arch = pmb.build.autodetect.arch(apkbuild) if arch is None else arch
chroot = pmb.build.autodetect.chroot(apkbuild, pkg_arch)
cross = cross or pmb.build.autodetect.crosscompile(apkbuild, pkg_arch)
pkgver = get_pkgver(apkbuild["pkgver"], src is None)
build_queue.append(
{
"name": name,
"arch": pkg_arch,
"aports": aports.name, # the pmaports source repo (e.g. "systemd")
"apkbuild": apkbuild,
"pkgver": pkgver,
"output_path": output_path(
pkg_arch, apkbuild["pkgname"], apkbuild["pkgver"], apkbuild["pkgrel"]
pkg_arch, apkbuild["pkgname"], pkgver, apkbuild["pkgrel"]
),
"channel": pmb.config.pmaports.read_config(aports)["channel"],
"depends": depends,
@ -455,6 +458,7 @@ def packages(
run_abuild(
context,
pkg["apkbuild"],
pkg["pkgver"],
channel,
pkg_arch,
strict,

View file

@ -1,5 +1,6 @@
import enum
from pathlib import Path
from typing import Any
from pmb.core.pkgrepo import pkgrepo_paths
import pmb.helpers.run
import pmb.chroot
@ -180,7 +181,8 @@ def handle_csum_failure(apkbuild, chroot: Chroot):
def run_abuild(
context: Context,
apkbuild,
apkbuild: dict[str, Any],
pkgver: str,
channel,
arch: Arch,
strict=False,
@ -283,7 +285,7 @@ def run_abuild(
if src and strict:
logging.debug(f"({suffix}) Ensuring previous build artifacts are removed")
pmb.chroot.root(["rm", "-rf", "/tmp/pmbootstrap-local-source-copy"], suffix)
override_source(apkbuild, apkbuild["pkgver"], src, suffix)
override_source(apkbuild, pkgver, src, suffix)
link_to_git_dir(suffix)
try: