ddeb024
From 1b0f3869dd8bc9a6251095d3c0fff2d0904f11e3 Mon Sep 17 00:00:00 2001
ddeb024
From: Nils Philippsen <nils@tiptoe.de>
ddeb024
Date: Sat, 13 Aug 2016 14:38:28 +0200
ddeb024
Subject: [PATCH] AppData release tags need a date to be valid
ddeb024
ddeb024
Or a timestamp, but that's deprecated. Create it from the last commit,
ddeb024
store it in/retrieve it from revision.cc and substitute it in the
ddeb024
template.
ddeb024
ddeb024
https://www.freedesktop.org/software/appstream/docs/chap-Metadata.html#tag-releases
ddeb024
---
ddeb024
 gtk2_ardour/ardour.appdata.xml.in.in |  2 +-
ddeb024
 gtk2_ardour/wscript                  |  1 +
ddeb024
 wscript                              | 44 ++++++++++++++++++++++++------------
ddeb024
 3 files changed, 32 insertions(+), 15 deletions(-)
ddeb024
ddeb024
diff --git a/gtk2_ardour/ardour.appdata.xml.in.in b/gtk2_ardour/ardour.appdata.xml.in.in
ddeb024
index 1b2b940..9b8421a 100644
ddeb024
--- a/gtk2_ardour/ardour.appdata.xml.in.in
ddeb024
+++ b/gtk2_ardour/ardour.appdata.xml.in.in
ddeb024
@@ -5,7 +5,7 @@
ddeb024
   <project_license>GPL-2.0+</project_license>
ddeb024
   <name>Ardour</name>
ddeb024
   <releases>
ddeb024
-    <release version="@VERSION@" />
ddeb024
+    <release version="@VERSION@" date="@DATE@" />
ddeb024
   </releases>
ddeb024
   <summary>Digital Audio Workstation</summary>
ddeb024
   <description>
ddeb024
diff --git a/gtk2_ardour/wscript b/gtk2_ardour/wscript
ddeb024
index e1c349f..c20a728 100644
ddeb024
--- a/gtk2_ardour/wscript
ddeb024
+++ b/gtk2_ardour/wscript
ddeb024
@@ -762,6 +762,7 @@ def build(bld):
ddeb024
                     'ARDOUR_EXEC' : str (bld.env['lwrcase_dirname']),
ddeb024
                     'ARDOUR_ICON' : str (bld.env['lwrcase_dirname']),
ddeb024
                     'VERSION': str (bld.env['VERSION']),
ddeb024
+                    'DATE': str (bld.env['DATE']),
ddeb024
     }
ddeb024
 
ddeb024
     if bld.env['FREEDESKTOP']:
ddeb024
diff --git a/wscript b/wscript
ddeb024
index fce1359..c2ffb67 100644
ddeb024
--- a/wscript
ddeb024
+++ b/wscript
ddeb024
@@ -147,25 +147,35 @@ clang_darwin_dict['cxx-strict'] = [ '-ansi', '-Wnon-virtual-dtor', '-Woverloaded
ddeb024
 clang_darwin_dict['full-optimization'] = [ '-O3', '-ffast-math', '-fstrength-reduce' ]
ddeb024
 compiler_flags_dictionaries['clang-darwin'] = clang_darwin_dict;
ddeb024
 
ddeb024
-def fetch_git_revision ():
ddeb024
-    cmd = "git describe HEAD | sed 's/^[A-Za-z0-9]*+//'"
ddeb024
-    output = subprocess.Popen(cmd, shell=True, stderr=subprocess.STDOUT, stdout=subprocess.PIPE).communicate()[0].splitlines()
ddeb024
-    rev = output[0].decode ('utf-8')
ddeb024
-    return rev
ddeb024
+def fetch_git_revision_date ():
ddeb024
+    cmd = ["git", "describe", "HEAD"]
ddeb024
+    output = subprocess.Popen(cmd, stderr=subprocess.STDOUT, stdout=subprocess.PIPE).communicate()[0].splitlines()
ddeb024
+    rev = re.sub(r"^[A-Za-z0-9]*\+", "", output[0].decode('utf-8'))
ddeb024
+
ddeb024
+    cmd = ["git", "log", "-1", "--pretty=format:%ci", "HEAD"]
ddeb024
+    output = subprocess.Popen(cmd, stderr=subprocess.STDOUT, stdout=subprocess.PIPE).communicate()[0].splitlines()
ddeb024
+    date = output[0].decode('utf-8').split(None, 2)[0]
ddeb024
+
ddeb024
+    return rev, date
ddeb024
 
ddeb024
-def fetch_tarball_revision ():
ddeb024
+def fetch_tarball_revision_date():
ddeb024
     if not os.path.exists ('libs/ardour/revision.cc'):
ddeb024
         print ('This tarball was not created correctly - it is missing libs/ardour/revision.cc')
ddeb024
         sys.exit (1)
ddeb024
     with open('libs/ardour/revision.cc') as f:
ddeb024
         content = f.readlines()
ddeb024
         remove_punctuation_map = dict((ord(char), None) for char in '";')
ddeb024
-        return content[1].decode('utf-8').strip().split(' ')[7].translate (remove_punctuation_map)
ddeb024
+        raw_line_tokens = content[1].decode('utf-8').strip().split(' ')
ddeb024
+
ddeb024
+        rev = raw_line_tokens[7].translate(remove_punctuation_map)
ddeb024
+        date = raw_line_tokens[12].translate(remove_punctuation_map)
ddeb024
+
ddeb024
+        return rev, date
ddeb024
 
ddeb024
 if os.path.isdir (os.path.join(os.getcwd(), '.git')):
ddeb024
-    rev = fetch_git_revision ()
ddeb024
+    rev, rev_date = fetch_git_revision_date()
ddeb024
 else:
ddeb024
-    rev = fetch_tarball_revision ()
ddeb024
+    rev, rev_date = fetch_tarball_revision_date()
ddeb024
 
ddeb024
 #
ddeb024
 # rev is now of the form MAJOR.MINOR[-rcX]-rev-commit
ddeb024
@@ -257,7 +267,7 @@ def fetch_gcc_version (CC):
ddeb024
 def create_stored_revision():
ddeb024
     rev = ""
ddeb024
     if os.path.exists('.git'):
ddeb024
-        rev = fetch_git_revision();
ddeb024
+        rev, rev_date = fetch_git_revision_date();
ddeb024
         print("Git version: " + rev + "\n")
ddeb024
     elif os.path.exists('libs/ardour/revision.cc'):
ddeb024
         print("Using packaged revision")
ddeb024
@@ -268,12 +278,16 @@ def create_stored_revision():
ddeb024
 
ddeb024
     try:
ddeb024
         #
ddeb024
-        # if you change the format of this, be sure to fix fetch_tarball_revision() above
ddeb024
-        # so that  it still works.
ddeb024
+        # if you change the format of this, be sure to fix fetch_tarball_revision_date()
ddeb024
+        # above so that  it still works.
ddeb024
         #
ddeb024
         text =  '#include "ardour/revision.h"\n'
ddeb024
-        text += 'namespace ARDOUR { const char* revision = \"%s\"; }\n' % rev
ddeb024
-        print('Writing revision info to libs/ardour/revision.cc using ' + rev)
ddeb024
+        text += (
ddeb024
+            'namespace ARDOUR { '
ddeb024
+                'const char* revision = \"%s\"; '
ddeb024
+                'const char* date = \"%s\"; }\n'
ddeb024
+        ) % (rev, rev_date)
ddeb024
+        print('Writing revision info to libs/ardour/revision.cc using ' + rev + ', ' + rev_date)
ddeb024
         o = open('libs/ardour/revision.cc', 'w')
ddeb024
         o.write(text)
ddeb024
         o.close()
ddeb024
@@ -1237,6 +1251,8 @@ const char* const ardour_config_info = "\\n\\
ddeb024
 def build(bld):
ddeb024
     create_stored_revision()
ddeb024
 
ddeb024
+    bld.env['DATE'] = rev_date
ddeb024
+
ddeb024
     # add directories that contain only headers, to workaround an issue with waf
ddeb024
 
ddeb024
     if not bld.is_defined('USE_EXTERNAL_LIBS'):
ddeb024
-- 
ddeb024
2.7.4
ddeb024