summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorPaul Eggleton <paul.eggleton@linux.intel.com>2015-06-16 17:16:51 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2015-06-18 09:14:06 +0100
commit2054b29dd7be74d09b53df178ef87c69b15a809e (patch)
tree980b4727db3176e15d6bcb9fe373cb791a565af3 /scripts
parente22c18113b11f557c4502738ccdfbb06093a759a (diff)
downloadpoky-2054b29dd7be74d09b53df178ef87c69b15a809e.tar.gz
devtool: deploy: fix preservation of symlinks and permissions/ownership
It turns out that scp can't be used to copy symlinks because it follows them instead of copying them, and this is by design (since it emulates rcp which also behaved this way); the unfortunate result is that symlinks that point to valid files on the host translate into the host file being copied to the target (yuck). The simplest alternative that does not have this undesirable behaviour is to use tar and pipe it over ssh. At the same time, it would be even better if we properly reflect file permissions and ownership on the target that have been established within the pseudo environment. We can do this by executing the copy process under pseudo, which turns out to be quite easy with access to the pseudo environment set up by the build system. Fixes [YOCTO #7868]. (From OE-Core rev: 69adaed0e982d627ebfa57b360b0ee049ea7a276) Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts')
-rw-r--r--scripts/lib/devtool/__init__.py16
-rw-r--r--scripts/lib/devtool/deploy.py10
2 files changed, 23 insertions, 3 deletions
diff --git a/scripts/lib/devtool/__init__.py b/scripts/lib/devtool/__init__.py
index ea0b63e767..61b810c938 100644
--- a/scripts/lib/devtool/__init__.py
+++ b/scripts/lib/devtool/__init__.py
@@ -80,6 +80,22 @@ def exec_watch(cmd, **options):
80 80
81 return buf, None 81 return buf, None
82 82
83def exec_fakeroot(d, cmd, **kwargs):
84 """Run a command under fakeroot (pseudo, in fact) so that it picks up the appropriate file permissions"""
85 # Grab the command and check it actually exists
86 fakerootcmd = d.getVar('FAKEROOTCMD', True)
87 if not os.path.exists(fakerootcmd):
88 logger.error('pseudo executable %s could not be found - have you run a build yet? pseudo-native should install this and if you have run any build then that should have been built')
89 return 2
90 # Set up the appropriate environment
91 newenv = dict(os.environ)
92 fakerootenv = d.getVar('FAKEROOTENV', True)
93 for varvalue in fakerootenv.split():
94 if '=' in varvalue:
95 splitval = varvalue.split('=', 1)
96 newenv[splitval[0]] = splitval[1]
97 return subprocess.call("%s %s" % (fakerootcmd, cmd), env=newenv, **kwargs)
98
83def setup_tinfoil(): 99def setup_tinfoil():
84 """Initialize tinfoil api from bitbake""" 100 """Initialize tinfoil api from bitbake"""
85 import scriptpath 101 import scriptpath
diff --git a/scripts/lib/devtool/deploy.py b/scripts/lib/devtool/deploy.py
index ca74a8e51d..448db9637d 100644
--- a/scripts/lib/devtool/deploy.py
+++ b/scripts/lib/devtool/deploy.py
@@ -19,7 +19,7 @@
19import os 19import os
20import subprocess 20import subprocess
21import logging 21import logging
22from devtool import exec_build_env_command, setup_tinfoil, DevtoolError 22from devtool import exec_fakeroot, setup_tinfoil, DevtoolError
23 23
24logger = logging.getLogger('devtool') 24logger = logging.getLogger('devtool')
25 25
@@ -73,9 +73,13 @@ def deploy(args, config, basepath, workspace):
73 extraoptions = '' 73 extraoptions = ''
74 if args.no_host_check: 74 if args.no_host_check:
75 extraoptions += '-o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no' 75 extraoptions += '-o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no'
76 if not args.show_status: 76 if args.show_status:
77 tarextractopts = 'xv'
78 else:
79 tarextractopts = 'x'
77 extraoptions += ' -q' 80 extraoptions += ' -q'
78 ret = subprocess.call('scp -r %s %s/* %s:%s' % (extraoptions, recipe_outdir, args.target, destdir), shell=True) 81 # We cannot use scp here, because it doesn't preserve symlinks
82 ret = exec_fakeroot(rd, 'tar cf - . | ssh %s %s \'tar %s -C %s -f -\'' % (extraoptions, args.target, tarextractopts, destdir), cwd=recipe_outdir, shell=True)
79 if ret != 0: 83 if ret != 0:
80 raise DevtoolError('Deploy failed - rerun with -s to get a complete ' 84 raise DevtoolError('Deploy failed - rerun with -s to get a complete '
81 'error message') 85 'error message')