reordered operations in add_commit (as in pacman 2.9.x)
This commit is contained in:
parent
8b48763b5d
commit
3a9a203c46
1 changed files with 212 additions and 203 deletions
|
@ -320,6 +320,12 @@ int add_commit(pmtrans_t *trans, pmdb_t *db)
|
|||
if(oldpkg) {
|
||||
STRNCPY(oldpkg->name, local->name, PKG_NAME_LEN);
|
||||
STRNCPY(oldpkg->version, local->version, PKG_VERSION_LEN);
|
||||
if(!(local->infolevel & INFRQ_FILES)) {
|
||||
char name[(PKG_NAME_LEN-1)+1+(PKG_VERSION_LEN-1)+1];
|
||||
snprintf(name, (PKG_NAME_LEN-1)+1+(PKG_VERSION_LEN-1)+1, "%s-%s", local->name, local->version);
|
||||
_alpm_log(PM_LOG_DEBUG, "loading FILES info for %s", local->name);
|
||||
db_read(db, name, INFRQ_FILES, local);
|
||||
}
|
||||
oldpkg->backup = _alpm_list_strdup(local->backup);
|
||||
}
|
||||
|
||||
|
@ -330,7 +336,6 @@ int add_commit(pmtrans_t *trans, pmdb_t *db)
|
|||
|
||||
if(oldpkg) {
|
||||
pmtrans_t *tr;
|
||||
|
||||
_alpm_log(PM_LOG_FLOW1, "removing old package first (%s-%s)", oldpkg->name, oldpkg->version);
|
||||
tr = trans_new();
|
||||
if(tr == NULL) {
|
||||
|
@ -371,83 +376,14 @@ int add_commit(pmtrans_t *trans, pmdb_t *db)
|
|||
_alpm_log(PM_LOG_FLOW1, "adding new package (%s-%s)", info->name, info->version);
|
||||
}
|
||||
|
||||
/* Add the package to the database */
|
||||
t = time(NULL);
|
||||
|
||||
/* Update the requiredby field by scaning the whole database
|
||||
* looking for packages depending on the package to add */
|
||||
for(lp = db_get_pkgcache(db); lp; lp = lp->next) {
|
||||
pmpkg_t *tmpp = lp->data;
|
||||
PMList *tmppm = NULL;
|
||||
if(tmpp == NULL) {
|
||||
continue;
|
||||
}
|
||||
for(tmppm = tmpp->depends; tmppm; tmppm = tmppm->next) {
|
||||
pmdepend_t depend;
|
||||
if(splitdep(tmppm->data, &depend)) {
|
||||
continue;
|
||||
}
|
||||
if(tmppm->data && !strcmp(depend.name, info->name)) {
|
||||
info->requiredby = pm_list_add(info->requiredby, strdup(tmpp->name));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* make an install date (in UTC) */
|
||||
STRNCPY(info->installdate, asctime(gmtime(&t)), sizeof(info->installdate));
|
||||
/* remove the extra line feed appended by asctime() */
|
||||
info->installdate[strlen(info->installdate)-1] = 0;
|
||||
|
||||
_alpm_log(PM_LOG_FLOW1, "updating database");
|
||||
_alpm_log(PM_LOG_FLOW2, "adding database entry %s", info->name);
|
||||
if(db_write(db, info, INFRQ_ALL)) {
|
||||
_alpm_log(PM_LOG_ERROR, "could not update database entry %s/%s-%s", db->treename, info->name, info->version);
|
||||
alpm_logaction(NULL, "error updating database for %s-%s!", info->name, info->version);
|
||||
RET_ERR(PM_ERR_DB_WRITE, -1);
|
||||
}
|
||||
if(db_add_pkgincache(db, info) == -1) {
|
||||
_alpm_log(PM_LOG_ERROR, "could not add entry %s in cache", info->name);
|
||||
}
|
||||
|
||||
/* update dependency packages' REQUIREDBY fields */
|
||||
_alpm_log(PM_LOG_FLOW2, "updating dependency packages 'requiredby' fields");
|
||||
for(lp = info->depends; lp; lp = lp->next) {
|
||||
pmpkg_t *depinfo;
|
||||
pmdepend_t depend;
|
||||
if(splitdep(lp->data, &depend)) {
|
||||
continue;
|
||||
}
|
||||
depinfo = db_get_pkgfromcache(db, depend.name);
|
||||
if(depinfo == NULL) {
|
||||
/* look for a provides package */
|
||||
PMList *provides = _alpm_db_whatprovides(db, depend.name);
|
||||
if(provides) {
|
||||
/* TODO: should check _all_ packages listed in provides, not just
|
||||
* the first one.
|
||||
*/
|
||||
/* use the first one */
|
||||
depinfo = db_get_pkgfromcache(db, ((pmpkg_t *)provides->data)->name);
|
||||
FREELISTPTR(provides);
|
||||
if(depinfo == NULL) {
|
||||
/* wtf */
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
depinfo->requiredby = pm_list_add(depinfo->requiredby, strdup(info->name));
|
||||
_alpm_log(PM_LOG_DEBUG, "updating 'requiredby' field for package %s", depinfo->name);
|
||||
if(db_write(db, depinfo, INFRQ_DEPENDS)) {
|
||||
_alpm_log(PM_LOG_ERROR, "could not update 'requiredby' database entry %s/%s-%s", db->treename, depinfo->name, depinfo->version);
|
||||
}
|
||||
}
|
||||
if(!(trans->flags & PM_TRANS_FLAG_DBONLY)) {
|
||||
_alpm_log(PM_LOG_FLOW1, "extracting files");
|
||||
|
||||
/* Extract the .tar.gz package */
|
||||
if(tar_open(&tar, info->data, &gztype, O_RDONLY, 0, TAR_GNU) == -1) {
|
||||
RET_ERR(PM_ERR_PKG_OPEN, -1);
|
||||
}
|
||||
_alpm_log(PM_LOG_FLOW1, "extracting files");
|
||||
|
||||
for(i = 0; !th_read(tar); i++) {
|
||||
int nb = 0;
|
||||
int notouch = 0;
|
||||
|
@ -644,6 +580,79 @@ int add_commit(pmtrans_t *trans, pmdb_t *db)
|
|||
alpm_logaction("errors occurred while %s %s",
|
||||
(pmo_upgrade ? "upgrading" : "installing"), info->name);
|
||||
}
|
||||
}
|
||||
|
||||
/* Add the package to the database */
|
||||
t = time(NULL);
|
||||
|
||||
/* Update the requiredby field by scaning the whole database
|
||||
* looking for packages depending on the package to add */
|
||||
for(lp = db_get_pkgcache(db); lp; lp = lp->next) {
|
||||
pmpkg_t *tmpp = lp->data;
|
||||
PMList *tmppm = NULL;
|
||||
if(tmpp == NULL) {
|
||||
continue;
|
||||
}
|
||||
for(tmppm = tmpp->depends; tmppm; tmppm = tmppm->next) {
|
||||
pmdepend_t depend;
|
||||
if(splitdep(tmppm->data, &depend)) {
|
||||
continue;
|
||||
}
|
||||
if(tmppm->data && !strcmp(depend.name, info->name)) {
|
||||
info->requiredby = pm_list_add(info->requiredby, strdup(tmpp->name));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* make an install date (in UTC) */
|
||||
STRNCPY(info->installdate, asctime(gmtime(&t)), sizeof(info->installdate));
|
||||
/* remove the extra line feed appended by asctime() */
|
||||
info->installdate[strlen(info->installdate)-1] = 0;
|
||||
|
||||
_alpm_log(PM_LOG_FLOW1, "updating database");
|
||||
_alpm_log(PM_LOG_FLOW2, "adding database entry %s", info->name);
|
||||
if(db_write(db, info, INFRQ_ALL)) {
|
||||
_alpm_log(PM_LOG_ERROR, "could not update database entry %s/%s-%s", db->treename, info->name, info->version);
|
||||
alpm_logaction(NULL, "error updating database for %s-%s!", info->name, info->version);
|
||||
RET_ERR(PM_ERR_DB_WRITE, -1);
|
||||
}
|
||||
if(db_add_pkgincache(db, info) == -1) {
|
||||
_alpm_log(PM_LOG_ERROR, "could not add entry %s in cache", info->name);
|
||||
}
|
||||
|
||||
/* update dependency packages' REQUIREDBY fields */
|
||||
_alpm_log(PM_LOG_FLOW2, "updating dependency packages 'requiredby' fields");
|
||||
for(lp = info->depends; lp; lp = lp->next) {
|
||||
pmpkg_t *depinfo;
|
||||
pmdepend_t depend;
|
||||
if(splitdep(lp->data, &depend)) {
|
||||
continue;
|
||||
}
|
||||
depinfo = db_get_pkgfromcache(db, depend.name);
|
||||
if(depinfo == NULL) {
|
||||
/* look for a provides package */
|
||||
PMList *provides = _alpm_db_whatprovides(db, depend.name);
|
||||
if(provides) {
|
||||
/* TODO: should check _all_ packages listed in provides, not just
|
||||
* the first one.
|
||||
*/
|
||||
/* use the first one */
|
||||
depinfo = db_get_pkgfromcache(db, ((pmpkg_t *)provides->data)->name);
|
||||
FREELISTPTR(provides);
|
||||
if(depinfo == NULL) {
|
||||
/* wtf */
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
depinfo->requiredby = pm_list_add(depinfo->requiredby, strdup(info->name));
|
||||
_alpm_log(PM_LOG_DEBUG, "updating 'requiredby' field for package %s", depinfo->name);
|
||||
if(db_write(db, depinfo, INFRQ_DEPENDS)) {
|
||||
_alpm_log(PM_LOG_ERROR, "could not update 'requiredby' database entry %s/%s-%s", db->treename, depinfo->name, depinfo->version);
|
||||
}
|
||||
}
|
||||
|
||||
/* run the post-install script if it exists */
|
||||
if(info->scriptlet) {
|
||||
|
|
Loading…
Add table
Reference in a new issue