libxbps: change the epoch char to ':' to differentiate the starting char in pkgname.
Added xbps_get_pkg_epoch(), to get the epoch version string.
This commit is contained in:
parent
a79d7b5884
commit
17b7651137
@ -1124,6 +1124,16 @@ char *xbps_get_pkg_name(const char *pkg);
|
||||
*/
|
||||
char *xbps_get_pkgpattern_name(const char *pattern);
|
||||
|
||||
/**
|
||||
* Gets the package epoch version in a package string, i.e <b>foo-2.0:epoch</b>.
|
||||
*
|
||||
* @param[in] pkg Package string.
|
||||
*
|
||||
* @return A string with the epoch version string, NULL if it couldn't find
|
||||
* the epoch component.
|
||||
*/
|
||||
const char *xbps_get_pkg_epoch(const char *pkg);
|
||||
|
||||
/**
|
||||
* Gets the package version in a package string, i.e <b>foo-2.0</b>.
|
||||
*
|
||||
|
@ -29,7 +29,7 @@
|
||||
* split_version(pkgname, endname, epoch, revision) returns a pointer to
|
||||
* the version portion of a package name and the two special components.
|
||||
*
|
||||
* Syntax is: ${PKGNAME}-${VERSION}[_${PKGREVISION}][-${EPOCH}]
|
||||
* Syntax is: ${PKGNAME}-${VERSION}[_${PKGREVISION}][:${EPOCH}]
|
||||
*
|
||||
*/
|
||||
static const char *
|
||||
@ -54,8 +54,8 @@ split_version(const char *pkgname, const char **endname, unsigned long *epoch,
|
||||
}
|
||||
endversionstr = ch;
|
||||
|
||||
/* Look for the last '-' in the remaining version string */
|
||||
ch = strrchr(endversionstr ? endversionstr + 1 : versionstr, '-');
|
||||
/* Look for the last ':' in the remaining version string */
|
||||
ch = strrchr(endversionstr ? endversionstr + 1 : versionstr, ':');
|
||||
if (epoch != NULL) {
|
||||
*epoch = ch ? strtoul(ch + 1, NULL, 10) : 0;
|
||||
}
|
||||
@ -216,7 +216,7 @@ get_component(const char *position, version_component *component)
|
||||
* comparison of the basenames is done.
|
||||
*
|
||||
* The port version is defined by:
|
||||
* ${VERSION}[_${PKGREVISION}][-${EPOCH}]
|
||||
* ${VERSION}[_${PKGREVISION}][:${EPOCH}]
|
||||
* ${EPOCH} supersedes ${VERSION} supersedes ${PKGREVISION}.
|
||||
*
|
||||
* The epoch and revision are defined to be a single number, while the rest
|
||||
|
14
lib/util.c
14
lib/util.c
@ -183,6 +183,20 @@ xbps_check_is_installed_pkgname(const char *pkgname)
|
||||
return false;
|
||||
}
|
||||
|
||||
const char *
|
||||
xbps_get_pkg_epoch(const char *pkg)
|
||||
{
|
||||
const char *tmp;
|
||||
|
||||
assert(pkg != NULL);
|
||||
|
||||
tmp = strrchr(pkg, ':');
|
||||
if (tmp == NULL)
|
||||
return NULL;
|
||||
|
||||
return tmp + 1; /* skip first ':' */
|
||||
}
|
||||
|
||||
const char *
|
||||
xbps_get_pkg_version(const char *pkg)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user