[gimp/gimp-2-10] app: store the revision number in a data file.



commit ae2aa6c79b661ae60850667c789cd3c47c640c80
Author: Jehan <jehan girinstud io>
Date:   Thu Feb 13 23:59:46 2020 +0100

    app: store the revision number in a data file.
    
    I realized having the revision as a build number is the wrong idea as it
    implies packagers will have to rebuild GIMP for just a revision. Yet
    very often revision may just be data change or dependency fix/update
    without rebuild needed (i.e. no ABI change).
    Instead let's keep this package information as a file 'gimp-release'
    (inspired by /etc/os-release and other /etc/*-release files of
    distributions).
    
    (cherry picked from commit 87e9ebcfadb1fa23c2b5546cbe88204f1db3c1d2)

 app-tools/Makefile.am |  2 ++
 app/gimp-update.c     |  3 ++-
 app/gimp-version.c    | 34 +++++++++++++++++++++++++++++++++-
 app/gimp-version.h    |  7 ++++---
 4 files changed, 41 insertions(+), 5 deletions(-)
---
diff --git a/app-tools/Makefile.am b/app-tools/Makefile.am
index 75200b1e90..533229afde 100644
--- a/app-tools/Makefile.am
+++ b/app-tools/Makefile.am
@@ -4,6 +4,7 @@ AUTOMAKE_OPTIONS = subdir-objects
 
 libapp = $(top_builddir)/app/libapp.a
 libappwidgets = $(top_builddir)/app/widgets/libappwidgets.a
+libgimpbase = $(top_builddir)/libgimpbase/libgimpbase-$(GIMP_API_VERSION).la
 
 if PLATFORM_OSX
 xobjective_c = "-xobjective-c"
@@ -41,6 +42,7 @@ gimp_debug_tool_@GIMP_TOOL_VERSION@_CPPFLAGS = \
 gimp_debug_tool_@GIMP_TOOL_VERSION@_LDADD = \
        $(libappwidgets)        \
        $(libapp)               \
+       $(libgimpbase)                                          \
        $(GIO_LIBS)             \
        $(GEGL_LIBS)            \
        $(GTK_LIBS)             \
diff --git a/app/gimp-update.c b/app/gimp-update.c
index 7215b4a538..2f823eb422 100644
--- a/app/gimp-update.c
+++ b/app/gimp-update.c
@@ -40,6 +40,7 @@
 
 #include "gimp-intl.h"
 #include "gimp-update.h"
+#include "gimp-version.h"
 
 
 static gboolean
@@ -205,7 +206,7 @@ gimp_check_updates_callback (GObject      *source,
                       break;
                     }
                 }
-              if (build_revision <= GIMP_BUILD_REVISION)
+              if (build_revision <= gimp_version_get_revision ())
                 {
                   /* Already using the last officially released
                    * revision. */
diff --git a/app/gimp-version.c b/app/gimp-version.c
index a752c77805..d6c6699494 100644
--- a/app/gimp-version.c
+++ b/app/gimp-version.c
@@ -227,7 +227,9 @@ gimp_version (gboolean be_verbose,
                                       "# C compiler #\n%s\n"
                                       "# Libraries #\n%s",
                                       GIMP_GIT_VERSION,
-                                      GIMP_BUILD_ID, GIMP_BUILD_REVISION, GIMP_BUILD_PLATFORM,
+                                      GIMP_BUILD_ID,
+                                      gimp_version_get_revision (),
+                                      GIMP_BUILD_PLATFORM,
                                       CC_VERSION,
                                       lib_versions);
       g_free (lib_versions);
@@ -240,3 +242,33 @@ gimp_version (gboolean be_verbose,
 
   return version;
 }
+
+gint
+gimp_version_get_revision (void)
+{
+  GKeyFile *key_file;
+  gchar    *gimp_release;
+  gint      revision = 0;
+
+  key_file = g_key_file_new ();
+
+  /* The gimp-release file is inspired by /etc/os-release and similar
+   * distribution files. Right now its main use is to number the package
+   * revision. This information is not a build variable because a new
+   * package version does not necessarily imply a rebuild (maybe just
+   * installed data or dependencies change).
+   */
+  gimp_release = g_build_filename (gimp_data_directory (), "gimp-release", NULL);
+  /* Absence of the file is not an error. Actually most third-party
+   * builds probably won't install such file.
+   */
+  if (g_key_file_load_from_file (key_file, gimp_release, G_KEY_FILE_NONE, NULL))
+    {
+      if (g_key_file_has_key (key_file, "package", "revision", NULL))
+        revision = g_key_file_get_integer (key_file, "package", "revision", NULL);
+    }
+  g_key_file_free (key_file);
+  g_free (gimp_release);
+
+  return revision;
+}
diff --git a/app/gimp-version.h b/app/gimp-version.h
index 07ba20cf4a..ec6bb09ecc 100644
--- a/app/gimp-version.h
+++ b/app/gimp-version.h
@@ -19,9 +19,10 @@
 #define __APP_GIMP_VERSION_H__
 
 
-void    gimp_version_show (gboolean be_verbose);
-gchar * gimp_version      (gboolean be_verbose,
-                           gboolean localized);
+void    gimp_version_show         (gboolean be_verbose);
+gchar * gimp_version              (gboolean be_verbose,
+                                   gboolean localized);
 
+gint    gimp_version_get_revision (void);
 
 #endif /* __APP_GIMP_VERSION_H__ */


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]