index : pacman | |
Archlinux32 fork of pacman | gitolite user |
summaryrefslogtreecommitdiff |
author | Aaron Griffin <aaron@archlinux.org> | 2006-11-15 07:50:37 +0000 |
---|---|---|
committer | Aaron Griffin <aaron@archlinux.org> | 2006-11-15 07:50:37 +0000 |
commit | 00ce9ea7394e6e21010d3758e5d949e2b449f64d (patch) | |
tree | 1e91d8c80cf2e535978b6fa51031765460234c9d /lib/libalpm/package.c | |
parent | 74e780f25df5642e19e6b8cc42ff1432fb7fe1b9 (diff) |
-rw-r--r-- | lib/libalpm/package.c | 29 |
diff --git a/lib/libalpm/package.c b/lib/libalpm/package.c index 85d76151..1302ebe5 100644 --- a/lib/libalpm/package.c +++ b/lib/libalpm/package.c @@ -435,6 +435,30 @@ pmpkg_t *_alpm_pkg_isin(char *needle, pmlist_t *haystack) return(NULL); } +char *_alpm_pkg_makefilename(pmpkg_t *pkg) +{ + char *fname = NULL; + int len = 0, arch_valid = 0; + + len = strlen(pkg->name) + strlen(pkg->version) + strlen(PM_EXT_PKG) + 3; + if(pkg->arch && strlen(pkg->arch) > 0) { + arch_valid = 1; + len += strlen(pkg->arch) + 1; + } + + if((fname = (char *)calloc(len, sizeof(char))) == NULL) { + RET_ERR(PM_ERR_MEMORY, NULL); + } + + if(arch_valid) { + snprintf(fname, len-1, "%s-%s-%s" PM_EXT_PKG, pkg->name, pkg->version, pkg->arch); + } else { + snprintf(fname, len-1, "%s-%s" PM_EXT_PKG, pkg->name, pkg->version); + } + + return fname; +} + int _alpm_pkg_splitname(char *target, char *name, char *version, int witharch) { char tmp[PKG_FULLNAME_LEN+7]; @@ -456,12 +480,9 @@ int _alpm_pkg_splitname(char *target, char *name, char *version, int witharch) *p = '\0'; } - if((p = _alpm_pkgname_has_arch(tmp))) { - *p = '\0'; - } if(witharch) { /* trim architecture */ - if((p = _alpm_pkgname_has_arch(tmp))) { + if((p = alpm_pkg_name_hasarch(tmp))) { *p = 0; } } |