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 (3)
  • Caleb Connolly's avatar
    config: init: dont clobber config (MR 2470) · 70dc8552
    Caleb Connolly authored and Oliver Smith's avatar Oliver Smith committed
    
    When pmbootstrap starts up, it loads the config file (or uses the
    defaults) and then merged some arguments (e.g. --work) into it. However
    in config.init.frontend() we were creating yet another new Config, but
    it's too late to merge args in at this point...
    
    Rework this slightly to fix that major oversight and remove the totally
    unnecessary hack of calling pmb.config.load() again.
    
    This fixes calling pmbootstrap init with --work
    
    Signed-off-by: default avatarCaleb Connolly <caleb@postmarketos.org>
    70dc8552
  • Caleb Connolly's avatar
    core: pkgrepo: support arbitrarily named pmaports directories (MR 2470) · a72a60f5
    Caleb Connolly authored and Oliver Smith's avatar Oliver Smith committed
    
    There was an oversight when this API was originally created and it
    implicitly assumed that the pmaports repository was always named
    "pmaports". This unfortunately broke some peoples workflows.
    
    Introduce a new "pkgrepo_name()" function and adjust the codebase to use
    it, as well as adjusting pkgrepo internally to special case the
    "pmaports" repo so that it's always named pmaports no matter what the
    directory itself is named.
    
    This is probably more complexity than we should be dealing with here, we
    should probably create a new type to encode this behaviour.
    
    Fixes: #2412
    Signed-off-by: default avatarCaleb Connolly <caleb@postmarketos.org>
    a72a60f5
  • Caleb Connolly's avatar
    config: init: support --aports too (MR 2470) · d57b9e31
    Caleb Connolly authored and Oliver Smith's avatar Oliver Smith committed
    
    We shouldn't overwrite config.aports if the user specified a custom
    --aports directory. We only want to do this to update the default if
    they're using a custom workdir.
    
    Make the code here less aggressive, and correctly use the last entry in
    config.aports as "pmaports" instead of the first.
    
    Fixes: #2386
    Signed-off-by: default avatarCaleb Connolly <caleb@postmarketos.org>
    d57b9e31
import enum
from pathlib import Path
from pmb.core.pkgrepo import pkgrepo_paths
from pmb.core.pkgrepo import pkgrepo_name, pkgrepo_paths
import pmb.helpers.run
import pmb.chroot
......@@ -126,10 +126,10 @@ def mount_pmaports(chroot: Chroot = Chroot.native()) -> dict[str, Path]:
"""
dest_paths = {}
for repo in pkgrepo_paths(skip_extras=True):
destination = Path("/mnt") / repo.name
destination = Path("/mnt") / pkgrepo_name(repo)
outside_destination = chroot / destination
pmb.helpers.mount.bind(repo, outside_destination, umount=True)
dest_paths[repo.name] = destination
dest_paths[pkgrepo_name(repo)] = destination
return dest_paths
......
......@@ -83,7 +83,7 @@ def ask_for_username(default_user: str) -> str:
return ret
def ask_for_work_path(args: PmbArgs) -> tuple[Path, bool]:
def ask_for_work_path(default: Path | None) -> tuple[Path, bool]:
"""Ask for the work path, until we can create it (when it does not exist) and write into it.
:returns: (path, exists)
......@@ -98,9 +98,7 @@ def ask_for_work_path(args: PmbArgs) -> tuple[Path, bool]:
)
while True:
try:
work = os.path.expanduser(
pmb.helpers.cli.ask("Work path", None, get_context().config.work, False)
)
work = os.path.expanduser(pmb.helpers.cli.ask("Work path", None, default, False))
work = os.path.realpath(work)
exists = os.path.exists(work)
......@@ -697,15 +695,15 @@ def frontend(args: PmbArgs) -> None:
require_programs()
# Work folder (needs to be first, so we can create chroots early)
config = pmb.config.load(args.config)
# Update context to point to new config
get_context().config = config
config = get_context().config
using_default_pmaports = config.aports[-1].is_relative_to(config.work)
config.work, work_exists = ask_for_work_path(args)
config.work, work_exists = ask_for_work_path(config.work)
# If the work dir is not the default, reset aports and make
# it relative to the work dir
if not config.aports[0].is_relative_to(config.work):
# If the work dir changed then we need to update the pmaports path
# to be relative to the new workdir
if using_default_pmaports:
config.aports = [config.work / "cache_git/pmaports"]
# Update args and save config (so chroots and 'pmbootstrap log' work)
......
......@@ -2,7 +2,12 @@
# SPDX-License-Identifier: GPL-3.0-or-later
import configparser
from pathlib import Path
from pmb.core.pkgrepo import pkgrepo_default_path, pkgrepo_paths, pkgrepo_relative_path
from pmb.core.pkgrepo import (
pkgrepo_default_path,
pkgrepo_name,
pkgrepo_paths,
pkgrepo_relative_path,
)
from pmb.helpers import logging
import os
import sys
......@@ -97,7 +102,7 @@ def read_config(aports: Path | None = None) -> dict[str, Any]:
if aports is None:
aports = pkgrepo_paths()[0]
systemd = aports.name == "systemd"
systemd = pkgrepo_name(aports) == "systemd"
# extra-repos don't have a pmaports.cfg
# so jump up the main aports dir
if "extra-repos" in aports.parts:
......
......@@ -28,21 +28,42 @@ def pkgrepo_paths(skip_extras: bool = False) -> list[Path]:
return out_paths
@Cache()
def pkgrepo_default_path() -> Path:
return pkgrepo_paths(skip_extras=True)[0]
def pkgrepo_names(skip_exras: bool = False) -> list[str]:
"""
Return a list of all the package repository names.
Return a list of all the package repository names. We REQUIRE
that the last repository is "pmaports", though the directory
may be named differently. So we hardcode the name here.
"""
return [aports.name for aports in pkgrepo_paths(skip_exras)]
names = [aports.name for aports in pkgrepo_paths(skip_exras)]
names[-1] = "pmaports"
return names
def pkgrepo_name(path: Path) -> str:
"""
Return the name of the package repository with the given path. This
MUST be used instead of "path.name" as we need special handling
for the pmaports repository.
"""
if path == get_context().config.aports[-1]:
return "pmaports"
return path.name
def pkgrepo_path(name: str) -> Path:
"""
Return the absolute path to the package repository with the given name.
"""
# The pmaports repo is always last, and we hardcode the name.
if name == "pmaports":
return get_context().config.aports[-1]
for aports in pkgrepo_paths():
if aports.name == name:
return aports
......@@ -56,7 +77,7 @@ def pkgrepo_name_from_subdir(subdir: Path) -> str:
"""
for aports in pkgrepo_paths():
if subdir.is_relative_to(aports):
return aports.name
return pkgrepo_name(aports)
raise RuntimeError(f"aports subdir '{subdir}' not found")
......@@ -105,14 +126,14 @@ def pkgrepo_iter_package_dirs(skip_extra_repos: bool = False) -> Generator[Path,
if "extra-repos" not in repo.parts and "extra-repos" in pdir.parts:
continue
pkg = os.path.basename(pdir)
if pkg in seen[repo.name]:
if pkg in seen[pkgrepo_name(repo)]:
raise RuntimeError(
f"Package {pkg} found in multiple aports "
"subfolders. Please put it only in one folder."
)
if pkg in [x for li in seen.values() for x in li]:
continue
seen[repo.name].append(pkg)
seen[pkgrepo_name(repo)].append(pkg)
yield pdir
......
......@@ -5,7 +5,7 @@ from enum import Enum
from pathlib import Path
from typing import Final
from pmb.core.context import get_context
from pmb.core.pkgrepo import pkgrepo_default_path, pkgrepo_path
from pmb.core.pkgrepo import pkgrepo_default_path, pkgrepo_path, pkgrepo_name
from pmb.helpers import logging
import os
import re
......@@ -107,7 +107,10 @@ def get_upstream_remote(aports: Path) -> str:
Usually "origin", but the user may have set up their git repository differently.
"""
name_repo = aports.parts[-1]
name_repo = pkgrepo_name(aports)
if name_repo not in pmb.config.git_repos:
logging.warning(f"WARNING: can't determine remote for {name_repo}, using 'origin'")
return "origin"
urls = pmb.config.git_repos[name_repo]
lines = list_remotes(aports)
for line in lines:
......
......@@ -2,7 +2,12 @@
# SPDX-License-Identifier: GPL-3.0-or-later
from collections.abc import Sequence
from pmb.core.chroot import Chroot
from pmb.core.pkgrepo import pkgrepo_iter_package_dirs, pkgrepo_names, pkgrepo_relative_path
from pmb.core.pkgrepo import (
pkgrepo_iter_package_dirs,
pkgrepo_name,
pkgrepo_names,
pkgrepo_relative_path,
)
from pmb.helpers import logging
from pmb.helpers.exceptions import NonBugError
from pmb.helpers.toml import load_toml_file
......@@ -69,7 +74,7 @@ def check(pkgnames: Sequence[str]) -> None:
continue
repo, relpath = pkgrepo_relative_path(pkgdir)
apkbuilds[repo.name].append(os.fspath(relpath / "APKBUILD"))
apkbuilds[pkgrepo_name(repo)].append(os.fspath(relpath / "APKBUILD"))
found_pkgnames.add(pkgdir.name)
# Check we found all the packages in pkgnames
......@@ -94,7 +99,7 @@ def check(pkgnames: Sequence[str]) -> None:
["apkbuild-lint"] + apkbuild_paths,
check=False,
output="stdout",
working_dir=dest_paths[repo.name],
working_dir=dest_paths[pkgrepo_name(repo)],
env={"CUSTOM_VALID_OPTIONS": " ".join(get_custom_valid_options())},
):
has_failed = True
......
......@@ -886,6 +886,7 @@ def get_parser():
parser.add_argument(
"-w",
"--work",
type=lambda x: Path(x).absolute(),
help="folder where all data gets stored (chroots, caches, built packages)",
)
parser.add_argument(
......