libalpm: check for duplicate filenames
This partially fixes FS#67850 It fixes the case for -S'ing packages but not -U'ing urls. pacman -S a/a b/b resolving dependencies... error: packages a and b have the same filename: a-1-1-any.pkg.tar.zst error: failed to prepare transaction (duplicate filename) Signed-off-by: Allan McRae <allan@archlinux.org>
This commit is contained in:
parent
d6ffa7f561
commit
618fa4f675
3 changed files with 23 additions and 0 deletions
|
@ -257,6 +257,8 @@ typedef enum _alpm_errno_t {
|
||||||
ALPM_ERR_TRANS_NULL,
|
ALPM_ERR_TRANS_NULL,
|
||||||
/** Duplicate target in transaction */
|
/** Duplicate target in transaction */
|
||||||
ALPM_ERR_TRANS_DUP_TARGET,
|
ALPM_ERR_TRANS_DUP_TARGET,
|
||||||
|
/** Duplicate filename in transaction */
|
||||||
|
ALPM_ERR_TRANS_DUP_FILENAME,
|
||||||
/** A transaction has not been initialized */
|
/** A transaction has not been initialized */
|
||||||
ALPM_ERR_TRANS_NOT_INITIALIZED,
|
ALPM_ERR_TRANS_NOT_INITIALIZED,
|
||||||
/** Transaction has not been prepared */
|
/** Transaction has not been prepared */
|
||||||
|
|
|
@ -90,6 +90,8 @@ const char SYMEXPORT *alpm_strerror(alpm_errno_t err)
|
||||||
return _("transaction not initialized");
|
return _("transaction not initialized");
|
||||||
case ALPM_ERR_TRANS_DUP_TARGET:
|
case ALPM_ERR_TRANS_DUP_TARGET:
|
||||||
return _("duplicate target");
|
return _("duplicate target");
|
||||||
|
case ALPM_ERR_TRANS_DUP_FILENAME:
|
||||||
|
return _("duplicate filename");
|
||||||
case ALPM_ERR_TRANS_NOT_INITIALIZED:
|
case ALPM_ERR_TRANS_NOT_INITIALIZED:
|
||||||
return _("transaction not initialized");
|
return _("transaction not initialized");
|
||||||
case ALPM_ERR_TRANS_NOT_PREPARED:
|
case ALPM_ERR_TRANS_NOT_PREPARED:
|
||||||
|
|
|
@ -464,6 +464,25 @@ int _alpm_sync_prepare(alpm_handle_t *handle, alpm_list_t **data)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Ensure two packages don't have the same filename */
|
||||||
|
for(i = resolved; i; i = i->next) {
|
||||||
|
alpm_pkg_t *pkg1 = i->data;
|
||||||
|
for(j = i->next; j; j = j->next) {
|
||||||
|
alpm_pkg_t *pkg2 = j->data;
|
||||||
|
if(strcmp(pkg1->filename, pkg2->filename) == 0) {
|
||||||
|
alpm_list_free(resolved);
|
||||||
|
ret = -1;
|
||||||
|
handle->pm_errno = ALPM_ERR_TRANS_DUP_FILENAME;
|
||||||
|
_alpm_log(handle, ALPM_LOG_ERROR, _("packages %s and %s have the same filename: %s\n"),
|
||||||
|
pkg1->name, pkg2->name, pkg1->filename);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(ret != 0) {
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
|
||||||
/* Set DEPEND reason for pulled packages */
|
/* Set DEPEND reason for pulled packages */
|
||||||
for(i = resolved; i; i = i->next) {
|
for(i = resolved; i; i = i->next) {
|
||||||
alpm_pkg_t *pkg = i->data;
|
alpm_pkg_t *pkg = i->data;
|
||||||
|
|
Loading…
Add table
Reference in a new issue