diff options
author | Jürg Billeter <j@bitron.ch> | 2017-08-15 14:55:57 +0200 |
---|---|---|
committer | Jürg Billeter <j@bitron.ch> | 2017-08-15 14:55:57 +0200 |
commit | 8e695fe4bacb470cf9095581176451b8bb88083e (patch) | |
tree | 4f49056140bf3dfe65c2882da3987ef2115d2959 | |
parent | 4b9f0d256c1cc15bb19221cb775e5a62e815ae9d (diff) | |
download | buildstream-source-bundle-import.tar.gz |
import.py: Implement generate_script() for source bundlessource-bundle-import
Fixes #59
-rw-r--r-- | buildstream/plugins/elements/import.py | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/buildstream/plugins/elements/import.py b/buildstream/plugins/elements/import.py index a6178a179..3ab7f7833 100644 --- a/buildstream/plugins/elements/import.py +++ b/buildstream/plugins/elements/import.py @@ -91,6 +91,32 @@ class ImportElement(BuildElement): # And we're done return '/output' + def generate_script(self): + build_root = self.get_variable('build-root') + install_root = self.get_variable('install-root') + commands = [] + + # The directory to grab + inputdir = os.path.join(build_root, self.normal_name, self.source.lstrip(os.sep)) + inputdir = inputdir.rstrip(os.sep) + + # The output target directory + outputdir = os.path.join(install_root, self.target.lstrip(os.sep)) + outputdir = outputdir.rstrip(os.sep) + + # Ensure target directory parent exists but target directory doesn't + commands.append("mkdir -p {}".format(os.path.dirname(outputdir))) + commands.append("[ ! -e {} ] || rmdir {}".format(outputdir, outputdir)) + + # Move it over + commands.append("mv {} {}".format(inputdir, outputdir)) + + script = "" + for cmd in commands: + script += "(set -ex; {}\n) || exit 1\n".format(cmd) + + return script + # Plugin entry point def setup(): |