Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • postmarketOS/pmbootstrap
  • fossdd/pmbootstrap
  • Adrian/pmbootstrap
  • JustSoup321/pmbootstrap
  • longnoserob/pmbootstrap
  • sixthkrum/pmbootstrap
  • ollieparanoid/pmbootstrap
  • magdesign/pmbootstrap
  • anjandev/pmbootstrap
  • HenriDellal/pmbootstrap
  • Minecrell/pmbootstrap
  • chipiguay/pmbootstrap
  • ijiki16/pmbootstrap
  • whynothugo/pmbootstrap
  • amessier/pmbootstrap
  • Eisenbahnfan/pmbootstrap
  • user0-07161/pmbootstrap
  • SzczurekYT/pmbootstrap
  • neuschaefer/pmbootstrap
  • knuxify/pmbootstrap
  • Frieder.Hannenheim/pmbootstrap
21 results
Show changes
Commits on Source (5)
......@@ -323,6 +323,7 @@ def process_package(
arch: Arch | None,
fallback_arch: Arch,
force: bool,
from_src: bool,
) -> list[str]:
"""
:param arch: Set if we should build for a specific arch.
......@@ -330,7 +331,17 @@ def process_package(
# Only build when APKBUILD exists
base_aports, base_apkbuild = get_apkbuild(pkgname)
if not base_apkbuild:
# We allow this function to be called for packages that aren't in pmaports
# and just do nothing in this case. However this can be quite confusing
# when building an Alpine package with --src since we'll just do nothing
if pmb.parse.apkindex.providers(pkgname, fallback_arch, False):
if from_src:
raise NonBugError(
f"Package {pkgname} is not in pmaports, but exists in Alpine."
" to build it with --src you first need to fork it to pmaports."
f" Please run 'pmbootstrap aportgen --fork-alpine {pkgname}' and then"
" try again"
)
return []
raise RuntimeError(
f"{pkgname}: Could not find aport, and" " could not find this package in any APKINDEX!"
......@@ -548,7 +559,7 @@ def packages(
all_dependencies: list[str] = []
for pkgname in pkgnames:
all_dependencies += process_package(
context, queue_build, pkgname, arch, fallback_arch, force
context, queue_build, pkgname, arch, fallback_arch, force, src is not None
)
# If any of our common build packages need to be built and are missing, then add them
......
......@@ -68,7 +68,9 @@ def run_command(args: PmbArgs):
case "flasher":
command = Flasher(
args.action_flasher,
args.autoinstall,
# FIXME: defaults copied from pmb/helpers/arguments.py
# we should have these defaults defined in one place!
getattr(args, "autoinstall", True),
getattr(args, "cmdline", None),
args.flash_method,
getattr(args, "no_reboot", None),
......
......@@ -3,12 +3,10 @@
import pmb.config
from pmb.core.context import Context
from pmb.core.pkgrepo import pkgrepo_default_path
from pmb.helpers import logging
from pmb.types import PmbArgs
import pmb.helpers.git
import pmb.helpers.args
__args: PmbArgs = PmbArgs()
"""This file constructs the args variable, which is passed to almost all
functions in the pmbootstrap code base. Here's a listing of the kind of
......@@ -49,7 +47,7 @@ __args: PmbArgs = PmbArgs()
def init(args: PmbArgs) -> PmbArgs:
global __args
args_ = PmbArgs()
# Basic initialization
# print(json.dumps(args.__dict__))
# sys.exit(0)
......@@ -120,14 +118,6 @@ def init(args: PmbArgs) -> PmbArgs:
# Copy all properties from args to out that don't start with underscores
for key, value in vars(args).items():
if not key.startswith("_") and not key == "from_argparse":
setattr(__args, key, value)
setattr(args_, key, value)
return __args
def please_i_really_need_args() -> PmbArgs:
import traceback
traceback.print_stack(file=logging.logfd)
logging.warning("FIXME: retrieved args where it shouldn't be needed!")
return __args
return args_
......@@ -5,7 +5,6 @@ from typing import cast, overload, Any, Literal
from collections.abc import Sequence
from pmb.core.apkindex_block import ApkindexBlock
from pmb.core.arch import Arch
from pmb.core.context import get_context
from pmb.helpers import logging
from pathlib import Path
import tarfile
......@@ -315,8 +314,9 @@ def parse_blocks(path: Path) -> list[ApkindexBlock]:
ret.append(block)
def cache_key(path: Path) -> str:
return str(path.relative_to(get_context().config.work, walk_up=True))
# FIXME: come up with something better here...
def cache_key(path: Path) -> int:
return hash(path)
def clear_cache(path: Path) -> bool:
......
from pathlib import Path
from pmb.core.arch import Arch
import pytest
from .apkindex import parse as parse_apkindex
import pmb.parse.apkindex
from .apkindex import parse as parse_apkindex, clear_cache as clear_apkindex_cache
example_apkindex = """
C:Q1p+nGf5oBAmbU9FQvV4MhfEmWqVE=
......@@ -231,13 +234,20 @@ D:blkid btrfs-progs buffyboard busybox-extras bzip2 cryptsetup device-mapper dev
p:postmarketos-ramdisk=3.3.5-r2"""
def test_apkindex_parse(tmp_path) -> None:
@pytest.fixture
def valid_apkindex_file(tmp_path) -> Path:
# FIXME: use tmpfile fixture from !2453
tmpfile = tmp_path / "APKINDEX.1"
print(tmp_path)
f = open(tmpfile, "w")
f.write(example_apkindex)
f.close()
return tmpfile
def test_apkindex_parse(valid_apkindex_file) -> None:
tmpfile = valid_apkindex_file
blocks = parse_apkindex(tmpfile, True)
for k, v in blocks.items():
print(f"{k}: {v}")
......@@ -409,3 +419,24 @@ i:postmarketos-base-ui=29-r1 xorg-server
# We expect parsing to succeed when the timestamp is missing
parse_apkindex(tmpfile, True)
def test_apkindex_parse_cache_hit(valid_apkindex_file, monkeypatch) -> None:
# First parse normally, filling the cache
parse_apkindex(valid_apkindex_file)
# Mock that always asserts when called
def mock_parse_next_block(path, lines):
assert False
# parse_next_block() is only called on cache miss
monkeypatch.setattr(pmb.parse.apkindex, "parse_next_block", mock_parse_next_block)
# Now we expect the cache to be hit and thus the mock won't be called, so no assertion error
parse_apkindex(valid_apkindex_file)
# Now we clear the cache, the mock should be called and we'll assert
clear_apkindex_cache(valid_apkindex_file)
with pytest.raises(AssertionError):
parse_apkindex(valid_apkindex_file)