[ostree] osbuild: Version built artifacts
- From: Colin Walters <walters src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [ostree] osbuild: Version built artifacts
- Date: Fri, 11 Nov 2011 11:55:31 +0000 (UTC)
commit cd17e9a2a358876d41c6935076d17ba00f90b0a3
Author: Colin Walters <walters verbum org>
Date: Fri Nov 11 06:44:22 2011 -0500
osbuild: Version built artifacts
osbuild/ostree-buildone | 24 ++++++++++++++++++++
.../ostree-buildone-makeinstall-split-artifacts | 2 +-
2 files changed, 25 insertions(+), 1 deletions(-)
---
diff --git a/osbuild/ostree-buildone b/osbuild/ostree-buildone
index 077be41..2f2fc6d 100644
--- a/osbuild/ostree-buildone
+++ b/osbuild/ostree-buildone
@@ -243,12 +243,36 @@ def _on_make_exit(pid, estatus):
else:
_output_filter.finish(False)
+def _get_version():
+ if not os.path.isdir('.git'):
+ sys.stderr.write("ostree-buildone: error: Couldn't find .git directory")
+ sys.exit(1)
+
+ proc = subprocess.Popen(['git', 'describe'], stdout=subprocess.PIPE)
+ output = proc.communicate()[0].strip()
+ if proc.wait() != 0:
+ proc = subprocess.Popen(['git', 'rev-parse', 'HEAD'], stdout=subprocess.PIPE)
+ if proc.wait() != 0:
+ sys.stderr.write("ostree-buildone: error: git rev-parse HEAD failed")
+ sys.exit(1)
+ output = proc.communicate()[0].strip()
+ return output
+
if __name__ == '__main__':
user_tmpdir = os.environ.get('XDG_RUNTIME_DIR')
if user_tmpdir is None:
user_tmpdir = os.path.join(os.environ.get('TMPDIR', '/tmp'), 'metabuild-%s' % (os.getuid(), ))
else:
user_tmpdir = os.path.join(user_tmpdir, 'ostree-build')
+
+ os.environ['OSBUILD_VERSION'] = _get_version()
+
+ if os.path.isdir('_build'):
+ for filename in os.listdir('_build'):
+ path = os.path.join('_build', filename)
+ if filename.startswith('artifact-'):
+ os.unlink(path)
+
if not os.path.isdir(user_tmpdir):
os.makedirs(user_tmpdir)
logfile_path = os.path.join(user_tmpdir, '%s.log' % (os.path.basename(os.getcwd()), ))
diff --git a/osbuild/ostree-buildone-makeinstall-split-artifacts b/osbuild/ostree-buildone-makeinstall-split-artifacts
index accb527..85167a5 100644
--- a/osbuild/ostree-buildone-makeinstall-split-artifacts
+++ b/osbuild/ostree-buildone-makeinstall-split-artifacts
@@ -50,7 +50,7 @@ def run_sync(args, env=None):
func("pid %d exited with code %d" % (proc.pid, returncode))
basename=os.path.basename(os.getcwd())
-artifact_prefix='artifact-%s' % (basename, )
+artifact_prefix='artifact-%s,%s' % (basename, os.environ['OSBUILD_VERSION'])
origdir=os.getcwd()
os.chdir('_build')
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]