* Implement command to retrieve and set configuration values * qemu: show advice to use "pmbootstrap config" * Allow "pmbootstrap config" without positional arguments (prints the full config) * Check valid variable names
This commit is contained in:
parent
ab1bcd2e6f
commit
401c29af76
|
@ -21,6 +21,8 @@ along with pmbootstrap. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
import json
|
import json
|
||||||
|
import sys
|
||||||
|
|
||||||
import pmb.aportgen
|
import pmb.aportgen
|
||||||
import pmb.build
|
import pmb.build
|
||||||
import pmb.config
|
import pmb.config
|
||||||
|
@ -80,6 +82,25 @@ def chroot(args):
|
||||||
pmb.chroot.root(args, args.command, suffix, log=False)
|
pmb.chroot.root(args, args.command, suffix, log=False)
|
||||||
|
|
||||||
|
|
||||||
|
def config(args):
|
||||||
|
pmb.helpers.logging.disable()
|
||||||
|
if args.name and args.name not in pmb.config.defaults:
|
||||||
|
valid_keys = ", ".join(sorted(pmb.config.defaults.keys()))
|
||||||
|
print("The variable name you have specified is invalid.")
|
||||||
|
print("The following are supported: " + valid_keys)
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
cfg = pmb.config.load(args)
|
||||||
|
if args.value:
|
||||||
|
cfg["pmbootstrap"][args.name] = args.value
|
||||||
|
pmb.config.save(args, cfg)
|
||||||
|
elif args.name:
|
||||||
|
value = cfg["pmbootstrap"].get(args.name, "")
|
||||||
|
print(value)
|
||||||
|
else:
|
||||||
|
cfg.write(sys.stdout)
|
||||||
|
|
||||||
|
|
||||||
def index(args):
|
def index(args):
|
||||||
pmb.build.index_repo(args)
|
pmb.build.index_repo(args)
|
||||||
|
|
||||||
|
|
|
@ -101,3 +101,8 @@ def init(args):
|
||||||
log_handler._args = args
|
log_handler._args = args
|
||||||
handler.setFormatter(formatter)
|
handler.setFormatter(formatter)
|
||||||
root_logger.addHandler(handler)
|
root_logger.addHandler(handler)
|
||||||
|
|
||||||
|
|
||||||
|
def disable():
|
||||||
|
logger = logging.getLogger()
|
||||||
|
logger.disabled = True
|
||||||
|
|
|
@ -218,6 +218,12 @@ def arguments():
|
||||||
parse_apkindex.add_argument("apkindex_path")
|
parse_apkindex.add_argument("apkindex_path")
|
||||||
parse_apkindex.add_argument("package", default=None, nargs="?")
|
parse_apkindex.add_argument("package", default=None, nargs="?")
|
||||||
|
|
||||||
|
# Action: config
|
||||||
|
config = sub.add_parser("config",
|
||||||
|
help="get and set pmbootstrap options")
|
||||||
|
config.add_argument("name", nargs="?", help="variable name")
|
||||||
|
config.add_argument("value", nargs="?", help="set variable to value")
|
||||||
|
|
||||||
# Action: qemu
|
# Action: qemu
|
||||||
qemu = sub.add_parser("qemu")
|
qemu = sub.add_parser("qemu")
|
||||||
qemu.add_argument("--arch", choices=["aarch64", "arm", "x86_64"],
|
qemu.add_argument("--arch", choices=["aarch64", "arm", "x86_64"],
|
||||||
|
|
|
@ -40,7 +40,8 @@ def system_image(args, device):
|
||||||
logging.debug("Could not find system image: " + path)
|
logging.debug("Could not find system image: " + path)
|
||||||
img_command = "pmbootstrap install"
|
img_command = "pmbootstrap install"
|
||||||
if device != args.device:
|
if device != args.device:
|
||||||
img_command = "pmbootstrap init' and '" + img_command
|
img_command = ("pmbootstrap config device " + device +
|
||||||
|
"' and '" + img_command)
|
||||||
message = "The system image '{0}' has not been generated yet, please" \
|
message = "The system image '{0}' has not been generated yet, please" \
|
||||||
" run '{1}' first.".format(device, img_command)
|
" run '{1}' first.".format(device, img_command)
|
||||||
raise RuntimeError(message)
|
raise RuntimeError(message)
|
||||||
|
|
Loading…
Reference in New Issue