From: Tomas Mlcoch Date: Fri, 11 Mar 2016 11:23:45 +0000 (+0100) Subject: Misc: Add cr_version_string_with_features() function X-Git-Tag: upstream/0.10.0~15 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=56ef13736051d4611deea571f0b7fc356c66bc26;p=services%2Fcreaterepo_c.git Misc: Add cr_version_string_with_features() function 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 --- diff --git a/CMakeLists.txt b/CMakeLists.txt index daae72c..7757066 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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 diff --git a/src/misc.c b/src/misc.c index ed05827..8644e31 100644 --- a/src/misc.c +++ b/src/misc.c @@ -36,10 +36,14 @@ #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 + ")"); +} diff --git a/src/misc.h b/src/misc.h index 7e45017..822aee3 100644 --- a/src/misc.h +++ b/src/misc.h @@ -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