summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/libalpm/add.c53
-rw-r--r--lib/libalpm/alpm.c3
-rw-r--r--lib/libalpm/deps.c6
-rw-r--r--lib/libalpm/sync.c3
-rw-r--r--lib/libalpm/util.c4
5 files changed, 58 insertions, 11 deletions
diff --git a/lib/libalpm/add.c b/lib/libalpm/add.c
index 880b4dc3..778558fb 100644
--- a/lib/libalpm/add.c
+++ b/lib/libalpm/add.c
@@ -252,7 +252,18 @@ int add_commit(pmdb_t *db, pmtrans_t *trans)
TRANS_CB(trans, PM_TRANS_EVT_UPGRADE_START, info, NULL);
/* we'll need the full record for backup checks later */
- if((oldpkg = db_scan(db, info->name, INFRQ_ALL)) != NULL) {
+ /* ORE
+ in fact, there's only a need for "backup" and "md5sum" fields, so
+ we should only copy these 2 ones from info, and thus save a call
+ to db_scan(ALL) and the allocation of a package */
+ oldpkg = db_scan(db, info->name, INFRQ_ALL);
+
+ /* pre_upgrade scriptlet */
+ if(info->scriptlet) {
+ runscriptlet(info->data, "pre_upgrade", info->version, oldpkg ? oldpkg->version : NULL);
+ }
+
+ if(oldpkg) {
pmtrans_t *tr;
_alpm_log(PM_LOG_FLOW2, "removing old package first...\n");
@@ -285,6 +296,11 @@ int add_commit(pmdb_t *db, pmtrans_t *trans)
}
if(!pmo_upgrade) {
TRANS_CB(trans, PM_TRANS_EVT_ADD_START, info, NULL);
+
+ /* pre_install scriptlet */
+ if(info->scriptlet) {
+ runscriptlet(info->data, "pre_install", info->version, NULL);
+ }
}
/* Add the package to the database */
@@ -296,6 +312,9 @@ int add_commit(pmdb_t *db, pmtrans_t *trans)
pmpkg_t *tmpp = NULL;
PMList *tmppm = NULL;
+ /* ORE
+ is it useful to call db_scan(DEPENDS)?
+ depends info are already stored in the cache... */
tmpp = db_scan(db, ((pmpkg_t *)lp->data)->name, INFRQ_DEPENDS);
if(tmpp == NULL) {
continue;
@@ -317,7 +336,9 @@ int add_commit(pmdb_t *db, pmtrans_t *trans)
info->reason = PM_PKG_REASON_EXPLICIT;
/* ORE
only relevant for sync operations?
- if(pm_list_is_strin(dependonly, info->data)) {
+ 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) */
@@ -328,15 +349,25 @@ int add_commit(pmdb_t *db, pmtrans_t *trans)
RET_ERR(PM_ERR_DB_WRITE, -1);
}
+ /* ORE
+ in case of an installation, then add info in the pkgcache
+ in case of an upgrade, then replace the existing one (or just add because
+ trans_remove should already has removed it? */
+
/* update dependency packages' REQUIREDBY fields */
for(lp = info->depends; lp; lp = lp->next) {
pmpkg_t *depinfo = NULL;
pmdepend_t depend;
splitdep(lp->data, &depend);
+ /* ORE
+ same thing here: we should browse the cache instead of using db_scan */
depinfo = db_scan(db, depend.name, INFRQ_DESC|INFRQ_DEPENDS);
if(depinfo == NULL) {
/* look for a provides package */
+ /* ORE
+ _alpm_db_whatprovides() should return a list of pointer to pkg from the
+ cache, thus eliminating the need for db_scan(DEPENDS) */
PMList *provides = _alpm_db_whatprovides(db, depend.name);
if(provides) {
/* use the first one */
@@ -354,6 +385,9 @@ int add_commit(pmdb_t *db, pmtrans_t *trans)
continue;
}
}
+ /* ORE
+ if depinfo points on a package from the cache, the cache will be updated
+ automatically here! */
depinfo->requiredby = pm_list_add(depinfo->requiredby, strdup(info->name));
db_write(db, depinfo, INFRQ_DEPENDS);
FREEPKG(depinfo);
@@ -558,13 +592,13 @@ int add_commit(pmdb_t *db, pmtrans_t *trans)
}
/* run the post-install script if it exists */
- /* ORE
- test info->scriplet before blindly calling runscriplet? */
+ if(info->scriplet) {
snprintf(pm_install, PATH_MAX, "%s%s/%s/%s-%s/install", handle->root, handle->dbpath, db->treename, info->name, info->version);
- if(pmo_upgrade) {
- _alpm_runscriptlet(handle->root, pm_install, "post_upgrade", info->version, oldpkg ? oldpkg->version : NULL);
- } else {
- _alpm_runscriptlet(handle->root, pm_install, "post_install", info->version, NULL);
+ if(pmo_upgrade) {
+ _alpm_runscriptlet(handle->root, pm_install, "post_upgrade", info->version, oldpkg ? oldpkg->version : NULL);
+ } else {
+ _alpm_runscriptlet(handle->root, pm_install, "post_install", info->version, NULL);
+ }
}
if(pmo_upgrade) {
@@ -583,6 +617,9 @@ int add_commit(pmdb_t *db, pmtrans_t *trans)
_alpm_log(PM_LOG_FLOW2, "running \"%ssbin/ldconfig -r %s\"", handle->root, handle->root);
_alpm_ldconfig(handle->root);
+ /* cache needs to be rebuilt */
+ db_free_pkgcache(db);
+
return(0);
}
diff --git a/lib/libalpm/alpm.c b/lib/libalpm/alpm.c
index d4854a3d..41b604ad 100644
--- a/lib/libalpm/alpm.c
+++ b/lib/libalpm/alpm.c
@@ -241,6 +241,9 @@ int alpm_db_update(PM_DB *db, char *archive, char *ts)
/* ORE
stat() the archive to check it exists */
+ /* Cache needs to be rebuild */
+ db_free_pkgcache(db);
+
/* remove the old dir */
_alpm_log(PM_LOG_FLOW2, "removing %s (if it exists)\n", db->path);
/* ORE
diff --git a/lib/libalpm/deps.c b/lib/libalpm/deps.c
index 0e210b4e..66b72e58 100644
--- a/lib/libalpm/deps.c
+++ b/lib/libalpm/deps.c
@@ -462,10 +462,14 @@ void splitdep(char *depstr, pmdepend_t *depend)
char *str = NULL;
char *ptr = NULL;
- if(depstr == NULL) {
+ if(depstr == NULL || depend == NULL) {
return;
}
+ depend->mod = 0;
+ depend->name[0] = 0;
+ depend->version[0] = 0;
+
str = strdup(depstr);
if((ptr = strstr(str, ">="))) {
diff --git a/lib/libalpm/sync.c b/lib/libalpm/sync.c
index 8a049c74..1d4108dd 100644
--- a/lib/libalpm/sync.c
+++ b/lib/libalpm/sync.c
@@ -242,6 +242,9 @@ int sync_commit(pmdb_t *db, pmtrans_t *trans)
}*/
}
+ /* cache needs to be rebuilt */
+ db_free_pkgcache(db);
+
return(0);
}
diff --git a/lib/libalpm/util.c b/lib/libalpm/util.c
index bebc996a..12b81be3 100644
--- a/lib/libalpm/util.c
+++ b/lib/libalpm/util.c
@@ -391,7 +391,7 @@ int _alpm_runscriptlet(char *root, char *installfn, char *script, char *ver, cha
}
/* ORE
- pm_cblog(PM_LOG_FLOW2, "Executing %s script...\n", script);*/
+ _alpm_log(PM_LOG_FLOW2, "Executing %s script...\n", script);*/
if(oldver) {
snprintf(cmdline, PATH_MAX, "echo \"umask 0022; source %s %s %s %s\" | chroot %s /bin/sh",
scriptpath, script, ver, oldver, root);
@@ -400,7 +400,7 @@ int _alpm_runscriptlet(char *root, char *installfn, char *script, char *ver, cha
scriptpath, script, ver, root);
}
/* ORE
- pm_cblog(PM_LOG_FLOW2, "%s\n", cmdline);*/
+ _alpm_log(PM_LOG_FLOW2, "%s\n", cmdline);*/
system(cmdline);
if(strlen(tmpdir) && _alpm_rmrf(tmpdir)) {