forked from Mirror/pmbootstrap
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:
parent
3d9607aa99
commit
9dfa89c58c
11 changed files with 15 additions and 14 deletions
|
@ -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
|
||||
include.
|
||||
|
||||
For example, a `~/.config/pmbootstrap.cfg` may contain:
|
||||
For example, a `~/.config/pmbootstrap_v3.cfg` may contain:
|
||||
|
||||
[pmbootstrap]
|
||||
# ...
|
||||
|
|
|
@ -85,7 +85,7 @@ set_alias_pmbootstrap() {
|
|||
return 1
|
||||
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
|
||||
else
|
||||
echo "NOTE: First run of pmbootstrap, running 'pmbootstrap init'"
|
||||
|
|
|
@ -77,7 +77,8 @@ def sudo(cmd: Sequence[PathString]) -> Sequence[PathString]:
|
|||
defaults: dict[str, PathString] = {
|
||||
"cipher": "aes-xts-plain64",
|
||||
"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
|
||||
# times on slower devices due to host systems being MUCH faster than the
|
||||
|
|
|
@ -67,7 +67,7 @@ def load(path: Path) -> Config:
|
|||
|
||||
def serialize(config: Config, skip_defaults=True) -> configparser.ConfigParser:
|
||||
"""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 skip_defaults: Skip writing out default values
|
||||
|
|
|
@ -135,8 +135,8 @@ def ask_for_channel(config: Config):
|
|||
|
||||
# Default for first run: "recommended" from channels.cfg
|
||||
# Otherwise, if valid: channel from pmaports.cfg of current branch
|
||||
# The actual channel name is not saved in pmbootstrap.cfg, because then we
|
||||
# would need to sync it with what is checked out in pmaports.git.
|
||||
# The actual channel name is not saved in pmbootstrap_v3.cfg, because then
|
||||
# we would need to sync it with what is checked out in pmaports.git.
|
||||
default = pmb.config.pmaports.read_config()["channel"]
|
||||
choices = channels_cfg["channels"].keys()
|
||||
if config.is_default_channel or default not in choices:
|
||||
|
|
|
@ -30,8 +30,8 @@ def test_load(config_file):
|
|||
|
||||
@pytest.fixture
|
||||
def config_file_2_3_x(tmp_path: Path):
|
||||
"""Fixture to create a temporary pmbootstrap.cfg file with 2.3.x format."""
|
||||
file = tmp_path / "pmbootstrap.cfg"
|
||||
"""Fixture to create a temporary pmbootstrap_v3.cfg file with 2.3.x format."""
|
||||
file = tmp_path / "pmbootstrap_v3.cfg"
|
||||
contents = """[pmbootstrap]
|
||||
aports = /home/user/.local/var/pmbootstrap/cache_git/pmaports
|
||||
ccache_size = 32G
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
"""Save, read, verify workdir state related information in $WORK/workdir.cfg,
|
||||
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."""
|
||||
|
||||
import configparser
|
||||
|
|
|
@ -13,20 +13,20 @@ _testdir = Path(__file__).parent / "data/tests"
|
|||
|
||||
@pytest.fixture
|
||||
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")
|
||||
|
||||
flavour = "default"
|
||||
if hasattr(request, "param") and request.param:
|
||||
flavour = request.param
|
||||
|
||||
out_file = tmp_path / "pmbootstrap.cfg"
|
||||
out_file = tmp_path / "pmbootstrap_v3.cfg"
|
||||
workdir = tmp_path / "work"
|
||||
workdir.mkdir()
|
||||
|
||||
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}")
|
||||
cfg = configs[flavour]
|
||||
contents = open(file).read().format(workdir, cfg)
|
||||
|
|
|
@ -25,7 +25,7 @@ __args: PmbArgs = PmbArgs()
|
|||
...
|
||||
|
||||
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
|
||||
fall back to the defaults defined in pmb/config/__init__.py (see
|
||||
"defaults = {..."). The user's config file gets generated interactively
|
||||
|
|
|
@ -818,7 +818,7 @@ def get_parser():
|
|||
dest="config",
|
||||
type=lambda x: Path(x),
|
||||
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(
|
||||
"-mp",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue