Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/libalpm/add.c39
-rw-r--r--lib/libalpm/alpm.c8
-rw-r--r--lib/libalpm/sync.c48
-rw-r--r--lib/libalpm/trans.c1
4 files changed, 47 insertions, 49 deletions
diff --git a/lib/libalpm/add.c b/lib/libalpm/add.c
index e3efbd1c..7325ca13 100644
--- a/lib/libalpm/add.c
+++ b/lib/libalpm/add.c
@@ -125,6 +125,11 @@ int add_loadtarget(pmtrans_t *trans, pmdb_t *db, char *name)
pm_errno = PM_ERR_PKG_INVALID;
goto error;
}
+
+ /* set the reason to EXPLICIT by default
+ * it will be overwritten in the case of an upgrade or a sync operation */
+ info->reason = PM_PKG_REASON_EXPLICIT;
+
/* add the package to the transaction */
trans->packages = pm_list_add(trans->packages, info);
@@ -147,10 +152,6 @@ int add_prepare(pmtrans_t *trans, pmdb_t *db, PMList **data)
/* Check dependencies
*/
-
- /* ORE ???
- No need to check deps if pacman_add was called during a sync:
- it is already done in pacman_sync */
if(!(trans->flags & PM_TRANS_FLAG_NODEPS)) {
PMList *j;
@@ -238,7 +239,6 @@ int add_commit(pmtrans_t *trans, pmdb_t *db)
TAR *tar = NULL;
char expath[PATH_MAX];
time_t t;
- pmpkg_t *info = NULL;
PMList *targ, *lp;
ASSERT(db != NULL, RET_ERR(PM_ERR_DB_NULL, -1));
@@ -257,26 +257,25 @@ int add_commit(pmtrans_t *trans, pmdb_t *db)
};
unsigned short pmo_upgrade;
char pm_install[PATH_MAX];
+ pmpkg_t *info = (pmpkg_t *)targ->data;
pmpkg_t *oldpkg = NULL;
- info = (pmpkg_t *)targ->data;
errors = 0;
pmo_upgrade = (trans->type == PM_TRANS_TYPE_UPGRADE) ? 1 : 0;
/* see if this is an upgrade. if so, remove the old package first */
if(pmo_upgrade) {
- if(pkg_isin(info, db_get_pkgcache(db))) {
+ pmpkg_t *local = db_get_pkgfromcache(db, info->name);
+ if(local) {
TRANS_CB(trans, PM_TRANS_EVT_UPGRADE_START, info, NULL);
_alpm_log(PM_LOG_FLOW1, "upgrading package %s-%s", info->name, info->version);
- /* we'll need the full record for backup checks later */
+ /* we'll need to save some record for backup checks later */
oldpkg = pkg_new();
if(oldpkg) {
- STRNCPY(oldpkg->name, info->name, PKG_NAME_LEN);
- STRNCPY(oldpkg->version, info->version, PKG_VERSION_LEN);
- oldpkg->backup = _alpm_list_strdup(info->backup);
- /* ORE
- oldpkg->reason = info->reason;*/
+ STRNCPY(oldpkg->name, local->name, PKG_NAME_LEN);
+ STRNCPY(oldpkg->version, local->version, PKG_VERSION_LEN);
+ oldpkg->backup = _alpm_list_strdup(local->backup);
}
/* pre_upgrade scriptlet */
@@ -297,8 +296,7 @@ int add_commit(pmtrans_t *trans, pmdb_t *db)
RET_ERR(PM_ERR_TRANS_ABORT, -1);
}
/* copy over the install reason */
- /* ORE?
- info->reason = oldpkg->reason; */
+ info->reason = local->reason;
if(remove_loadtarget(tr, db, info->name) == -1) {
FREETRANS(tr);
RET_ERR(PM_ERR_TRANS_ABORT, -1);
@@ -351,17 +349,6 @@ int add_commit(pmtrans_t *trans, pmdb_t *db)
}
_alpm_log(PM_LOG_FLOW1, "updating database");
- /* Figure out whether this package was installed explicitly by the user
- * or installed as a dependency for another package
- */
- info->reason = PM_PKG_REASON_EXPLICIT;
- /* ORE
- only relevant for sync operations?
- usage of info->data should be ok for TRANS_TYPE_ADD, but wrong for
- TRANS_TYPE_SYNC
- if(pm_list_is_strin(trans->targets, info->data) || pmo_d_resolve) {
- info->reason = PM_PKG_REASON_DEPEND;
- }*/
/* make an install date (in UTC) */
STRNCPY(info->installdate, asctime(gmtime(&t)), sizeof(info->installdate));
_alpm_log(PM_LOG_FLOW2, "adding database entry %s", info->name);
diff --git a/lib/libalpm/alpm.c b/lib/libalpm/alpm.c
index 8f5a1649..20bb516c 100644
--- a/lib/libalpm/alpm.c
+++ b/lib/libalpm/alpm.c
@@ -69,7 +69,7 @@ int alpm_initialize(char *root)
handle = handle_new();
if(handle == NULL) {
- RET_ERR(PM_ERR_MEM_ERROR, -1);
+ RET_ERR(PM_ERR_MEMORY, -1);
}
/* lock db */
@@ -111,10 +111,8 @@ int alpm_release()
}
/* and also sync ones */
for(i = handle->dbs_sync; i; i = i->next) {
- if(i->data) {
- db_close(i->data);
- i->data = NULL;
- }
+ db_close(i->data);
+ i->data = NULL;
}
FREEHANDLE(handle);
diff --git a/lib/libalpm/sync.c b/lib/libalpm/sync.c
index 0d537274..8d6ee1d0 100644
--- a/lib/libalpm/sync.c
+++ b/lib/libalpm/sync.c
@@ -254,7 +254,7 @@ int sync_addtarget(pmtrans_t *trans, pmdb_t *db_local, PMList *dbs_sync, char *n
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);
+ STRNCPY(targline, name, (PKG_NAME_LEN-1)+1+(DB_TREENAME_LEN-1)+1);
targ = strchr(targline, '/');
if(targ) {
*targ = '\0';
@@ -294,7 +294,7 @@ int sync_addtarget(pmtrans_t *trans, pmdb_t *db_local, PMList *dbs_sync, char *n
/* 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", local->name, local->version);
+ _alpm_log(PM_LOG_WARNING, "%s-%s is up to date -- skipping", local->name, local->version);
return(0);
}
}
@@ -352,9 +352,6 @@ int sync_prepare(pmtrans_t *trans, pmdb_t *db_local, PMList *dbs_sync, PMList **
/* pm_errno is set by resolvedeps */
goto error;
}
- /* ORE
- if called from makepkg, reason should be set to REASON_DEPEND
- spkg->reason = PM_PKG_REASON_EXPLICIT;*/
}
for(i = list; i; i = i->next) {
pmpkg_t *spkg = i->data;
@@ -472,7 +469,7 @@ int sync_commit(pmtrans_t *trans, pmdb_t *db_local)
{
PMList *i;
PMList *data;
- pmtrans_t *tr;
+ pmtrans_t *tr = NULL;
int replaces = 0;
ASSERT(db_local != NULL, RET_ERR(PM_ERR_DB_NULL, -1));
@@ -492,9 +489,15 @@ int sync_commit(pmtrans_t *trans, pmdb_t *db_local)
for(i = trans->packages; i; i = i->next) {
pmsyncpkg_t *sync = i->data;
if(sync->type == PM_SYNC_TYPE_REPLACE) {
- pmpkg_t *pkg = sync->pkg;
- if(trans_addtarget(tr, pkg->name)) {
- goto error;
+ PMList *pkgs = sync->data;
+ PMList *j;
+ for(j = pkgs; j; j = j->next) {
+ pmpkg_t *pkg = j->data;
+ if(!pkg_isin(pkg, tr->packages)) {
+ if(trans_addtarget(tr, pkg->name) == -1) {
+ goto error;
+ }
+ }
}
replaces++;
}
@@ -514,7 +517,7 @@ int sync_commit(pmtrans_t *trans, pmdb_t *db_local)
goto error;
}
}
- trans_free(tr);
+ FREETRANS(tr);
/* install targets */
_alpm_log(PM_LOG_FLOW1, "installing packages");
@@ -531,13 +534,21 @@ int sync_commit(pmtrans_t *trans, pmdb_t *db_local)
}
for(i = trans->packages; i; i = i->next) {
pmsyncpkg_t *sync = i->data;
- if(sync->type != PM_SYNC_TYPE_REPLACE) {
- pmpkg_t *spkg = sync->pkg;
- char str[PATH_MAX];
- snprintf(str, PATH_MAX, "%s" PM_CACHEDIR "/%s-%s" PM_EXT_PKG, handle->root, spkg->name, spkg->version);
- if(trans_addtarget(tr, str) == -1) {
- goto error;
- }
+ pmpkg_t *spkg = sync->pkg;
+ char str[PATH_MAX];
+ snprintf(str, PATH_MAX, "%s" PM_CACHEDIR "/%s-%s" PM_EXT_PKG, handle->root, spkg->name, spkg->version);
+ if(trans_addtarget(tr, str) == -1) {
+ goto error;
+ }
+ /* using list_last() is ok because addtarget() adds the new target at the
+ * end of the tr->packages list */
+ spkg = pm_list_last(tr->packages)->data;
+ if(sync->type == PM_SYNC_TYPE_DEPEND) {
+ /* ORE
+ * if called from makepkg, reason should be set to PM_PKG_REASON_DEPEND */
+ spkg->reason = PM_PKG_REASON_DEPEND;
+ } else {
+ spkg->reason = PM_PKG_REASON_EXPLICIT;
}
}
if(trans_prepare(tr, &data) == -1) {
@@ -552,7 +563,7 @@ int sync_commit(pmtrans_t *trans, pmdb_t *db_local)
pm_errno = PM_ERR_XXX;
goto error;
}
- trans_free(tr);
+ FREETRANS(tr);
/* propagate replaced packages' requiredby fields to their new owners */
if(replaces) {
@@ -595,6 +606,7 @@ int sync_commit(pmtrans_t *trans, pmdb_t *db_local)
return(0);
error:
+ FREETRANS(tr);
return(-1);
}
diff --git a/lib/libalpm/trans.c b/lib/libalpm/trans.c
index 0a68a2bc..7f33f13d 100644
--- a/lib/libalpm/trans.c
+++ b/lib/libalpm/trans.c
@@ -133,6 +133,7 @@ int trans_addtarget(pmtrans_t *trans, char *target)
}
break;
}
+
trans->targets = pm_list_add(trans->targets, strdup(target));
return(0);