summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAurelien Foret <aurelien@archlinux.org>2005-03-31 00:32:43 +0200
committerAurelien Foret <aurelien@archlinux.org>2005-03-31 00:32:43 +0200
commit4d21e4f721077387734c8f77017e0dba8a95a14b (patch)
treed47779158c1dfaacd26cb6bdaedfc109c1eb9f5d
parentb009c5bafa63581a0c590a8c1a1d8dafd5e7654a (diff)
downloadpacman-4d21e4f721077387734c8f77017e0dba8a95a14b.tar.gz
pacman-4d21e4f721077387734c8f77017e0dba8a95a14b.tar.xz
started the work on "pacman_sync"
-rw-r--r--lib/libalpm/add.c5
-rw-r--r--lib/libalpm/alpm.h1
-rw-r--r--lib/libalpm/deps.c111
-rw-r--r--lib/libalpm/deps.h2
-rw-r--r--lib/libalpm/remove.c1
-rw-r--r--lib/libalpm/sync.c96
-rw-r--r--lib/libalpm/sync.h2
-rw-r--r--lib/libalpm/trans.c14
-rw-r--r--src/pacman/sync.c171
9 files changed, 192 insertions, 211 deletions
diff --git a/lib/libalpm/add.c b/lib/libalpm/add.c
index 3b7eca72..286c8f2a 100644
--- a/lib/libalpm/add.c
+++ b/lib/libalpm/add.c
@@ -101,11 +101,8 @@ int add_loadtarget(pmdb_t *db, pmtrans_t *trans, char *name)
_alpm_log(PM_LOG_WARNING, "replacing older version of %s %s by %s in target list", pkg->name, pkg->version, info->version);
FREEPKG(j->data);
j->data = info;
- return(0);
- } else {
- pm_errno = PM_ERR_TRANS_DUP_TARGET;
- goto error;
}
+ return(0);
}
}
diff --git a/lib/libalpm/alpm.h b/lib/libalpm/alpm.h
index 6f2980e0..ff61a5e8 100644
--- a/lib/libalpm/alpm.h
+++ b/lib/libalpm/alpm.h
@@ -199,6 +199,7 @@ enum {
#define PM_TRANS_FLAG_CASCADE 0x10
#define PM_TRANS_FLAG_RECURSE 0x20
#define PM_TRANS_FLAG_DBONLY 0x40
+#define PM_TRANS_FLAG_SYSUPG 0x80
/* Events */
enum {
diff --git a/lib/libalpm/deps.c b/lib/libalpm/deps.c
index a0490d42..63512a82 100644
--- a/lib/libalpm/deps.c
+++ b/lib/libalpm/deps.c
@@ -25,6 +25,7 @@
/* pacman */
#include "util.h"
#include "log.h"
+#include "error.h"
#include "list.h"
#include "package.h"
#include "db.h"
@@ -541,13 +542,16 @@ PMList* removedeps(pmdb_t *db, PMList *targs)
*
* make sure *list and *trail are already initialized
*/
-int resolvedeps(pmdb_t *local, PMList *databases, pmsync_t *sync, PMList *list, PMList *trail, PMList **data)
+int resolvedeps(pmdb_t *local, PMList *dbs_sync, pmpkg_t *syncpkg, PMList *list, PMList *trail)
{
PMList *i, *j;
PMList *targ;
PMList *deps = NULL;
+ PMList **data = NULL;
- targ = pm_list_add(NULL, sync->spkg);
+ _alpm_log(PM_LOG_FUNCTION, "%s => %s", __FUNCTION__, syncpkg->name);
+
+ targ = pm_list_add(NULL, syncpkg);
deps = checkdeps(local, PM_TRANS_TYPE_ADD, targ);
FREELISTPTR(targ);
@@ -559,99 +563,68 @@ int resolvedeps(pmdb_t *local, PMList *databases, pmsync_t *sync, PMList *list,
int found = 0;
pmdepmissing_t *miss = i->data;
+ printf("pkg=%s: dep.name=%s\n", miss->target, miss->depend.name);
+
/* XXX: conflicts are now treated specially in the _add and _sync functions */
- /*if(miss->type == CONFLICT) {
+ /*if(miss->type == PM_DEP_TYPE_CONFLICT) {
_alpm_log(PM_LOG_ERROR, "cannot resolve dependencies for \"%s\" (it conflict with %s)", miss->target, miss->depend.name);
return(1);
} else*/
if(miss->type == PM_DEP_TYPE_DEPEND) {
- pmsync_t *sync = NULL;
-
+ pmpkg_t *sync = NULL;
/* find the package in one of the repositories */
-
/* check literals */
- for(j = databases; !sync && j; j = j->next) {
+ for(j = dbs_sync; !sync && j; j = j->next) {
PMList *k;
pmdb_t *dbs = j->data;
-
for(k = db_get_pkgcache(dbs); !sync && k; k = k->next) {
pmpkg_t *pkg = k->data;
-
if(!strcmp(miss->depend.name, pkg->name)) {
- sync = sync_new(PM_SYSUPG_DEPEND, NULL, k->data);
- if(sync == NULL) {
- pm_errno = PM_ERR_MEMORY;
- goto error;
- }
- /* ORE
- sync->pkg->reason = PM_PKG_REASON_DEPEND;*/
+
+ /* re-fetch the package record with dependency info */
+ sync = db_scan(dbs, pkg->name, INFRQ_DESC | INFRQ_DEPENDS);
+ sync->reason = PM_PKG_REASON_DEPEND;
}
}
}
-
/* check provides */
- /* ORE
- for(j = databases; !s && j; j = j->next) {
+ for(j = dbs_sync; !sync && j; j = j->next) {
PMList *provides;
-
- provides = _alpm_db_whatprovides(j->data, miss->depend.name);
+ pmdb_t *dbs = j->data;
+ provides = _alpm_db_whatprovides(dbs, miss->depend.name);
if(provides) {
- s = sync_new(PM_SYSUPG_DEPEND, NULL, !!!provides->data!!!);
- if(s == NULL) {
- pm_errno = PM_ERR_MEMORY;
- goto error;
- }
- sync->pkg->reason = PM_PKG_REASON_DEPEND;
- }
- FREELIST(provides);
- }*/
-
- if(sync == NULL) {
- pmdepmissing_t *m = (pmdepmissing_t *)malloc(sizeof(pmdepmissing_t));
- if(m == NULL) {
- /* ORE
- Free memory before leaving */
- pm_errno = PM_ERR_MEMORY;
- goto error;
+ /* re-fetch the package record with dependency info */
+ sync = db_scan(dbs, provides->data, INFRQ_DESC | INFRQ_DEPENDS);
+ sync->reason = PM_PKG_REASON_DEPEND;
}
- *m = *(pmdepmissing_t *)i->data;
- *data = pm_list_add(*data, m);
- continue;
+ FREELISTPTR(provides);
}
-
- if(*data) {
- /* there is at least an unresolvable dep... so we only
- * continue to get the whole list of unresolvable deps */
- continue;
+ if(sync == NULL) {
+ _alpm_log(PM_LOG_ERROR, "cannot resolve dependencies for \"%s\" (\"%s\" is not in the package set", miss->target, miss->depend.name);
+ return(1);
}
-
found = 0;
for(j = list; j && !found; j = j->next) {
- pmsync_t *tmp = j->data;
-
- if(tmp && !strcmp(tmp->spkg->name, sync->spkg->name)) {
+ pmpkg_t *tmp = j->data;
+ if(tmp && !strcmp(tmp->name, sync->name)) {
found = 1;
}
}
-
if(found) {
/* this dep is already in the target list */
FREE(sync);
continue;
}
-
- _alpm_log(PM_LOG_FLOW2, "resolving %s", sync->spkg->name);
+ _alpm_log(PM_LOG_FLOW2, "resolving %s", sync->name);
found = 0;
for(j = trail; j; j = j->next) {
- pmsync_t *tmp = j->data;
-
- if(tmp && !strcmp(tmp->spkg->name, sync->spkg->name)) {
+ pmpkg_t *tmp = j->data;
+ if(tmp && !strcmp(tmp->name, sync->name)) {
found = 1;
}
}
-
if(!found) {
/* check pmo_ignorepkg and pmo_s_ignore to make sure we haven't pulled in
* something we're not supposed to.
@@ -659,8 +632,8 @@ int resolvedeps(pmdb_t *local, PMList *databases, pmsync_t *sync, PMList *list,
int usedep = 1;
found = 0;
/* ORE
- for(j = pmo_ignorepkg; j && !found; j = j->next) {
- if(!strcmp(j->data, sync->pkg->name)) {
+ for(j = handle->ignorepkg; j && !found; j = j->next) {
+ if(!strcmp(j->data, sync->name)) {
found = 1;
}
}
@@ -668,17 +641,18 @@ int resolvedeps(pmdb_t *local, PMList *databases, pmsync_t *sync, PMList *list,
if(!strcmp(j->data, sync->pkg->name)) {
found = 1;
}
- }
+ }*/
if(found) {
+ /* ORE
usedep = yesno("%s requires %s, but it is in IgnorePkg. Install anyway? [Y/n] ",
- miss->target, sync->pkg->name);
- }*/
+ miss->target, sync->pkg->name);*/
+ }
if(usedep) {
trail = pm_list_add(trail, sync);
- if(resolvedeps(local, databases, sync, list, trail, data)) {
+ if(resolvedeps(local, dbs_sync, sync, list, trail)) {
goto error;
}
- _alpm_log(PM_LOG_FLOW2, "adding %s-%s", sync->spkg->name, sync->spkg->version);
+ _alpm_log(PM_LOG_FLOW2, "adding %s-%s", sync->name, sync->version);
list = pm_list_add(list, sync);
} else {
_alpm_log(PM_LOG_ERROR, "cannot resolve dependencies for \"%s\"", miss->target);
@@ -687,7 +661,7 @@ int resolvedeps(pmdb_t *local, PMList *databases, pmsync_t *sync, PMList *list,
}
} else {
/* cycle detected -- skip it */
- _alpm_log(PM_LOG_FLOW2, "dependency cycle detected: %s", sync->spkg->name);
+ _alpm_log(PM_LOG_FLOW2, "dependency cycle detected: %s", sync->name);
FREE(sync);
}
}
@@ -695,10 +669,9 @@ int resolvedeps(pmdb_t *local, PMList *databases, pmsync_t *sync, PMList *list,
FREELIST(deps);
- if(*data) {
- pm_errno = PM_ERR_UNRESOLVABLE_DEPS;
- return(-1);
- }
+ /*if(*data) {
+ RET_ERR(PM_ERR_UNRESOLVABLE_DEPS, -1);
+ }*/
return(0);
diff --git a/lib/libalpm/deps.h b/lib/libalpm/deps.h
index b45fa48c..cc0d891b 100644
--- a/lib/libalpm/deps.h
+++ b/lib/libalpm/deps.h
@@ -40,7 +40,7 @@ PMList *sortbydeps(PMList *targets, int mode);
PMList *checkdeps(pmdb_t *db, unsigned char op, PMList *packages);
int splitdep(char *depstr, pmdepend_t *depend);
PMList *removedeps(pmdb_t *db, PMList *targs);
-int resolvedeps(pmdb_t *local, PMList *databases, pmsync_t *sync, PMList *list, PMList *trail, PMList **data);
+int resolvedeps(pmdb_t *local, PMList *dbs_sync, pmpkg_t *syncpkg, PMList *list, PMList *trail);
#endif /* _ALPM_DEPS_H */
diff --git a/lib/libalpm/remove.c b/lib/libalpm/remove.c
index 9b9f91dc..70bfeecf 100644
--- a/lib/libalpm/remove.c
+++ b/lib/libalpm/remove.c
@@ -208,7 +208,6 @@ int remove_commit(pmdb_t *db, pmtrans_t *trans)
_alpm_log(PM_LOG_ERROR, "failed to remove database entry %s/%s-%s", db->treename, info->name, info->version);
}
-
/* update dependency packages' REQUIREDBY fields */
_alpm_log(PM_LOG_FLOW2, "updating dependency packages 'requiredby' fields");
for(lp = info->depends; lp; lp = lp->next) {
diff --git a/lib/libalpm/sync.c b/lib/libalpm/sync.c
index 1d4108dd..8e839b0c 100644
--- a/lib/libalpm/sync.c
+++ b/lib/libalpm/sync.c
@@ -26,6 +26,7 @@
/* pacman */
#include "log.h"
#include "util.h"
+#include "error.h"
#include "list.h"
#include "package.h"
#include "db.h"
@@ -53,6 +54,11 @@ pmsync_t *sync_new(int type, pmpkg_t *lpkg, pmpkg_t *spkg)
return(sync);
}
+int sync_parsedb(char *archive)
+{
+ return(0);
+}
+
int sync_sysupgrade(PMList **data)
{
PMList *i, *j, *k;
@@ -121,24 +127,20 @@ int sync_sysupgrade(PMList **data)
/* local version is newer */
_alpm_log(PM_LOG_FLOW1, "%s-%s: local version is newer",
local->name, local->version);
- continue;
} else if(cmp == 0) {
/* versions are identical */
- continue;
} else if(pm_list_is_strin(i->data, handle->ignorepkg)) {
/* package should be ignored (IgnorePkg) */
_alpm_log(PM_LOG_FLOW1, "%s-%s: ignoring package upgrade (%s)",
local->name, local->version, spkg->version);
- continue;
- }
-
- sync = sync_new(PM_SYSUPG_UPGRADE, local, spkg);
- if(sync == NULL) {
- pm_errno = PM_ERR_MEMORY;
- goto error;
+ } else {
+ sync = sync_new(PM_SYSUPG_UPGRADE, local, spkg);
+ if(sync == NULL) {
+ pm_errno = PM_ERR_MEMORY;
+ goto error;
+ }
+ targets = pm_list_add(targets, sync);
}
-
- targets = pm_list_add(targets, sync);
}
*data = targets;
@@ -150,8 +152,69 @@ error:
return(-1);
}
-int sync_resolvedeps(PMList **syncs)
+int sync_addtarget(pmdb_t *db, PMList *dbs_sync, pmtrans_t *trans, char *name)
{
+ char targline[(PKG_NAME_LEN-1)+1+(DB_TREENAME_LEN-1)+1];
+ char *targ, *treename;
+ PMList *j;
+ pmpkg_t *local;
+ pmpkg_t *sync = NULL;
+ int cmp;
+
+ ASSERT(db != NULL, RET_ERR(PM_ERR_DB_NULL, -1));
+ ASSERT(trans != NULL, RET_ERR(PM_ERR_TRANS_NULL, -1));
+ ASSERT(name != NULL, RET_ERR(PM_ERR_WRONG_ARGS, -1));
+
+ strncpy(targline, name, (PKG_NAME_LEN-1)+1+(DB_TREENAME_LEN-1)+1);
+ targ = strchr(targline, '/');
+ if(targ) {
+ *targ = '\0';
+ targ++;
+ treename = targline;
+ for(j = dbs_sync; j && !sync; j = j->next) {
+ pmdb_t *dbs = j->data;
+ if(strcmp(dbs->treename, targline) == 0) {
+ sync = alpm_db_readpkg(dbs, targ);
+ }
+ }
+ } else {
+ targ = targline;
+ for(j = dbs_sync; j && !sync; j = j->next) {
+ pmdb_t *dbs = j->data;
+ sync = alpm_db_readpkg(dbs, targ);
+ }
+ }
+
+ if(sync == NULL) {
+ RET_ERR(PM_ERR_PKG_NOT_FOUND, -1);
+ }
+
+ /* if not a sysupgrade, compare versions and determine if it is necessary */
+ if(!trans->flags & PM_TRANS_FLAG_SYSUPG) {
+ local = alpm_db_readpkg(db, name);
+ if(local) {
+ cmp = alpm_pkg_vercmp(local->version, sync->version);
+ if(cmp > 0) {
+ /* local version is newer - get confirmation first */
+ /* ORE
+ if(!yesno(":: %s-%s: local version is newer. Upgrade anyway? [Y/n] ", lpkgname, lpkgver)) {
+ }*/
+ _alpm_log(PM_LOG_WARNING, "%s-%s: local version is newer -- skipping");
+ return(0);
+ } else if(cmp == 0) {
+ /* versions are identical */
+ /* ORE
+ if(!yesno(":: %s-%s: is up to date. Upgrade anyway? [Y/n] ", lpkgname, lpkgver)) {
+ }*/
+ _alpm_log(PM_LOG_WARNING, "%s-%s: is up to date -- skipping");
+ return(0);
+ }
+ }
+ }
+
+ /* add the package to the transaction */
+ trans->packages = pm_list_add(trans->packages, sync);
+
return(0);
}
@@ -159,10 +222,12 @@ int sync_prepare(pmdb_t *db, pmtrans_t *trans, PMList **data)
{
PMList *i;
PMList *trail = NULL;
+ PMList *list = NULL;
/* Resolve targets dependencies */
- for(i = trans->targets; i; i = i->next) {
- if(resolvedeps(handle->db_local, handle->dbs_sync, i->data, trans->targets, trail, data) == -1) {
+ for(i = trans->packages; i; i = i->next) {
+ pmpkg_t *sync = i->data;
+ if(resolvedeps(handle->db_local, handle->dbs_sync, sync, list, trail) == -1) {
/* pm_errno is set by resolvedeps */
goto error;
}
@@ -204,11 +269,8 @@ int sync_commit(pmdb_t *db, pmtrans_t *trans)
for(i = files; i; i = i->next) {
trans_addtarget(tr, i->data);
}
-
trans_prepare(tr, &data);
-
trans_commit(tr);
-
trans_free(tr);
/* propagate replaced packages' requiredby fields to their new owners */
diff --git a/lib/libalpm/sync.h b/lib/libalpm/sync.h
index 00bd7c57..667dc4f4 100644
--- a/lib/libalpm/sync.h
+++ b/lib/libalpm/sync.h
@@ -39,6 +39,8 @@ pmsyncpkg_t *find_pkginsync(char *needle, PMList *haystack);
PMList *rm_pkginsync(char *needle, PMList *haystack);*/
int sync_sysupgrade(PMList **data);
+
+int sync_addtarget(pmdb_t *db, PMList *dbs_sync, pmtrans_t *trans, char *name);
int sync_prepare(pmdb_t *db, pmtrans_t *trans, PMList **data);
int sync_commit(pmdb_t *db, pmtrans_t *trans);
diff --git a/lib/libalpm/trans.c b/lib/libalpm/trans.c
index 7bd37e1f..6e278cd7 100644
--- a/lib/libalpm/trans.c
+++ b/lib/libalpm/trans.c
@@ -61,7 +61,12 @@ void trans_free(pmtrans_t *trans)
}
FREELIST(trans->targets);
- FREELISTPKGS(trans->packages);
+ /* ORE - ugly */
+ if(trans->type == PM_TRANS_TYPE_SYNC) {
+ FREELISTPTR(trans->packages);
+ } else {
+ FREELISTPKGS(trans->packages);
+ }
free(trans);
}
@@ -109,9 +114,14 @@ int trans_addtarget(pmtrans_t *trans, char *target)
return(-1);
}
break;
+ case PM_TRANS_TYPE_SYNC:
+ if(sync_addtarget(handle->db_local, handle->dbs_sync, trans, target) == -1) {
+ /* pm_errno is set by add_loadtarget() */
+ return(-1);
+ }
+ break;
}
trans->targets = pm_list_add(trans->targets, strdup(target));
- trans->state = STATE_INITIALIZED;
return(0);
}
diff --git a/src/pacman/sync.c b/src/pacman/sync.c
index 01a535cb..1dc6ceea 100644
--- a/src/pacman/sync.c
+++ b/src/pacman/sync.c
@@ -364,7 +364,7 @@ static int sync_list(list_t *syncs, list_t *targets)
int pacman_sync(list_t *targets)
{
- int allgood = 1, confirm = 0;
+ int confirm = 0;
int retval = 0;
list_t *final = NULL;
list_t *i, *j;
@@ -420,19 +420,19 @@ int pacman_sync(list_t *targets)
return(sync_list(pmc_syncs, targets));
}
+ /* Step 1: create a new transaction...
+ */
+ if(alpm_trans_init(PM_TRANS_TYPE_SYNC, pmo_flags, NULL) == -1) {
+ ERR(NL, "failed to init transaction (%s)\n", alpm_strerror(pm_errno));
+ retval = 1;
+ goto cleanup;
+ }
+
if(pmo_s_upgrade) {
alpm_logaction("starting full system upgrade");
+
if(alpm_sync_sysupgrade(&data) == -1) {
- if(pm_errno == PM_ERR_UNRESOLVABLE_DEPS) {
- ERR(NL, "cannot resolve dependencies\n");
- for(lp = alpm_list_first(data); lp; lp = alpm_list_next(lp)) {
- PM_DEPMISS *miss = alpm_list_getdata(lp);
- ERR(NL, " %s: \"%s\" is not in the package set\n", alpm_dep_getinfo(miss, PM_DEP_TARGET), alpm_dep_getinfo(miss, PM_DEP_NAME));
- }
- alpm_list_free(data);
- } else {
- ERR(NL, "%s\n", alpm_strerror(pm_errno));
- }
+ ERR(NL, "%s\n", alpm_strerror(pm_errno));
return(1);
}
@@ -446,13 +446,15 @@ int pacman_sync(list_t *targets)
PM_SYNC *sync = alpm_list_getdata(lp);
if(!strcmp("pacman", alpm_pkg_getinfo(alpm_sync_getinfo(sync, PM_SYNC_SYNCPKG), PM_PKG_NAME))) {
- ERR(NL, "\n:: pacman has detected a newer version of the \"pacman\" package.\n");
- ERR(NL, ":: It is recommended that you allow pacman to upgrade itself\n");
- ERR(NL, ":: first, then you can re-run the operation with the newer version.\n");
- ERR(NL, "::\n");
+ MSG(NL, "\n:: pacman has detected a newer version of the \"pacman\" package.\n");
+ MSG(NL, ":: It is recommended that you allow pacman to upgrade itself\n");
+ MSG(NL, ":: first, then you can re-run the operation with the newer version.\n");
+ MSG(NL, "::\n");
if(yesno(":: Upgrade pacman first? [Y/n] ")) {
+ /* ORE
+ we should substitute existing targets with "pacman" */
alpm_list_free(data);
- data = NULL;
+ return(0);
}
}
}
@@ -472,56 +474,30 @@ int pacman_sync(list_t *targets)
switch((int)alpm_sync_getinfo(sync, PM_SYNC_TYPE)) {
case PM_SYSUPG_REPLACE:
+ MSG(NL, "Replace %s by '%s-%s'\n", lpkgname, spkgname, spkgver);
if(yesno(":: Replace %s with %s from \"%s\"? [Y/n] ", lpkgname, spkgname, NULL/*dbs->db->treename*/)) {
- DBG("adding '%s-%s' to replaces candidates\n", spkgname, spkgver);
- final = list_add(final, spkg);
}
break;
case PM_SYSUPG_UPGRADE:
- DBG("Upgrade %s (%s => %s)\n", lpkgname, lpkgver, spkgver);
- final = list_add(final, spkg);
+ MSG(NL, "Upgrade %s (%s => %s)\n", lpkgname, lpkgver, spkgver);
+ targets = list_add(targets, strdup(spkgname));
break;
default:
break;
}
}
alpm_list_free(data);
- } else {
- /* process targets */
- for(i = targets; i; i = i->next) {
- char *treename;
- char *targ;
- char *targline;
- PM_PKG *local = NULL;
-
- targline = strdup((char *)i->data);
- targ = index(targline, '/');
- if(targ) {
- *targ = '\0';
- targ++;
- treename = targline;
- } else {
- targ = targline;
- treename = NULL;
- }
+ }
- if(treename == NULL) {
- for(j = pmc_syncs; j && !local; j = j->next) {
- sync_t *sync = j->data;
- local = alpm_db_readpkg(sync->db, targ);
- }
- } else {
- for(j = pmc_syncs; j && !local; j = j->next) {
- sync_t *sync = j->data;
- if(strcmp(sync->treename, treename) == 0) {
- local = alpm_db_readpkg(sync->db, targ);
- }
- }
- }
+ /* and add targets to it
+ */
+ for(i = targets; i; i = i->next) {
+ char *targ = i->data;
- if(local == NULL) {
- PM_GRP *grp = NULL;
+ if(alpm_trans_addtarget(targ) == -1) {
+ if(pm_errno == PM_ERR_PKG_NOT_FOUND) {
+ PM_GRP *grp;
/* target not found: check if it's a group */
for(j = pmc_syncs; j && !grp; j = j->next) {
sync_t *sync = j->data;
@@ -548,68 +524,19 @@ int pacman_sync(list_t *targets)
}
}
if(grp == NULL) {
- ERR(NL, "package \"%s\" not found", targ);
+ ERR(NL, "failed to add target '%s': not found in sync db\n", targ);
return(1);
}
- }
- if(treename) {
- FREE(targline);
- }
-
- }
-
- if(!pmo_s_downloadonly && !pmo_s_printuris) {
- /* this is an upgrade, compare versions and determine if it is necessary */
- for(i = targets; i; i = i->next) {
- int cmp;
- PM_PKG *local, *sync;
- char *lpkgname, *lpkgver, *spkgver;
-
- local = alpm_db_readpkg(db_local, i->data);
- lpkgname = alpm_pkg_getinfo(local, PM_PKG_NAME);
- lpkgver = alpm_pkg_getinfo(local, PM_PKG_VERSION);
-
- sync = alpm_db_readpkg(db_local, i->data);
- spkgver = alpm_pkg_getinfo(sync, PM_PKG_VERSION);
-
- cmp = alpm_pkg_vercmp(lpkgver, spkgver);
- if(cmp > 0) {
- /* local version is newer - get confirmation first */
- if(!yesno(":: %s-%s: local version is newer. Upgrade anyway? [Y/n] ", lpkgname, lpkgver)) {
- /* ORE
- char *data = list_remove(targets, lpkgname);
- free(data);*/
- }
- } else if(cmp == 0) {
- /* versions are identical */
- if(!yesno(":: %s-%s: is up to date. Upgrade anyway? [Y/n] ", lpkgname, lpkgver)) {
- /* ORE
- char *data = list_remove(targets, lpkgname);
- free(data);*/
- }
- }
+ continue;
+ } else {
+ ERR(NL, "failed to add target '%s': %s\n", (char *)i->data, alpm_strerror(pm_errno));
+ retval = 1;
+ goto cleanup;
}
}
}
- /* Step 1: create a new transaction */
- if(alpm_trans_init(PM_TRANS_TYPE_SYNC, pmo_flags, NULL) == -1) {
- ERR(NL, "failed to init transaction (%s)\n", alpm_strerror(pm_errno));
- retval = 1;
- goto cleanup;
- }
- /* and add targets to it */
- for(i = targets; i; i = i->next) {
- if(alpm_trans_addtarget(i->data) == -1) {
- ERR(NL, "failed to add target '%s' (%s)\n", (char *)i->data, alpm_strerror(pm_errno));
- retval = 1;
- goto cleanup;
- }
- }
-
PM_LIST_display("target :", alpm_trans_getinfo(PM_TRANS_TARGETS));
- /* ORE
- TBD */
/* Step 2: "compute" the transaction based on targets and flags */
if(alpm_trans_prepare(&data) == -1) {
@@ -761,29 +688,39 @@ int pacman_sync(list_t *targets)
/* Check integrity of files */
MSG(NL, "checking package integrity... ");
- allgood = 1;
for(i = final; i; i = i->next) {
- char /*str[PATH_MAX],*/ pkgname[PATH_MAX];
+ char /*str[PATH_MAX],*/ pkgname[PATH_MAX] = "dummy";
char *md5sum1, *md5sum2;
snprintf(pkgname, PATH_MAX, "%s-%s"PM_EXT_PKG, "", "");
md5sum1 = NULL;
+ /* ORE
+ md5sum1 = sync->pkg->md5sum;
+ if(md5sum1 == NULL) {
+ ERR(NL, "can't get md5 checksum for package %s\n", pkgname);
+ retval = 1;
+ continue;
+ } */
+
md5sum2 = NULL;
+ /* ORE
+ md5sum2 = alpm_get_md5sum();
+ if(md5sum2 == NULL) {
+ ERR(NL, "can't get md5 checksum for package %s\n", pkgname);
+ retval = 1;
+ continue;
+ } */
if(strcmp(md5sum1, md5sum2) != 0) {
- if(allgood) {
- printf("\n");
- }
- ERR(NL, "error: archive %s is corrupted\n", "");
- allgood = 0;
+ retval = 1;
+ ERR(NL, "error: archive %s is corrupted\n", pkgname);
}
FREE(md5sum2);
}
- if(!allgood) {
- retval = 1;
+ if(retval) {
goto cleanup;
}
MSG(CL, "done.\n");