xbps-repo: genindex target now removes any obsolete binpkg not registered in index.
This commit is contained in:
parent
c7e4630056
commit
3399184511
3
NEWS
3
NEWS
@ -1,5 +1,8 @@
|
|||||||
xbps-0.16 (???):
|
xbps-0.16 (???):
|
||||||
|
|
||||||
|
* xbps-repo(8): 'genindex' target is now able to remove binary packages
|
||||||
|
when a greater version exists on the index.
|
||||||
|
|
||||||
* xbps-repo(8): 'sync' target now is able to sync just a single repository
|
* xbps-repo(8): 'sync' target now is able to sync just a single repository
|
||||||
by passing the repository URI as argument, i.e:
|
by passing the repository URI as argument, i.e:
|
||||||
|
|
||||||
|
@ -139,7 +139,7 @@ add_binpkg_to_index(prop_array_t idx,
|
|||||||
const char *pkgname, *version, *regver, *oldfilen, *oldpkgver;
|
const char *pkgname, *version, *regver, *oldfilen, *oldpkgver;
|
||||||
const char *arch, *oldarch;
|
const char *arch, *oldarch;
|
||||||
char *sha256, *filen, *tmpfilen, *oldfilepath, *buf;
|
char *sha256, *filen, *tmpfilen, *oldfilepath, *buf;
|
||||||
int rv = 0;
|
int ret = 0, rv = 0;
|
||||||
|
|
||||||
tmpfilen = strdup(file);
|
tmpfilen = strdup(file);
|
||||||
if (tmpfilen == NULL)
|
if (tmpfilen == NULL)
|
||||||
@ -175,25 +175,43 @@ add_binpkg_to_index(prop_array_t idx,
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
prop_dictionary_get_cstring_nocopy(curpkgd, "version", ®ver);
|
prop_dictionary_get_cstring_nocopy(curpkgd, "version", ®ver);
|
||||||
if (xbps_cmpver(version, regver) <= 0) {
|
ret = xbps_cmpver(version, regver);
|
||||||
|
if (ret == 0) {
|
||||||
|
/* same version */
|
||||||
fprintf(stderr, "index: skipping `%s-%s' (%s), `%s-%s' already "
|
fprintf(stderr, "index: skipping `%s-%s' (%s), `%s-%s' already "
|
||||||
"registered.\n", pkgname, version,
|
"registered.\n", pkgname, version,
|
||||||
arch, pkgname, regver);
|
arch, pkgname, regver);
|
||||||
prop_object_release(newpkgd);
|
prop_object_release(newpkgd);
|
||||||
rv = EEXIST;
|
rv = EEXIST;
|
||||||
goto out;
|
goto out;
|
||||||
|
} else if (ret == -1) {
|
||||||
|
/* idx version is greater, remove current binpkg */
|
||||||
|
oldfilepath = xbps_xasprintf("%s/%s", filedir, filen);
|
||||||
|
assert(oldfilepath != NULL);
|
||||||
|
if (remove(oldfilepath) == -1) {
|
||||||
|
rv = errno;
|
||||||
|
xbps_error_printf("failed to remove old binpkg "
|
||||||
|
"`%s': %s\n", oldfilepath, strerror(rv));
|
||||||
|
free(oldfilepath);
|
||||||
|
prop_object_release(newpkgd);
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
free(oldfilepath);
|
||||||
|
buf = xbps_xasprintf("`%s-%s' (%s)", pkgname, version, arch);
|
||||||
|
assert(buf != NULL);
|
||||||
|
prop_object_release(newpkgd);
|
||||||
|
printf("index: removed obsolete binpkg %s.\n", buf);
|
||||||
|
free(buf);
|
||||||
|
goto out;
|
||||||
}
|
}
|
||||||
/*
|
/* current binpkg is greater than idx version */
|
||||||
* Current binpkg is newer than the one registered
|
|
||||||
* in package index, remove outdated binpkg file
|
|
||||||
* and its dictionary from the pkg index.
|
|
||||||
*/
|
|
||||||
prop_dictionary_get_cstring_nocopy(curpkgd,
|
prop_dictionary_get_cstring_nocopy(curpkgd,
|
||||||
"filename", &oldfilen);
|
"filename", &oldfilen);
|
||||||
prop_dictionary_get_cstring_nocopy(curpkgd,
|
prop_dictionary_get_cstring_nocopy(curpkgd,
|
||||||
"pkgver", &oldpkgver);
|
"pkgver", &oldpkgver);
|
||||||
prop_dictionary_get_cstring_nocopy(curpkgd,
|
prop_dictionary_get_cstring_nocopy(curpkgd,
|
||||||
"architecture", &oldarch);
|
"architecture", &oldarch);
|
||||||
|
|
||||||
buf = strdup(oldpkgver);
|
buf = strdup(oldpkgver);
|
||||||
if (buf == NULL) {
|
if (buf == NULL) {
|
||||||
prop_object_release(newpkgd);
|
prop_object_release(newpkgd);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user