diff --git a/include/xbps_api.h b/include/xbps_api.h index 78a1d18389e..58f1e970d29 100644 --- a/include/xbps_api.h +++ b/include/xbps_api.h @@ -150,6 +150,7 @@ bool xbps_check_is_installed_pkgname(const char *); char * xbps_get_pkg_index_plist(const char *); char * xbps_get_pkg_name(const char *); const char * xbps_get_pkg_version(const char *); +const char * xbps_get_pkg_revision(const char *); bool xbps_pkg_has_rundeps(prop_dictionary_t); void xbps_set_rootdir(const char *); const char * xbps_get_rootdir(void); diff --git a/lib/util.c b/lib/util.c index 1975f04f66b..2cd63840945 100644 --- a/lib/util.c +++ b/lib/util.c @@ -171,6 +171,21 @@ xbps_get_pkg_version(const char *pkg) return tmp + 1; /* skip first '-' */ } +const char * +xbps_get_pkg_revision(const char *pkg) +{ + const char *tmp; + + assert(pkg != NULL); + + /* Get the required revision */ + tmp = strrchr(pkg, '_'); + if (tmp == NULL) + return NULL; + + return tmp + 1; /* skip first '_' */ +} + char * xbps_get_pkg_name(const char *pkg) {