diff options
author | Tristan Maat <tristan.maat@codethink.com> | 2017-06-28 10:24:22 +0100 |
---|---|---|
committer | Tristan Maat <tristan.maat@codethink.com> | 2017-06-28 10:24:22 +0100 |
commit | 3893a1385c85af8fb5ebd093e30270bcc7df4674 (patch) | |
tree | 0dc39a84e7e3ae390e7dd5f089ccd24f9680f400 | |
parent | 9ae1e1a290f67628d4e68632618b0aa9aa92b4e3 (diff) | |
download | buildstream-3893a1385c85af8fb5ebd093e30270bcc7df4674.tar.gz |
Fix #42
- Add a `--directory` option to source-bundle
- Remove the `name` argument
- Rename the tempdir
-rwxr-xr-x[-rw-r--r--] | buildstream/_frontend/main.py | 7 | ||||
-rwxr-xr-x[-rw-r--r--] | buildstream/_pipeline.py | 19 |
2 files changed, 14 insertions, 12 deletions
diff --git a/buildstream/_frontend/main.py b/buildstream/_frontend/main.py index 1b7bf7125..97c0fef60 100644..100755 --- a/buildstream/_frontend/main.py +++ b/buildstream/_frontend/main.py @@ -383,10 +383,11 @@ def checkout(app, target, arch, variant, directory, force): help='A variant of the specified target') @click.option('--force', '-f', default=False, is_flag=True, help="Overwrite files existing in checkout directory") +@click.option('--directory', default=os.getcwd(), + help="The directory to write the tarball to") @click.argument('target') -@click.argument('name') @click.pass_obj -def source_bundle(app, name, target, arch, variant, force, +def source_bundle(app, target, arch, variant, force, directory, track, deps, compression, except_): """Produce a build bundle to be manually executed @@ -402,7 +403,7 @@ def source_bundle(app, name, target, arch, variant, force, dependencies = app.pipeline.deps_elements(deps, except_) app.print_heading(dependencies) app.pipeline.source_bundle(app.scheduler, dependencies, force, track, - name, compression, except_) + compression, except_, directory) click.echo("") except _BstError as e: click.echo("") diff --git a/buildstream/_pipeline.py b/buildstream/_pipeline.py index 75d838ea6..783973c99 100644..100755 --- a/buildstream/_pipeline.py +++ b/buildstream/_pipeline.py @@ -523,23 +523,23 @@ class Pipeline(): # directory (str): The directory to checkout the artifact to # def source_bundle(self, scheduler, dependencies, force, - track_first, name, compression, except_): + track_first, compression, except_, directory): # Find the correct filename for the compression algorithm - name += ".tar" + tar_location = os.path.join(directory, self.target.normal_name + ".tar") if compression != "none": - name += "." + compression + tar_location += "." + compression # Attempt writing a file to generate a good error message # early # # FIXME: A bit hackish try: - open(name, mode="x") - os.remove(name) + open(tar_location, mode="x") + os.remove(tar_location) except IOError as e: raise PipelineError("Cannot write to {0}: {1}" - .format(name, e)) from e + .format(tar_location, e)) from e plan = list(dependencies) self.fetch(scheduler, plan, track_first) @@ -569,7 +569,8 @@ class Pipeline(): self._write_element_sources(tempdir, plan) self._write_build_script(tempdir, plan) - self._collect_sources(tempdir, name, compression) + self._collect_sources(tempdir, tar_location, + self.target.normal_name, compression) # Write all source elements to the given directory def _write_element_sources(self, directory, elements): @@ -597,7 +598,7 @@ class Pipeline(): os.chmod(script_path, stat.S_IEXEC | stat.S_IREAD) # Collect the sources in the given sandbox into a tarfile - def _collect_sources(self, directory, tar_name, compression): + def _collect_sources(self, directory, tar_name, element_name, compression): with self.target.timed_activity("Creating tarball {}".format(tar_name)): if compression == "none": permissions = "w:" @@ -605,4 +606,4 @@ class Pipeline(): permissions = "w:" + compression with tarfile.open(tar_name, permissions) as tar: - tar.add(directory, arcname=os.path.basename(directory)) + tar.add(directory, arcname=element_name) |