pmbootstrap chroot --xauth: new option (MR 1944)

Make it easy to start any X11 application from the native chroot.
This commit is contained in:
Oliver Smith 2020-06-02 23:29:33 +02:00
parent 2dd707a7ea
commit 6d013b4472
No known key found for this signature in database
GPG key ID: 5AE7F5513E0885CB
2 changed files with 17 additions and 2 deletions

View file

@ -117,20 +117,31 @@ def chroot(args):
not suffix.startswith("buildroot_")):
raise RuntimeError("--user is only supported for native or"
" buildroot_* chroots.")
if args.xauth and suffix != "native":
raise RuntimeError("--xauth is only supported for native chroot.")
# apk: check minimum version, install packages
pmb.chroot.apk.check_min_version(args, suffix)
if args.add:
pmb.chroot.apk.install(args, args.add.split(","), suffix)
# Xauthority
env = {}
if args.xauth:
pmb.chroot.other.copy_xauthority(args)
env["DISPLAY"] = os.environ.get("DISPLAY")
env["XAUTHORITY"] = "/home/pmos/.Xauthority"
# Run the command as user/root
if args.user:
logging.info("(" + suffix + ") % su pmos -c '" +
" ".join(args.command) + "'")
pmb.chroot.user(args, args.command, suffix, output=args.output)
pmb.chroot.user(args, args.command, suffix, output=args.output,
env=env)
else:
logging.info("(" + suffix + ") % " + " ".join(args.command))
pmb.chroot.root(args, args.command, suffix, output=args.output)
pmb.chroot.root(args, args.command, suffix, output=args.output,
env=env)
def config(args):