xbps-repo: properly fix index-files update.

This commit is contained in:
Juan RP 2012-05-31 23:48:58 +02:00
parent 356bd655cf
commit ff2e434b56

View File

@ -232,8 +232,9 @@ repo_genindex_files(const char *pkgdir)
{ {
prop_array_t idx; prop_array_t idx;
struct index_files_data *ifd = NULL; struct index_files_data *ifd = NULL;
size_t i; size_t i, x;
char *plist, *tmppkgver, *pkgver, *arch, *saveptr; const char *p, *arch;
char *plist, *pkgver;
int rv; int rv;
plist = xbps_pkg_index_plist(pkgdir); plist = xbps_pkg_index_plist(pkgdir);
@ -281,16 +282,23 @@ repo_genindex_files(const char *pkgdir)
if (rv != 0) if (rv != 0)
goto out; goto out;
for (i = 0; i < prop_array_count(ifd->obsoletes); i++) { for (i = 0; i < prop_array_count(ifd->obsoletes); i++) {
prop_array_get_cstring(ifd->obsoletes, i, &tmppkgver); prop_array_get_cstring_nocopy(ifd->obsoletes, i, &p);
pkgver = strtok_r(tmppkgver, ",", &saveptr); pkgver = strdup(p);
arch = strtok_r(NULL, ",", &saveptr); for (x = 0; x < strlen(p); x++) {
free(tmppkgver); if ((pkgver[x] = p[x]) == ',') {
pkgver[x] = '\0';
break;
}
}
arch = strchr(p, ',') + 1;
if (!xbps_remove_pkg_from_array_by_pkgver( if (!xbps_remove_pkg_from_array_by_pkgver(
ifd->idxfiles, pkgver, arch)) { ifd->idxfiles, pkgver, arch)) {
free(pkgver);
rv = EINVAL; rv = EINVAL;
goto out; goto out;
} }
printf("Removed obsolete entry for `%s'.\n", pkgver); printf("Removed obsolete entry for `%s'.\n", pkgver);
free(pkgver);
} }
} }
if (!ifd->flush) if (!ifd->flush)