mirror of
https://github.com/moparisthebest/pacman
synced 2024-11-10 11:35:00 -05:00
Remove global handle dependencies from sync/upgrade paths
This kills a lot more global handle business off. sync.c still requires the handle declaration for one reference that can't be changed yet; it will be removed in a future patch which isolates all of the necesary API changes. Signed-off-by: Dan McGee <dan@archlinux.org>
This commit is contained in:
parent
d2f05f72f0
commit
e68f5d9a30
@ -47,9 +47,6 @@
|
|||||||
#include "remove.h"
|
#include "remove.h"
|
||||||
#include "handle.h"
|
#include "handle.h"
|
||||||
|
|
||||||
/* global handle variable */
|
|
||||||
extern pmhandle_t *handle;
|
|
||||||
|
|
||||||
/** Add a package to the transaction. */
|
/** Add a package to the transaction. */
|
||||||
int SYMEXPORT alpm_add_pkg(pmpkg_t *pkg)
|
int SYMEXPORT alpm_add_pkg(pmpkg_t *pkg)
|
||||||
{
|
{
|
||||||
@ -60,11 +57,10 @@ int SYMEXPORT alpm_add_pkg(pmpkg_t *pkg)
|
|||||||
|
|
||||||
/* Sanity checks */
|
/* Sanity checks */
|
||||||
ASSERT(pkg != NULL, RET_ERR(PM_ERR_WRONG_ARGS, -1));
|
ASSERT(pkg != NULL, RET_ERR(PM_ERR_WRONG_ARGS, -1));
|
||||||
ASSERT(handle != NULL, RET_ERR(PM_ERR_HANDLE_NULL, -1));
|
trans = pkg->handle->trans;
|
||||||
trans = handle->trans;
|
|
||||||
ASSERT(trans != NULL, RET_ERR(PM_ERR_TRANS_NULL, -1));
|
ASSERT(trans != NULL, RET_ERR(PM_ERR_TRANS_NULL, -1));
|
||||||
ASSERT(trans->state == STATE_INITIALIZED, RET_ERR(PM_ERR_TRANS_NOT_INITIALIZED, -1));
|
ASSERT(trans->state == STATE_INITIALIZED, RET_ERR(PM_ERR_TRANS_NOT_INITIALIZED, -1));
|
||||||
db_local = handle->db_local;
|
db_local = pkg->handle->db_local;
|
||||||
|
|
||||||
pkgname = pkg->name;
|
pkgname = pkg->name;
|
||||||
pkgver = pkg->version;
|
pkgver = pkg->version;
|
||||||
@ -132,9 +128,8 @@ static int perform_extraction(struct archive *archive,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int extract_single_file(struct archive *archive,
|
static int extract_single_file(pmhandle_t *handle, struct archive *archive,
|
||||||
struct archive_entry *entry, pmpkg_t *newpkg, pmpkg_t *oldpkg,
|
struct archive_entry *entry, pmpkg_t *newpkg, pmpkg_t *oldpkg)
|
||||||
pmtrans_t *trans, pmdb_t *db)
|
|
||||||
{
|
{
|
||||||
const char *entryname;
|
const char *entryname;
|
||||||
mode_t entrymode;
|
mode_t entrymode;
|
||||||
@ -152,12 +147,12 @@ static int extract_single_file(struct archive *archive,
|
|||||||
if(strcmp(entryname, ".INSTALL") == 0) {
|
if(strcmp(entryname, ".INSTALL") == 0) {
|
||||||
/* the install script goes inside the db */
|
/* the install script goes inside the db */
|
||||||
snprintf(filename, PATH_MAX, "%s%s-%s/install",
|
snprintf(filename, PATH_MAX, "%s%s-%s/install",
|
||||||
_alpm_db_path(db), newpkg->name, newpkg->version);
|
_alpm_db_path(handle->db_local), newpkg->name, newpkg->version);
|
||||||
archive_entry_set_perm(entry, 0644);
|
archive_entry_set_perm(entry, 0644);
|
||||||
} else if(strcmp(entryname, ".CHANGELOG") == 0) {
|
} else if(strcmp(entryname, ".CHANGELOG") == 0) {
|
||||||
/* the changelog goes inside the db */
|
/* the changelog goes inside the db */
|
||||||
snprintf(filename, PATH_MAX, "%s%s-%s/changelog",
|
snprintf(filename, PATH_MAX, "%s%s-%s/changelog",
|
||||||
_alpm_db_path(db), newpkg->name, newpkg->version);
|
_alpm_db_path(handle->db_local), newpkg->name, newpkg->version);
|
||||||
archive_entry_set_perm(entry, 0644);
|
archive_entry_set_perm(entry, 0644);
|
||||||
} else if(*entryname == '.') {
|
} else if(*entryname == '.') {
|
||||||
/* for now, ignore all files starting with '.' that haven't
|
/* for now, ignore all files starting with '.' that haven't
|
||||||
@ -426,7 +421,7 @@ static int extract_single_file(struct archive *archive,
|
|||||||
_alpm_log(PM_LOG_DEBUG, "extracting %s\n", filename);
|
_alpm_log(PM_LOG_DEBUG, "extracting %s\n", filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(trans->flags & PM_TRANS_FLAG_FORCE) {
|
if(handle->trans->flags & PM_TRANS_FLAG_FORCE) {
|
||||||
/* if FORCE was used, unlink() each file (whether it's there
|
/* if FORCE was used, unlink() each file (whether it's there
|
||||||
* or not) before extracting. This prevents the old "Text file busy"
|
* or not) before extracting. This prevents the old "Text file busy"
|
||||||
* error that crops up if forcing a glibc or pacman upgrade. */
|
* error that crops up if forcing a glibc or pacman upgrade. */
|
||||||
@ -467,15 +462,15 @@ static int extract_single_file(struct archive *archive,
|
|||||||
return errors;
|
return errors;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int commit_single_pkg(pmpkg_t *newpkg, size_t pkg_current,
|
static int commit_single_pkg(pmhandle_t *handle, pmpkg_t *newpkg,
|
||||||
size_t pkg_count, pmtrans_t *trans, pmdb_t *db)
|
size_t pkg_current, size_t pkg_count)
|
||||||
{
|
{
|
||||||
int i, ret = 0, errors = 0;
|
int i, ret = 0, errors = 0;
|
||||||
char scriptlet[PATH_MAX+1];
|
char scriptlet[PATH_MAX+1];
|
||||||
int is_upgrade = 0;
|
int is_upgrade = 0;
|
||||||
pmpkg_t *oldpkg = NULL;
|
pmpkg_t *oldpkg = NULL;
|
||||||
|
pmdb_t *db = handle->db_local;
|
||||||
ASSERT(trans != NULL, RET_ERR(PM_ERR_TRANS_NULL, -1));
|
pmtrans_t *trans = handle->trans;
|
||||||
|
|
||||||
snprintf(scriptlet, PATH_MAX, "%s%s-%s/install",
|
snprintf(scriptlet, PATH_MAX, "%s%s-%s/install",
|
||||||
_alpm_db_path(db), alpm_pkg_get_name(newpkg),
|
_alpm_db_path(db), alpm_pkg_get_name(newpkg),
|
||||||
@ -501,7 +496,7 @@ static int commit_single_pkg(pmpkg_t *newpkg, size_t pkg_current,
|
|||||||
|
|
||||||
/* pre_upgrade scriptlet */
|
/* pre_upgrade scriptlet */
|
||||||
if(alpm_pkg_has_scriptlet(newpkg) && !(trans->flags & PM_TRANS_FLAG_NOSCRIPTLET)) {
|
if(alpm_pkg_has_scriptlet(newpkg) && !(trans->flags & PM_TRANS_FLAG_NOSCRIPTLET)) {
|
||||||
_alpm_runscriptlet(handle, newpkg->origin_data.file,
|
_alpm_runscriptlet(newpkg->handle, newpkg->origin_data.file,
|
||||||
"pre_upgrade", newpkg->version, oldpkg->version);
|
"pre_upgrade", newpkg->version, oldpkg->version);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -513,7 +508,7 @@ static int commit_single_pkg(pmpkg_t *newpkg, size_t pkg_current,
|
|||||||
|
|
||||||
/* pre_install scriptlet */
|
/* pre_install scriptlet */
|
||||||
if(alpm_pkg_has_scriptlet(newpkg) && !(trans->flags & PM_TRANS_FLAG_NOSCRIPTLET)) {
|
if(alpm_pkg_has_scriptlet(newpkg) && !(trans->flags & PM_TRANS_FLAG_NOSCRIPTLET)) {
|
||||||
_alpm_runscriptlet(handle, newpkg->origin_data.file,
|
_alpm_runscriptlet(newpkg->handle, newpkg->origin_data.file,
|
||||||
"pre_install", newpkg->version, NULL);
|
"pre_install", newpkg->version, NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -527,7 +522,7 @@ static int commit_single_pkg(pmpkg_t *newpkg, size_t pkg_current,
|
|||||||
|
|
||||||
if(oldpkg) {
|
if(oldpkg) {
|
||||||
/* set up fake remove transaction */
|
/* set up fake remove transaction */
|
||||||
if(_alpm_upgraderemove_package(handle, oldpkg, newpkg) == -1) {
|
if(_alpm_upgraderemove_package(newpkg->handle, oldpkg, newpkg) == -1) {
|
||||||
pm_errno = PM_ERR_TRANS_ABORT;
|
pm_errno = PM_ERR_TRANS_ABORT;
|
||||||
ret = -1;
|
ret = -1;
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -577,8 +572,9 @@ static int commit_single_pkg(pmpkg_t *newpkg, size_t pkg_current,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* libarchive requires this for extracting hard links */
|
/* libarchive requires this for extracting hard links */
|
||||||
if(chdir(handle->root) != 0) {
|
if(chdir(newpkg->handle->root) != 0) {
|
||||||
_alpm_log(PM_LOG_ERROR, _("could not change directory to %s (%s)\n"), handle->root, strerror(errno));
|
_alpm_log(PM_LOG_ERROR, _("could not change directory to %s (%s)\n"),
|
||||||
|
newpkg->handle->root, strerror(errno));
|
||||||
ret = -1;
|
ret = -1;
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
@ -622,8 +618,7 @@ static int commit_single_pkg(pmpkg_t *newpkg, size_t pkg_current,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* extract the next file from the archive */
|
/* extract the next file from the archive */
|
||||||
errors += extract_single_file(archive, entry, newpkg, oldpkg,
|
errors += extract_single_file(newpkg->handle, archive, entry, newpkg, oldpkg);
|
||||||
trans, db);
|
|
||||||
}
|
}
|
||||||
archive_read_finish(archive);
|
archive_read_finish(archive);
|
||||||
|
|
||||||
@ -681,11 +676,11 @@ static int commit_single_pkg(pmpkg_t *newpkg, size_t pkg_current,
|
|||||||
if(alpm_pkg_has_scriptlet(newpkg)
|
if(alpm_pkg_has_scriptlet(newpkg)
|
||||||
&& !(trans->flags & PM_TRANS_FLAG_NOSCRIPTLET)) {
|
&& !(trans->flags & PM_TRANS_FLAG_NOSCRIPTLET)) {
|
||||||
if(is_upgrade) {
|
if(is_upgrade) {
|
||||||
_alpm_runscriptlet(handle, scriptlet, "post_upgrade",
|
_alpm_runscriptlet(newpkg->handle, scriptlet, "post_upgrade",
|
||||||
alpm_pkg_get_version(newpkg),
|
alpm_pkg_get_version(newpkg),
|
||||||
oldpkg ? alpm_pkg_get_version(oldpkg) : NULL);
|
oldpkg ? alpm_pkg_get_version(oldpkg) : NULL);
|
||||||
} else {
|
} else {
|
||||||
_alpm_runscriptlet(handle, scriptlet, "post_install",
|
_alpm_runscriptlet(newpkg->handle, scriptlet, "post_install",
|
||||||
alpm_pkg_get_version(newpkg), NULL);
|
alpm_pkg_get_version(newpkg), NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -701,14 +696,12 @@ cleanup:
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int _alpm_upgrade_packages(pmtrans_t *trans, pmdb_t *db)
|
int _alpm_upgrade_packages(pmhandle_t *handle)
|
||||||
{
|
{
|
||||||
size_t pkg_count, pkg_current;
|
size_t pkg_count, pkg_current;
|
||||||
int skip_ldconfig = 0, ret = 0;
|
int skip_ldconfig = 0, ret = 0;
|
||||||
alpm_list_t *targ;
|
alpm_list_t *targ;
|
||||||
|
pmtrans_t *trans = handle->trans;
|
||||||
ASSERT(trans != NULL, RET_ERR(PM_ERR_TRANS_NULL, -1));
|
|
||||||
ASSERT(db != NULL, RET_ERR(PM_ERR_DB_NULL, -1));
|
|
||||||
|
|
||||||
if(trans->add == NULL) {
|
if(trans->add == NULL) {
|
||||||
return 0;
|
return 0;
|
||||||
@ -724,7 +717,7 @@ int _alpm_upgrade_packages(pmtrans_t *trans, pmdb_t *db)
|
|||||||
}
|
}
|
||||||
|
|
||||||
pmpkg_t *newpkg = (pmpkg_t *)targ->data;
|
pmpkg_t *newpkg = (pmpkg_t *)targ->data;
|
||||||
if(commit_single_pkg(newpkg, pkg_current, pkg_count, trans, db)) {
|
if(commit_single_pkg(handle, newpkg, pkg_current, pkg_count)) {
|
||||||
/* something screwed up on the commit, abort the trans */
|
/* something screwed up on the commit, abort the trans */
|
||||||
trans->state = STATE_INTERRUPTED;
|
trans->state = STATE_INTERRUPTED;
|
||||||
pm_errno = PM_ERR_TRANS_ABORT;
|
pm_errno = PM_ERR_TRANS_ABORT;
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
#include "alpm_list.h"
|
#include "alpm_list.h"
|
||||||
#include "trans.h"
|
#include "trans.h"
|
||||||
|
|
||||||
int _alpm_upgrade_packages(pmtrans_t *trans, pmdb_t *db);
|
int _alpm_upgrade_packages(pmhandle_t *handle);
|
||||||
|
|
||||||
#endif /* _ALPM_ADD_H */
|
#endif /* _ALPM_ADD_H */
|
||||||
|
|
||||||
|
@ -40,9 +40,6 @@
|
|||||||
#include "log.h"
|
#include "log.h"
|
||||||
#include "deps.h"
|
#include "deps.h"
|
||||||
|
|
||||||
/* global handle variable */
|
|
||||||
extern pmhandle_t *handle;
|
|
||||||
|
|
||||||
pmconflict_t *_alpm_conflict_new(const char *package1, const char *package2,
|
pmconflict_t *_alpm_conflict_new(const char *package1, const char *package2,
|
||||||
const char *reason)
|
const char *reason)
|
||||||
{
|
{
|
||||||
@ -308,7 +305,7 @@ static int dir_belongsto_pkg(char *dirpath, pmpkg_t *pkg)
|
|||||||
char abspath[PATH_MAX];
|
char abspath[PATH_MAX];
|
||||||
DIR *dir;
|
DIR *dir;
|
||||||
|
|
||||||
snprintf(abspath, PATH_MAX, "%s%s", handle->root, dirpath);
|
snprintf(abspath, PATH_MAX, "%s%s", pkg->handle->root, dirpath);
|
||||||
dir = opendir(abspath);
|
dir = opendir(abspath);
|
||||||
if(dir == NULL) {
|
if(dir == NULL) {
|
||||||
return 1;
|
return 1;
|
||||||
@ -320,7 +317,7 @@ static int dir_belongsto_pkg(char *dirpath, pmpkg_t *pkg)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
snprintf(path, PATH_MAX, "%s/%s", dirpath, name);
|
snprintf(path, PATH_MAX, "%s/%s", dirpath, name);
|
||||||
snprintf(abspath, PATH_MAX, "%s%s", handle->root, path);
|
snprintf(abspath, PATH_MAX, "%s%s", pkg->handle->root, path);
|
||||||
if(stat(abspath, &sbuf) != 0) {
|
if(stat(abspath, &sbuf) != 0) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -347,14 +344,15 @@ static int dir_belongsto_pkg(char *dirpath, pmpkg_t *pkg)
|
|||||||
/* Find file conflicts that may occur during the transaction with two checks:
|
/* Find file conflicts that may occur during the transaction with two checks:
|
||||||
* 1: check every target against every target
|
* 1: check every target against every target
|
||||||
* 2: check every target against the filesystem */
|
* 2: check every target against the filesystem */
|
||||||
alpm_list_t *_alpm_db_find_fileconflicts(pmdb_t *db, pmtrans_t *trans,
|
alpm_list_t *_alpm_db_find_fileconflicts(pmhandle_t *handle,
|
||||||
alpm_list_t *upgrade, alpm_list_t *remove)
|
alpm_list_t *upgrade, alpm_list_t *remove)
|
||||||
{
|
{
|
||||||
alpm_list_t *i, *j, *conflicts = NULL;
|
alpm_list_t *i, *j, *conflicts = NULL;
|
||||||
size_t numtargs = alpm_list_count(upgrade);
|
size_t numtargs = alpm_list_count(upgrade);
|
||||||
size_t current;
|
size_t current;
|
||||||
|
pmtrans_t *trans = handle->trans;
|
||||||
|
|
||||||
if(db == NULL || upgrade == NULL || trans == NULL) {
|
if(!upgrade) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -402,7 +400,7 @@ alpm_list_t *_alpm_db_find_fileconflicts(pmdb_t *db, pmtrans_t *trans,
|
|||||||
|
|
||||||
/* CHECK 2: check every target against the filesystem */
|
/* CHECK 2: check every target against the filesystem */
|
||||||
_alpm_log(PM_LOG_DEBUG, "searching for filesystem conflicts: %s\n", p1->name);
|
_alpm_log(PM_LOG_DEBUG, "searching for filesystem conflicts: %s\n", p1->name);
|
||||||
dbpkg = _alpm_db_get_pkgfromcache(db, p1->name);
|
dbpkg = _alpm_db_get_pkgfromcache(handle->db_local, p1->name);
|
||||||
|
|
||||||
/* Do two different checks here. If the package is currently installed,
|
/* Do two different checks here. If the package is currently installed,
|
||||||
* then only check files that are new in the new package. If the package
|
* then only check files that are new in the new package. If the package
|
||||||
@ -456,7 +454,7 @@ alpm_list_t *_alpm_db_find_fileconflicts(pmdb_t *db, pmtrans_t *trans,
|
|||||||
if(!p2 || strcmp(p1->name, p2->name) == 0) {
|
if(!p2 || strcmp(p1->name, p2->name) == 0) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
pmpkg_t *localp2 = _alpm_db_get_pkgfromcache(db, p2->name);
|
pmpkg_t *localp2 = _alpm_db_get_pkgfromcache(handle->db_local, p2->name);
|
||||||
|
|
||||||
/* localp2->files will be removed (target conflicts are handled by CHECK 1) */
|
/* localp2->files will be removed (target conflicts are handled by CHECK 1) */
|
||||||
if(localp2 && alpm_list_find_str(alpm_pkg_get_files(localp2), filestr)) {
|
if(localp2 && alpm_list_find_str(alpm_pkg_get_files(localp2), filestr)) {
|
||||||
|
@ -42,8 +42,8 @@ pmconflict_t *_alpm_conflict_dup(const pmconflict_t *conflict);
|
|||||||
void _alpm_conflict_free(pmconflict_t *conflict);
|
void _alpm_conflict_free(pmconflict_t *conflict);
|
||||||
alpm_list_t *_alpm_innerconflicts(alpm_list_t *packages);
|
alpm_list_t *_alpm_innerconflicts(alpm_list_t *packages);
|
||||||
alpm_list_t *_alpm_outerconflicts(pmdb_t *db, alpm_list_t *packages);
|
alpm_list_t *_alpm_outerconflicts(pmdb_t *db, alpm_list_t *packages);
|
||||||
alpm_list_t *_alpm_db_find_fileconflicts(pmdb_t *db, pmtrans_t *trans,
|
alpm_list_t *_alpm_db_find_fileconflicts(pmhandle_t *handle,
|
||||||
alpm_list_t *upgrade, alpm_list_t *remove);
|
alpm_list_t *upgrade, alpm_list_t *remove);
|
||||||
|
|
||||||
void _alpm_fileconflict_free(pmfileconflict_t *conflict);
|
void _alpm_fileconflict_free(pmfileconflict_t *conflict);
|
||||||
|
|
||||||
|
@ -233,7 +233,7 @@ alpm_list_t SYMEXPORT *alpm_find_grp_pkgs(alpm_list_t *dbs,
|
|||||||
if(_alpm_pkg_should_ignore(pkg)) {
|
if(_alpm_pkg_should_ignore(pkg)) {
|
||||||
ignorelist = alpm_list_add(ignorelist, pkg);
|
ignorelist = alpm_list_add(ignorelist, pkg);
|
||||||
int install = 0;
|
int install = 0;
|
||||||
QUESTION(handle->trans, PM_TRANS_CONV_INSTALL_IGNOREPKG, pkg,
|
QUESTION(db->handle->trans, PM_TRANS_CONV_INSTALL_IGNOREPKG, pkg,
|
||||||
NULL, NULL, &install);
|
NULL, NULL, &install);
|
||||||
if(!install)
|
if(!install)
|
||||||
continue;
|
continue;
|
||||||
@ -270,7 +270,7 @@ static int compute_download_size(pmpkg_t *newpkg)
|
|||||||
if(fpath) {
|
if(fpath) {
|
||||||
FREE(fpath);
|
FREE(fpath);
|
||||||
size = 0;
|
size = 0;
|
||||||
} else if(handle->usedelta) {
|
} else if(newpkg->handle->usedelta) {
|
||||||
off_t dltsize;
|
off_t dltsize;
|
||||||
off_t pkgsize = alpm_pkg_get_size(newpkg);
|
off_t pkgsize = alpm_pkg_get_size(newpkg);
|
||||||
|
|
||||||
@ -300,16 +300,15 @@ static int compute_download_size(pmpkg_t *newpkg)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int _alpm_sync_prepare(pmtrans_t *trans, pmdb_t *db_local, alpm_list_t *dbs_sync, alpm_list_t **data)
|
int _alpm_sync_prepare(pmhandle_t *handle, alpm_list_t **data)
|
||||||
{
|
{
|
||||||
alpm_list_t *deps = NULL;
|
alpm_list_t *deps = NULL;
|
||||||
alpm_list_t *unresolvable = NULL;
|
alpm_list_t *unresolvable = NULL;
|
||||||
alpm_list_t *i, *j;
|
alpm_list_t *i, *j;
|
||||||
alpm_list_t *remove = NULL;
|
alpm_list_t *remove = NULL;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
pmtrans_t *trans = handle->trans;
|
||||||
ASSERT(db_local != NULL, RET_ERR(PM_ERR_DB_NULL, -1));
|
pmdb_t *db_local = handle->db_local;
|
||||||
ASSERT(trans != NULL, RET_ERR(PM_ERR_TRANS_NULL, -1));
|
|
||||||
|
|
||||||
if(data) {
|
if(data) {
|
||||||
*data = NULL;
|
*data = NULL;
|
||||||
@ -340,7 +339,7 @@ int _alpm_sync_prepare(pmtrans_t *trans, pmdb_t *db_local, alpm_list_t *dbs_sync
|
|||||||
building up a list of packages which could not be resolved. */
|
building up a list of packages which could not be resolved. */
|
||||||
for(i = trans->add; i; i = i->next) {
|
for(i = trans->add; i; i = i->next) {
|
||||||
pmpkg_t *pkg = i->data;
|
pmpkg_t *pkg = i->data;
|
||||||
if(_alpm_resolvedeps(localpkgs, dbs_sync, pkg, trans->add,
|
if(_alpm_resolvedeps(localpkgs, handle->dbs_sync, pkg, trans->add,
|
||||||
&resolved, remove, data) == -1) {
|
&resolved, remove, data) == -1) {
|
||||||
unresolvable = alpm_list_add(unresolvable, pkg);
|
unresolvable = alpm_list_add(unresolvable, pkg);
|
||||||
}
|
}
|
||||||
@ -725,7 +724,7 @@ static int validate_deltas(pmtrans_t *trans, alpm_list_t *deltas,
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int download_files(pmtrans_t *trans, alpm_list_t **deltas)
|
static int download_files(pmhandle_t *handle, alpm_list_t **deltas)
|
||||||
{
|
{
|
||||||
const char *cachedir;
|
const char *cachedir;
|
||||||
alpm_list_t *i, *j;
|
alpm_list_t *i, *j;
|
||||||
@ -733,7 +732,7 @@ static int download_files(pmtrans_t *trans, alpm_list_t **deltas)
|
|||||||
int errors = 0;
|
int errors = 0;
|
||||||
|
|
||||||
cachedir = _alpm_filecache_setup();
|
cachedir = _alpm_filecache_setup();
|
||||||
trans->state = STATE_DOWNLOADING;
|
handle->trans->state = STATE_DOWNLOADING;
|
||||||
|
|
||||||
/* Total progress - figure out the total download size if required to
|
/* Total progress - figure out the total download size if required to
|
||||||
* pass to the callback. This function is called once, and it is up to the
|
* pass to the callback. This function is called once, and it is up to the
|
||||||
@ -741,7 +740,7 @@ static int download_files(pmtrans_t *trans, alpm_list_t **deltas)
|
|||||||
if(handle->totaldlcb) {
|
if(handle->totaldlcb) {
|
||||||
off_t total_size = (off_t)0;
|
off_t total_size = (off_t)0;
|
||||||
/* sum up the download size for each package and store total */
|
/* sum up the download size for each package and store total */
|
||||||
for(i = trans->add; i; i = i->next) {
|
for(i = handle->trans->add; i; i = i->next) {
|
||||||
pmpkg_t *spkg = i->data;
|
pmpkg_t *spkg = i->data;
|
||||||
total_size += spkg->download_size;
|
total_size += spkg->download_size;
|
||||||
}
|
}
|
||||||
@ -752,7 +751,7 @@ static int download_files(pmtrans_t *trans, alpm_list_t **deltas)
|
|||||||
for(i = handle->dbs_sync; i; i = i->next) {
|
for(i = handle->dbs_sync; i; i = i->next) {
|
||||||
pmdb_t *current = i->data;
|
pmdb_t *current = i->data;
|
||||||
|
|
||||||
for(j = trans->add; j; j = j->next) {
|
for(j = handle->trans->add; j; j = j->next) {
|
||||||
pmpkg_t *spkg = j->data;
|
pmpkg_t *spkg = j->data;
|
||||||
|
|
||||||
if(spkg->origin != PKG_FROM_FILE && current == spkg->origin_data.db) {
|
if(spkg->origin != PKG_FROM_FILE && current == spkg->origin_data.db) {
|
||||||
@ -781,7 +780,7 @@ static int download_files(pmtrans_t *trans, alpm_list_t **deltas)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(files) {
|
if(files) {
|
||||||
EVENT(trans, PM_TRANS_EVT_RETRIEVE_START, current->treename, NULL);
|
EVENT(handle->trans, PM_TRANS_EVT_RETRIEVE_START, current->treename, NULL);
|
||||||
for(j = files; j; j = j->next) {
|
for(j = files; j; j = j->next) {
|
||||||
const char *filename = j->data;
|
const char *filename = j->data;
|
||||||
alpm_list_t *server;
|
alpm_list_t *server;
|
||||||
@ -819,7 +818,7 @@ static int download_files(pmtrans_t *trans, alpm_list_t **deltas)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for(j = trans->add; j; j = j->next) {
|
for(j = handle->trans->add; j; j = j->next) {
|
||||||
pmpkg_t *pkg = j->data;
|
pmpkg_t *pkg = j->data;
|
||||||
pkg->infolevel &= ~INFRQ_DSIZE;
|
pkg->infolevel &= ~INFRQ_DSIZE;
|
||||||
pkg->download_size = 0;
|
pkg->download_size = 0;
|
||||||
@ -832,16 +831,15 @@ static int download_files(pmtrans_t *trans, alpm_list_t **deltas)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int _alpm_sync_commit(pmtrans_t *trans, pmdb_t *db_local, alpm_list_t **data)
|
int _alpm_sync_commit(pmhandle_t *handle, alpm_list_t **data)
|
||||||
{
|
{
|
||||||
alpm_list_t *i;
|
alpm_list_t *i;
|
||||||
alpm_list_t *deltas = NULL;
|
alpm_list_t *deltas = NULL;
|
||||||
size_t numtargs, current = 0, replaces = 0;
|
size_t numtargs, current = 0, replaces = 0;
|
||||||
int errors;
|
int errors;
|
||||||
|
pmtrans_t *trans = handle->trans;
|
||||||
|
|
||||||
ASSERT(trans != NULL, RET_ERR(PM_ERR_TRANS_NULL, -1));
|
if(download_files(handle, &deltas)) {
|
||||||
|
|
||||||
if(download_files(trans, &deltas)) {
|
|
||||||
alpm_list_free(deltas);
|
alpm_list_free(deltas);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -915,8 +913,8 @@ int _alpm_sync_commit(pmtrans_t *trans, pmdb_t *db_local, alpm_list_t **data)
|
|||||||
EVENT(trans, PM_TRANS_EVT_FILECONFLICTS_START, NULL, NULL);
|
EVENT(trans, PM_TRANS_EVT_FILECONFLICTS_START, NULL, NULL);
|
||||||
|
|
||||||
_alpm_log(PM_LOG_DEBUG, "looking for file conflicts\n");
|
_alpm_log(PM_LOG_DEBUG, "looking for file conflicts\n");
|
||||||
alpm_list_t *conflict = _alpm_db_find_fileconflicts(db_local, trans,
|
alpm_list_t *conflict = _alpm_db_find_fileconflicts(handle,
|
||||||
trans->add, trans->remove);
|
trans->add, trans->remove);
|
||||||
if(conflict) {
|
if(conflict) {
|
||||||
if(data) {
|
if(data) {
|
||||||
*data = conflict;
|
*data = conflict;
|
||||||
@ -955,7 +953,7 @@ int _alpm_sync_commit(pmtrans_t *trans, pmdb_t *db_local, alpm_list_t **data)
|
|||||||
|
|
||||||
/* install targets */
|
/* install targets */
|
||||||
_alpm_log(PM_LOG_DEBUG, "installing packages\n");
|
_alpm_log(PM_LOG_DEBUG, "installing packages\n");
|
||||||
if(_alpm_upgrade_packages(trans, handle->db_local) == -1) {
|
if(_alpm_upgrade_packages(handle) == -1) {
|
||||||
_alpm_log(PM_LOG_ERROR, _("could not commit transaction\n"));
|
_alpm_log(PM_LOG_ERROR, _("could not commit transaction\n"));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -24,8 +24,8 @@
|
|||||||
|
|
||||||
#include "alpm.h"
|
#include "alpm.h"
|
||||||
|
|
||||||
int _alpm_sync_prepare(pmtrans_t *trans, pmdb_t *db_local, alpm_list_t *dbs_sync, alpm_list_t **data);
|
int _alpm_sync_prepare(pmhandle_t *handle, alpm_list_t **data);
|
||||||
int _alpm_sync_commit(pmtrans_t *trans, pmdb_t *db_local, alpm_list_t **data);
|
int _alpm_sync_commit(pmhandle_t *handle, alpm_list_t **data);
|
||||||
|
|
||||||
#endif /* _ALPM_SYNC_H */
|
#endif /* _ALPM_SYNC_H */
|
||||||
|
|
||||||
|
@ -202,7 +202,7 @@ int SYMEXPORT alpm_trans_prepare(alpm_list_t **data)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if(_alpm_sync_prepare(trans, handle->db_local, handle->dbs_sync, data) == -1) {
|
if(_alpm_sync_prepare(handle, data) == -1) {
|
||||||
/* pm_errno is set by _alpm_sync_prepare() */
|
/* pm_errno is set by _alpm_sync_prepare() */
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -241,7 +241,7 @@ int SYMEXPORT alpm_trans_commit(alpm_list_t **data)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if(_alpm_sync_commit(trans, handle->db_local, data) == -1) {
|
if(_alpm_sync_commit(handle, data) == -1) {
|
||||||
/* pm_errno is set by _alpm_sync_commit() */
|
/* pm_errno is set by _alpm_sync_commit() */
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user