Fix "pmbootstrap config args /new/path" (MR 2374)

Fix writing config options that are stored as CSV-list. Without this
patch:

$ pmbootstrap config aports /tmp/pmaports
[23:43:58] Config changed: aports='/tmp/pmaports'
$ pmbootstrap config aports
[PosixPath('/'), PosixPath('t'), PosixPath('m'), PosixPath('p'), PosixPath('/'), PosixPath('p'), PosixPath('m'), PosixPath('a'), PosixPath('p'), PosixPath('o'), PosixPath('r'), PosixPath('t'), PosixPath('s')]

Storing strings as CSV list isn't great and we probably want to
implement this more elegantly, see the related issue. But let's fix this
first.

Related: pmbootstrap issue 2412
This commit is contained in:
Oliver Smith 2024-07-17 23:43:19 +02:00
parent e746c181a7
commit b14a872fad
No known key found for this signature in database
GPG key ID: 5AE7F5513E0885CB

View file

@ -242,7 +242,10 @@ def config(args: PmbArgs):
logging.info(f"Config changed to default: {args.name}='{def_value}'")
pmb.config.save(args.config, config)
elif args.value is not None:
setattr(config, args.name, args.value)
if isinstance(getattr(Config, args.name), list):
setattr(config, args.name, args.value.split(","))
else:
setattr(config, args.name, args.value)
logging.info("Config changed: " + args.name + "='" + args.value + "'")
pmb.config.save(args.config, config)
elif args.name: