[OE-core] [PATCH] devtool: Add IPv6 deploy targets targets
From: Breno Leitao Unfortunately devtool is not able to deploy (and undeploy) into IPv6 hosts. This patch simply adds a way to use IPv6 target address similarly to ssh/scp, as foo@[:::]:/destdir. In order to do it, I've created a function that parses the hostname, user and destdir, and then create a target_ssh (for ssh like parameter -- foo@xxx:::zzz) and target_scp for scp paramers as -- foo@[:::zzz]:/destdir. The urlparsing is done by urlparse module and ip version discovery is done by ipaddress module. This is the tests I have been using to validate my patch IPV4_FORMATS=" root@11.11.11.2:/tmp root@11.11.11.2 11.11.11.2:/tmp 11.11.11.2 " IPV6_FORMATS=" root@[2620:10d:c0bb:403:dac4:97ff:feda:3325]:/tmp root@[2620:10d:c0bb:403:dac4:97ff:feda:3325] [2620:10d:c0bb:403:dac4:97ff:feda:3325]:/tmp [2620:10d:c0bb:403:dac4:97ff:feda:3325] " HOSTNAMES=" r...@foo.bar:/tmp r...@foo.bar foo.bar:/tmp foo.bar " for I in $IPV6_FORMATS do devtool deploy-target -6 -s mypkg ${I} devtool undeploy-target -6 -s mypkg ${I} done for I in $HOSTNAMES do devtool deploy-target -s mypkg ${I} devtool undeploy-target -s mypkg ${I} done for I in $IPV4_FORMATS do devtool deploy-target -s mypkg ${I} devtool undeploy-target -s mypkg ${I} done --- scripts/lib/devtool/deploy.py | 61 +++ 1 file changed, 47 insertions(+), 14 deletions(-) diff --git a/scripts/lib/devtool/deploy.py b/scripts/lib/devtool/deploy.py index 6a997735fc..1580256e2a 100644 --- a/scripts/lib/devtool/deploy.py +++ b/scripts/lib/devtool/deploy.py @@ -11,6 +11,8 @@ import os import shutil import subprocess import tempfile +import urllib +import ipaddress import bb.utils import argparse_oe @@ -134,6 +136,18 @@ def _prepare_remote_script(deploy, verbose=False, dryrun=False, undeployall=Fals return '\n'.join(lines) +def parse_ip(args): +t = urllib.parse.urlparse("ssh://" + args.target) + +try: +ip = ipaddress.ip_address(t.hostname) +version = ip.version +except ValueError: +# hostname instead of ip return version 0 +version = None; + +return t.username, t.hostname, t.path, version + def deploy(args, config, basepath, workspace): """Entry point for the devtool 'deploy' subcommand""" @@ -143,14 +157,7 @@ def deploy(args, config, basepath, workspace): check_workspace_recipe(workspace, args.recipename, checksrc=False) -try: -host, destdir = args.target.split(':') -except ValueError: -destdir = '/' -else: -args.target = host -if not destdir.endswith('/'): -destdir += '/' +user, host, destdir, ipversion = parse_ip(args) tinfoil = setup_tinfoil(basepath=basepath) try: @@ -235,16 +242,30 @@ def deploy(args, config, basepath, workspace): f.write('%d\n' % ftotalsize) for fpath, fsize in filelist: f.write('%s %d\n' % (fpath, fsize)) + +# Need to generate target as a scp format +if ipversion == 6: +target_scp = "[%s]:%s" % (host, os.path.dirname(tmpscript)) +else: +target_scp = "%s:%s" % (host, os.path.dirname(tmpscript)) +if user: +target_scp = "%s@%s" % (user, target_scp) + # Copy them to the target -ret = subprocess.call("scp %s %s %s %s/* %s:%s" % (scp_sshexec, scp_port, extraoptions, tmpdir, args.target, os.path.dirname(tmpscript)), shell=True) +ret = subprocess.call("scp %s %s %s %s/* %s" % (scp_sshexec, scp_port, extraoptions, tmpdir, target_scp), shell=True) if ret != 0: raise DevtoolError('Failed to copy script to %s - rerun with -s to ' 'get a complete error message' % args.target) finally: shutil.rmtree(tmpdir) +if user: +target_ssh = "%s@%s" % (user, host) +else: +target_ssh = host + # Now run the script -ret = exec_fakeroot(rd, 'tar cf - . | %s %s %s %s \'sh %s %s %s %s\'' % (ssh_sshexec, ssh_port, extraoptions, args.target, tmpscript, args.recipename, destdir, tmpfilelist), cwd=recipe_outdir, shell=True) +ret = exec_fakeroot(rd, 'tar cf - . | %s %s %s %s \'sh %s %s %s %s\'' % (ssh_sshexec, ssh_port, extraoptions, target_ssh, tmpscript, args.recipename, destdir, tmpfilelist), cwd=recipe_outdir, shell=True) if ret != 0: raise DevtoolError('Deploy failed - rerun with -s to get a complete ' 'error message') @@ -268,6 +289,8 @@ def undeploy(args, config, basepath, workspace): elif not args.recipename and not args.all: raise
[OE-core] [PATCH] weston-init: Fix WESTON_USER typo
From: Breno Leitao Commit 837c786d600ba69('weston-init: Add support for non-root start') added a typo that uses WEST_USER instead of WESTON_USER variable when chwon'ing the XDG_RUNTIME_DIR directory. Since WEST_USER is not defined, it will `chown :$WESTON_USER file`, which will work, but that is not 100% correctly and should be fixed. This patch basically fix the typo and now the file will be chown'ed to the WESTON_USER user. Signed-off-by: Breno Leitao --- meta/recipes-graphics/wayland/weston-init/weston-start | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/meta/recipes-graphics/wayland/weston-init/weston-start b/meta/recipes-graphics/wayland/weston-init/weston-start index d19dbcbf75..ccc7093425 100755 --- a/meta/recipes-graphics/wayland/weston-init/weston-start +++ b/meta/recipes-graphics/wayland/weston-init/weston-start @@ -75,7 +75,7 @@ if test -z "$XDG_RUNTIME_DIR"; then fi if [ -n "$WESTON_USER" ] then - chown $WEST_USER:$WESTON_USER $XDG_RUNTIME_DIR + chown $WESTON_USER:$WESTON_USER $XDG_RUNTIME_DIR fi fi -- 2.17.1 -- ___ Openembedded-core mailing list Openembedded-core@lists.openembedded.org http://lists.openembedded.org/mailman/listinfo/openembedded-core
[OE-core] [PATCH 2/2] weston-init: Add support for non-root start
From: Breno Leitao This commit adds support for two variables (WESTON_USER and WESTON_TTY) that would be passed to weston_launch. It allows starting weston as a non-root user. Signed-off-by: Breno Leitao --- .../wayland/weston-init/weston-start| 17 +++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/meta/recipes-graphics/wayland/weston-init/weston-start b/meta/recipes-graphics/wayland/weston-init/weston-start index 0c4fee23d5..86c68fc533 100755 --- a/meta/recipes-graphics/wayland/weston-init/weston-start +++ b/meta/recipes-graphics/wayland/weston-init/weston-start @@ -27,10 +27,19 @@ if [ -n "$WAYLAND_DISPLAY" ]; then echo "ERROR: A Wayland compositor is already running, nested Weston instance is not supported yet." exit 1 fi + +if [ -n "$WESTON_USER" ]; then + if [ -z "$WESTON_TTY" ]; then + echo "ERROR: If you have WESTON_USER variable set, you also need WESTON_TTY." + exit 1 + fi + weston_args_user="-u $WESTON_USER -t $WESTON_TTY" +fi + if [ -n "$DISPLAY" ]; then launcher="weston" else - launcher="weston-launch --" + launcher="weston-launch $weston_args_user --" fi openvt_args="-s" @@ -59,11 +68,15 @@ if [ -d "$modules_dir" ]; then fi if test -z "$XDG_RUNTIME_DIR"; then - export XDG_RUNTIME_DIR=/run/user/`id -u` + export XDG_RUNTIME_DIR=/run/user/`id -u ${WESTON_USER}` if ! test -d "$XDG_RUNTIME_DIR"; then mkdir --parents $XDG_RUNTIME_DIR chmod 0700 $XDG_RUNTIME_DIR fi + if [ -n "$WESTON_USER" ] + then + chown $WEST_USER:$WESTON_USER $XDG_RUNTIME_DIR + fi fi exec openvt $openvt_args -- $launcher $weston_args --log=@LOCALSTATEDIR@/log/weston.log -- 2.17.1 -- ___ Openembedded-core mailing list Openembedded-core@lists.openembedded.org http://lists.openembedded.org/mailman/listinfo/openembedded-core
[OE-core] [PATCH 1/2] weston-init: Fix tab indentation
From: Breno Leitao This patch simply fixes space and tab mixes. It converts space to tabs. This is being done since I am going to change the code in the next commit and I do not want to change more lines than it is required, thus, I am creating a commit just to fix indentation, so I can create a cleaner patch later. Signed-off-by: Breno Leitao --- .../wayland/weston-init/weston-start | 14 +++--- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/meta/recipes-graphics/wayland/weston-init/weston-start b/meta/recipes-graphics/wayland/weston-init/weston-start index e72fbaaac4..0c4fee23d5 100755 --- a/meta/recipes-graphics/wayland/weston-init/weston-start +++ b/meta/recipes-graphics/wayland/weston-init/weston-start @@ -5,8 +5,8 @@ export PATH="/sbin:/usr/sbin:/bin:/usr/bin" usage() { -cat <] [-- ] + cat <] [-- ] EOF } @@ -59,11 +59,11 @@ if [ -d "$modules_dir" ]; then fi if test -z "$XDG_RUNTIME_DIR"; then -export XDG_RUNTIME_DIR=/run/user/`id -u` -if ! test -d "$XDG_RUNTIME_DIR"; then -mkdir --parents $XDG_RUNTIME_DIR -chmod 0700 $XDG_RUNTIME_DIR -fi + export XDG_RUNTIME_DIR=/run/user/`id -u` + if ! test -d "$XDG_RUNTIME_DIR"; then + mkdir --parents $XDG_RUNTIME_DIR + chmod 0700 $XDG_RUNTIME_DIR + fi fi exec openvt $openvt_args -- $launcher $weston_args --log=@LOCALSTATEDIR@/log/weston.log -- 2.17.1 -- ___ Openembedded-core mailing list Openembedded-core@lists.openembedded.org http://lists.openembedded.org/mailman/listinfo/openembedded-core