+def git_get_tarball(v: Verification, channel: Channel) -> str:
+ with tempfile.TemporaryDirectory() as output_dir:
+ output_filename = os.path.join(
+ output_dir, channel.release_name + '.tar.xz')
+ with open(output_filename, 'w') as output_file:
+ v.status(
+ 'Generating tarball for git revision %s' %
+ channel.git_revision)
+ git = subprocess.Popen(['git',
+ '-C',
+ git_cachedir(channel.git_repo),
+ 'archive',
+ '--prefix=%s/' % channel.release_name,
+ channel.git_revision],
+ stdout=subprocess.PIPE)
+ xz = subprocess.Popen(['xz'], stdin=git.stdout, stdout=output_file)
+ xz.wait()
+ git.wait()
+ v.result(git.returncode == 0 and xz.returncode == 0)
+
+ v.status('Putting tarball in Nix store')
+ process = subprocess.run(
+ ['nix-store', '--add', output_filename], capture_output=True)
+ v.result(process.returncode == 0)
+ return process.stdout.decode().strip()
+
+