From be39f49a5461d5804e4391266dfea6dd076691f4 Mon Sep 17 00:00:00 2001 From: Aurelien Foret Date: Fri, 17 Feb 2006 22:35:26 +0000 Subject: prepend library function names with _alpm (helped with the patch from VMiklos ) added log and event callbacks to sync_commit internal transactions --- lib/libalpm/add.c | 76 +++++++++++++++++++++++++++---------------------------- 1 file changed, 38 insertions(+), 38 deletions(-) (limited to 'lib/libalpm/add.c') diff --git a/lib/libalpm/add.c b/lib/libalpm/add.c index 800cc0df..5d29abdd 100644 --- a/lib/libalpm/add.c +++ b/lib/libalpm/add.c @@ -57,7 +57,7 @@ static int add_faketarget(pmtrans_t *trans, char *name) char *str = NULL; pmpkg_t *dummy = NULL; - if((dummy = pkg_new(NULL, NULL)) == NULL) { + if((dummy = _alpm_pkg_new(NULL, NULL)) == NULL) { RET_ERR(PM_ERR_MEMORY, -1); } @@ -80,7 +80,7 @@ static int add_faketarget(pmtrans_t *trans, char *name) } else if(strncmp("version", p, q-p) == 0) { STRNCPY(dummy->version, q+1, PKG_VERSION_LEN); } else if(strncmp("depend", p, q-p) == 0) { - dummy->depends = pm_list_add(dummy->depends, strdup(q+1)); + dummy->depends = _alpm_list_add(dummy->depends, strdup(q+1)); } else { _alpm_log(PM_LOG_ERROR, "could not parse token %s", p); } @@ -92,12 +92,12 @@ static int add_faketarget(pmtrans_t *trans, char *name) } /* add the package to the transaction */ - trans->packages = pm_list_add(trans->packages, dummy); + trans->packages = _alpm_list_add(trans->packages, dummy); return(0); } -int add_loadtarget(pmtrans_t *trans, pmdb_t *db, char *name) +int _alpm_add_loadtarget(pmtrans_t *trans, pmdb_t *db, char *name) { pmpkg_t *info = NULL; pmpkg_t *dummy; @@ -121,7 +121,7 @@ int add_loadtarget(pmtrans_t *trans, pmdb_t *db, char *name) goto error; } - if(pkg_splitname(name, pkgname, pkgver) == -1) { + if(_alpm_pkg_splitname(name, pkgname, pkgver) == -1) { pm_errno = PM_ERR_PKG_INVALID_NAME; goto error; } @@ -134,15 +134,15 @@ int add_loadtarget(pmtrans_t *trans, pmdb_t *db, char *name) if(trans->type != PM_TRANS_TYPE_UPGRADE) { /* only install this package if it is not already installed */ - if(db_get_pkgfromcache(db, pkgname)) { + if(_alpm_db_get_pkgfromcache(db, pkgname)) { pm_errno = PM_ERR_PKG_INSTALLED; goto error; } } else { if(trans->flags & PM_TRANS_FLAG_FRESHEN) { /* only upgrade/install this package if it is already installed and at a lesser version */ - dummy = db_get_pkgfromcache(db, pkgname); - if(dummy == NULL || versioncmp(dummy->version, pkgver) >= 0) { + dummy = _alpm_db_get_pkgfromcache(db, pkgname); + if(dummy == NULL || _alpm_versioncmp(dummy->version, pkgver) >= 0) { pm_errno = PM_ERR_PKG_CANT_FRESH; goto error; } @@ -154,11 +154,11 @@ int add_loadtarget(pmtrans_t *trans, pmdb_t *db, char *name) for(i = trans->packages; i; i = i->next) { pmpkg_t *pkg = i->data; if(strcmp(pkg->name, pkgname) == 0) { - if(versioncmp(pkg->version, pkgver) < 0) { + if(_alpm_versioncmp(pkg->version, pkgver) < 0) { pmpkg_t *newpkg; _alpm_log(PM_LOG_WARNING, "replacing older version %s-%s by %s in target list", pkg->name, pkg->version, pkgver); - if((newpkg = pkg_load(name)) == NULL) { + if((newpkg = _alpm_pkg_load(name)) == NULL) { /* pm_errno is already set by pkg_load() */ goto error; } @@ -173,7 +173,7 @@ int add_loadtarget(pmtrans_t *trans, pmdb_t *db, char *name) } _alpm_log(PM_LOG_FLOW2, "reading '%s' metadata", pkgname); - info = pkg_load(name); + info = _alpm_pkg_load(name); if(info == NULL) { /* pm_errno is already set by pkg_load() */ goto error; @@ -189,7 +189,7 @@ int add_loadtarget(pmtrans_t *trans, pmdb_t *db, char *name) } /* add the package to the transaction */ - trans->packages = pm_list_add(trans->packages, info); + trans->packages = _alpm_list_add(trans->packages, info); return(0); @@ -198,7 +198,7 @@ error: return(-1); } -int add_prepare(pmtrans_t *trans, pmdb_t *db, PMList **data) +int _alpm_add_prepare(pmtrans_t *trans, pmdb_t *db, PMList **data) { PMList *lp; @@ -212,7 +212,7 @@ int add_prepare(pmtrans_t *trans, pmdb_t *db, PMList **data) /* look for unsatisfied dependencies */ _alpm_log(PM_LOG_FLOW1, "looking for unsatisfied dependencies"); - lp = checkdeps(db, trans->type, trans->packages); + lp = _alpm_checkdeps(db, trans->type, trans->packages); if(lp != NULL) { if(data) { *data = lp; @@ -224,7 +224,7 @@ int add_prepare(pmtrans_t *trans, pmdb_t *db, PMList **data) /* no unsatisfied deps, so look for conflicts */ _alpm_log(PM_LOG_FLOW1, "looking for conflicts"); - lp = checkconflicts(db, trans->packages); + lp = _alpm_checkconflicts(db, trans->packages); if(lp != NULL) { if(data) { *data = lp; @@ -236,7 +236,7 @@ int add_prepare(pmtrans_t *trans, pmdb_t *db, PMList **data) /* re-order w.r.t. dependencies */ _alpm_log(PM_LOG_FLOW1, "sorting by dependencies"); - lp = sortbydeps(trans->packages, PM_TRANS_TYPE_ADD); + lp = _alpm_sortbydeps(trans->packages, PM_TRANS_TYPE_ADD); /* free the old alltargs */ FREELISTPTR(trans->packages); trans->packages = lp; @@ -252,7 +252,7 @@ int add_prepare(pmtrans_t *trans, pmdb_t *db, PMList **data) EVENT(trans, PM_TRANS_EVT_FILECONFLICTS_START, NULL, NULL); _alpm_log(PM_LOG_FLOW1, "looking for file conflicts"); - lp = db_find_conflicts(db, trans->packages, handle->root, &skiplist); + lp = _alpm_db_find_conflicts(db, trans->packages, handle->root, &skiplist); if(lp != NULL) { if(data) { *data = lp; @@ -272,7 +272,7 @@ int add_prepare(pmtrans_t *trans, pmdb_t *db, PMList **data) return(0); } -int add_commit(pmtrans_t *trans, pmdb_t *db) +int _alpm_add_commit(pmtrans_t *trans, pmdb_t *db) { int i, ret = 0, errors = 0; TAR *tar = NULL; @@ -304,19 +304,19 @@ int add_commit(pmtrans_t *trans, pmdb_t *db) /* see if this is an upgrade. if so, remove the old package first */ if(pmo_upgrade) { - pmpkg_t *local = db_get_pkgfromcache(db, info->name); + pmpkg_t *local = _alpm_db_get_pkgfromcache(db, info->name); if(local) { EVENT(trans, PM_TRANS_EVT_UPGRADE_START, info, NULL); _alpm_log(PM_LOG_FLOW1, "upgrading package %s-%s", info->name, info->version); /* we'll need to save some record for backup checks later */ - oldpkg = pkg_new(local->name, local->version); + oldpkg = _alpm_pkg_new(local->name, local->version); if(oldpkg) { if(!(local->infolevel & INFRQ_FILES)) { char name[PKG_FULLNAME_LEN]; snprintf(name, PKG_FULLNAME_LEN, "%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); + _alpm_db_read(db, name, INFRQ_FILES, local); } oldpkg->backup = _alpm_list_strdup(local->backup); } @@ -329,23 +329,23 @@ 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(); + tr = _alpm_trans_new(); if(tr == NULL) { RET_ERR(PM_ERR_TRANS_ABORT, -1); } - if(trans_init(tr, PM_TRANS_TYPE_UPGRADE, trans->flags, NULL, NULL) == -1) { + if(_alpm_trans_init(tr, PM_TRANS_TYPE_UPGRADE, trans->flags, NULL, NULL) == -1) { FREETRANS(tr); RET_ERR(PM_ERR_TRANS_ABORT, -1); } /* copy over the install reason */ info->reason = local->reason; - if(remove_loadtarget(tr, db, info->name) == -1) { + if(_alpm_remove_loadtarget(tr, db, info->name) == -1) { FREETRANS(tr); RET_ERR(PM_ERR_TRANS_ABORT, -1); } /* copy the skiplist over */ tr->skiplist = _alpm_list_strdup(trans->skiplist); - if(remove_commit(tr, db) == -1) { + if(_alpm_remove_commit(tr, db) == -1) { FREETRANS(tr); RET_ERR(PM_ERR_TRANS_ABORT, -1); } @@ -404,7 +404,7 @@ int add_commit(pmtrans_t *trans, pmdb_t *db) * eg, /home/httpd/html/index.html may be removed so index.php * could be used. */ - if(pm_list_is_strin(pathname, handle->noextract)) { + if(_alpm_list_is_strin(pathname, handle->noextract)) { alpm_logaction("notice: %s is in NoExtract -- skipping extraction", pathname); tar_skip_regfile(tar); continue; @@ -412,11 +412,11 @@ int add_commit(pmtrans_t *trans, pmdb_t *db) if(!stat(expath, &buf) && !S_ISDIR(buf.st_mode)) { /* file already exists */ - if(pm_list_is_strin(pathname, handle->noupgrade)) { + if(_alpm_list_is_strin(pathname, handle->noupgrade)) { notouch = 1; } else { if(!pmo_upgrade || oldpkg == NULL) { - nb = pm_list_is_strin(pathname, info->backup); + nb = _alpm_list_is_strin(pathname, info->backup); } else { /* op == PM_TRANS_TYPE_UPGRADE */ md5_orig = _alpm_needbackup(pathname, oldpkg->backup); @@ -593,7 +593,7 @@ int add_commit(pmtrans_t *trans, pmdb_t *db) /* Update the requiredby field by scanning the whole database * looking for packages depending on the package to add */ - for(lp = db_get_pkgcache(db); lp; lp = lp->next) { + for(lp = _alpm_db_get_pkgcache(db); lp; lp = lp->next) { pmpkg_t *tmpp = lp->data; PMList *tmppm = NULL; if(tmpp == NULL) { @@ -601,12 +601,12 @@ int add_commit(pmtrans_t *trans, pmdb_t *db) } for(tmppm = tmpp->depends; tmppm; tmppm = tmppm->next) { pmdepend_t depend; - if(splitdep(tmppm->data, &depend)) { + if(_alpm_splitdep(tmppm->data, &depend)) { continue; } if(tmppm->data && !strcmp(depend.name, info->name)) { _alpm_log(PM_LOG_DEBUG, "adding '%s' in requiredby field for '%s'", tmpp->name, info->name); - info->requiredby = pm_list_add(info->requiredby, strdup(tmpp->name)); + info->requiredby = _alpm_list_add(info->requiredby, strdup(tmpp->name)); } } } @@ -618,13 +618,13 @@ int add_commit(pmtrans_t *trans, pmdb_t *db) _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)) { + if(_alpm_db_write(db, info, INFRQ_ALL)) { _alpm_log(PM_LOG_ERROR, "could not update database entry %s-%s", 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) { + if(_alpm_db_add_pkgincache(db, info) == -1) { _alpm_log(PM_LOG_ERROR, "could not add entry '%s' in cache", info->name); } @@ -635,10 +635,10 @@ int add_commit(pmtrans_t *trans, pmdb_t *db) for(lp = info->depends; lp; lp = lp->next) { pmpkg_t *depinfo; pmdepend_t depend; - if(splitdep(lp->data, &depend)) { + if(_alpm_splitdep(lp->data, &depend)) { continue; } - depinfo = db_get_pkgfromcache(db, depend.name); + depinfo = _alpm_db_get_pkgfromcache(db, depend.name); if(depinfo == NULL) { /* look for a provides package */ PMList *provides = _alpm_db_whatprovides(db, depend.name); @@ -647,7 +647,7 @@ int add_commit(pmtrans_t *trans, pmdb_t *db) * the first one. */ /* use the first one */ - depinfo = db_get_pkgfromcache(db, ((pmpkg_t *)provides->data)->name); + depinfo = _alpm_db_get_pkgfromcache(db, ((pmpkg_t *)provides->data)->name); FREELISTPTR(provides); } if(depinfo == NULL) { @@ -657,8 +657,8 @@ int add_commit(pmtrans_t *trans, pmdb_t *db) } } _alpm_log(PM_LOG_DEBUG, "adding '%s' in requiredby field for '%s'", info->name, depinfo->name); - depinfo->requiredby = pm_list_add(depinfo->requiredby, strdup(info->name)); - if(db_write(db, depinfo, INFRQ_DEPENDS)) { + depinfo->requiredby = _alpm_list_add(depinfo->requiredby, strdup(info->name)); + if(_alpm_db_write(db, depinfo, INFRQ_DEPENDS)) { _alpm_log(PM_LOG_ERROR, "could not update 'requiredby' database entry %s-%s", depinfo->name, depinfo->version); } -- cgit v1.2.3-54-g00ecf