summaryrefslogtreecommitdiffstats
path: root/meta/lib
diff options
context:
space:
mode:
Diffstat (limited to 'meta/lib')
-rw-r--r--meta/lib/oe/path.py49
1 files changed, 4 insertions, 45 deletions
diff --git a/meta/lib/oe/path.py b/meta/lib/oe/path.py
index 413ebfb395..dbba60a304 100644
--- a/meta/lib/oe/path.py
+++ b/meta/lib/oe/path.py
@@ -66,21 +66,21 @@ def copytree(src, dst):
66 66
67 bb.utils.mkdirhier(dst) 67 bb.utils.mkdirhier(dst)
68 cmd = 'tar -cf - -C %s -p . | tar -xf - -C %s' % (src, dst) 68 cmd = 'tar -cf - -C %s -p . | tar -xf - -C %s' % (src, dst)
69 check_output(cmd, shell=True, stderr=subprocess.STDOUT) 69 subprocess.check_output(cmd, shell=True, stderr=subprocess.STDOUT)
70 70
71def copyhardlinktree(src, dst): 71def copyhardlinktree(src, dst):
72 """ Make the hard link when possible, otherwise copy. """ 72 """ Make the hard link when possible, otherwise copy. """
73 bb.utils.mkdirhier(dst) 73 bb.utils.mkdirhier(dst)
74 if os.path.isdir(src) and not len(os.listdir(src)): 74 if os.path.isdir(src) and not len(os.listdir(src)):
75 return 75 return
76 76
77 if (os.stat(src).st_dev == os.stat(dst).st_dev): 77 if (os.stat(src).st_dev == os.stat(dst).st_dev):
78 # Need to copy directories only with tar first since cp will error if two 78 # Need to copy directories only with tar first since cp will error if two
79 # writers try and create a directory at the same time 79 # writers try and create a directory at the same time
80 cmd = 'cd %s; find . -type d -print | tar -cf - -C %s -p --files-from - --no-recursion | tar -xf - -C %s' % (src, src, dst) 80 cmd = 'cd %s; find . -type d -print | tar -cf - -C %s -p --files-from - --no-recursion | tar -xf - -C %s' % (src, src, dst)
81 check_output(cmd, shell=True, stderr=subprocess.STDOUT) 81 subprocess.check_output(cmd, shell=True, stderr=subprocess.STDOUT)
82 cmd = 'cd %s; find . -print0 | cpio --null -pdlu %s' % (src, dst) 82 cmd = 'cd %s; find . -print0 | cpio --null -pdlu %s' % (src, dst)
83 check_output(cmd, shell=True, stderr=subprocess.STDOUT) 83 subprocess.check_output(cmd, shell=True, stderr=subprocess.STDOUT)
84 else: 84 else:
85 copytree(src, dst) 85 copytree(src, dst)
86 86
@@ -105,47 +105,6 @@ def symlink(source, destination, force=False):
105 if e.errno != errno.EEXIST or os.readlink(destination) != source: 105 if e.errno != errno.EEXIST or os.readlink(destination) != source:
106 raise 106 raise
107 107
108class CalledProcessError(Exception):
109 def __init__(self, retcode, cmd, output = None):
110 self.retcode = retcode
111 self.cmd = cmd
112 self.output = output
113 def __str__(self):
114 return "Command '%s' returned non-zero exit status %d with output %s" % (self.cmd, self.retcode, self.output)
115
116# Not needed when we move to python 2.7
117def check_output(*popenargs, **kwargs):
118 r"""Run command with arguments and return its output as a byte string.
119
120 If the exit code was non-zero it raises a CalledProcessError. The
121 CalledProcessError object will have the return code in the returncode
122 attribute and output in the output attribute.
123
124 The arguments are the same as for the Popen constructor. Example:
125
126 >>> check_output(["ls", "-l", "/dev/null"])
127 'crw-rw-rw- 1 root root 1, 3 Oct 18 2007 /dev/null\n'
128
129 The stdout argument is not allowed as it is used internally.
130 To capture standard error in the result, use stderr=STDOUT.
131
132 >>> check_output(["/bin/sh", "-c",
133 ... "ls -l non_existent_file ; exit 0"],
134 ... stderr=STDOUT)
135 'ls: non_existent_file: No such file or directory\n'
136 """
137 if 'stdout' in kwargs:
138 raise ValueError('stdout argument not allowed, it will be overridden.')
139 process = subprocess.Popen(stdout=subprocess.PIPE, *popenargs, **kwargs)
140 output, unused_err = process.communicate()
141 retcode = process.poll()
142 if retcode:
143 cmd = kwargs.get("args")
144 if cmd is None:
145 cmd = popenargs[0]
146 raise CalledProcessError(retcode, cmd, output=output)
147 return output
148
149def find(dir, **walkoptions): 108def find(dir, **walkoptions):
150 """ Given a directory, recurses into that directory, 109 """ Given a directory, recurses into that directory,
151 returning all files as absolute paths. """ 110 returning all files as absolute paths. """