2005-03-14 20:51:43 -05:00
|
|
|
/*
|
|
|
|
* sync.c
|
2007-11-16 21:18:45 -05:00
|
|
|
*
|
2011-01-05 23:45:15 -05:00
|
|
|
* Copyright (c) 2006-2011 Pacman Development Team <pacman-dev@archlinux.org>
|
2009-07-01 03:08:33 -04:00
|
|
|
* Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
|
2006-10-15 15:31:03 -04:00
|
|
|
* Copyright (c) 2005 by Aurelien Foret <orelien@chez.com>
|
|
|
|
* Copyright (c) 2005 by Christian Hamar <krics@linuxforum.hu>
|
|
|
|
* Copyright (c) 2005, 2006 by Miklos Vajna <vmiklos@frugalware.org>
|
2007-11-16 21:18:45 -05:00
|
|
|
*
|
2005-03-14 20:51:43 -05:00
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
2007-12-10 23:55:22 -05:00
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2005-03-14 20:51:43 -05:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
2007-03-05 17:13:33 -05:00
|
|
|
|
2008-06-01 22:47:31 -04:00
|
|
|
#include <sys/types.h> /* off_t */
|
2005-03-14 20:51:43 -05:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
2009-02-19 13:12:34 -05:00
|
|
|
#include <stdint.h> /* intmax_t */
|
2007-04-29 12:47:02 -04:00
|
|
|
#include <unistd.h>
|
2010-12-17 13:48:09 -05:00
|
|
|
#include <limits.h>
|
2007-03-05 17:13:33 -05:00
|
|
|
|
|
|
|
/* libalpm */
|
|
|
|
#include "sync.h"
|
|
|
|
#include "alpm_list.h"
|
2005-03-14 20:51:43 -05:00
|
|
|
#include "log.h"
|
|
|
|
#include "package.h"
|
|
|
|
#include "db.h"
|
|
|
|
#include "deps.h"
|
2006-01-15 10:55:16 -05:00
|
|
|
#include "conflict.h"
|
2005-03-14 20:51:43 -05:00
|
|
|
#include "trans.h"
|
Use sync.c for upgrade transaction prepare and commit
This patch utilizes the power of sync.c to fix FS#3492 and FS#5798.
Now an upgrade transaction is just a sync transaction internally (in alpm),
so all sync features are available with -U as well:
* conflict resolving
* sync dependencies from sync repos
* remove unresolvable targets
See http://www.archlinux.org/pipermail/pacman-dev/2009-June/008725.html
for the concept.
We use "mixed" target list, where PKG_FROM_FILE origin indicates local
package file, PKG_FROM_CACHE indicates sync package. The front-end can add
only one type of packages (depending on transaction type) atm, but if alpm
resolves dependencies for -U, we may get a real mixed trans->packages list.
_alpm_pkg_free_trans() was modified so that it can handle both target types
_alpm_add_prepare() was removed, we use _alpm_sync_prepare() instead
_alpm_add_commit() was renamed to _alpm_upgrade_targets()
sync.c (and deps.c) was modified slightly to handle mixed target lists,
the modifications are straightforward. There is one notable change here: We
don't create new upgrade trans in sync.c, we replace the pkgcache entries
with the loaded package files in the target list (this is a bit hackish) and
call _alpm_upgrade_targets(). This implies a TODO (pkg->origin_data.db is
not accessible anymore), but it doesn't hurt anything with pacman front-end,
so it will be fixed later (otherwise this patch would be huge).
I updated the documentation of -U and I added a new pactest, upgrade090.py,
to test the syncdeps feature of -U.
Signed-off-by: Nagy Gabor <ngaba@bibl.u-szeged.hu>
Signed-off-by: Dan McGee <dan@archlinux.org>
2009-06-09 11:23:46 -04:00
|
|
|
#include "add.h"
|
2006-10-15 15:31:03 -04:00
|
|
|
#include "util.h"
|
2005-03-14 20:51:43 -05:00
|
|
|
#include "handle.h"
|
2005-12-26 01:40:29 -05:00
|
|
|
#include "alpm.h"
|
2008-01-22 22:36:11 -05:00
|
|
|
#include "dload.h"
|
2007-10-19 13:17:53 -04:00
|
|
|
#include "delta.h"
|
2009-07-15 13:14:01 -04:00
|
|
|
#include "remove.h"
|
2010-11-16 00:57:39 -05:00
|
|
|
#include "diskspace.h"
|
2008-12-07 12:58:24 -05:00
|
|
|
#include "signing.h"
|
2005-03-14 20:51:43 -05:00
|
|
|
|
2008-01-27 19:44:23 -05:00
|
|
|
/** Check for new version of pkg in sync repos
|
|
|
|
* (only the first occurrence is considered in sync)
|
|
|
|
*/
|
|
|
|
pmpkg_t SYMEXPORT *alpm_sync_newversion(pmpkg_t *pkg, alpm_list_t *dbs_sync)
|
|
|
|
{
|
2011-03-20 20:45:57 -04:00
|
|
|
ASSERT(pkg != NULL, return NULL);
|
2009-04-13 09:08:38 -04:00
|
|
|
|
2008-01-27 19:44:23 -05:00
|
|
|
alpm_list_t *i;
|
|
|
|
pmpkg_t *spkg = NULL;
|
|
|
|
|
|
|
|
for(i = dbs_sync; !spkg && i; i = i->next) {
|
|
|
|
spkg = _alpm_db_get_pkgfromcache(i->data, alpm_pkg_get_name(pkg));
|
|
|
|
}
|
|
|
|
|
|
|
|
if(spkg == NULL) {
|
|
|
|
_alpm_log(PM_LOG_DEBUG, "'%s' not found in sync db => no upgrade\n",
|
|
|
|
alpm_pkg_get_name(pkg));
|
2011-03-20 20:45:57 -04:00
|
|
|
return NULL;
|
2008-01-27 19:44:23 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
/* compare versions and see if spkg is an upgrade */
|
2009-04-13 09:08:38 -04:00
|
|
|
if(_alpm_pkg_compare_versions(spkg, pkg) > 0) {
|
2008-01-27 19:44:23 -05:00
|
|
|
_alpm_log(PM_LOG_DEBUG, "new version of '%s' found (%s => %s)\n",
|
|
|
|
alpm_pkg_get_name(pkg), alpm_pkg_get_version(pkg),
|
|
|
|
alpm_pkg_get_version(spkg));
|
2011-03-20 20:45:57 -04:00
|
|
|
return spkg;
|
2008-01-27 19:44:23 -05:00
|
|
|
}
|
2009-04-13 09:08:38 -04:00
|
|
|
/* spkg is not an upgrade */
|
2011-03-20 20:45:57 -04:00
|
|
|
return NULL;
|
2008-01-27 19:44:23 -05:00
|
|
|
}
|
|
|
|
|
2011-04-17 03:45:52 -04:00
|
|
|
/** Search for packages to upgrade and add them to the transaction. */
|
2009-07-16 08:55:45 -04:00
|
|
|
int SYMEXPORT alpm_sync_sysupgrade(int enable_downgrade)
|
2006-12-29 12:04:58 -05:00
|
|
|
{
|
2009-04-13 09:08:38 -04:00
|
|
|
alpm_list_t *i, *j, *k;
|
2009-07-16 08:55:45 -04:00
|
|
|
pmtrans_t *trans;
|
|
|
|
pmdb_t *db_local;
|
|
|
|
alpm_list_t *dbs_sync;
|
2005-03-14 20:51:43 -05:00
|
|
|
|
2007-01-30 03:14:10 -05:00
|
|
|
ALPM_LOG_FUNC;
|
|
|
|
|
2009-07-16 08:55:45 -04:00
|
|
|
ASSERT(handle != NULL, RET_ERR(PM_ERR_HANDLE_NULL, -1));
|
|
|
|
trans = handle->trans;
|
|
|
|
db_local = handle->db_local;
|
|
|
|
dbs_sync = handle->dbs_sync;
|
|
|
|
ASSERT(trans != NULL, RET_ERR(PM_ERR_TRANS_NULL, -1));
|
|
|
|
ASSERT(trans->state == STATE_INITIALIZED, RET_ERR(PM_ERR_TRANS_NOT_INITIALIZED, -1));
|
|
|
|
|
2007-08-24 18:10:40 -04:00
|
|
|
_alpm_log(PM_LOG_DEBUG, "checking for package upgrades\n");
|
2011-02-25 09:22:09 -05:00
|
|
|
for(i = _alpm_db_get_pkgcache(db_local); i; i = i->next) {
|
2009-04-13 09:08:38 -04:00
|
|
|
pmpkg_t *lpkg = i->data;
|
2007-08-24 18:10:40 -04:00
|
|
|
|
2009-07-15 13:14:01 -04:00
|
|
|
if(_alpm_pkg_find(trans->add, lpkg->name)) {
|
2009-04-13 09:08:38 -04:00
|
|
|
_alpm_log(PM_LOG_DEBUG, "%s is already in the target list -- skipping\n", lpkg->name);
|
2007-08-24 18:10:40 -04:00
|
|
|
continue;
|
|
|
|
}
|
2006-12-29 12:04:58 -05:00
|
|
|
|
2009-04-13 09:08:38 -04:00
|
|
|
/* Search for literal then replacers in each sync database.
|
|
|
|
* If found, don't check other databases */
|
|
|
|
for(j = dbs_sync; j; j = j->next) {
|
|
|
|
pmdb_t *sdb = j->data;
|
|
|
|
/* Check sdb */
|
|
|
|
pmpkg_t *spkg = _alpm_db_get_pkgfromcache(sdb, lpkg->name);
|
2011-04-20 20:00:59 -04:00
|
|
|
if(spkg) {
|
|
|
|
/* 1. literal was found in sdb */
|
2009-04-13 09:08:38 -04:00
|
|
|
int cmp = _alpm_pkg_compare_versions(spkg, lpkg);
|
|
|
|
if(cmp > 0) {
|
|
|
|
_alpm_log(PM_LOG_DEBUG, "new version of '%s' found (%s => %s)\n",
|
|
|
|
lpkg->name, lpkg->version, spkg->version);
|
|
|
|
/* check IgnorePkg/IgnoreGroup */
|
|
|
|
if(_alpm_pkg_should_ignore(spkg) || _alpm_pkg_should_ignore(lpkg)) {
|
|
|
|
_alpm_log(PM_LOG_WARNING, _("%s: ignoring package upgrade (%s => %s)\n"),
|
|
|
|
lpkg->name, lpkg->version, spkg->version);
|
|
|
|
} else {
|
|
|
|
_alpm_log(PM_LOG_DEBUG, "adding package %s-%s to the transaction targets\n",
|
|
|
|
spkg->name, spkg->version);
|
2009-07-15 13:14:01 -04:00
|
|
|
trans->add = alpm_list_add(trans->add, spkg);
|
2009-04-13 09:08:38 -04:00
|
|
|
}
|
|
|
|
} else if(cmp < 0) {
|
2009-05-14 12:25:16 -04:00
|
|
|
if(enable_downgrade) {
|
|
|
|
/* check IgnorePkg/IgnoreGroup */
|
|
|
|
if(_alpm_pkg_should_ignore(spkg) || _alpm_pkg_should_ignore(lpkg)) {
|
|
|
|
_alpm_log(PM_LOG_WARNING, _("%s: ignoring package downgrade (%s => %s)\n"),
|
|
|
|
lpkg->name, lpkg->version, spkg->version);
|
|
|
|
} else {
|
|
|
|
_alpm_log(PM_LOG_WARNING, _("%s: downgrading from version %s to version %s\n"),
|
|
|
|
lpkg->name, lpkg->version, spkg->version);
|
2009-07-15 13:14:01 -04:00
|
|
|
trans->add = alpm_list_add(trans->add, spkg);
|
2009-05-14 12:25:16 -04:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
_alpm_log(PM_LOG_WARNING, _("%s: local (%s) is newer than %s (%s)\n"),
|
|
|
|
lpkg->name, lpkg->version, sdb->treename, spkg->version);
|
|
|
|
}
|
2009-04-13 09:08:38 -04:00
|
|
|
}
|
2011-04-20 20:00:59 -04:00
|
|
|
/* jump to next local package */
|
|
|
|
break;
|
|
|
|
} else {
|
|
|
|
/* 2. search for replacers in sdb */
|
2009-04-13 09:08:38 -04:00
|
|
|
int found = 0;
|
2011-02-25 09:22:09 -05:00
|
|
|
for(k = _alpm_db_get_pkgcache(sdb); k; k = k->next) {
|
2009-04-13 09:08:38 -04:00
|
|
|
spkg = k->data;
|
|
|
|
if(alpm_list_find_str(alpm_pkg_get_replaces(spkg), lpkg->name)) {
|
|
|
|
found = 1;
|
|
|
|
/* check IgnorePkg/IgnoreGroup */
|
|
|
|
if(_alpm_pkg_should_ignore(spkg) || _alpm_pkg_should_ignore(lpkg)) {
|
|
|
|
_alpm_log(PM_LOG_WARNING, _("ignoring package replacement (%s-%s => %s-%s)\n"),
|
|
|
|
lpkg->name, lpkg->version, spkg->name, spkg->version);
|
|
|
|
continue;
|
|
|
|
}
|
2007-08-24 18:10:40 -04:00
|
|
|
|
2009-04-13 09:08:38 -04:00
|
|
|
int doreplace = 0;
|
|
|
|
QUESTION(trans, PM_TRANS_CONV_REPLACE_PKG, lpkg, spkg, sdb->treename, &doreplace);
|
|
|
|
if(!doreplace) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2011-03-21 10:02:03 -04:00
|
|
|
/* If spkg is already in the target list, we append lpkg to spkg's
|
|
|
|
* removes list */
|
2009-07-15 13:14:01 -04:00
|
|
|
pmpkg_t *tpkg = _alpm_pkg_find(trans->add, spkg->name);
|
2009-04-13 09:08:38 -04:00
|
|
|
if(tpkg) {
|
|
|
|
/* sanity check, multiple repos can contain spkg->name */
|
|
|
|
if(tpkg->origin_data.db != sdb) {
|
|
|
|
_alpm_log(PM_LOG_WARNING, _("cannot replace %s by %s\n"),
|
|
|
|
lpkg->name, spkg->name);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
_alpm_log(PM_LOG_DEBUG, "appending %s to the removes list of %s\n",
|
|
|
|
lpkg->name, tpkg->name);
|
|
|
|
tpkg->removes = alpm_list_add(tpkg->removes, lpkg);
|
|
|
|
/* check the to-be-replaced package's reason field */
|
|
|
|
if(alpm_pkg_get_reason(lpkg) == PM_PKG_REASON_EXPLICIT) {
|
|
|
|
tpkg->reason = PM_PKG_REASON_EXPLICIT;
|
|
|
|
}
|
2011-04-20 20:00:59 -04:00
|
|
|
} else {
|
|
|
|
/* add spkg to the target list */
|
2009-04-13 09:08:38 -04:00
|
|
|
/* copy over reason */
|
|
|
|
spkg->reason = alpm_pkg_get_reason(lpkg);
|
|
|
|
spkg->removes = alpm_list_add(NULL, lpkg);
|
|
|
|
_alpm_log(PM_LOG_DEBUG, "adding package %s-%s to the transaction targets\n",
|
|
|
|
spkg->name, spkg->version);
|
2009-07-15 13:14:01 -04:00
|
|
|
trans->add = alpm_list_add(trans->add, spkg);
|
2009-04-13 09:08:38 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(found) {
|
|
|
|
break; /* jump to next local package */
|
|
|
|
}
|
2008-01-27 19:44:23 -05:00
|
|
|
}
|
2005-03-14 20:51:43 -05:00
|
|
|
}
|
2006-12-29 12:04:58 -05:00
|
|
|
}
|
2007-08-24 18:10:40 -04:00
|
|
|
|
2011-03-20 20:45:57 -04:00
|
|
|
return 0;
|
2005-03-14 20:51:43 -05:00
|
|
|
}
|
|
|
|
|
2010-10-16 18:59:53 -04:00
|
|
|
/** Find group members across a list of databases.
|
|
|
|
* If a member exists in several databases, only the first database is used.
|
|
|
|
* IgnorePkg is also handled.
|
|
|
|
* @param dbs the list of pmdb_t *
|
|
|
|
* @pram name the name of the group
|
|
|
|
* @return the list of pmpkg_t * (caller is responsible for alpm_list_free)
|
|
|
|
*/
|
|
|
|
alpm_list_t SYMEXPORT *alpm_find_grp_pkgs(alpm_list_t *dbs,
|
|
|
|
const char *name)
|
|
|
|
{
|
|
|
|
alpm_list_t *i, *j, *pkgs = NULL, *ignorelist = NULL;
|
|
|
|
|
|
|
|
for(i = dbs; i; i = i->next) {
|
|
|
|
pmdb_t *db = i->data;
|
|
|
|
pmgrp_t *grp = alpm_db_readgrp(db, name);
|
|
|
|
|
|
|
|
if(!grp)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
for(j = alpm_grp_get_pkgs(grp); j; j = j->next) {
|
|
|
|
pmpkg_t *pkg = j->data;
|
|
|
|
|
|
|
|
if(_alpm_pkg_find(ignorelist, alpm_pkg_get_name(pkg))) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if(_alpm_pkg_should_ignore(pkg)) {
|
|
|
|
ignorelist = alpm_list_add(ignorelist, pkg);
|
|
|
|
int install = 0;
|
|
|
|
QUESTION(handle->trans, PM_TRANS_CONV_INSTALL_IGNOREPKG, pkg,
|
|
|
|
NULL, NULL, &install);
|
|
|
|
if(!install)
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if(!_alpm_pkg_find(pkgs, alpm_pkg_get_name(pkg))) {
|
|
|
|
pkgs = alpm_list_add(pkgs, pkg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
alpm_list_free(ignorelist);
|
2011-03-20 20:45:57 -04:00
|
|
|
return pkgs;
|
2010-10-16 18:59:53 -04:00
|
|
|
}
|
|
|
|
|
2008-02-16 11:47:22 -05:00
|
|
|
/** Compute the size of the files that will be downloaded to install a
|
|
|
|
* package.
|
|
|
|
* @param newpkg the new package to upgrade to
|
|
|
|
*/
|
2008-04-26 14:03:53 -04:00
|
|
|
static int compute_download_size(pmpkg_t *newpkg)
|
2008-02-16 11:47:22 -05:00
|
|
|
{
|
2008-04-26 14:03:53 -04:00
|
|
|
const char *fname;
|
|
|
|
char *fpath;
|
2008-06-01 22:47:31 -04:00
|
|
|
off_t size = 0;
|
2008-02-16 11:47:22 -05:00
|
|
|
|
2010-10-27 02:25:45 -04:00
|
|
|
if(newpkg->origin != PKG_FROM_SYNCDB) {
|
2010-05-05 18:07:37 -04:00
|
|
|
newpkg->infolevel |= INFRQ_DSIZE;
|
Use sync.c for upgrade transaction prepare and commit
This patch utilizes the power of sync.c to fix FS#3492 and FS#5798.
Now an upgrade transaction is just a sync transaction internally (in alpm),
so all sync features are available with -U as well:
* conflict resolving
* sync dependencies from sync repos
* remove unresolvable targets
See http://www.archlinux.org/pipermail/pacman-dev/2009-June/008725.html
for the concept.
We use "mixed" target list, where PKG_FROM_FILE origin indicates local
package file, PKG_FROM_CACHE indicates sync package. The front-end can add
only one type of packages (depending on transaction type) atm, but if alpm
resolves dependencies for -U, we may get a real mixed trans->packages list.
_alpm_pkg_free_trans() was modified so that it can handle both target types
_alpm_add_prepare() was removed, we use _alpm_sync_prepare() instead
_alpm_add_commit() was renamed to _alpm_upgrade_targets()
sync.c (and deps.c) was modified slightly to handle mixed target lists,
the modifications are straightforward. There is one notable change here: We
don't create new upgrade trans in sync.c, we replace the pkgcache entries
with the loaded package files in the target list (this is a bit hackish) and
call _alpm_upgrade_targets(). This implies a TODO (pkg->origin_data.db is
not accessible anymore), but it doesn't hurt anything with pacman front-end,
so it will be fixed later (otherwise this patch would be huge).
I updated the documentation of -U and I added a new pactest, upgrade090.py,
to test the syncdeps feature of -U.
Signed-off-by: Nagy Gabor <ngaba@bibl.u-szeged.hu>
Signed-off-by: Dan McGee <dan@archlinux.org>
2009-06-09 11:23:46 -04:00
|
|
|
newpkg->download_size = 0;
|
2011-03-20 20:45:57 -04:00
|
|
|
return 0;
|
Use sync.c for upgrade transaction prepare and commit
This patch utilizes the power of sync.c to fix FS#3492 and FS#5798.
Now an upgrade transaction is just a sync transaction internally (in alpm),
so all sync features are available with -U as well:
* conflict resolving
* sync dependencies from sync repos
* remove unresolvable targets
See http://www.archlinux.org/pipermail/pacman-dev/2009-June/008725.html
for the concept.
We use "mixed" target list, where PKG_FROM_FILE origin indicates local
package file, PKG_FROM_CACHE indicates sync package. The front-end can add
only one type of packages (depending on transaction type) atm, but if alpm
resolves dependencies for -U, we may get a real mixed trans->packages list.
_alpm_pkg_free_trans() was modified so that it can handle both target types
_alpm_add_prepare() was removed, we use _alpm_sync_prepare() instead
_alpm_add_commit() was renamed to _alpm_upgrade_targets()
sync.c (and deps.c) was modified slightly to handle mixed target lists,
the modifications are straightforward. There is one notable change here: We
don't create new upgrade trans in sync.c, we replace the pkgcache entries
with the loaded package files in the target list (this is a bit hackish) and
call _alpm_upgrade_targets(). This implies a TODO (pkg->origin_data.db is
not accessible anymore), but it doesn't hurt anything with pacman front-end,
so it will be fixed later (otherwise this patch would be huge).
I updated the documentation of -U and I added a new pactest, upgrade090.py,
to test the syncdeps feature of -U.
Signed-off-by: Nagy Gabor <ngaba@bibl.u-szeged.hu>
Signed-off-by: Dan McGee <dan@archlinux.org>
2009-06-09 11:23:46 -04:00
|
|
|
}
|
|
|
|
|
2008-04-26 14:03:53 -04:00
|
|
|
fname = alpm_pkg_get_filename(newpkg);
|
|
|
|
ASSERT(fname != NULL, RET_ERR(PM_ERR_PKG_INVALID_NAME, -1));
|
|
|
|
fpath = _alpm_filecache_find(fname);
|
|
|
|
|
2008-02-16 11:47:22 -05:00
|
|
|
if(fpath) {
|
|
|
|
FREE(fpath);
|
|
|
|
size = 0;
|
|
|
|
} else if(handle->usedelta) {
|
2008-06-01 22:47:31 -04:00
|
|
|
off_t dltsize;
|
|
|
|
off_t pkgsize = alpm_pkg_get_size(newpkg);
|
2008-02-16 11:47:22 -05:00
|
|
|
|
|
|
|
dltsize = _alpm_shortest_delta_path(
|
|
|
|
alpm_pkg_get_deltas(newpkg),
|
|
|
|
alpm_pkg_get_filename(newpkg),
|
|
|
|
&newpkg->delta_path);
|
|
|
|
|
|
|
|
if(newpkg->delta_path && (dltsize < pkgsize * MAX_DELTA_RATIO)) {
|
|
|
|
_alpm_log(PM_LOG_DEBUG, "using delta size\n");
|
|
|
|
size = dltsize;
|
|
|
|
} else {
|
|
|
|
_alpm_log(PM_LOG_DEBUG, "using package size\n");
|
|
|
|
size = alpm_pkg_get_size(newpkg);
|
|
|
|
alpm_list_free(newpkg->delta_path);
|
|
|
|
newpkg->delta_path = NULL;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
size = alpm_pkg_get_size(newpkg);
|
|
|
|
}
|
|
|
|
|
2009-02-19 13:12:34 -05:00
|
|
|
_alpm_log(PM_LOG_DEBUG, "setting download size %jd for pkg %s\n",
|
|
|
|
(intmax_t)size, alpm_pkg_get_name(newpkg));
|
2008-02-16 11:47:22 -05:00
|
|
|
|
2010-05-05 18:07:37 -04:00
|
|
|
newpkg->infolevel |= INFRQ_DSIZE;
|
2008-02-16 11:47:22 -05:00
|
|
|
newpkg->download_size = size;
|
2011-03-20 20:45:57 -04:00
|
|
|
return 0;
|
2008-02-16 11:47:22 -05:00
|
|
|
}
|
|
|
|
|
2007-01-19 04:28:44 -05:00
|
|
|
int _alpm_sync_prepare(pmtrans_t *trans, pmdb_t *db_local, alpm_list_t *dbs_sync, alpm_list_t **data)
|
2005-03-14 20:51:43 -05:00
|
|
|
{
|
2007-01-19 04:28:44 -05:00
|
|
|
alpm_list_t *deps = NULL;
|
2009-01-26 07:48:39 -05:00
|
|
|
alpm_list_t *unresolvable = NULL;
|
2007-06-10 23:16:09 -04:00
|
|
|
alpm_list_t *i, *j;
|
2009-07-15 13:14:01 -04:00
|
|
|
alpm_list_t *remove = NULL;
|
2006-03-04 05:16:36 -05:00
|
|
|
int ret = 0;
|
2005-04-02 18:21:10 -05:00
|
|
|
|
2007-01-30 03:14:10 -05:00
|
|
|
ALPM_LOG_FUNC;
|
|
|
|
|
2005-04-16 18:15:50 -04:00
|
|
|
ASSERT(db_local != NULL, RET_ERR(PM_ERR_DB_NULL, -1));
|
2005-04-06 17:01:40 -04:00
|
|
|
ASSERT(trans != NULL, RET_ERR(PM_ERR_TRANS_NULL, -1));
|
2005-04-08 15:37:23 -04:00
|
|
|
|
2006-01-07 13:25:28 -05:00
|
|
|
if(data) {
|
|
|
|
*data = NULL;
|
|
|
|
}
|
2005-04-06 17:01:40 -04:00
|
|
|
|
2009-03-07 13:44:34 -05:00
|
|
|
if(!(trans->flags & PM_TRANS_FLAG_NODEPS)) {
|
|
|
|
alpm_list_t *resolved = NULL; /* target list after resolvedeps */
|
|
|
|
|
2009-01-26 07:48:39 -05:00
|
|
|
/* Build up list by repeatedly resolving each transaction package */
|
2005-04-13 15:59:04 -04:00
|
|
|
/* Resolve targets dependencies */
|
2005-05-04 15:55:23 -04:00
|
|
|
EVENT(trans, PM_TRANS_EVT_RESOLVEDEPS_START, NULL, NULL);
|
2007-08-23 22:26:55 -04:00
|
|
|
_alpm_log(PM_LOG_DEBUG, "resolving target's dependencies\n");
|
2007-08-12 16:26:54 -04:00
|
|
|
|
2009-09-12 14:50:03 -04:00
|
|
|
/* build remove list for resolvedeps */
|
2009-07-15 13:14:01 -04:00
|
|
|
for(i = trans->add; i; i = i->next) {
|
2009-03-07 13:44:34 -05:00
|
|
|
pmpkg_t *spkg = i->data;
|
|
|
|
for(j = spkg->removes; j; j = j->next) {
|
2008-01-27 06:24:50 -05:00
|
|
|
remove = alpm_list_add(remove, j->data);
|
2007-08-12 16:26:54 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-03-21 10:02:03 -04:00
|
|
|
/* Compute the fake local database for resolvedeps (partial fix for the
|
|
|
|
* phonon/qt issue) */
|
|
|
|
alpm_list_t *localpkgs = alpm_list_diff(_alpm_db_get_pkgcache(db_local),
|
|
|
|
trans->add, _alpm_pkg_cmp);
|
2010-05-16 20:33:28 -04:00
|
|
|
|
2011-02-25 08:51:58 -05:00
|
|
|
/* Resolve packages in the transaction one at a time, in addition
|
2009-01-26 07:48:39 -05:00
|
|
|
building up a list of packages which could not be resolved. */
|
2009-07-15 13:14:01 -04:00
|
|
|
for(i = trans->add; i; i = i->next) {
|
2009-03-07 13:44:34 -05:00
|
|
|
pmpkg_t *pkg = i->data;
|
2010-05-16 20:33:28 -04:00
|
|
|
if(_alpm_resolvedeps(localpkgs, dbs_sync, pkg, trans->add,
|
2009-03-08 16:56:13 -04:00
|
|
|
&resolved, remove, data) == -1) {
|
2009-01-26 07:48:39 -05:00
|
|
|
unresolvable = alpm_list_add(unresolvable, pkg);
|
|
|
|
}
|
2009-03-07 13:44:34 -05:00
|
|
|
/* Else, [resolved] now additionally contains [pkg] and all of its
|
2009-01-26 07:48:39 -05:00
|
|
|
dependencies not already on the list */
|
|
|
|
}
|
2010-05-16 20:33:28 -04:00
|
|
|
alpm_list_free(localpkgs);
|
2009-01-26 07:48:39 -05:00
|
|
|
|
2009-02-22 05:25:31 -05:00
|
|
|
/* If there were unresolvable top-level packages, prompt the user to
|
|
|
|
see if they'd like to ignore them rather than failing the sync */
|
2009-01-26 07:48:39 -05:00
|
|
|
if(unresolvable != NULL) {
|
2009-02-22 05:25:31 -05:00
|
|
|
int remove_unresolvable = 0;
|
|
|
|
QUESTION(handle->trans, PM_TRANS_CONV_REMOVE_PKGS, unresolvable,
|
|
|
|
NULL, NULL, &remove_unresolvable);
|
2011-04-20 20:45:16 -04:00
|
|
|
if(remove_unresolvable) {
|
2009-02-22 05:25:31 -05:00
|
|
|
/* User wants to remove the unresolvable packages from the
|
2009-03-07 10:25:29 -05:00
|
|
|
transaction. The packages will be removed from the actual
|
|
|
|
transaction when the transaction packages are replaced with a
|
2009-02-22 05:25:31 -05:00
|
|
|
dependency-reordered list below */
|
2009-03-07 10:25:29 -05:00
|
|
|
pm_errno = 0; /* pm_errno was set by resolvedeps */
|
|
|
|
if(data) {
|
|
|
|
alpm_list_free_inner(*data, (alpm_list_fn_free)_alpm_depmiss_free);
|
|
|
|
alpm_list_free(*data);
|
|
|
|
*data = NULL;
|
|
|
|
}
|
|
|
|
} else {
|
2009-02-22 05:25:31 -05:00
|
|
|
/* pm_errno is set by resolvedeps */
|
2009-03-07 13:44:34 -05:00
|
|
|
alpm_list_free(resolved);
|
2009-02-22 05:25:31 -05:00
|
|
|
ret = -1;
|
|
|
|
goto cleanup;
|
|
|
|
}
|
2005-04-02 18:21:10 -05:00
|
|
|
}
|
2006-10-15 15:31:03 -04:00
|
|
|
|
2009-03-07 13:44:34 -05:00
|
|
|
/* Set DEPEND reason for pulled packages */
|
|
|
|
for(i = resolved; i; i = i->next) {
|
|
|
|
pmpkg_t *pkg = i->data;
|
2009-07-15 13:14:01 -04:00
|
|
|
if(!_alpm_pkg_find(trans->add, pkg->name)) {
|
2009-03-07 13:44:34 -05:00
|
|
|
pkg->reason = PM_PKG_REASON_DEPEND;
|
2005-04-08 15:37:23 -04:00
|
|
|
}
|
|
|
|
}
|
2006-10-15 15:31:03 -04:00
|
|
|
|
Use sync.c for upgrade transaction prepare and commit
This patch utilizes the power of sync.c to fix FS#3492 and FS#5798.
Now an upgrade transaction is just a sync transaction internally (in alpm),
so all sync features are available with -U as well:
* conflict resolving
* sync dependencies from sync repos
* remove unresolvable targets
See http://www.archlinux.org/pipermail/pacman-dev/2009-June/008725.html
for the concept.
We use "mixed" target list, where PKG_FROM_FILE origin indicates local
package file, PKG_FROM_CACHE indicates sync package. The front-end can add
only one type of packages (depending on transaction type) atm, but if alpm
resolves dependencies for -U, we may get a real mixed trans->packages list.
_alpm_pkg_free_trans() was modified so that it can handle both target types
_alpm_add_prepare() was removed, we use _alpm_sync_prepare() instead
_alpm_add_commit() was renamed to _alpm_upgrade_targets()
sync.c (and deps.c) was modified slightly to handle mixed target lists,
the modifications are straightforward. There is one notable change here: We
don't create new upgrade trans in sync.c, we replace the pkgcache entries
with the loaded package files in the target list (this is a bit hackish) and
call _alpm_upgrade_targets(). This implies a TODO (pkg->origin_data.db is
not accessible anymore), but it doesn't hurt anything with pacman front-end,
so it will be fixed later (otherwise this patch would be huge).
I updated the documentation of -U and I added a new pactest, upgrade090.py,
to test the syncdeps feature of -U.
Signed-off-by: Nagy Gabor <ngaba@bibl.u-szeged.hu>
Signed-off-by: Dan McGee <dan@archlinux.org>
2009-06-09 11:23:46 -04:00
|
|
|
/* Unresolvable packages will be removed from the target list, so
|
|
|
|
we free the transaction specific fields */
|
|
|
|
alpm_list_free_inner(unresolvable, (alpm_list_fn_free)_alpm_pkg_free_trans);
|
|
|
|
|
2006-10-15 15:31:03 -04:00
|
|
|
/* re-order w.r.t. dependencies */
|
2009-07-15 13:14:01 -04:00
|
|
|
alpm_list_free(trans->add);
|
|
|
|
trans->add = _alpm_sortbydeps(resolved, 0);
|
2009-03-07 13:44:34 -05:00
|
|
|
alpm_list_free(resolved);
|
2006-10-15 15:31:03 -04:00
|
|
|
|
2005-05-04 15:55:23 -04:00
|
|
|
EVENT(trans, PM_TRANS_EVT_RESOLVEDEPS_DONE, NULL, NULL);
|
2006-03-04 05:16:36 -05:00
|
|
|
}
|
|
|
|
|
2008-08-17 13:23:12 -04:00
|
|
|
if(!(trans->flags & PM_TRANS_FLAG_NOCONFLICTS)) {
|
2006-03-04 05:16:36 -05:00
|
|
|
/* check for inter-conflicts and whatnot */
|
|
|
|
EVENT(trans, PM_TRANS_EVT_INTERCONFLICTS_START, NULL, NULL);
|
|
|
|
|
2007-08-23 22:26:55 -04:00
|
|
|
_alpm_log(PM_LOG_DEBUG, "looking for conflicts\n");
|
2005-04-17 16:09:06 -04:00
|
|
|
|
2007-08-12 18:17:32 -04:00
|
|
|
/* 1. check for conflicts in the target list */
|
|
|
|
_alpm_log(PM_LOG_DEBUG, "check targets vs targets\n");
|
2009-07-15 13:14:01 -04:00
|
|
|
deps = _alpm_innerconflicts(trans->add);
|
2007-08-12 18:17:32 -04:00
|
|
|
|
|
|
|
for(i = deps; i; i = i->next) {
|
|
|
|
pmconflict_t *conflict = i->data;
|
2009-03-07 13:44:34 -05:00
|
|
|
pmpkg_t *rsync, *sync, *sync1, *sync2;
|
2007-08-12 18:17:32 -04:00
|
|
|
|
|
|
|
/* have we already removed one of the conflicting targets? */
|
2009-07-15 13:14:01 -04:00
|
|
|
sync1 = _alpm_pkg_find(trans->add, conflict->package1);
|
|
|
|
sync2 = _alpm_pkg_find(trans->add, conflict->package2);
|
2007-08-12 18:17:32 -04:00
|
|
|
if(!sync1 || !sync2) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
_alpm_log(PM_LOG_DEBUG, "conflicting packages in the sync list: '%s' <-> '%s'\n",
|
|
|
|
conflict->package1, conflict->package2);
|
|
|
|
|
|
|
|
/* if sync1 provides sync2, we remove sync2 from the targets, and vice versa */
|
Cleanup usages of alpm_list_find and alpm_list_remove.
* remove obsolete and unused *_cmp helper functions like deppkg_cmp and
_alpm_grp_cmp
* new alpm_list_remove_str function, used 6 times in handle.c
* remove _alpm_prov_cmp / _alpm_db_whatprovides and replace them by
a more general alpm_find_pkg_satisfiers with a cleaner implementation.
before: alpm_db_whatprovides(db, targ)
after: alpm_find_pkg_satisfiers(alpm_db_getpkgcache(db), targ)
* remove satisfycmp and replace alpm_list_find + satisfycmp usage by
_alpm_find_dep_satisfiers.
before : alpm_list_find(_alpm_db_get_pkgcache(db), dep, satisfycmp)
after : _alpm_find_dep_satisfiers(_alpm_db_get_pkgcache(db), dep)
* remove _alpm_pkgname_pkg_cmp, which was used with alpm_list_remove, and
use _alpm_pkg_find + alpm_list_remove with _alpm_pkg_cmp instead.
This commit actually get rids of all complicated and asymmetric _cmp
functions. I first thought these functions were worth it, be caused it
allowed us to reuse list_find and list_remove. But this was at the detriment
of the clarity and also the ease of use of these functions, dangerous
because of their asymmetricity.
Signed-off-by: Chantry Xavier <shiningxc@gmail.com>
Signed-off-by: Dan McGee <dan@archlinux.org>
2008-05-10 12:47:42 -04:00
|
|
|
pmdepend_t *dep1 = _alpm_splitdep(conflict->package1);
|
|
|
|
pmdepend_t *dep2 = _alpm_splitdep(conflict->package2);
|
2010-10-12 15:47:40 -04:00
|
|
|
if(_alpm_depcmp(sync1, dep2)) {
|
2007-08-12 18:17:32 -04:00
|
|
|
rsync = sync2;
|
|
|
|
sync = sync1;
|
2010-10-12 15:47:40 -04:00
|
|
|
} else if(_alpm_depcmp(sync2, dep1)) {
|
2007-08-12 18:17:32 -04:00
|
|
|
rsync = sync1;
|
|
|
|
sync = sync2;
|
|
|
|
} else {
|
2008-01-25 15:52:35 -05:00
|
|
|
_alpm_log(PM_LOG_ERROR, _("unresolvable package conflicts detected\n"));
|
2007-08-12 18:17:32 -04:00
|
|
|
pm_errno = PM_ERR_CONFLICTING_DEPS;
|
|
|
|
ret = -1;
|
2008-01-25 15:52:35 -05:00
|
|
|
if(data) {
|
|
|
|
pmconflict_t *newconflict = _alpm_conflict_dup(conflict);
|
|
|
|
if(newconflict) {
|
|
|
|
*data = alpm_list_add(*data, newconflict);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
alpm_list_free_inner(deps, (alpm_list_fn_free)_alpm_conflict_free);
|
|
|
|
alpm_list_free(deps);
|
Cleanup usages of alpm_list_find and alpm_list_remove.
* remove obsolete and unused *_cmp helper functions like deppkg_cmp and
_alpm_grp_cmp
* new alpm_list_remove_str function, used 6 times in handle.c
* remove _alpm_prov_cmp / _alpm_db_whatprovides and replace them by
a more general alpm_find_pkg_satisfiers with a cleaner implementation.
before: alpm_db_whatprovides(db, targ)
after: alpm_find_pkg_satisfiers(alpm_db_getpkgcache(db), targ)
* remove satisfycmp and replace alpm_list_find + satisfycmp usage by
_alpm_find_dep_satisfiers.
before : alpm_list_find(_alpm_db_get_pkgcache(db), dep, satisfycmp)
after : _alpm_find_dep_satisfiers(_alpm_db_get_pkgcache(db), dep)
* remove _alpm_pkgname_pkg_cmp, which was used with alpm_list_remove, and
use _alpm_pkg_find + alpm_list_remove with _alpm_pkg_cmp instead.
This commit actually get rids of all complicated and asymmetric _cmp
functions. I first thought these functions were worth it, be caused it
allowed us to reuse list_find and list_remove. But this was at the detriment
of the clarity and also the ease of use of these functions, dangerous
because of their asymmetricity.
Signed-off-by: Chantry Xavier <shiningxc@gmail.com>
Signed-off-by: Dan McGee <dan@archlinux.org>
2008-05-10 12:47:42 -04:00
|
|
|
_alpm_dep_free(dep1);
|
|
|
|
_alpm_dep_free(dep2);
|
2007-08-12 18:17:32 -04:00
|
|
|
goto cleanup;
|
|
|
|
}
|
Cleanup usages of alpm_list_find and alpm_list_remove.
* remove obsolete and unused *_cmp helper functions like deppkg_cmp and
_alpm_grp_cmp
* new alpm_list_remove_str function, used 6 times in handle.c
* remove _alpm_prov_cmp / _alpm_db_whatprovides and replace them by
a more general alpm_find_pkg_satisfiers with a cleaner implementation.
before: alpm_db_whatprovides(db, targ)
after: alpm_find_pkg_satisfiers(alpm_db_getpkgcache(db), targ)
* remove satisfycmp and replace alpm_list_find + satisfycmp usage by
_alpm_find_dep_satisfiers.
before : alpm_list_find(_alpm_db_get_pkgcache(db), dep, satisfycmp)
after : _alpm_find_dep_satisfiers(_alpm_db_get_pkgcache(db), dep)
* remove _alpm_pkgname_pkg_cmp, which was used with alpm_list_remove, and
use _alpm_pkg_find + alpm_list_remove with _alpm_pkg_cmp instead.
This commit actually get rids of all complicated and asymmetric _cmp
functions. I first thought these functions were worth it, be caused it
allowed us to reuse list_find and list_remove. But this was at the detriment
of the clarity and also the ease of use of these functions, dangerous
because of their asymmetricity.
Signed-off-by: Chantry Xavier <shiningxc@gmail.com>
Signed-off-by: Dan McGee <dan@archlinux.org>
2008-05-10 12:47:42 -04:00
|
|
|
_alpm_dep_free(dep1);
|
|
|
|
_alpm_dep_free(dep2);
|
2007-08-12 18:17:32 -04:00
|
|
|
|
2008-03-10 10:38:08 -04:00
|
|
|
/* Prints warning */
|
|
|
|
_alpm_log(PM_LOG_WARNING,
|
|
|
|
_("removing '%s' from target list because it conflicts with '%s'\n"),
|
2009-03-07 13:44:34 -05:00
|
|
|
rsync->name, sync->name);
|
2009-07-15 13:14:01 -04:00
|
|
|
trans->add = alpm_list_remove(trans->add, rsync, _alpm_pkg_cmp, NULL);
|
Use sync.c for upgrade transaction prepare and commit
This patch utilizes the power of sync.c to fix FS#3492 and FS#5798.
Now an upgrade transaction is just a sync transaction internally (in alpm),
so all sync features are available with -U as well:
* conflict resolving
* sync dependencies from sync repos
* remove unresolvable targets
See http://www.archlinux.org/pipermail/pacman-dev/2009-June/008725.html
for the concept.
We use "mixed" target list, where PKG_FROM_FILE origin indicates local
package file, PKG_FROM_CACHE indicates sync package. The front-end can add
only one type of packages (depending on transaction type) atm, but if alpm
resolves dependencies for -U, we may get a real mixed trans->packages list.
_alpm_pkg_free_trans() was modified so that it can handle both target types
_alpm_add_prepare() was removed, we use _alpm_sync_prepare() instead
_alpm_add_commit() was renamed to _alpm_upgrade_targets()
sync.c (and deps.c) was modified slightly to handle mixed target lists,
the modifications are straightforward. There is one notable change here: We
don't create new upgrade trans in sync.c, we replace the pkgcache entries
with the loaded package files in the target list (this is a bit hackish) and
call _alpm_upgrade_targets(). This implies a TODO (pkg->origin_data.db is
not accessible anymore), but it doesn't hurt anything with pacman front-end,
so it will be fixed later (otherwise this patch would be huge).
I updated the documentation of -U and I added a new pactest, upgrade090.py,
to test the syncdeps feature of -U.
Signed-off-by: Nagy Gabor <ngaba@bibl.u-szeged.hu>
Signed-off-by: Dan McGee <dan@archlinux.org>
2009-06-09 11:23:46 -04:00
|
|
|
_alpm_pkg_free_trans(rsync); /* rsync is not transaction target anymore */
|
2007-08-12 18:17:32 -04:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
alpm_list_free_inner(deps, (alpm_list_fn_free)_alpm_conflict_free);
|
|
|
|
alpm_list_free(deps);
|
|
|
|
deps = NULL;
|
|
|
|
|
|
|
|
/* 2. we check for target vs db conflicts (and resolve)*/
|
|
|
|
_alpm_log(PM_LOG_DEBUG, "check targets vs db and db vs targets\n");
|
2009-07-15 13:14:01 -04:00
|
|
|
deps = _alpm_outerconflicts(db_local, trans->add);
|
2007-08-12 18:17:32 -04:00
|
|
|
|
|
|
|
for(i = deps; i; i = i->next) {
|
|
|
|
pmconflict_t *conflict = i->data;
|
|
|
|
|
|
|
|
/* if conflict->package2 (the local package) is not elected for removal,
|
|
|
|
we ask the user */
|
|
|
|
int found = 0;
|
2009-07-15 13:14:01 -04:00
|
|
|
for(j = trans->add; j && !found; j = j->next) {
|
2009-03-07 13:44:34 -05:00
|
|
|
pmpkg_t *spkg = j->data;
|
|
|
|
if(_alpm_pkg_find(spkg->removes, conflict->package2)) {
|
2008-01-27 06:24:50 -05:00
|
|
|
found = 1;
|
2006-01-17 16:18:33 -05:00
|
|
|
}
|
2007-08-12 18:17:32 -04:00
|
|
|
}
|
|
|
|
if(found) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
_alpm_log(PM_LOG_DEBUG, "package '%s' conflicts with '%s'\n",
|
|
|
|
conflict->package1, conflict->package2);
|
|
|
|
|
2009-07-15 13:14:01 -04:00
|
|
|
pmpkg_t *sync = _alpm_pkg_find(trans->add, conflict->package1);
|
2007-08-12 18:17:32 -04:00
|
|
|
pmpkg_t *local = _alpm_db_get_pkgfromcache(db_local, conflict->package2);
|
|
|
|
int doremove = 0;
|
|
|
|
QUESTION(trans, PM_TRANS_CONV_CONFLICT_PKG, conflict->package1,
|
2009-08-31 10:20:18 -04:00
|
|
|
conflict->package2, conflict->reason, &doremove);
|
2007-08-12 18:17:32 -04:00
|
|
|
if(doremove) {
|
2008-01-27 06:24:50 -05:00
|
|
|
/* append to the removes list */
|
2007-08-12 18:17:32 -04:00
|
|
|
_alpm_log(PM_LOG_DEBUG, "electing '%s' for removal\n", conflict->package2);
|
2008-01-27 06:24:50 -05:00
|
|
|
sync->removes = alpm_list_add(sync->removes, local);
|
2007-08-12 18:17:32 -04:00
|
|
|
} else { /* abort */
|
|
|
|
_alpm_log(PM_LOG_ERROR, _("unresolvable package conflicts detected\n"));
|
2008-01-25 15:52:35 -05:00
|
|
|
pm_errno = PM_ERR_CONFLICTING_DEPS;
|
|
|
|
ret = -1;
|
Fix several memleaks, mostly related to errors handling.
* The frontend calls alpm_trans_prepare(&data), and in case of errors,
receive the missing dependencies / conflicts / etc in the data pointer.
It apparently needs to free this structure totally with :
alpm_list_free_inner(data, free)
alpm_list_free(data)
So I added alpm_list_free_inner(data, free) in
pacman/{sync.c,remove.c,add,c}
* in _alpm_sync_prepare, the deps and asked lists were not freed in case
of errors (unresolvable conflicts).
Besides the code for handling this case was duplicated.
* in _alpm_remove_commit, free was used instead of alpm_list_free for
newfiles.
* newline fix in pacman/sync.c
Signed-off-by: Chantry Xavier <shiningxc@gmail.com>
Signed-off-by: Dan McGee <dan@archlinux.org>
2007-11-21 13:51:46 -05:00
|
|
|
if(data) {
|
2008-01-25 15:52:35 -05:00
|
|
|
pmconflict_t *newconflict = _alpm_conflict_dup(conflict);
|
|
|
|
if(newconflict) {
|
|
|
|
*data = alpm_list_add(*data, newconflict);
|
Fix several memleaks, mostly related to errors handling.
* The frontend calls alpm_trans_prepare(&data), and in case of errors,
receive the missing dependencies / conflicts / etc in the data pointer.
It apparently needs to free this structure totally with :
alpm_list_free_inner(data, free)
alpm_list_free(data)
So I added alpm_list_free_inner(data, free) in
pacman/{sync.c,remove.c,add,c}
* in _alpm_sync_prepare, the deps and asked lists were not freed in case
of errors (unresolvable conflicts).
Besides the code for handling this case was duplicated.
* in _alpm_remove_commit, free was used instead of alpm_list_free for
newfiles.
* newline fix in pacman/sync.c
Signed-off-by: Chantry Xavier <shiningxc@gmail.com>
Signed-off-by: Dan McGee <dan@archlinux.org>
2007-11-21 13:51:46 -05:00
|
|
|
}
|
|
|
|
}
|
2008-01-11 01:01:58 -05:00
|
|
|
alpm_list_free_inner(deps, (alpm_list_fn_free)_alpm_conflict_free);
|
|
|
|
alpm_list_free(deps);
|
2006-03-04 05:16:36 -05:00
|
|
|
goto cleanup;
|
2005-04-17 16:09:06 -04:00
|
|
|
}
|
2005-04-06 17:01:40 -04:00
|
|
|
}
|
2005-05-04 15:55:23 -04:00
|
|
|
EVENT(trans, PM_TRANS_EVT_INTERCONFLICTS_DONE, NULL, NULL);
|
2007-08-12 18:17:32 -04:00
|
|
|
alpm_list_free_inner(deps, (alpm_list_fn_free)_alpm_conflict_free);
|
|
|
|
alpm_list_free(deps);
|
2006-03-04 05:16:36 -05:00
|
|
|
}
|
2005-04-13 15:59:04 -04:00
|
|
|
|
2009-09-12 14:50:03 -04:00
|
|
|
/* Build trans->remove list */
|
|
|
|
for(i = trans->add; i; i = i->next) {
|
|
|
|
pmpkg_t *spkg = i->data;
|
|
|
|
for(j = spkg->removes; j; j = j->next) {
|
2011-03-21 09:59:59 -04:00
|
|
|
pmpkg_t *rpkg = j->data;
|
|
|
|
if(!_alpm_pkg_find(trans->remove, rpkg->name)) {
|
|
|
|
_alpm_log(PM_LOG_DEBUG, "adding '%s' to remove list\n", rpkg->name);
|
|
|
|
trans->remove = alpm_list_add(trans->remove, _alpm_pkg_dup(rpkg));
|
|
|
|
}
|
2006-01-05 15:53:41 -05:00
|
|
|
}
|
2009-09-12 14:50:03 -04:00
|
|
|
}
|
2007-08-12 16:26:54 -04:00
|
|
|
|
2009-09-12 14:50:03 -04:00
|
|
|
if(!(trans->flags & PM_TRANS_FLAG_NODEPS)) {
|
2007-08-12 16:26:54 -04:00
|
|
|
_alpm_log(PM_LOG_DEBUG, "checking dependencies\n");
|
2011-02-25 09:22:09 -05:00
|
|
|
deps = alpm_checkdeps(_alpm_db_get_pkgcache(db_local), 1, trans->remove, trans->add);
|
2007-08-12 16:26:54 -04:00
|
|
|
if(deps) {
|
|
|
|
pm_errno = PM_ERR_UNSATISFIED_DEPS;
|
|
|
|
ret = -1;
|
2007-12-22 10:57:43 -05:00
|
|
|
if(data) {
|
|
|
|
*data = deps;
|
|
|
|
} else {
|
2007-08-12 18:17:32 -04:00
|
|
|
alpm_list_free_inner(deps, (alpm_list_fn_free)_alpm_depmiss_free);
|
|
|
|
alpm_list_free(deps);
|
2007-12-22 10:57:43 -05:00
|
|
|
}
|
2007-08-12 16:26:54 -04:00
|
|
|
goto cleanup;
|
2006-01-05 15:53:41 -05:00
|
|
|
}
|
|
|
|
}
|
2009-07-15 13:14:01 -04:00
|
|
|
for(i = trans->add; i; i = i->next) {
|
2008-02-16 11:47:22 -05:00
|
|
|
/* update download size field */
|
|
|
|
pmpkg_t *spkg = i->data;
|
2008-04-26 14:03:53 -04:00
|
|
|
if(compute_download_size(spkg) != 0) {
|
|
|
|
ret = -1;
|
|
|
|
goto cleanup;
|
|
|
|
}
|
2008-02-16 11:47:22 -05:00
|
|
|
}
|
2005-03-14 20:51:43 -05:00
|
|
|
|
2006-03-04 05:16:36 -05:00
|
|
|
cleanup:
|
2009-01-26 07:48:39 -05:00
|
|
|
alpm_list_free(unresolvable);
|
2009-09-12 14:50:03 -04:00
|
|
|
alpm_list_free(remove);
|
2006-03-04 05:16:36 -05:00
|
|
|
|
2011-03-20 20:45:57 -04:00
|
|
|
return ret;
|
2005-03-14 20:51:43 -05:00
|
|
|
}
|
|
|
|
|
2007-10-19 13:17:54 -04:00
|
|
|
/** Returns the size of the files that will be downloaded to install a
|
|
|
|
* package.
|
|
|
|
* @param newpkg the new package to upgrade to
|
|
|
|
* @return the size of the download
|
|
|
|
*/
|
2008-06-01 22:47:31 -04:00
|
|
|
off_t SYMEXPORT alpm_pkg_download_size(pmpkg_t *newpkg)
|
2007-10-19 13:17:54 -04:00
|
|
|
{
|
2010-05-05 18:07:37 -04:00
|
|
|
if(!(newpkg->infolevel & INFRQ_DSIZE)) {
|
|
|
|
compute_download_size(newpkg);
|
|
|
|
}
|
2011-03-20 20:45:57 -04:00
|
|
|
return newpkg->download_size;
|
2007-10-19 13:17:54 -04:00
|
|
|
}
|
|
|
|
|
2009-04-11 15:13:03 -04:00
|
|
|
static int endswith(const char *filename, const char *extension)
|
2009-02-19 13:12:34 -05:00
|
|
|
{
|
2009-04-11 15:13:03 -04:00
|
|
|
const char *s = filename + strlen(filename) - strlen(extension);
|
2011-03-20 20:45:57 -04:00
|
|
|
return strcmp(s, extension) == 0;
|
2009-02-19 13:12:34 -05:00
|
|
|
}
|
|
|
|
|
2007-10-19 13:17:53 -04:00
|
|
|
/** Applies delta files to create an upgraded package file.
|
|
|
|
*
|
|
|
|
* All intermediate files are deleted, leaving only the starting and
|
|
|
|
* ending package files.
|
|
|
|
*
|
|
|
|
* @param trans the transaction
|
|
|
|
*
|
|
|
|
* @return 0 if all delta files were able to be applied, 1 otherwise.
|
|
|
|
*/
|
2008-02-27 10:09:49 -05:00
|
|
|
static int apply_deltas(pmtrans_t *trans)
|
2007-10-19 13:17:53 -04:00
|
|
|
{
|
2008-02-27 10:09:49 -05:00
|
|
|
alpm_list_t *i;
|
2007-10-19 13:17:53 -04:00
|
|
|
int ret = 0;
|
|
|
|
const char *cachedir = _alpm_filecache_setup();
|
|
|
|
|
2009-07-15 13:14:01 -04:00
|
|
|
for(i = trans->add; i; i = i->next) {
|
2009-03-07 13:44:34 -05:00
|
|
|
pmpkg_t *spkg = i->data;
|
2008-02-27 10:09:49 -05:00
|
|
|
alpm_list_t *delta_path = spkg->delta_path;
|
|
|
|
alpm_list_t *dlts = NULL;
|
2007-10-19 13:17:53 -04:00
|
|
|
|
2008-02-27 10:09:49 -05:00
|
|
|
if(!delta_path) {
|
|
|
|
continue;
|
|
|
|
}
|
2007-10-19 13:17:53 -04:00
|
|
|
|
2008-02-27 10:09:49 -05:00
|
|
|
for(dlts = delta_path; dlts; dlts = dlts->next) {
|
|
|
|
pmdelta_t *d = dlts->data;
|
|
|
|
char *delta, *from, *to;
|
|
|
|
char command[PATH_MAX];
|
2009-10-11 15:02:20 -04:00
|
|
|
size_t len = 0;
|
2007-10-19 13:17:53 -04:00
|
|
|
|
2008-02-27 10:09:49 -05:00
|
|
|
delta = _alpm_filecache_find(d->delta);
|
|
|
|
/* the initial package might be in a different cachedir */
|
|
|
|
if(dlts == delta_path) {
|
|
|
|
from = _alpm_filecache_find(d->from);
|
2007-10-19 13:17:53 -04:00
|
|
|
} else {
|
2008-02-27 10:09:49 -05:00
|
|
|
/* len = cachedir len + from len + '/' + null */
|
|
|
|
len = strlen(cachedir) + strlen(d->from) + 2;
|
|
|
|
CALLOC(from, len, sizeof(char), RET_ERR(PM_ERR_MEMORY, 1));
|
|
|
|
snprintf(from, len, "%s/%s", cachedir, d->from);
|
2007-10-19 13:17:53 -04:00
|
|
|
}
|
2008-02-27 10:09:49 -05:00
|
|
|
len = strlen(cachedir) + strlen(d->to) + 2;
|
|
|
|
CALLOC(to, len, sizeof(char), RET_ERR(PM_ERR_MEMORY, 1));
|
|
|
|
snprintf(to, len, "%s/%s", cachedir, d->to);
|
2007-10-19 13:17:53 -04:00
|
|
|
|
2008-02-27 10:09:49 -05:00
|
|
|
/* build the patch command */
|
2009-02-19 13:12:34 -05:00
|
|
|
if(endswith(to, ".gz")) {
|
2009-05-21 18:24:26 -04:00
|
|
|
/* special handling for gzip : we disable timestamp with -n option */
|
|
|
|
snprintf(command, PATH_MAX, "xdelta3 -d -q -R -c -s %s %s | gzip -n > %s", from, delta, to);
|
|
|
|
} else {
|
|
|
|
snprintf(command, PATH_MAX, "xdelta3 -d -q -s %s %s %s", from, delta, to);
|
2009-02-19 13:12:34 -05:00
|
|
|
}
|
2008-02-27 10:09:49 -05:00
|
|
|
|
2009-02-19 13:12:34 -05:00
|
|
|
_alpm_log(PM_LOG_DEBUG, "command: %s\n", command);
|
2008-02-27 10:09:49 -05:00
|
|
|
|
|
|
|
EVENT(trans, PM_TRANS_EVT_DELTA_PATCH_START, d->to, d->delta);
|
|
|
|
|
|
|
|
int retval = system(command);
|
|
|
|
if(retval == 0) {
|
|
|
|
EVENT(trans, PM_TRANS_EVT_DELTA_PATCH_DONE, NULL, NULL);
|
|
|
|
|
|
|
|
/* delete the delta file */
|
|
|
|
unlink(delta);
|
|
|
|
|
|
|
|
/* Delete the 'from' package but only if it is an intermediate
|
|
|
|
* package. The starting 'from' package should be kept, just
|
|
|
|
* as if deltas were not used. */
|
|
|
|
if(dlts != delta_path) {
|
|
|
|
unlink(from);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
FREE(from);
|
|
|
|
FREE(to);
|
|
|
|
FREE(delta);
|
|
|
|
|
|
|
|
if(retval != 0) {
|
|
|
|
/* one delta failed for this package, cancel the remaining ones */
|
|
|
|
EVENT(trans, PM_TRANS_EVT_DELTA_PATCH_FAILED, NULL, NULL);
|
|
|
|
ret = 1;
|
|
|
|
break;
|
2007-10-19 13:17:53 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-03-20 20:45:57 -04:00
|
|
|
return ret;
|
2007-10-19 13:17:53 -04:00
|
|
|
}
|
|
|
|
|
2007-10-19 13:17:52 -04:00
|
|
|
/** 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
|
2008-12-07 12:58:24 -05:00
|
|
|
* @param filename the absolute path of the file to test
|
2007-10-19 13:17:52 -04:00
|
|
|
* @param md5sum the expected md5sum of the file
|
|
|
|
*
|
2008-02-26 18:50:17 -05:00
|
|
|
* @return 0 if the md5sum matched, 1 if not, -1 in case of errors
|
2007-10-19 13:17:52 -04:00
|
|
|
*/
|
2008-12-07 12:58:24 -05:00
|
|
|
static int test_md5sum(pmtrans_t *trans, const char *filepath,
|
2008-02-26 18:50:17 -05:00
|
|
|
const char *md5sum)
|
2007-10-19 13:17:52 -04:00
|
|
|
{
|
2008-12-07 12:58:24 -05:00
|
|
|
int ret = _alpm_test_md5sum(filepath, md5sum);
|
2008-02-26 18:50:17 -05:00
|
|
|
if(ret == 1) {
|
2007-10-19 13:17:52 -04:00
|
|
|
int doremove = 0;
|
2011-03-25 11:57:20 -04:00
|
|
|
QUESTION(trans, PM_TRANS_CONV_CORRUPTED_PKG, (char *)filepath,
|
2007-10-19 13:17:52 -04:00
|
|
|
NULL, NULL, &doremove);
|
|
|
|
if(doremove) {
|
|
|
|
unlink(filepath);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-03-20 20:45:57 -04:00
|
|
|
return ret;
|
2007-10-19 13:17:52 -04:00
|
|
|
}
|
|
|
|
|
2007-01-19 04:28:44 -05:00
|
|
|
int _alpm_sync_commit(pmtrans_t *trans, pmdb_t *db_local, alpm_list_t **data)
|
2005-03-14 20:51:43 -05:00
|
|
|
{
|
2007-01-19 04:28:44 -05:00
|
|
|
alpm_list_t *i, *j, *files = NULL;
|
2008-02-27 10:09:49 -05:00
|
|
|
alpm_list_t *deltas = NULL;
|
2011-01-11 22:12:08 -05:00
|
|
|
size_t numtargs, current = 0, replaces = 0;
|
2008-02-26 18:50:17 -05:00
|
|
|
int errors = 0;
|
2007-08-20 13:28:51 -04:00
|
|
|
const char *cachedir = NULL;
|
2008-02-27 11:45:01 -05:00
|
|
|
int ret = -1;
|
2005-04-14 17:07:38 -04:00
|
|
|
|
2007-01-30 03:14:10 -05:00
|
|
|
ALPM_LOG_FUNC;
|
|
|
|
|
2005-04-14 17:07:38 -04:00
|
|
|
ASSERT(trans != NULL, RET_ERR(PM_ERR_TRANS_NULL, -1));
|
|
|
|
|
2007-08-20 13:28:51 -04:00
|
|
|
cachedir = _alpm_filecache_setup();
|
2006-10-15 15:31:03 -04:00
|
|
|
trans->state = STATE_DOWNLOADING;
|
2007-11-09 19:54:19 -05:00
|
|
|
|
2008-06-02 00:10:30 -04:00
|
|
|
/* 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
|
|
|
|
* frontend to compute incremental progress. */
|
|
|
|
if(handle->totaldlcb) {
|
|
|
|
off_t total_size = (off_t)0;
|
|
|
|
/* sum up the download size for each package and store total */
|
2009-07-15 13:14:01 -04:00
|
|
|
for(i = trans->add; i; i = i->next) {
|
2009-03-07 13:44:34 -05:00
|
|
|
pmpkg_t *spkg = i->data;
|
2008-06-02 00:10:30 -04:00
|
|
|
total_size += spkg->download_size;
|
|
|
|
}
|
|
|
|
handle->totaldlcb(total_size);
|
|
|
|
}
|
|
|
|
|
2006-10-15 15:31:03 -04:00
|
|
|
/* group sync records by repository and download */
|
|
|
|
for(i = handle->dbs_sync; i; i = i->next) {
|
|
|
|
pmdb_t *current = i->data;
|
|
|
|
|
2009-07-15 13:14:01 -04:00
|
|
|
for(j = trans->add; j; j = j->next) {
|
2009-03-07 13:44:34 -05:00
|
|
|
pmpkg_t *spkg = j->data;
|
2006-10-15 15:31:03 -04:00
|
|
|
|
2008-05-11 13:00:18 -04:00
|
|
|
if(spkg->origin != PKG_FROM_FILE && current == spkg->origin_data.db) {
|
2006-11-22 04:03:41 -05:00
|
|
|
const char *fname = NULL;
|
2006-10-15 15:31:03 -04:00
|
|
|
|
2006-11-22 04:03:41 -05:00
|
|
|
fname = alpm_pkg_get_filename(spkg);
|
2008-02-13 14:42:43 -05:00
|
|
|
ASSERT(fname != NULL, RET_ERR(PM_ERR_PKG_INVALID_NAME, -1));
|
2009-02-19 13:12:34 -05:00
|
|
|
alpm_list_t *delta_path = spkg->delta_path;
|
|
|
|
if(delta_path) {
|
|
|
|
/* using deltas */
|
|
|
|
alpm_list_t *dlts = NULL;
|
|
|
|
|
|
|
|
for(dlts = delta_path; dlts; dlts = dlts->next) {
|
|
|
|
pmdelta_t *d = dlts->data;
|
|
|
|
|
|
|
|
if(d->download_size != 0) {
|
|
|
|
/* add the delta filename to the download list if needed */
|
|
|
|
files = alpm_list_add(files, strdup(d->delta));
|
2007-10-19 13:17:53 -04:00
|
|
|
}
|
2008-08-17 13:23:12 -04:00
|
|
|
|
2009-02-19 13:12:34 -05:00
|
|
|
/* keep a list of all the delta files for md5sums */
|
|
|
|
deltas = alpm_list_add(deltas, d);
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
/* not using deltas */
|
|
|
|
if(spkg->download_size != 0) {
|
|
|
|
/* add the filename to the download list if needed */
|
2008-08-17 13:23:12 -04:00
|
|
|
files = alpm_list_add(files, strdup(fname));
|
2006-10-15 15:31:03 -04:00
|
|
|
}
|
|
|
|
}
|
2009-02-19 13:12:34 -05:00
|
|
|
|
2006-10-15 15:31:03 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(files) {
|
|
|
|
EVENT(trans, PM_TRANS_EVT_RETRIEVE_START, current->treename, NULL);
|
2010-05-05 18:07:37 -04:00
|
|
|
errors = _alpm_download_files(files, current->servers, cachedir);
|
|
|
|
|
2011-04-20 20:45:16 -04:00
|
|
|
if(errors) {
|
2007-08-20 13:28:51 -04:00
|
|
|
_alpm_log(PM_LOG_WARNING, _("failed to retrieve some files from %s\n"),
|
|
|
|
current->treename);
|
2009-06-06 12:03:29 -04:00
|
|
|
if(pm_errno == 0) {
|
|
|
|
pm_errno = PM_ERR_RETRIEVE;
|
|
|
|
}
|
2008-02-27 11:45:01 -05:00
|
|
|
goto error;
|
2006-10-15 15:31:03 -04:00
|
|
|
}
|
2008-04-26 14:03:53 -04:00
|
|
|
FREELIST(files);
|
2006-10-15 15:31:03 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-05-14 15:58:31 -04:00
|
|
|
for(j = trans->add; j; j = j->next) {
|
|
|
|
pmpkg_t *pkg = j->data;
|
|
|
|
pkg->infolevel &= ~INFRQ_DSIZE;
|
|
|
|
pkg->download_size = 0;
|
|
|
|
}
|
|
|
|
|
2008-06-02 00:10:30 -04:00
|
|
|
/* clear out value to let callback know we are done */
|
|
|
|
if(handle->totaldlcb) {
|
|
|
|
handle->totaldlcb(0);
|
|
|
|
}
|
|
|
|
|
2009-02-19 13:12:34 -05:00
|
|
|
/* if we have deltas to work with */
|
|
|
|
if(handle->usedelta && deltas) {
|
2007-10-19 13:17:53 -04:00
|
|
|
int ret = 0;
|
2009-02-19 13:12:34 -05:00
|
|
|
errors = 0;
|
|
|
|
/* Check integrity of deltas */
|
|
|
|
EVENT(trans, PM_TRANS_EVT_DELTA_INTEGRITY_START, NULL, NULL);
|
|
|
|
|
|
|
|
for(i = deltas; i; i = i->next) {
|
|
|
|
pmdelta_t *d = alpm_list_getdata(i);
|
|
|
|
const char *filename = alpm_delta_get_filename(d);
|
2008-12-07 12:58:24 -05:00
|
|
|
char *filepath = _alpm_filecache_find(filename);
|
2009-02-19 13:12:34 -05:00
|
|
|
const char *md5sum = alpm_delta_get_md5sum(d);
|
|
|
|
|
2008-12-07 12:58:24 -05:00
|
|
|
if(test_md5sum(trans, filepath, md5sum) != 0) {
|
2009-02-19 13:12:34 -05:00
|
|
|
errors++;
|
|
|
|
*data = alpm_list_add(*data, strdup(filename));
|
2007-10-19 13:17:53 -04:00
|
|
|
}
|
2008-12-07 12:58:24 -05:00
|
|
|
FREE(filepath);
|
2009-02-19 13:12:34 -05:00
|
|
|
}
|
|
|
|
if(errors) {
|
|
|
|
pm_errno = PM_ERR_DLT_INVALID;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
EVENT(trans, PM_TRANS_EVT_DELTA_INTEGRITY_DONE, NULL, NULL);
|
2007-10-19 13:17:53 -04:00
|
|
|
|
2009-02-19 13:12:34 -05:00
|
|
|
/* Use the deltas to generate the packages */
|
|
|
|
EVENT(trans, PM_TRANS_EVT_DELTA_PATCHES_START, NULL, NULL);
|
|
|
|
ret = apply_deltas(trans);
|
|
|
|
EVENT(trans, PM_TRANS_EVT_DELTA_PATCHES_DONE, NULL, NULL);
|
2007-10-19 13:17:53 -04:00
|
|
|
|
|
|
|
if(ret) {
|
|
|
|
pm_errno = PM_ERR_DLT_PATCHFAILED;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Check integrity of packages */
|
2011-01-11 22:12:08 -05:00
|
|
|
numtargs = alpm_list_count(trans->add);
|
2006-10-15 15:31:03 -04:00
|
|
|
EVENT(trans, PM_TRANS_EVT_INTEGRITY_START, NULL, NULL);
|
|
|
|
|
2008-02-26 18:50:17 -05:00
|
|
|
errors = 0;
|
2008-12-07 12:58:24 -05:00
|
|
|
|
2011-01-18 14:19:25 -05:00
|
|
|
for(i = trans->add; i; i = i->next, current++) {
|
2009-03-07 13:44:34 -05:00
|
|
|
pmpkg_t *spkg = i->data;
|
2011-01-11 22:12:08 -05:00
|
|
|
int percent = (current * 100) / numtargs;
|
Use sync.c for upgrade transaction prepare and commit
This patch utilizes the power of sync.c to fix FS#3492 and FS#5798.
Now an upgrade transaction is just a sync transaction internally (in alpm),
so all sync features are available with -U as well:
* conflict resolving
* sync dependencies from sync repos
* remove unresolvable targets
See http://www.archlinux.org/pipermail/pacman-dev/2009-June/008725.html
for the concept.
We use "mixed" target list, where PKG_FROM_FILE origin indicates local
package file, PKG_FROM_CACHE indicates sync package. The front-end can add
only one type of packages (depending on transaction type) atm, but if alpm
resolves dependencies for -U, we may get a real mixed trans->packages list.
_alpm_pkg_free_trans() was modified so that it can handle both target types
_alpm_add_prepare() was removed, we use _alpm_sync_prepare() instead
_alpm_add_commit() was renamed to _alpm_upgrade_targets()
sync.c (and deps.c) was modified slightly to handle mixed target lists,
the modifications are straightforward. There is one notable change here: We
don't create new upgrade trans in sync.c, we replace the pkgcache entries
with the loaded package files in the target list (this is a bit hackish) and
call _alpm_upgrade_targets(). This implies a TODO (pkg->origin_data.db is
not accessible anymore), but it doesn't hurt anything with pacman front-end,
so it will be fixed later (otherwise this patch would be huge).
I updated the documentation of -U and I added a new pactest, upgrade090.py,
to test the syncdeps feature of -U.
Signed-off-by: Nagy Gabor <ngaba@bibl.u-szeged.hu>
Signed-off-by: Dan McGee <dan@archlinux.org>
2009-06-09 11:23:46 -04:00
|
|
|
if(spkg->origin == PKG_FROM_FILE) {
|
|
|
|
continue; /* pkg_load() has been already called, this package is valid */
|
|
|
|
}
|
2011-01-11 22:12:08 -05:00
|
|
|
PROGRESS(trans, PM_TRANS_PROGRESS_INTEGRITY_START, "", percent,
|
|
|
|
numtargs, current);
|
Use sync.c for upgrade transaction prepare and commit
This patch utilizes the power of sync.c to fix FS#3492 and FS#5798.
Now an upgrade transaction is just a sync transaction internally (in alpm),
so all sync features are available with -U as well:
* conflict resolving
* sync dependencies from sync repos
* remove unresolvable targets
See http://www.archlinux.org/pipermail/pacman-dev/2009-June/008725.html
for the concept.
We use "mixed" target list, where PKG_FROM_FILE origin indicates local
package file, PKG_FROM_CACHE indicates sync package. The front-end can add
only one type of packages (depending on transaction type) atm, but if alpm
resolves dependencies for -U, we may get a real mixed trans->packages list.
_alpm_pkg_free_trans() was modified so that it can handle both target types
_alpm_add_prepare() was removed, we use _alpm_sync_prepare() instead
_alpm_add_commit() was renamed to _alpm_upgrade_targets()
sync.c (and deps.c) was modified slightly to handle mixed target lists,
the modifications are straightforward. There is one notable change here: We
don't create new upgrade trans in sync.c, we replace the pkgcache entries
with the loaded package files in the target list (this is a bit hackish) and
call _alpm_upgrade_targets(). This implies a TODO (pkg->origin_data.db is
not accessible anymore), but it doesn't hurt anything with pacman front-end,
so it will be fixed later (otherwise this patch would be huge).
I updated the documentation of -U and I added a new pactest, upgrade090.py,
to test the syncdeps feature of -U.
Signed-off-by: Nagy Gabor <ngaba@bibl.u-szeged.hu>
Signed-off-by: Dan McGee <dan@archlinux.org>
2009-06-09 11:23:46 -04:00
|
|
|
|
2008-02-26 18:50:17 -05:00
|
|
|
const char *filename = alpm_pkg_get_filename(spkg);
|
2008-12-07 12:58:24 -05:00
|
|
|
char *filepath = _alpm_filecache_find(filename);
|
2008-02-26 18:50:17 -05:00
|
|
|
const char *md5sum = alpm_pkg_get_md5sum(spkg);
|
2008-12-07 12:58:24 -05:00
|
|
|
const pmpgpsig_t *pgpsig = alpm_pkg_get_pgpsig(spkg);
|
2011-03-25 21:40:16 -04:00
|
|
|
pgp_verify_t check_sig;
|
2007-06-04 14:50:16 -04:00
|
|
|
|
2008-12-07 12:58:24 -05:00
|
|
|
/* check md5sum first */
|
|
|
|
if(test_md5sum(trans, filepath, md5sum) != 0) {
|
2008-02-26 18:50:17 -05:00
|
|
|
errors++;
|
|
|
|
*data = alpm_list_add(*data, strdup(filename));
|
2008-12-07 12:58:24 -05:00
|
|
|
FREE(filepath);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
/* check PGP signature next */
|
2008-12-17 05:55:07 -05:00
|
|
|
pmdb_t *sdb = alpm_pkg_get_db(spkg);
|
|
|
|
|
2011-03-25 21:40:16 -04:00
|
|
|
check_sig = _alpm_db_get_sigverify_level(sdb);
|
|
|
|
|
|
|
|
if(check_sig != PM_PGP_VERIFY_NEVER) {
|
2008-12-17 05:55:07 -05:00
|
|
|
int ret = _alpm_gpgme_checksig(filepath, pgpsig);
|
2011-03-25 21:40:16 -04:00
|
|
|
if((check_sig == PM_PGP_VERIFY_ALWAYS && ret != 0) ||
|
|
|
|
(check_sig == PM_PGP_VERIFY_OPTIONAL && ret == 1)) {
|
2008-12-17 05:55:07 -05:00
|
|
|
errors++;
|
|
|
|
*data = alpm_list_add(*data, strdup(filename));
|
|
|
|
FREE(filepath);
|
|
|
|
continue;
|
|
|
|
}
|
Use sync.c for upgrade transaction prepare and commit
This patch utilizes the power of sync.c to fix FS#3492 and FS#5798.
Now an upgrade transaction is just a sync transaction internally (in alpm),
so all sync features are available with -U as well:
* conflict resolving
* sync dependencies from sync repos
* remove unresolvable targets
See http://www.archlinux.org/pipermail/pacman-dev/2009-June/008725.html
for the concept.
We use "mixed" target list, where PKG_FROM_FILE origin indicates local
package file, PKG_FROM_CACHE indicates sync package. The front-end can add
only one type of packages (depending on transaction type) atm, but if alpm
resolves dependencies for -U, we may get a real mixed trans->packages list.
_alpm_pkg_free_trans() was modified so that it can handle both target types
_alpm_add_prepare() was removed, we use _alpm_sync_prepare() instead
_alpm_add_commit() was renamed to _alpm_upgrade_targets()
sync.c (and deps.c) was modified slightly to handle mixed target lists,
the modifications are straightforward. There is one notable change here: We
don't create new upgrade trans in sync.c, we replace the pkgcache entries
with the loaded package files in the target list (this is a bit hackish) and
call _alpm_upgrade_targets(). This implies a TODO (pkg->origin_data.db is
not accessible anymore), but it doesn't hurt anything with pacman front-end,
so it will be fixed later (otherwise this patch would be huge).
I updated the documentation of -U and I added a new pactest, upgrade090.py,
to test the syncdeps feature of -U.
Signed-off-by: Nagy Gabor <ngaba@bibl.u-szeged.hu>
Signed-off-by: Dan McGee <dan@archlinux.org>
2009-06-09 11:23:46 -04:00
|
|
|
}
|
|
|
|
/* load the package file and replace pkgcache entry with it in the target list */
|
|
|
|
/* TODO: alpm_pkg_get_db() will not work on this target anymore */
|
|
|
|
_alpm_log(PM_LOG_DEBUG, "replacing pkgcache entry with package file for target %s\n", spkg->name);
|
|
|
|
pmpkg_t *pkgfile;
|
|
|
|
if(alpm_pkg_load(filepath, 1, &pkgfile) != 0) {
|
|
|
|
_alpm_pkg_free(pkgfile);
|
|
|
|
errors++;
|
|
|
|
*data = alpm_list_add(*data, strdup(filename));
|
|
|
|
FREE(filepath);
|
|
|
|
continue;
|
2006-10-15 15:31:03 -04:00
|
|
|
}
|
Use sync.c for upgrade transaction prepare and commit
This patch utilizes the power of sync.c to fix FS#3492 and FS#5798.
Now an upgrade transaction is just a sync transaction internally (in alpm),
so all sync features are available with -U as well:
* conflict resolving
* sync dependencies from sync repos
* remove unresolvable targets
See http://www.archlinux.org/pipermail/pacman-dev/2009-June/008725.html
for the concept.
We use "mixed" target list, where PKG_FROM_FILE origin indicates local
package file, PKG_FROM_CACHE indicates sync package. The front-end can add
only one type of packages (depending on transaction type) atm, but if alpm
resolves dependencies for -U, we may get a real mixed trans->packages list.
_alpm_pkg_free_trans() was modified so that it can handle both target types
_alpm_add_prepare() was removed, we use _alpm_sync_prepare() instead
_alpm_add_commit() was renamed to _alpm_upgrade_targets()
sync.c (and deps.c) was modified slightly to handle mixed target lists,
the modifications are straightforward. There is one notable change here: We
don't create new upgrade trans in sync.c, we replace the pkgcache entries
with the loaded package files in the target list (this is a bit hackish) and
call _alpm_upgrade_targets(). This implies a TODO (pkg->origin_data.db is
not accessible anymore), but it doesn't hurt anything with pacman front-end,
so it will be fixed later (otherwise this patch would be huge).
I updated the documentation of -U and I added a new pactest, upgrade090.py,
to test the syncdeps feature of -U.
Signed-off-by: Nagy Gabor <ngaba@bibl.u-szeged.hu>
Signed-off-by: Dan McGee <dan@archlinux.org>
2009-06-09 11:23:46 -04:00
|
|
|
FREE(filepath);
|
|
|
|
pkgfile->reason = spkg->reason; /* copy over install reason */
|
|
|
|
i->data = pkgfile;
|
|
|
|
_alpm_pkg_free_trans(spkg); /* spkg has been removed from the target list */
|
2006-10-15 15:31:03 -04:00
|
|
|
}
|
2008-12-17 05:55:07 -05:00
|
|
|
|
2011-01-11 22:12:08 -05:00
|
|
|
PROGRESS(trans, PM_TRANS_PROGRESS_INTEGRITY_START, "", 100,
|
|
|
|
numtargs, current);
|
|
|
|
EVENT(trans, PM_TRANS_EVT_INTEGRITY_DONE, NULL, NULL);
|
2008-12-17 05:55:07 -05:00
|
|
|
|
|
|
|
|
2008-02-26 18:50:17 -05:00
|
|
|
if(errors) {
|
|
|
|
pm_errno = PM_ERR_PKG_INVALID;
|
2006-10-15 15:31:03 -04:00
|
|
|
goto error;
|
|
|
|
}
|
2011-01-11 22:12:08 -05:00
|
|
|
|
2006-10-15 15:31:03 -04:00
|
|
|
if(trans->flags & PM_TRANS_FLAG_DOWNLOADONLY) {
|
2010-05-16 01:34:38 -04:00
|
|
|
ret = 0;
|
|
|
|
goto error;
|
2006-10-15 15:31:03 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
trans->state = STATE_COMMITING;
|
2009-01-02 11:43:05 -05:00
|
|
|
|
2009-07-15 13:14:01 -04:00
|
|
|
replaces = alpm_list_count(trans->remove);
|
2009-01-02 11:43:05 -05:00
|
|
|
|
|
|
|
/* fileconflict check */
|
|
|
|
if(!(trans->flags & PM_TRANS_FLAG_FORCE)) {
|
|
|
|
EVENT(trans, PM_TRANS_EVT_FILECONFLICTS_START, NULL, NULL);
|
|
|
|
|
|
|
|
_alpm_log(PM_LOG_DEBUG, "looking for file conflicts\n");
|
Use sync.c for upgrade transaction prepare and commit
This patch utilizes the power of sync.c to fix FS#3492 and FS#5798.
Now an upgrade transaction is just a sync transaction internally (in alpm),
so all sync features are available with -U as well:
* conflict resolving
* sync dependencies from sync repos
* remove unresolvable targets
See http://www.archlinux.org/pipermail/pacman-dev/2009-June/008725.html
for the concept.
We use "mixed" target list, where PKG_FROM_FILE origin indicates local
package file, PKG_FROM_CACHE indicates sync package. The front-end can add
only one type of packages (depending on transaction type) atm, but if alpm
resolves dependencies for -U, we may get a real mixed trans->packages list.
_alpm_pkg_free_trans() was modified so that it can handle both target types
_alpm_add_prepare() was removed, we use _alpm_sync_prepare() instead
_alpm_add_commit() was renamed to _alpm_upgrade_targets()
sync.c (and deps.c) was modified slightly to handle mixed target lists,
the modifications are straightforward. There is one notable change here: We
don't create new upgrade trans in sync.c, we replace the pkgcache entries
with the loaded package files in the target list (this is a bit hackish) and
call _alpm_upgrade_targets(). This implies a TODO (pkg->origin_data.db is
not accessible anymore), but it doesn't hurt anything with pacman front-end,
so it will be fixed later (otherwise this patch would be huge).
I updated the documentation of -U and I added a new pactest, upgrade090.py,
to test the syncdeps feature of -U.
Signed-off-by: Nagy Gabor <ngaba@bibl.u-szeged.hu>
Signed-off-by: Dan McGee <dan@archlinux.org>
2009-06-09 11:23:46 -04:00
|
|
|
alpm_list_t *conflict = _alpm_db_find_fileconflicts(db_local, trans,
|
2009-07-15 13:14:01 -04:00
|
|
|
trans->add, trans->remove);
|
2009-01-02 11:43:05 -05:00
|
|
|
if(conflict) {
|
|
|
|
pm_errno = PM_ERR_FILE_CONFLICTS;
|
|
|
|
if(data) {
|
|
|
|
*data = conflict;
|
|
|
|
} else {
|
|
|
|
alpm_list_free_inner(conflict, (alpm_list_fn_free)_alpm_fileconflict_free);
|
|
|
|
alpm_list_free(conflict);
|
|
|
|
}
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
|
|
|
|
EVENT(trans, PM_TRANS_EVT_FILECONFLICTS_DONE, NULL, NULL);
|
2005-04-13 17:01:28 -04:00
|
|
|
}
|
2009-01-02 11:43:05 -05:00
|
|
|
|
2010-11-16 00:57:39 -05:00
|
|
|
/* check available disk space */
|
2010-11-16 01:54:30 -05:00
|
|
|
if(handle->checkspace) {
|
2010-11-16 02:07:43 -05:00
|
|
|
EVENT(trans, PM_TRANS_EVT_DISKSPACE_START, NULL, NULL);
|
|
|
|
|
2010-11-16 01:54:30 -05:00
|
|
|
_alpm_log(PM_LOG_DEBUG, "checking available disk space\n");
|
|
|
|
if(_alpm_check_diskspace(trans, handle->db_local) == -1) {
|
2011-02-28 18:50:23 -05:00
|
|
|
_alpm_log(PM_LOG_ERROR, "%s\n", _("not enough free disk space"));
|
2010-11-16 01:54:30 -05:00
|
|
|
goto error;
|
|
|
|
}
|
2010-11-16 02:07:43 -05:00
|
|
|
|
|
|
|
EVENT(trans, PM_TRANS_EVT_DISKSPACE_DONE, NULL, NULL);
|
2010-11-16 00:57:39 -05:00
|
|
|
}
|
|
|
|
|
2009-01-02 11:43:05 -05:00
|
|
|
/* remove conflicting and to-be-replaced packages */
|
|
|
|
if(replaces) {
|
|
|
|
_alpm_log(PM_LOG_DEBUG, "removing conflicting and to-be-replaced packages\n");
|
|
|
|
/* we want the frontend to be aware of commit details */
|
2009-07-15 13:14:01 -04:00
|
|
|
if(_alpm_remove_packages(trans, handle->db_local) == -1) {
|
2009-01-02 11:43:05 -05:00
|
|
|
_alpm_log(PM_LOG_ERROR, _("could not commit removal transaction\n"));
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* install targets */
|
|
|
|
_alpm_log(PM_LOG_DEBUG, "installing packages\n");
|
Use sync.c for upgrade transaction prepare and commit
This patch utilizes the power of sync.c to fix FS#3492 and FS#5798.
Now an upgrade transaction is just a sync transaction internally (in alpm),
so all sync features are available with -U as well:
* conflict resolving
* sync dependencies from sync repos
* remove unresolvable targets
See http://www.archlinux.org/pipermail/pacman-dev/2009-June/008725.html
for the concept.
We use "mixed" target list, where PKG_FROM_FILE origin indicates local
package file, PKG_FROM_CACHE indicates sync package. The front-end can add
only one type of packages (depending on transaction type) atm, but if alpm
resolves dependencies for -U, we may get a real mixed trans->packages list.
_alpm_pkg_free_trans() was modified so that it can handle both target types
_alpm_add_prepare() was removed, we use _alpm_sync_prepare() instead
_alpm_add_commit() was renamed to _alpm_upgrade_targets()
sync.c (and deps.c) was modified slightly to handle mixed target lists,
the modifications are straightforward. There is one notable change here: We
don't create new upgrade trans in sync.c, we replace the pkgcache entries
with the loaded package files in the target list (this is a bit hackish) and
call _alpm_upgrade_targets(). This implies a TODO (pkg->origin_data.db is
not accessible anymore), but it doesn't hurt anything with pacman front-end,
so it will be fixed later (otherwise this patch would be huge).
I updated the documentation of -U and I added a new pactest, upgrade090.py,
to test the syncdeps feature of -U.
Signed-off-by: Nagy Gabor <ngaba@bibl.u-szeged.hu>
Signed-off-by: Dan McGee <dan@archlinux.org>
2009-06-09 11:23:46 -04:00
|
|
|
if(_alpm_upgrade_packages(trans, handle->db_local) == -1) {
|
2007-08-23 22:26:55 -04:00
|
|
|
_alpm_log(PM_LOG_ERROR, _("could not commit transaction\n"));
|
2005-04-13 17:01:28 -04:00
|
|
|
goto error;
|
2005-03-14 20:51:43 -05:00
|
|
|
}
|
2008-02-27 11:45:01 -05:00
|
|
|
ret = 0;
|
2005-04-13 17:01:28 -04:00
|
|
|
|
|
|
|
error:
|
2008-02-27 11:45:01 -05:00
|
|
|
FREELIST(files);
|
|
|
|
alpm_list_free(deltas);
|
2011-03-20 20:45:57 -04:00
|
|
|
return ret;
|
2005-03-14 20:51:43 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
/* vim: set ts=2 sw=2 noet: */
|