Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/lib/libalpm/sync.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libalpm/sync.c')
-rw-r--r--lib/libalpm/sync.c64
1 files changed, 30 insertions, 34 deletions
diff --git a/lib/libalpm/sync.c b/lib/libalpm/sync.c
index f125b4a6..95b5f9dc 100644
--- a/lib/libalpm/sync.c
+++ b/lib/libalpm/sync.c
@@ -152,7 +152,7 @@ static alpm_list_t *check_replacers(alpm_handle_t *handle, alpm_pkg_t *lpkg,
continue;
}
- QUESTION(handle->trans, ALPM_TRANS_CONV_REPLACE_PKG, lpkg, spkg,
+ QUESTION(handle, ALPM_TRANS_CONV_REPLACE_PKG, lpkg, spkg,
sdb->treename, &doreplace);
if(!doreplace) {
continue;
@@ -264,7 +264,7 @@ alpm_list_t SYMEXPORT *alpm_find_group_pkgs(alpm_list_t *dbs,
if(_alpm_pkg_should_ignore(db->handle, pkg)) {
ignorelist = alpm_list_add(ignorelist, pkg);
int install = 0;
- QUESTION(db->handle->trans, ALPM_TRANS_CONV_INSTALL_IGNOREPKG, pkg,
+ QUESTION(db->handle, ALPM_TRANS_CONV_INSTALL_IGNOREPKG, pkg,
NULL, NULL, &install);
if(!install)
continue;
@@ -360,7 +360,7 @@ int _alpm_sync_prepare(alpm_handle_t *handle, alpm_list_t **data)
/* Build up list by repeatedly resolving each transaction package */
/* Resolve targets dependencies */
- EVENT(trans, ALPM_TRANS_EVT_RESOLVEDEPS_START, NULL, NULL);
+ EVENT(handle, ALPM_TRANS_EVT_RESOLVEDEPS_START, NULL, NULL);
_alpm_log(handle, ALPM_LOG_DEBUG, "resolving target's dependencies\n");
/* build remove list for resolvedeps */
@@ -393,7 +393,7 @@ int _alpm_sync_prepare(alpm_handle_t *handle, alpm_list_t **data)
see if they'd like to ignore them rather than failing the sync */
if(unresolvable != NULL) {
int remove_unresolvable = 0;
- QUESTION(trans, ALPM_TRANS_CONV_REMOVE_PKGS, unresolvable,
+ QUESTION(handle, ALPM_TRANS_CONV_REMOVE_PKGS, unresolvable,
NULL, NULL, &remove_unresolvable);
if(remove_unresolvable) {
/* User wants to remove the unresolvable packages from the
@@ -431,12 +431,12 @@ int _alpm_sync_prepare(alpm_handle_t *handle, alpm_list_t **data)
trans->add = _alpm_sortbydeps(handle, resolved, 0);
alpm_list_free(resolved);
- EVENT(trans, ALPM_TRANS_EVT_RESOLVEDEPS_DONE, NULL, NULL);
+ EVENT(handle, ALPM_TRANS_EVT_RESOLVEDEPS_DONE, NULL, NULL);
}
if(!(trans->flags & ALPM_TRANS_FLAG_NOCONFLICTS)) {
/* check for inter-conflicts and whatnot */
- EVENT(trans, ALPM_TRANS_EVT_INTERCONFLICTS_START, NULL, NULL);
+ EVENT(handle, ALPM_TRANS_EVT_INTERCONFLICTS_START, NULL, NULL);
_alpm_log(handle, ALPM_LOG_DEBUG, "looking for conflicts\n");
@@ -525,7 +525,7 @@ int _alpm_sync_prepare(alpm_handle_t *handle, alpm_list_t **data)
alpm_pkg_t *sync = _alpm_pkg_find(trans->add, conflict->package1);
alpm_pkg_t *local = _alpm_db_get_pkgfromcache(handle->db_local, conflict->package2);
int doremove = 0;
- QUESTION(trans, ALPM_TRANS_CONV_CONFLICT_PKG, conflict->package1,
+ QUESTION(handle, ALPM_TRANS_CONV_CONFLICT_PKG, conflict->package1,
conflict->package2, conflict->reason->name, &doremove);
if(doremove) {
/* append to the removes list */
@@ -546,7 +546,7 @@ int _alpm_sync_prepare(alpm_handle_t *handle, alpm_list_t **data)
goto cleanup;
}
}
- EVENT(trans, ALPM_TRANS_EVT_INTERCONFLICTS_DONE, NULL, NULL);
+ EVENT(handle, ALPM_TRANS_EVT_INTERCONFLICTS_DONE, NULL, NULL);
alpm_list_free_inner(deps, (alpm_list_fn_free)_alpm_conflict_free);
alpm_list_free(deps);
}
@@ -646,7 +646,7 @@ static int apply_deltas(alpm_handle_t *handle)
if(!deltas_found) {
/* only show this if we actually have deltas to apply, and it is before
* the very first one */
- EVENT(trans, ALPM_TRANS_EVT_DELTA_PATCHES_START, NULL, NULL);
+ EVENT(handle, ALPM_TRANS_EVT_DELTA_PATCHES_START, NULL, NULL);
deltas_found = 1;
}
@@ -680,11 +680,11 @@ static int apply_deltas(alpm_handle_t *handle)
_alpm_log(handle, ALPM_LOG_DEBUG, "command: %s\n", command);
- EVENT(trans, ALPM_TRANS_EVT_DELTA_PATCH_START, d->to, d->delta);
+ EVENT(handle, ALPM_TRANS_EVT_DELTA_PATCH_START, d->to, d->delta);
int retval = system(command);
if(retval == 0) {
- EVENT(trans, ALPM_TRANS_EVT_DELTA_PATCH_DONE, NULL, NULL);
+ EVENT(handle, ALPM_TRANS_EVT_DELTA_PATCH_DONE, NULL, NULL);
/* delete the delta file */
unlink(delta);
@@ -702,7 +702,7 @@ static int apply_deltas(alpm_handle_t *handle)
if(retval != 0) {
/* one delta failed for this package, cancel the remaining ones */
- EVENT(trans, ALPM_TRANS_EVT_DELTA_PATCH_FAILED, NULL, NULL);
+ EVENT(handle, ALPM_TRANS_EVT_DELTA_PATCH_FAILED, NULL, NULL);
handle->pm_errno = ALPM_ERR_DLT_PATCHFAILED;
ret = 1;
break;
@@ -710,28 +710,25 @@ static int apply_deltas(alpm_handle_t *handle)
}
}
if(deltas_found) {
- EVENT(trans, ALPM_TRANS_EVT_DELTA_PATCHES_DONE, NULL, NULL);
+ EVENT(handle, ALPM_TRANS_EVT_DELTA_PATCHES_DONE, NULL, NULL);
}
return ret;
}
-/** Compares the md5sum of a file to the expected value.
- *
- * If the md5sum does not match, the user is asked whether the file
- * should be deleted.
- *
- * @param trans the transaction
+/**
+ * Prompts to delete the file now that we know it is invalid.
+ * @param handle the context handle
* @param filename the absolute path of the file to test
* @param reason an error code indicating the reason for package invalidity
*
* @return 1 if file was removed, 0 otherwise
*/
-static int prompt_to_delete(alpm_trans_t *trans, const char *filepath,
+static int prompt_to_delete(alpm_handle_t *handle, const char *filepath,
enum _alpm_errno_t reason)
{
int doremove = 0;
- QUESTION(trans, ALPM_TRANS_CONV_CORRUPTED_PKG, (char *)filepath,
+ QUESTION(handle, ALPM_TRANS_CONV_CORRUPTED_PKG, (char *)filepath,
&reason, NULL, &doremove);
if(doremove) {
unlink(filepath);
@@ -744,21 +741,20 @@ static int validate_deltas(alpm_handle_t *handle, alpm_list_t *deltas,
{
int errors = 0;
alpm_list_t *i;
- alpm_trans_t *trans = handle->trans;
if(!deltas) {
return 0;
}
/* Check integrity of deltas */
- EVENT(trans, ALPM_TRANS_EVT_DELTA_INTEGRITY_START, NULL, NULL);
+ EVENT(handle, ALPM_TRANS_EVT_DELTA_INTEGRITY_START, NULL, NULL);
for(i = deltas; i; i = i->next) {
alpm_delta_t *d = alpm_list_getdata(i);
char *filepath = _alpm_filecache_find(handle, d->delta);
if(_alpm_test_checksum(filepath, d->delta_md5, ALPM_CSUM_MD5)) {
- prompt_to_delete(trans, filepath, ALPM_ERR_DLT_INVALID);
+ prompt_to_delete(handle, filepath, ALPM_ERR_DLT_INVALID);
errors++;
*data = alpm_list_add(*data, strdup(d->delta));
}
@@ -844,7 +840,7 @@ static int download_files(alpm_handle_t *handle, alpm_list_t **deltas)
}
if(files) {
- EVENT(handle->trans, ALPM_TRANS_EVT_RETRIEVE_START, current->treename, NULL);
+ EVENT(handle, ALPM_TRANS_EVT_RETRIEVE_START, current->treename, NULL);
for(j = files; j; j = j->next) {
struct dload_payload *payload = j->data;
alpm_list_t *server;
@@ -931,7 +927,7 @@ int _alpm_sync_commit(alpm_handle_t *handle, alpm_list_t **data)
/* Check integrity of packages */
numtargs = alpm_list_count(trans->add);
- EVENT(trans, ALPM_TRANS_EVT_INTEGRITY_START, NULL, NULL);
+ EVENT(handle, ALPM_TRANS_EVT_INTEGRITY_START, NULL, NULL);
current = current_bytes = 0;
errors = 0;
@@ -943,7 +939,7 @@ int _alpm_sync_commit(alpm_handle_t *handle, alpm_list_t **data)
alpm_siglevel_t level;
int percent = (int)(((double)current_bytes / total_bytes) * 100);
- PROGRESS(trans, ALPM_TRANS_PROGRESS_INTEGRITY_START, "", percent,
+ PROGRESS(handle, ALPM_TRANS_PROGRESS_INTEGRITY_START, "", percent,
numtargs, current);
if(spkg->origin == PKG_FROM_FILE) {
continue; /* pkg_load() has been already called, this package is valid */
@@ -962,7 +958,7 @@ int _alpm_sync_commit(alpm_handle_t *handle, alpm_list_t **data)
spkg->name);
alpm_pkg_t *pkgfile =_alpm_pkg_load_internal(handle, filepath, spkg, 1, level);
if(!pkgfile) {
- prompt_to_delete(trans, filepath, handle->pm_errno);
+ prompt_to_delete(handle, filepath, handle->pm_errno);
errors++;
*data = alpm_list_add(*data, strdup(filename));
FREE(filepath);
@@ -974,9 +970,9 @@ int _alpm_sync_commit(alpm_handle_t *handle, alpm_list_t **data)
_alpm_pkg_free_trans(spkg); /* spkg has been removed from the target list */
}
- PROGRESS(trans, ALPM_TRANS_PROGRESS_INTEGRITY_START, "", 100,
+ PROGRESS(handle, ALPM_TRANS_PROGRESS_INTEGRITY_START, "", 100,
numtargs, current);
- EVENT(trans, ALPM_TRANS_EVT_INTEGRITY_DONE, NULL, NULL);
+ EVENT(handle, ALPM_TRANS_EVT_INTEGRITY_DONE, NULL, NULL);
if(errors) {
@@ -996,7 +992,7 @@ int _alpm_sync_commit(alpm_handle_t *handle, alpm_list_t **data)
/* fileconflict check */
if(!(trans->flags & ALPM_TRANS_FLAG_FORCE)) {
- EVENT(trans, ALPM_TRANS_EVT_FILECONFLICTS_START, NULL, NULL);
+ EVENT(handle, ALPM_TRANS_EVT_FILECONFLICTS_START, NULL, NULL);
_alpm_log(handle, ALPM_LOG_DEBUG, "looking for file conflicts\n");
alpm_list_t *conflict = _alpm_db_find_fileconflicts(handle,
@@ -1011,12 +1007,12 @@ int _alpm_sync_commit(alpm_handle_t *handle, alpm_list_t **data)
RET_ERR(handle, ALPM_ERR_FILE_CONFLICTS, -1);
}
- EVENT(trans, ALPM_TRANS_EVT_FILECONFLICTS_DONE, NULL, NULL);
+ EVENT(handle, ALPM_TRANS_EVT_FILECONFLICTS_DONE, NULL, NULL);
}
/* check available disk space */
if(handle->checkspace) {
- EVENT(trans, ALPM_TRANS_EVT_DISKSPACE_START, NULL, NULL);
+ EVENT(handle, ALPM_TRANS_EVT_DISKSPACE_START, NULL, NULL);
_alpm_log(handle, ALPM_LOG_DEBUG, "checking available disk space\n");
if(_alpm_check_diskspace(handle) == -1) {
@@ -1024,7 +1020,7 @@ int _alpm_sync_commit(alpm_handle_t *handle, alpm_list_t **data)
return -1;
}
- EVENT(trans, ALPM_TRANS_EVT_DISKSPACE_DONE, NULL, NULL);
+ EVENT(handle, ALPM_TRANS_EVT_DISKSPACE_DONE, NULL, NULL);
}
/* remove conflicting and to-be-replaced packages */