ostbuild: Write out related objects on composes

This commit is contained in:
Colin Walters 2012-05-11 16:24:32 -04:00
parent 829a760b56
commit 5d0744ea29
1 changed files with 18 additions and 11 deletions

View File

@ -59,20 +59,25 @@ class OstbuildCompose(builtins.Builtin):
for subpath in subtrees: for subpath in subtrees:
compose_contents.append((rev, subpath)) compose_contents.append((rev, subpath))
(fd, tmppath) = tempfile.mkstemp(suffix='.txt', prefix='ostbuild-compose-') (related_fd, related_tmppath) = tempfile.mkstemp(suffix='.txt', prefix='ostbuild-compose-')
f = os.fdopen(fd, 'w') (contents_fd, contents_tmppath) = tempfile.mkstemp(suffix='.txt', prefix='ostbuild-compose-')
related_f = os.fdopen(related_fd, 'w')
contents_f = os.fdopen(contents_fd, 'w')
for (branch, subpath) in compose_contents: for (branch, subpath) in compose_contents:
f.write(branch) related_f.write(' ')
f.write('\0') related_f.write(branch)
f.write(subpath) related_f.write('\n')
f.write('\0') contents_f.write(branch)
f.close() contents_f.write('\0')
contents_f.write(subpath)
contents_f.write('\0')
related_f.close()
contents_f.close()
run_sync(['ostree', '--repo=' + self.repo, run_sync(['ostree', '--repo=' + self.repo,
'checkout', '--user-mode', '--no-triggers', 'checkout', '--user-mode', '--no-triggers', '--union',
'--union', '--from-stdin', compose_rootdir], '--from-file=' + contents_tmppath, compose_rootdir])
stdin=open(tmppath)) os.unlink(contents_tmppath)
os.unlink(tmppath)
contents_path = os.path.join(compose_rootdir, 'contents.json') contents_path = os.path.join(compose_rootdir, 'contents.json')
f = open(contents_path, 'w') f = open(contents_path, 'w')
@ -82,7 +87,9 @@ class OstbuildCompose(builtins.Builtin):
run_sync(['ostree', '--repo=' + self.repo, run_sync(['ostree', '--repo=' + self.repo,
'commit', '-b', target['name'], '-s', 'Compose', 'commit', '-b', target['name'], '-s', 'Compose',
'--owner-uid=0', '--owner-gid=0', '--no-xattrs', '--owner-uid=0', '--owner-gid=0', '--no-xattrs',
'--related-objects-file=' + related_tmppath,
'--skip-if-unchanged'], cwd=compose_rootdir) '--skip-if-unchanged'], cwd=compose_rootdir)
os.unlink(related_tmppath)
shutil.rmtree(compose_rootdir) shutil.rmtree(compose_rootdir)
def execute(self, argv): def execute(self, argv):