Misc: Add cr_version_string_with_features() function
authorTomas Mlcoch <tmlcoch@redhat.com>
Fri, 11 Mar 2016 11:23:45 +0000 (12:23 +0100)
committerTomas Mlcoch <tmlcoch@redhat.com>
Fri, 11 Mar 2016 11:27:15 +0000 (12:27 +0100)
This function returns a static string which contains
version of createrepo_c library and list of features
which were enabled during compilation time.

Currently there are only two features:
"DeltaRPM" which means that createrepo_c lib was compiled
with support for generation of Delta RPMS.
"LegacyWeakdeps" which means that createrepo_c was compiled
with support for legacy weakdeps which are (were?) used in
OpenSuse and related distros.

Example string:
"0.10.0 (Features: DeltaRPM )"

Signed-off-by: Tomas Mlcoch <tmlcoch@redhat.com>
CMakeLists.txt
src/misc.c
src/misc.h

index daae72c380a76acab8dc6469f9d8db832853be3b..7757066fff259507c922f28529a4305648a13029 100644 (file)
@@ -92,6 +92,10 @@ IF (ENABLE_DRPM)
             set(CR_DELTA_RPM_SUPPORT "1")
         ENDIF (NOT DRPM_LIBRARY)
     endif (DRPM_PATH)
+
+    IF (CR_DELTA_RPM_SUPPORT)
+        ADD_DEFINITIONS("-DCR_DELTA_RPM_SUPPORT")
+    ENDIF (CR_DELTA_RPM_SUPPORT)
 ENDIF (ENABLE_DRPM)
 
 # Get package version
index ed0582797f24b8339ea25ae0df787921a399da40..8644e311841e8ad75fe9bc5ba7d5ccb5411d60e4 100644 (file)
 #include "cleanup.h"
 #include "error.h"
 #include "misc.h"
+#include "version.h"
 
 #define ERR_DOMAIN      CREATEREPO_C_ERROR
 #define BUFFER_SIZE     4096
 
+#define xstr(s) str(s)
+#define str(s) #s
+
 
 const char *
 cr_flag_to_str(gint64 flags)
@@ -1483,3 +1487,21 @@ cr_cut_dirs(gchar *path, gint cut_dirs)
 
     return cut+1;
 }
+
+const gchar *
+cr_version_string_with_features(void)
+{
+    return (xstr(CR_VERSION_MAJOR)
+            "."
+            xstr(CR_VERSION_MINOR)
+            "."
+            xstr(CR_VERSION_PATCH)
+            " (Features: "
+#ifdef CR_DELTA_RPM_SUPPORT
+            "DeltaRPM "
+#endif
+#ifdef ENABLE_LEGACY_WEAKDEPS
+            "LegacyWeakdeps "
+#endif
+            ")");
+}
index 7e45017f0f0e4cc439e0e101466690ff8c5771f9..822aee369375e17fa5cb2f61ffca342e7834539f 100644 (file)
@@ -529,6 +529,12 @@ cr_identical_files(const gchar *fn1,
 gchar *
 cr_cut_dirs(gchar *path, gint cut_dirs);
 
+/** Return string with createrepo_c lib version and available features
+ * @return              String with version and list of features
+ */
+const gchar *
+cr_version_string_with_features(void);
+
 /** @} */
 
 #ifdef __cplusplus