updated comments
This commit is contained in:
parent
2e28303ee5
commit
bcfc1244b4
5 changed files with 58 additions and 11 deletions
|
@ -252,7 +252,18 @@ int add_commit(pmdb_t *db, pmtrans_t *trans)
|
||||||
TRANS_CB(trans, PM_TRANS_EVT_UPGRADE_START, info, NULL);
|
TRANS_CB(trans, PM_TRANS_EVT_UPGRADE_START, info, NULL);
|
||||||
|
|
||||||
/* we'll need the full record for backup checks later */
|
/* 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;
|
pmtrans_t *tr;
|
||||||
|
|
||||||
_alpm_log(PM_LOG_FLOW2, "removing old package first...\n");
|
_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) {
|
if(!pmo_upgrade) {
|
||||||
TRANS_CB(trans, PM_TRANS_EVT_ADD_START, info, NULL);
|
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 */
|
/* Add the package to the database */
|
||||||
|
@ -296,6 +312,9 @@ int add_commit(pmdb_t *db, pmtrans_t *trans)
|
||||||
pmpkg_t *tmpp = NULL;
|
pmpkg_t *tmpp = NULL;
|
||||||
PMList *tmppm = 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);
|
tmpp = db_scan(db, ((pmpkg_t *)lp->data)->name, INFRQ_DEPENDS);
|
||||||
if(tmpp == NULL) {
|
if(tmpp == NULL) {
|
||||||
continue;
|
continue;
|
||||||
|
@ -317,7 +336,9 @@ int add_commit(pmdb_t *db, pmtrans_t *trans)
|
||||||
info->reason = PM_PKG_REASON_EXPLICIT;
|
info->reason = PM_PKG_REASON_EXPLICIT;
|
||||||
/* ORE
|
/* ORE
|
||||||
only relevant for sync operations?
|
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;
|
info->reason = PM_PKG_REASON_DEPEND;
|
||||||
}*/
|
}*/
|
||||||
/* make an install date (in UTC) */
|
/* 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);
|
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 */
|
/* update dependency packages' REQUIREDBY fields */
|
||||||
for(lp = info->depends; lp; lp = lp->next) {
|
for(lp = info->depends; lp; lp = lp->next) {
|
||||||
pmpkg_t *depinfo = NULL;
|
pmpkg_t *depinfo = NULL;
|
||||||
pmdepend_t depend;
|
pmdepend_t depend;
|
||||||
|
|
||||||
splitdep(lp->data, &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);
|
depinfo = db_scan(db, depend.name, INFRQ_DESC|INFRQ_DEPENDS);
|
||||||
if(depinfo == NULL) {
|
if(depinfo == NULL) {
|
||||||
/* look for a provides package */
|
/* 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);
|
PMList *provides = _alpm_db_whatprovides(db, depend.name);
|
||||||
if(provides) {
|
if(provides) {
|
||||||
/* use the first one */
|
/* use the first one */
|
||||||
|
@ -354,6 +385,9 @@ int add_commit(pmdb_t *db, pmtrans_t *trans)
|
||||||
continue;
|
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));
|
depinfo->requiredby = pm_list_add(depinfo->requiredby, strdup(info->name));
|
||||||
db_write(db, depinfo, INFRQ_DEPENDS);
|
db_write(db, depinfo, INFRQ_DEPENDS);
|
||||||
FREEPKG(depinfo);
|
FREEPKG(depinfo);
|
||||||
|
@ -558,13 +592,13 @@ int add_commit(pmdb_t *db, pmtrans_t *trans)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* run the post-install script if it exists */
|
/* run the post-install script if it exists */
|
||||||
/* ORE
|
if(info->scriplet) {
|
||||||
test info->scriplet before blindly calling runscriplet? */
|
|
||||||
snprintf(pm_install, PATH_MAX, "%s%s/%s/%s-%s/install", handle->root, handle->dbpath, db->treename, info->name, info->version);
|
snprintf(pm_install, PATH_MAX, "%s%s/%s/%s-%s/install", handle->root, handle->dbpath, db->treename, info->name, info->version);
|
||||||
if(pmo_upgrade) {
|
if(pmo_upgrade) {
|
||||||
_alpm_runscriptlet(handle->root, pm_install, "post_upgrade", info->version, oldpkg ? oldpkg->version : NULL);
|
_alpm_runscriptlet(handle->root, pm_install, "post_upgrade", info->version, oldpkg ? oldpkg->version : NULL);
|
||||||
} else {
|
} else {
|
||||||
_alpm_runscriptlet(handle->root, pm_install, "post_install", info->version, NULL);
|
_alpm_runscriptlet(handle->root, pm_install, "post_install", info->version, NULL);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(pmo_upgrade) {
|
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_log(PM_LOG_FLOW2, "running \"%ssbin/ldconfig -r %s\"", handle->root, handle->root);
|
||||||
_alpm_ldconfig(handle->root);
|
_alpm_ldconfig(handle->root);
|
||||||
|
|
||||||
|
/* cache needs to be rebuilt */
|
||||||
|
db_free_pkgcache(db);
|
||||||
|
|
||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -241,6 +241,9 @@ int alpm_db_update(PM_DB *db, char *archive, char *ts)
|
||||||
/* ORE
|
/* ORE
|
||||||
stat() the archive to check it exists */
|
stat() the archive to check it exists */
|
||||||
|
|
||||||
|
/* Cache needs to be rebuild */
|
||||||
|
db_free_pkgcache(db);
|
||||||
|
|
||||||
/* remove the old dir */
|
/* remove the old dir */
|
||||||
_alpm_log(PM_LOG_FLOW2, "removing %s (if it exists)\n", db->path);
|
_alpm_log(PM_LOG_FLOW2, "removing %s (if it exists)\n", db->path);
|
||||||
/* ORE
|
/* ORE
|
||||||
|
|
|
@ -462,10 +462,14 @@ void splitdep(char *depstr, pmdepend_t *depend)
|
||||||
char *str = NULL;
|
char *str = NULL;
|
||||||
char *ptr = NULL;
|
char *ptr = NULL;
|
||||||
|
|
||||||
if(depstr == NULL) {
|
if(depstr == NULL || depend == NULL) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
depend->mod = 0;
|
||||||
|
depend->name[0] = 0;
|
||||||
|
depend->version[0] = 0;
|
||||||
|
|
||||||
str = strdup(depstr);
|
str = strdup(depstr);
|
||||||
|
|
||||||
if((ptr = strstr(str, ">="))) {
|
if((ptr = strstr(str, ">="))) {
|
||||||
|
|
|
@ -242,6 +242,9 @@ int sync_commit(pmdb_t *db, pmtrans_t *trans)
|
||||||
}*/
|
}*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* cache needs to be rebuilt */
|
||||||
|
db_free_pkgcache(db);
|
||||||
|
|
||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -391,7 +391,7 @@ int _alpm_runscriptlet(char *root, char *installfn, char *script, char *ver, cha
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ORE
|
/* ORE
|
||||||
pm_cblog(PM_LOG_FLOW2, "Executing %s script...\n", script);*/
|
_alpm_log(PM_LOG_FLOW2, "Executing %s script...\n", script);*/
|
||||||
if(oldver) {
|
if(oldver) {
|
||||||
snprintf(cmdline, PATH_MAX, "echo \"umask 0022; source %s %s %s %s\" | chroot %s /bin/sh",
|
snprintf(cmdline, PATH_MAX, "echo \"umask 0022; source %s %s %s %s\" | chroot %s /bin/sh",
|
||||||
scriptpath, script, ver, oldver, root);
|
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);
|
scriptpath, script, ver, root);
|
||||||
}
|
}
|
||||||
/* ORE
|
/* ORE
|
||||||
pm_cblog(PM_LOG_FLOW2, "%s\n", cmdline);*/
|
_alpm_log(PM_LOG_FLOW2, "%s\n", cmdline);*/
|
||||||
system(cmdline);
|
system(cmdline);
|
||||||
|
|
||||||
if(strlen(tmpdir) && _alpm_rmrf(tmpdir)) {
|
if(strlen(tmpdir) && _alpm_rmrf(tmpdir)) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue