1
0
Fork 1
mirror of https://gitlab.postmarketos.org/postmarketOS/pmbootstrap.git synced 2025-07-12 19:09:56 +03:00

Use pmbootstrap_v3.cfg as config file (MR 2350)

Using pmbootstrap v3 with the old config can cause problems, for example
when having $WORK in the pmaports dir instead of the actual work path.
This is not supported anymore by v3 to reduce complexity. The format of
how mirrors are stored in the config also has changed.

Use a separate config file, so users can go back from v3 to 2.3.x if
they need to (for figuring out a regression) and so users won't run into
bugs when moving from 2.3.x to v3.
This commit is contained in:
Oliver Smith 2024-07-07 20:48:57 +02:00 committed by Caleb Connolly
parent 3d9607aa99
commit 9dfa89c58c
No known key found for this signature in database
GPG key ID: 0583312B195F64B6
11 changed files with 15 additions and 14 deletions

View file

@ -275,7 +275,7 @@ the `ssh_key_glob` configuration parameter in the pmbootstrap config file to a
string containing a glob that is to match the file or files you wish to string containing a glob that is to match the file or files you wish to
include. include.
For example, a `~/.config/pmbootstrap.cfg` may contain: For example, a `~/.config/pmbootstrap_v3.cfg` may contain:
[pmbootstrap] [pmbootstrap]
# ... # ...

View file

@ -85,7 +85,7 @@ set_alias_pmbootstrap() {
return 1 return 1
fi fi
if [ -e "${XDG_CONFIG_HOME:-$HOME/.config}"/pmbootstrap.cfg ]; then if [ -e "${XDG_CONFIG_HOME:-$HOME/.config}"/pmbootstrap_v3.cfg ]; then
"$pmbootstrap" work_migrate "$pmbootstrap" work_migrate
else else
echo "NOTE: First run of pmbootstrap, running 'pmbootstrap init'" echo "NOTE: First run of pmbootstrap, running 'pmbootstrap init'"

View file

@ -77,7 +77,8 @@ def sudo(cmd: Sequence[PathString]) -> Sequence[PathString]:
defaults: dict[str, PathString] = { defaults: dict[str, PathString] = {
"cipher": "aes-xts-plain64", "cipher": "aes-xts-plain64",
"config": Path( "config": Path(
(os.environ.get("XDG_CONFIG_HOME") or os.path.expanduser("~/.config")) + "/pmbootstrap.cfg" (os.environ.get("XDG_CONFIG_HOME") or os.path.expanduser("~/.config"))
+ "/pmbootstrap_v3.cfg"
), ),
# A higher value is typically desired, but this can lead to VERY long open # A higher value is typically desired, but this can lead to VERY long open
# times on slower devices due to host systems being MUCH faster than the # times on slower devices due to host systems being MUCH faster than the

View file

@ -67,7 +67,7 @@ def load(path: Path) -> Config:
def serialize(config: Config, skip_defaults=True) -> configparser.ConfigParser: def serialize(config: Config, skip_defaults=True) -> configparser.ConfigParser:
"""Serialize the config object into a ConfigParser to write it out """Serialize the config object into a ConfigParser to write it out
in the pmbootstrap.cfg INI format. in the pmbootstrap_v3.cfg INI format.
:param config: The config object to serialize :param config: The config object to serialize
:param skip_defaults: Skip writing out default values :param skip_defaults: Skip writing out default values

View file

@ -135,8 +135,8 @@ def ask_for_channel(config: Config):
# Default for first run: "recommended" from channels.cfg # Default for first run: "recommended" from channels.cfg
# Otherwise, if valid: channel from pmaports.cfg of current branch # Otherwise, if valid: channel from pmaports.cfg of current branch
# The actual channel name is not saved in pmbootstrap.cfg, because then we # The actual channel name is not saved in pmbootstrap_v3.cfg, because then
# would need to sync it with what is checked out in pmaports.git. # we would need to sync it with what is checked out in pmaports.git.
default = pmb.config.pmaports.read_config()["channel"] default = pmb.config.pmaports.read_config()["channel"]
choices = channels_cfg["channels"].keys() choices = channels_cfg["channels"].keys()
if config.is_default_channel or default not in choices: if config.is_default_channel or default not in choices:

View file

@ -30,8 +30,8 @@ def test_load(config_file):
@pytest.fixture @pytest.fixture
def config_file_2_3_x(tmp_path: Path): def config_file_2_3_x(tmp_path: Path):
"""Fixture to create a temporary pmbootstrap.cfg file with 2.3.x format.""" """Fixture to create a temporary pmbootstrap_v3.cfg file with 2.3.x format."""
file = tmp_path / "pmbootstrap.cfg" file = tmp_path / "pmbootstrap_v3.cfg"
contents = """[pmbootstrap] contents = """[pmbootstrap]
aports = /home/user/.local/var/pmbootstrap/cache_git/pmaports aports = /home/user/.local/var/pmbootstrap/cache_git/pmaports
ccache_size = 32G ccache_size = 32G

View file

@ -2,7 +2,7 @@
# SPDX-License-Identifier: GPL-3.0-or-later # SPDX-License-Identifier: GPL-3.0-or-later
"""Save, read, verify workdir state related information in $WORK/workdir.cfg, """Save, read, verify workdir state related information in $WORK/workdir.cfg,
for example the init dates of the chroots. This is not saved in for example the init dates of the chroots. This is not saved in
pmbootstrap.cfg, because pmbootstrap.cfg is not tied to a specific work pmbootstrap_v3.cfg, because pmbootstrap_v3.cfg is not tied to a specific work
dir.""" dir."""
import configparser import configparser

View file

@ -13,20 +13,20 @@ _testdir = Path(__file__).parent / "data/tests"
@pytest.fixture @pytest.fixture
def config_file(tmp_path_factory, request): def config_file(tmp_path_factory, request):
"""Fixture to create a temporary pmbootstrap.cfg file.""" """Fixture to create a temporary pmbootstrap_v3.cfg file."""
tmp_path = tmp_path_factory.mktemp("pmbootstrap") tmp_path = tmp_path_factory.mktemp("pmbootstrap")
flavour = "default" flavour = "default"
if hasattr(request, "param") and request.param: if hasattr(request, "param") and request.param:
flavour = request.param flavour = request.param
out_file = tmp_path / "pmbootstrap.cfg" out_file = tmp_path / "pmbootstrap_v3.cfg"
workdir = tmp_path / "work" workdir = tmp_path / "work"
workdir.mkdir() workdir.mkdir()
configs = {"default": f"aports = {workdir / 'cache_git' / 'pmaports'}", "no-repos": "aports = "} configs = {"default": f"aports = {workdir / 'cache_git' / 'pmaports'}", "no-repos": "aports = "}
file = _testdir / "pmbootstrap.cfg" file = _testdir / "pmbootstrap_v3.cfg"
print(f"CONFIG: {out_file}") print(f"CONFIG: {out_file}")
cfg = configs[flavour] cfg = configs[flavour]
contents = open(file).read().format(workdir, cfg) contents = open(file).read().format(workdir, cfg)

View file

@ -25,7 +25,7 @@ __args: PmbArgs = PmbArgs()
... ...
2. Argparse merged with others 2. Argparse merged with others
Variables from the user's config file (~/.config/pmbootstrap.cfg) that Variables from the user's config file (~/.config/pmbootstrap_v3.cfg) that
can be overridden from the command line (pmb/parse/arguments.py) and can be overridden from the command line (pmb/parse/arguments.py) and
fall back to the defaults defined in pmb/config/__init__.py (see fall back to the defaults defined in pmb/config/__init__.py (see
"defaults = {..."). The user's config file gets generated interactively "defaults = {..."). The user's config file gets generated interactively

View file

@ -818,7 +818,7 @@ def get_parser():
dest="config", dest="config",
type=lambda x: Path(x), type=lambda x: Path(x),
default=pmb.config.defaults["config"], default=pmb.config.defaults["config"],
help="path to pmbootstrap.cfg file (default in ~/.config/)", help="path to pmbootstrap_v3.cfg file (default in ~/.config/)",
) )
parser.add_argument( parser.add_argument(
"-mp", "-mp",