1
0
mirror of https://github.com/moparisthebest/pacman synced 2024-12-22 15:58:50 -05:00

Debug logging changes:

* The --debug params were goofy.  New setup allows --debug without params,
  --debug=<level> where level 1=debug output, 2=debug and download output,
  3=debug, download, and function tracing output.  This seems more sane to me.
* Removed PM_LOG_FLOW1 and PM_LOG_FLOW2.  They were just confusing.  When adding
  new functions, it is near impossible to determin if your output should be
  "flow1" or "flow2" without tracking all the way up the call chain.  Rarely
  would one ever say "ok, lets just show "flow2" output.  These have both been
  replaced with PM_LOG_DEBUG
* Removed the need for the root parameter on alpm_initialize. it is now
  defaulted to PM_ROOT just like dbpath and cachedir.  This allows alpm to be
  initialized BEFORE option parsing in the front end, saving us some duplicate
  variables in the frontend.
* Cleaned up front end variables due to early alpm_initialize call.
This commit is contained in:
Aaron Griffin 2007-01-31 06:10:21 +00:00
parent f4340129d5
commit 670319c2fb
19 changed files with 127 additions and 140 deletions

View File

@ -126,7 +126,7 @@ int SYMHIDDEN _alpm_add_loadtarget(pmtrans_t *trans, pmdb_t *db, char *name)
return(add_faketarget(trans, name));
}
_alpm_log(PM_LOG_FLOW2, _("loading target '%s'"), name);
_alpm_log(PM_LOG_DEBUG, _("loading target '%s'"), name);
/* TODO FS#5120 we need a better way to check if a package is a valid package,
* and read the metadata instead of relying on the filename for package name
@ -188,7 +188,7 @@ int SYMHIDDEN _alpm_add_loadtarget(pmtrans_t *trans, pmdb_t *db, char *name)
}
}
_alpm_log(PM_LOG_FLOW2, _("reading '%s' metadata"), pkgname);
_alpm_log(PM_LOG_DEBUG, _("reading '%s' metadata"), pkgname);
info = _alpm_pkg_load(name);
if(info == NULL) {
/* pm_errno is already set by pkg_load() */
@ -241,7 +241,7 @@ int _alpm_add_prepare(pmtrans_t *trans, pmdb_t *db, alpm_list_t **data)
EVENT(trans, PM_TRANS_EVT_CHECKDEPS_START, NULL, NULL);
/* look for unsatisfied dependencies */
_alpm_log(PM_LOG_FLOW1, _("looking for unsatisfied dependencies"));
_alpm_log(PM_LOG_DEBUG, _("looking for unsatisfied dependencies"));
lp = _alpm_checkdeps(trans, db, trans->type, trans->packages);
if(lp != NULL) {
if(data) {
@ -253,7 +253,7 @@ int _alpm_add_prepare(pmtrans_t *trans, pmdb_t *db, alpm_list_t **data)
}
/* no unsatisfied deps, so look for conflicts */
_alpm_log(PM_LOG_FLOW1, _("looking for conflicts"));
_alpm_log(PM_LOG_DEBUG, _("looking for conflicts"));
lp = _alpm_checkconflicts(db, trans->packages);
for(i = lp; i; i = i->next) {
int skip_this = 0;
@ -292,7 +292,7 @@ int _alpm_add_prepare(pmtrans_t *trans, pmdb_t *db, alpm_list_t **data)
}
/* re-order w.r.t. dependencies */
_alpm_log(PM_LOG_FLOW1, _("sorting by dependencies"));
_alpm_log(PM_LOG_DEBUG, _("sorting by dependencies"));
lp = _alpm_sortbydeps(trans->packages, PM_TRANS_TYPE_ADD);
/* free the old alltargs */
FREELISTPTR(trans->packages);
@ -304,7 +304,7 @@ int _alpm_add_prepare(pmtrans_t *trans, pmdb_t *db, alpm_list_t **data)
/* Cleaning up
*/
EVENT(trans, PM_TRANS_EVT_CLEANUP_START, NULL, NULL);
_alpm_log(PM_LOG_FLOW1, _("cleaning up"));
_alpm_log(PM_LOG_DEBUG, _("cleaning up"));
for (lp=trans->packages; lp!=NULL; lp=lp->next) {
info=(pmpkg_t *)lp->data;
for (rmlist=info->removes; rmlist!=NULL; rmlist=rmlist->next) {
@ -321,7 +321,7 @@ int _alpm_add_prepare(pmtrans_t *trans, pmdb_t *db, alpm_list_t **data)
EVENT(trans, PM_TRANS_EVT_FILECONFLICTS_START, NULL, NULL);
_alpm_log(PM_LOG_FLOW1, _("looking for file conflicts"));
_alpm_log(PM_LOG_DEBUG, _("looking for file conflicts"));
lp = _alpm_db_find_conflicts(db, trans, handle->root, &skiplist);
if(lp != NULL) {
if(data) {
@ -388,7 +388,7 @@ int _alpm_add_commit(pmtrans_t *trans, pmdb_t *db)
if(local) {
EVENT(trans, PM_TRANS_EVT_UPGRADE_START, info, NULL);
cb_state = PM_TRANS_PROGRESS_UPGRADE_START;
_alpm_log(PM_LOG_FLOW1, _("upgrading package %s-%s"), info->name, info->version);
_alpm_log(PM_LOG_DEBUG, _("upgrading package %s-%s"), info->name, info->version);
if((what = (char *)malloc(strlen(info->name)+1)) == NULL) {
RET_ERR(PM_ERR_MEMORY, -1);
}
@ -420,7 +420,7 @@ int _alpm_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);
_alpm_log(PM_LOG_DEBUG, _("removing old package first (%s-%s)"), oldpkg->name, oldpkg->version);
tr = _alpm_trans_new();
if(tr == NULL) {
RET_ERR(PM_ERR_TRANS_ABORT, -1);
@ -450,7 +450,7 @@ int _alpm_add_commit(pmtrans_t *trans, pmdb_t *db)
if(!pmo_upgrade) {
EVENT(trans, PM_TRANS_EVT_ADD_START, info, NULL);
cb_state = PM_TRANS_PROGRESS_ADD_START;
_alpm_log(PM_LOG_FLOW1, _("adding package %s-%s"), info->name, info->version);
_alpm_log(PM_LOG_DEBUG, _("adding package %s-%s"), info->name, info->version);
if((what = (char *)malloc(strlen(info->name)+1)) == NULL) {
RET_ERR(PM_ERR_MEMORY, -1);
}
@ -461,11 +461,11 @@ int _alpm_add_commit(pmtrans_t *trans, pmdb_t *db)
_alpm_runscriptlet(handle->root, info->data, "pre_install", info->version, NULL, trans);
}
} else {
_alpm_log(PM_LOG_FLOW1, _("adding new package %s-%s"), info->name, info->version);
_alpm_log(PM_LOG_DEBUG, _("adding new package %s-%s"), info->name, info->version);
}
if(!(trans->flags & PM_TRANS_FLAG_DBONLY)) {
_alpm_log(PM_LOG_FLOW1, _("extracting files"));
_alpm_log(PM_LOG_DEBUG, _("extracting files"));
/* Extract the package */
if ((archive = archive_read_new ()) == NULL)
@ -685,7 +685,7 @@ int _alpm_add_commit(pmtrans_t *trans, pmdb_t *db)
}
if(installnew) {
_alpm_log(PM_LOG_FLOW2, _("extracting %s"), pathname);
_alpm_log(PM_LOG_DEBUG, _("extracting %s"), pathname);
if(_alpm_copyfile(temp, expath)) {
_alpm_log(PM_LOG_ERROR, _("could not copy %s to %s (%s)"), temp, pathname, strerror(errno));
errors++;
@ -705,9 +705,9 @@ int _alpm_add_commit(pmtrans_t *trans, pmdb_t *db)
close(fd);
} else {
if(!notouch) {
_alpm_log(PM_LOG_FLOW2, _("extracting %s"), pathname);
_alpm_log(PM_LOG_DEBUG, _("extracting %s"), pathname);
} else {
_alpm_log(PM_LOG_FLOW2, _("%s is in NoUpgrade -- skipping"), pathname);
_alpm_log(PM_LOG_DEBUG, _("%s is in NoUpgrade -- skipping"), pathname);
strncat(expath, ".pacnew", PATH_MAX);
_alpm_log(PM_LOG_WARNING, _("extracting %s as %s.pacnew"), pathname, pathname);
alpm_logaction(_("warning: extracting %s%s as %s"), handle->root, pathname, expath);
@ -800,8 +800,8 @@ int _alpm_add_commit(pmtrans_t *trans, pmdb_t *db)
/* 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);
_alpm_log(PM_LOG_DEBUG, _("updating database"));
_alpm_log(PM_LOG_DEBUG, _("adding database entry '%s'"), info->name);
if(_alpm_db_write(db, info, INFRQ_ALL)) {
_alpm_log(PM_LOG_ERROR, _("could not update database entry %s-%s"),
info->name, info->version);
@ -815,7 +815,7 @@ int _alpm_add_commit(pmtrans_t *trans, pmdb_t *db)
/* XXX: This is copy-pasta from remove.c - refactor */
/* update dependency packages' REQUIREDBY fields */
if(info->depends) {
_alpm_log(PM_LOG_FLOW2, _("updating dependency packages 'requiredby' fields"));
_alpm_log(PM_LOG_DEBUG, _("updating dependency packages 'requiredby' fields"));
}
for(lp = info->depends; lp; lp = lp->next) {
pmpkg_t *depinfo;
@ -875,7 +875,7 @@ int _alpm_add_commit(pmtrans_t *trans, pmdb_t *db)
/* run ldconfig if it exists */
if(handle->trans->state != STATE_INTERRUPTED) {
_alpm_log(PM_LOG_FLOW1, _("running \"ldconfig -r %s\""), handle->root);
_alpm_log(PM_LOG_DEBUG, _("running \"ldconfig -r %s\""), handle->root);
_alpm_ldconfig(handle->root);
}

View File

@ -72,13 +72,10 @@ enum _pmerrno_t pm_errno SYMEXPORT;
/** Initializes the library. This must be called before any other
* functions are called.
* @param root the full path of the root we'll be installing to (usually /)
* @return 0 on success, -1 on error (pm_errno is set accordingly)
*/
int SYMEXPORT alpm_initialize(const char *root)
int SYMEXPORT alpm_initialize()
{
char str[PATH_MAX];
ASSERT(handle == NULL, RET_ERR(PM_ERR_HANDLE_NOT_NULL, -1));
handle = _alpm_handle_new();
@ -86,13 +83,6 @@ int SYMEXPORT alpm_initialize(const char *root)
RET_ERR(PM_ERR_MEMORY, -1);
}
STRNCPY(str, (root) ? root : PM_ROOT, PATH_MAX);
/* add a trailing '/' if there isn't one */
if(str[strlen(str)-1] != '/') {
strcat(str, "/");
}
handle->root = strdup(str);
return(0);
}
@ -185,7 +175,7 @@ int alpm_db_unregister(pmdb_t *db)
RET_ERR(PM_ERR_DB_NOT_FOUND, -1);
}
_alpm_log(PM_LOG_FLOW1, _("unregistering database '%s'"), db->treename);
_alpm_log(PM_LOG_DEBUG, _("unregistering database '%s'"), db->treename);
/* Cleanup */
_alpm_db_free_pkgcache(db);
@ -236,11 +226,11 @@ int alpm_db_setserver(pmdb_t *db, const char *url)
return(-1);
}
db->servers = alpm_list_add(db->servers, server);
_alpm_log(PM_LOG_FLOW2, _("adding new server to database '%s': protocol '%s', server '%s', path '%s'"),
_alpm_log(PM_LOG_DEBUG, _("adding new server to database '%s': protocol '%s', server '%s', path '%s'"),
db->treename, server->s_url->scheme, server->s_url->host, server->s_url->doc);
} else {
FREELIST(db->servers);
_alpm_log(PM_LOG_FLOW2, _("serverlist flushed for '%s'"), db->treename);
_alpm_log(PM_LOG_DEBUG, _("serverlist flushed for '%s'"), db->treename);
}
return(0);
@ -312,7 +302,7 @@ int SYMEXPORT alpm_db_update(int force, pmdb_t *db)
snprintf(path, PATH_MAX, "%s%s/%s" PM_EXT_DB, handle->root, handle->dbpath, db->treename);
/* remove the old dir */
_alpm_log(PM_LOG_FLOW2, _("flushing database %s/%s"), handle->dbpath, db->treename);
_alpm_log(PM_LOG_DEBUG, _("flushing database %s/%s"), handle->dbpath, db->treename);
for(lp = _alpm_db_get_pkgcache(db, INFRQ_NONE); lp; lp = lp->next) {
if(_alpm_db_remove(db, lp->data) == -1) {
if(lp->data) {
@ -497,7 +487,7 @@ int alpm_pkg_checksha1sum(pmpkg_t *pkg)
}
if(strcmp(sha1sum, pkg->sha1sum) == 0) {
_alpm_log(PM_LOG_FLOW1, _("checksums for package %s-%s are matching"),
_alpm_log(PM_LOG_DEBUG, _("checksums for package %s-%s are matching"),
pkg->name, pkg->version);
} else {
_alpm_log(PM_LOG_ERROR, _("sha1sums do not match for package %s-%s"),
@ -546,7 +536,7 @@ int alpm_pkg_checkmd5sum(pmpkg_t *pkg)
}
if(strcmp(md5sum, pkg->md5sum) == 0) {
_alpm_log(PM_LOG_FLOW1, _("checksums for package %s-%s are matching"),
_alpm_log(PM_LOG_DEBUG, _("checksums for package %s-%s are matching"),
pkg->name, pkg->version);
} else {
_alpm_log(PM_LOG_ERROR, _("md5sums do not match for package %s-%s"),

View File

@ -63,7 +63,7 @@ typedef struct __pmconflict_t pmconflict_t;
* Library
*/
int alpm_initialize(const char *root);
int alpm_initialize();
int alpm_release(void);
/*
@ -72,13 +72,11 @@ int alpm_release(void);
/* Levels */
typedef enum _pmloglevel_t {
PM_LOG_DEBUG = 0x01,
PM_LOG_ERROR = 0x02,
PM_LOG_WARNING = 0x04,
PM_LOG_FLOW1 = 0x08,
PM_LOG_FLOW2 = 0x10,
PM_LOG_FUNCTION = 0x20,
PM_LOG_DOWNLOAD = 0x40
PM_LOG_ERROR = 0x01,
PM_LOG_WARNING = 0x02,
PM_LOG_DEBUG = 0x04,
PM_LOG_DOWNLOAD = 0x08,
PM_LOG_FUNCTION = 0x10
} pmloglevel_t;
typedef void (*alpm_cb_log)(unsigned short, char *);

View File

@ -56,7 +56,7 @@ int _alpm_db_install(pmdb_t *db, const char *dbfile)
/* ORE
we should not simply unpack the archive, but better parse it and
db_write each entry (see sync_load_dbarchive to get archive content) */
_alpm_log(PM_LOG_FLOW2, _("unpacking database '%s'"), dbfile);
_alpm_log(PM_LOG_DEBUG, _("unpacking database '%s'"), dbfile);
if(_alpm_unpack(dbfile, db->path, NULL)) {
RET_ERR(PM_ERR_SYSTEM, -1);

View File

@ -174,12 +174,12 @@ pmdb_t *_alpm_db_register(char *treename, alpm_cb_db_register callback)
}
}
_alpm_log(PM_LOG_FLOW1, _("registering database '%s'"), treename);
_alpm_log(PM_LOG_DEBUG, _("registering database '%s'"), treename);
/* make sure the database directory exists */
snprintf(path, PATH_MAX, "%s%s/%s", handle->root, handle->dbpath, treename);
if(stat(path, &buf) != 0 || !S_ISDIR(buf.st_mode)) {
_alpm_log(PM_LOG_FLOW1, _("database directory '%s' does not exist -- try creating it"), path);
_alpm_log(PM_LOG_DEBUG, _("database directory '%s' does not exist -- try creating it"), path);
if(_alpm_makepath(path) != 0) {
RET_ERR(PM_ERR_SYSTEM, NULL);
}

View File

@ -495,7 +495,7 @@ alpm_list_t *_alpm_removedeps(pmdb_t *db, alpm_list_t *targs)
/* see if it was explicitly installed */
if(dep->reason == PM_PKG_REASON_EXPLICIT) {
_alpm_log(PM_LOG_FLOW2, _("excluding %s -- explicitly installed"), dep->name);
_alpm_log(PM_LOG_DEBUG, _("excluding %s -- explicitly installed"), dep->name);
needed = 1;
}
@ -515,7 +515,7 @@ alpm_list_t *_alpm_removedeps(pmdb_t *db, alpm_list_t *targs)
_alpm_log(PM_LOG_DEBUG, _("loading ALL info for '%s'"), pkg->name);
_alpm_db_read(db, INFRQ_ALL, pkg);
newtargs = alpm_list_add(newtargs, pkg);
_alpm_log(PM_LOG_FLOW2, _("adding '%s' to the targets"), pkg->name);
_alpm_log(PM_LOG_DEBUG, _("adding '%s' to the targets"), pkg->name);
newtargs = _alpm_removedeps(db, newtargs);
}
}

View File

@ -77,8 +77,10 @@ pmhandle_t *_alpm_handle_new()
handle->access = PM_ACCESS_RW;
#endif
handle->root = strdup(PM_ROOT);
handle->dbpath = strdup(PM_DBPATH);
handle->cachedir = strdup(PM_CACHEDIR);
handle->logmask = PM_LOG_ERROR | PM_LOG_WARNING;
return(handle);
}

View File

@ -89,7 +89,7 @@ int _alpm_remove_loadtarget(pmtrans_t *trans, pmdb_t *db, char *name)
}
}
_alpm_log(PM_LOG_FLOW2, _("adding %s in the targets list"), info->name);
_alpm_log(PM_LOG_DEBUG, _("adding %s in the targets list"), info->name);
trans->packages = alpm_list_add(trans->packages, info);
return(0);
@ -107,7 +107,7 @@ int _alpm_remove_prepare(pmtrans_t *trans, pmdb_t *db, alpm_list_t **data)
if(!(trans->flags & (PM_TRANS_FLAG_NODEPS)) && (trans->type != PM_TRANS_TYPE_UPGRADE)) {
EVENT(trans, PM_TRANS_EVT_CHECKDEPS_START, NULL, NULL);
_alpm_log(PM_LOG_FLOW1, _("looking for unsatisfied dependencies"));
_alpm_log(PM_LOG_DEBUG, _("looking for unsatisfied dependencies"));
lp = _alpm_checkdeps(trans, db, trans->type, trans->packages);
if(lp != NULL) {
if(trans->flags & PM_TRANS_FLAG_CASCADE) {
@ -117,7 +117,7 @@ int _alpm_remove_prepare(pmtrans_t *trans, pmdb_t *db, alpm_list_t **data)
pmdepmissing_t *miss = (pmdepmissing_t *)i->data;
pmpkg_t *info = _alpm_db_scan(db, miss->depend.name, INFRQ_ALL);
if(info) {
_alpm_log(PM_LOG_FLOW2, _("pulling %s in the targets list"), info->name);
_alpm_log(PM_LOG_DEBUG, _("pulling %s in the targets list"), info->name);
trans->packages = alpm_list_add(trans->packages, info);
} else {
_alpm_log(PM_LOG_ERROR, _("could not find %s in database -- skipping"),
@ -138,12 +138,12 @@ int _alpm_remove_prepare(pmtrans_t *trans, pmdb_t *db, alpm_list_t **data)
}
if(trans->flags & PM_TRANS_FLAG_RECURSE) {
_alpm_log(PM_LOG_FLOW1, _("finding removable dependencies"));
_alpm_log(PM_LOG_DEBUG, _("finding removable dependencies"));
trans->packages = _alpm_removedeps(db, trans->packages);
}
/* re-order w.r.t. dependencies */
_alpm_log(PM_LOG_FLOW1, _("sorting by dependencies"));
_alpm_log(PM_LOG_DEBUG, _("sorting by dependencies"));
lp = _alpm_sortbydeps(trans->packages, PM_TRANS_TYPE_REMOVE);
/* free the old alltargs */
FREELISTPTR(trans->packages);
@ -212,7 +212,7 @@ static void unlink_file(pmpkg_t *info, alpm_list_t *lp, alpm_list_t *targ,
}
}
if ( skipit ) {
_alpm_log(PM_LOG_FLOW2, _("skipping removal of %s as it has moved to another package"),
_alpm_log(PM_LOG_DEBUG, _("skipping removal of %s as it has moved to another package"),
line);
} else {
/* if the file is flagged, back it up to .pacsave */
@ -228,7 +228,7 @@ static void unlink_file(pmpkg_t *info, alpm_list_t *lp, alpm_list_t *targ,
}
}
} else {
_alpm_log(PM_LOG_FLOW2, _("unlinking %s"), line);
_alpm_log(PM_LOG_DEBUG, _("unlinking %s"), line);
int list_count = alpm_list_count(trans->packages); /* this way we don't have to call alpm_list_count twice during PROGRESS */
PROGRESS(trans, PM_TRANS_PROGRESS_REMOVE_START, info->name, (double)(percent * 100), list_count, (list_count - alpm_list_count(targ) + 1));
++(*position);
@ -262,7 +262,7 @@ int _alpm_remove_commit(pmtrans_t *trans, pmdb_t *db)
if(trans->type != PM_TRANS_TYPE_UPGRADE) {
EVENT(trans, PM_TRANS_EVT_REMOVE_START, info, NULL);
_alpm_log(PM_LOG_FLOW1, _("removing package %s-%s"), info->name, info->version);
_alpm_log(PM_LOG_DEBUG, _("removing package %s-%s"), info->name, info->version);
/* run the pre-remove scriptlet if it exists */
if(info->scriptlet && !(trans->flags & PM_TRANS_FLAG_NOSCRIPTLET)) {
@ -273,7 +273,7 @@ int _alpm_remove_commit(pmtrans_t *trans, pmdb_t *db)
if(!(trans->flags & PM_TRANS_FLAG_DBONLY)) {
int filenum = alpm_list_count(info->files);
_alpm_log(PM_LOG_FLOW1, _("removing files"));
_alpm_log(PM_LOG_DEBUG, _("removing files"));
/* iterate through the list backwards, unlinking files */
for(lp = alpm_list_last(info->files); lp; lp = lp->prev) {
@ -290,8 +290,8 @@ int _alpm_remove_commit(pmtrans_t *trans, pmdb_t *db)
}
/* remove the package from the database */
_alpm_log(PM_LOG_FLOW1, _("updating database"));
_alpm_log(PM_LOG_FLOW2, _("removing database entry '%s'"), info->name);
_alpm_log(PM_LOG_DEBUG, _("updating database"));
_alpm_log(PM_LOG_DEBUG, _("removing database entry '%s'"), info->name);
if(_alpm_db_remove(db, info) == -1) {
_alpm_log(PM_LOG_ERROR, _("could not remove database entry %s-%s"), info->name, info->version);
}
@ -300,7 +300,7 @@ int _alpm_remove_commit(pmtrans_t *trans, pmdb_t *db)
}
/* update dependency packages' REQUIREDBY fields */
_alpm_log(PM_LOG_FLOW2, _("updating dependency packages 'requiredby' fields"));
_alpm_log(PM_LOG_DEBUG, _("updating dependency packages 'requiredby' fields"));
for(lp = info->depends; lp; lp = lp->next) {
pmpkg_t *depinfo = NULL;
pmdepend_t depend;
@ -355,7 +355,7 @@ int _alpm_remove_commit(pmtrans_t *trans, pmdb_t *db)
/* run ldconfig if it exists */
if((trans->type != PM_TRANS_TYPE_UPGRADE) && (handle->trans->state != STATE_INTERRUPTED)) {
_alpm_log(PM_LOG_FLOW1, _("running \"ldconfig -r %s\""), handle->root);
_alpm_log(PM_LOG_DEBUG, _("running \"ldconfig -r %s\""), handle->root);
_alpm_ldconfig(handle->root);
}

View File

@ -138,7 +138,7 @@ static int find_replacements(pmtrans_t *trans, pmdb_t *db_local,
ALPM_LOG_FUNC;
/* check for "recommended" package replacements */
_alpm_log(PM_LOG_FLOW1, _("checking for package replacements"));
_alpm_log(PM_LOG_DEBUG, _("checking for package replacements"));
for(i = dbs_sync; i; i = i->next) {
for(j = _alpm_db_get_pkgcache(i->data, INFRQ_DESC); j; j = j->next) {
pmpkg_t *spkg = j->data;
@ -183,7 +183,7 @@ static int find_replacements(pmtrans_t *trans, pmdb_t *db_local,
sync->data = alpm_list_add(NULL, dummy);
trans->packages = alpm_list_add(trans->packages, sync);
}
_alpm_log(PM_LOG_FLOW2, _("%s-%s elected for upgrade (to be replaced by %s-%s)"),
_alpm_log(PM_LOG_DEBUG, _("%s-%s elected for upgrade (to be replaced by %s-%s)"),
lpkg->name, lpkg->version, spkg->name, spkg->version);
}
}
@ -205,10 +205,10 @@ int _alpm_sync_sysupgrade(pmtrans_t *trans, pmdb_t *db_local, alpm_list_t *dbs_s
ALPM_LOG_FUNC;
/* check for "recommended" package replacements */
_alpm_log(PM_LOG_FLOW1, _("checking for package replacements"));
_alpm_log(PM_LOG_DEBUG, _("checking for package replacements"));
if( find_replacements(trans, db_local, dbs_sync) == 0 ) {
/* match installed packages with the sync dbs and compare versions */
_alpm_log(PM_LOG_FLOW1, _("checking for package upgrades"));
_alpm_log(PM_LOG_DEBUG, _("checking for package upgrades"));
for(i = _alpm_db_get_pkgcache(db_local, INFRQ_NONE); i; i = i->next) {
int cmp;
int replace=0;
@ -254,11 +254,11 @@ int _alpm_sync_sysupgrade(pmtrans_t *trans, pmdb_t *db_local, alpm_list_t *dbs_s
local->name, local->version, spkg->version);
} else if(istoonew(spkg)) {
/* package too new (UpgradeDelay) */
_alpm_log(PM_LOG_FLOW1, _("%s-%s: delaying upgrade of package (%s)"),
_alpm_log(PM_LOG_DEBUG, _("%s-%s: delaying upgrade of package (%s)"),
local->name, local->version, spkg->version);
/* check if spkg->name is already in the packages list. */
} else {
_alpm_log(PM_LOG_FLOW2, _("%s-%s elected for upgrade (%s => %s)"),
_alpm_log(PM_LOG_DEBUG, _("%s-%s elected for upgrade (%s => %s)"),
local->name, local->version, local->version, spkg->version);
if(!find_pkginsync(spkg->name, trans->packages)) {
pmpkg_t *dummy = _alpm_pkg_new(local->name, local->version);
@ -314,7 +314,7 @@ int _alpm_sync_addtarget(pmtrans_t *trans, pmdb_t *db_local, alpm_list_t *dbs_sy
if(spkg == NULL) {
/* Search provides */
alpm_list_t *p;
_alpm_log(PM_LOG_FLOW2, _("target '%s' not found -- looking for provisions"), targ);
_alpm_log(PM_LOG_DEBUG, _("target '%s' not found -- looking for provisions"), targ);
p = _alpm_db_whatprovides(dbs, targ);
if(p == NULL) {
RET_ERR(PM_ERR_PKG_NOT_FOUND, -1);
@ -337,7 +337,7 @@ int _alpm_sync_addtarget(pmtrans_t *trans, pmdb_t *db_local, alpm_list_t *dbs_sy
}
if(spkg == NULL) {
/* Search provides */
_alpm_log(PM_LOG_FLOW2, _("target '%s' not found -- looking for provisions"), targ);
_alpm_log(PM_LOG_DEBUG, _("target '%s' not found -- looking for provisions"), targ);
for(j = dbs_sync; j && !spkg; j = j->next) {
pmdb_t *dbs = j->data;
alpm_list_t *p = _alpm_db_whatprovides(dbs, targ);
@ -389,7 +389,7 @@ int _alpm_sync_addtarget(pmtrans_t *trans, pmdb_t *db_local, alpm_list_t *dbs_sy
FREEPKG(dummy);
RET_ERR(PM_ERR_MEMORY, -1);
}
_alpm_log(PM_LOG_FLOW2, _("adding target '%s' to the transaction set"), spkg->name);
_alpm_log(PM_LOG_DEBUG, _("adding target '%s' to the transaction set"), spkg->name);
trans->packages = alpm_list_add(trans->packages, sync);
}
@ -437,7 +437,7 @@ int _alpm_sync_prepare(pmtrans_t *trans, pmdb_t *db_local, alpm_list_t *dbs_sync
/* Resolve targets dependencies */
EVENT(trans, PM_TRANS_EVT_RESOLVEDEPS_START, NULL, NULL);
_alpm_log(PM_LOG_FLOW1, _("resolving target's dependencies"));
_alpm_log(PM_LOG_DEBUG, _("resolving target's dependencies"));
for(i = trans->packages; i; i = i->next) {
pmpkg_t *spkg = ((pmsyncpkg_t *)i->data)->pkg;
if(_alpm_resolvedeps(db_local, dbs_sync, spkg, list, trail, trans, data) == -1) {
@ -457,7 +457,7 @@ int _alpm_sync_prepare(pmtrans_t *trans, pmdb_t *db_local, alpm_list_t *dbs_sync
goto cleanup;
}
trans->packages = alpm_list_add(trans->packages, sync);
_alpm_log(PM_LOG_FLOW2, _("adding package %s-%s to the transaction targets"),
_alpm_log(PM_LOG_DEBUG, _("adding package %s-%s to the transaction targets"),
spkg->name, spkg->version);
} else {
/* remove the original targets from the list if requested */
@ -492,7 +492,7 @@ int _alpm_sync_prepare(pmtrans_t *trans, pmdb_t *db_local, alpm_list_t *dbs_sync
EVENT(trans, PM_TRANS_EVT_RESOLVEDEPS_DONE, NULL, NULL);
_alpm_log(PM_LOG_FLOW1, _("looking for unresolvable dependencies"));
_alpm_log(PM_LOG_DEBUG, _("looking for unresolvable dependencies"));
deps = _alpm_checkdeps(trans, db_local, PM_TRANS_TYPE_UPGRADE, list);
if(deps) {
if(data) {
@ -512,7 +512,7 @@ int _alpm_sync_prepare(pmtrans_t *trans, pmdb_t *db_local, alpm_list_t *dbs_sync
/* check for inter-conflicts and whatnot */
EVENT(trans, PM_TRANS_EVT_INTERCONFLICTS_START, NULL, NULL);
_alpm_log(PM_LOG_FLOW1, _("looking for conflicts"));
_alpm_log(PM_LOG_DEBUG, _("looking for conflicts"));
deps = _alpm_checkconflicts(db_local, list);
if(deps) {
int errorout = 0;
@ -523,7 +523,7 @@ int _alpm_sync_prepare(pmtrans_t *trans, pmdb_t *db_local, alpm_list_t *dbs_sync
pmsyncpkg_t *sync;
pmpkg_t *local;
_alpm_log(PM_LOG_FLOW2, _("package '%s' is conflicting with '%s'"),
_alpm_log(PM_LOG_DEBUG, _("package '%s' is conflicting with '%s'"),
miss->target, miss->depend.name);
/* check if the conflicting package is one that's about to be removed/replaced.
@ -596,7 +596,7 @@ int _alpm_sync_prepare(pmtrans_t *trans, pmdb_t *db_local, alpm_list_t *dbs_sync
if(rmpkg) {
pmsyncpkg_t *rsync = find_pkginsync(rmpkg, trans->packages);
void *vpkg;
_alpm_log(PM_LOG_FLOW2, _("removing '%s' from target list"), rmpkg);
_alpm_log(PM_LOG_DEBUG, _("removing '%s' from target list"), rmpkg);
trans->packages = alpm_list_remove(trans->packages, rsync, pkg_cmp, &vpkg);
FREESYNC(vpkg);
continue;
@ -628,12 +628,12 @@ int _alpm_sync_prepare(pmtrans_t *trans, pmdb_t *db_local, alpm_list_t *dbs_sync
FREEPKG(sync->data);
}
/* append to the replaces list */
_alpm_log(PM_LOG_FLOW2, _("electing '%s' for removal"), miss->depend.name);
_alpm_log(PM_LOG_DEBUG, _("electing '%s' for removal"), miss->depend.name);
sync->data = alpm_list_add(sync->data, q);
if(rsync) {
/* remove it from the target list */
void *vpkg;
_alpm_log(PM_LOG_FLOW2, _("removing '%s' from target list"), miss->depend.name);
_alpm_log(PM_LOG_DEBUG, _("removing '%s' from target list"), miss->depend.name);
trans->packages = alpm_list_remove(trans->packages, rsync, pkg_cmp, &vpkg);
FREESYNC(vpkg);
}
@ -707,7 +707,7 @@ int _alpm_sync_prepare(pmtrans_t *trans, pmdb_t *db_local, alpm_list_t *dbs_sync
}
}
if(list) {
_alpm_log(PM_LOG_FLOW1, _("checking dependencies of packages designated for removal"));
_alpm_log(PM_LOG_DEBUG, _("checking dependencies of packages designated for removal"));
deps = _alpm_checkdeps(trans, db_local, PM_TRANS_TYPE_REMOVE, list);
if(deps) {
int errorout = 0;
@ -740,7 +740,7 @@ int _alpm_sync_prepare(pmtrans_t *trans, pmdb_t *db_local, alpm_list_t *dbs_sync
for(o = sp->pkg->provides; o && !pfound; o = o->next) {
if(!strcmp(m->data, o->data)) {
/* found matching provisio -- we're good to go */
_alpm_log(PM_LOG_FLOW2, _("found '%s' as a provision for '%s' -- conflict aborted"),
_alpm_log(PM_LOG_DEBUG, _("found '%s' as a provision for '%s' -- conflict aborted"),
sp->pkg->name, (char *)o->data);
pfound = 1;
}
@ -970,7 +970,7 @@ int _alpm_sync_commit(pmtrans_t *trans, pmdb_t *db_local, alpm_list_t **data)
}
}
if(replaces) {
_alpm_log(PM_LOG_FLOW1, _("removing conflicting and to-be-replaced packages"));
_alpm_log(PM_LOG_DEBUG, _("removing conflicting and to-be-replaced packages"));
if(_alpm_trans_prepare(tr, data) == -1) {
_alpm_log(PM_LOG_ERROR, _("could not prepare removal transaction"));
goto error;
@ -985,7 +985,7 @@ int _alpm_sync_commit(pmtrans_t *trans, pmdb_t *db_local, alpm_list_t **data)
FREETRANS(tr);
/* install targets */
_alpm_log(PM_LOG_FLOW1, _("installing packages"));
_alpm_log(PM_LOG_DEBUG, _("installing packages"));
tr = _alpm_trans_new();
if(tr == NULL) {
_alpm_log(PM_LOG_ERROR, _("could not create transaction"));
@ -1028,7 +1028,7 @@ int _alpm_sync_commit(pmtrans_t *trans, pmdb_t *db_local, alpm_list_t **data)
/* propagate replaced packages' requiredby fields to their new owners */
if(replaces) {
_alpm_log(PM_LOG_FLOW1, _("updating database for replaced packages' dependencies"));
_alpm_log(PM_LOG_DEBUG, _("updating database for replaced packages' dependencies"));
for(i = trans->packages; i; i = i->next) {
pmsyncpkg_t *sync = i->data;
if(sync->type == PM_SYNC_TYPE_REPLACE) {

View File

@ -468,7 +468,7 @@ int _alpm_runscriptlet(char *root, char *installfn, char *script, char *ver, cha
_alpm_log(PM_LOG_ERROR, _("could not change directory to %s (%s)"), root, strerror(errno));
}
_alpm_log(PM_LOG_FLOW2, _("executing %s script..."), script);
_alpm_log(PM_LOG_DEBUG, _("executing %s script..."), script);
if(oldver) {
snprintf(cmdline, PATH_MAX, "source %s %s %s %s",

View File

@ -67,7 +67,7 @@ int pacman_add(alpm_list_t *targets)
ERR(NL, "%s\n", alpm_strerror(pm_errno));
if(pm_errno == PM_ERR_HANDLE_LOCK) {
MSG(NL, _(" if you're sure a package manager is not already running,\n"
" you can remove %s%s\n"), config->root, PM_LOCK);
" you can remove %s%s\n"), alpm_option_get_root(), PM_LOCK);
}
return(1);
}
@ -124,7 +124,7 @@ int pacman_add(alpm_list_t *targets)
switch(alpm_conflict_get_type(conflict)) {
case PM_CONFLICT_TYPE_TARGET:
MSG(NL, _("%s%s exists in \"%s\" (target) and \"%s\" (target)"),
config->root,
alpm_option_get_root(),
alpm_conflict_get_file(conflict),
alpm_conflict_get_target(conflict),
alpm_conflict_get_ctarget(conflict));
@ -132,7 +132,7 @@ int pacman_add(alpm_list_t *targets)
case PM_CONFLICT_TYPE_FILE:
MSG(NL, _("%s: %s%s exists in filesystem"),
alpm_conflict_get_target(conflict),
config->root,
alpm_option_get_root(),
alpm_conflict_get_file(conflict));
break;
}

View File

@ -26,7 +26,6 @@
#include <libintl.h>
#include <alpm.h>
#include <alpm_list.h>
/* pacman */
#include "util.h"
#include "log.h"
@ -51,9 +50,7 @@ int config_free(config_t *config)
return(-1);
}
FREE(config->root);
FREE(config->configfile);
FREELIST(config->op_s_ignore);
free(config);
return(0);

View File

@ -25,9 +25,6 @@
typedef struct __config_t {
/* command line options */
char *root;
const char *dbpath;
const char *cachedir;
char *configfile;
unsigned short op;
unsigned short verbose;
@ -49,14 +46,12 @@ typedef struct __config_t {
unsigned short op_s_clean;
unsigned short op_s_dependsonly;
unsigned short op_s_downloadonly;
alpm_list_t *op_s_ignore;
unsigned short op_s_info;
unsigned short op_s_sync;
unsigned short op_s_search;
unsigned short op_s_upgrade;
unsigned short group;
unsigned int flags;
unsigned short debug;
unsigned short noask;
unsigned int ask;
} config_t;

View File

@ -67,7 +67,7 @@ int pacman_deptest(alpm_list_t *targets)
ERR(NL, "%s", alpm_strerror(pm_errno));
if(pm_errno == PM_ERR_HANDLE_LOCK) {
MSG(NL, _(" if you're sure a package manager is not already running,\n"
" you can remove %s%s\n"), config->root, PM_LOCK);
" you can remove %s%s\n"), alpm_option_get_root(), PM_LOCK);
}
return(1);
}

View File

@ -66,13 +66,10 @@ void cb_log(unsigned short level, char *msg)
case PM_LOG_WARNING:
sprintf(str, _("warning"));
break;
case PM_LOG_FLOW1:
sprintf(str, _("flow1"));
break;
case PM_LOG_FLOW2:
sprintf(str, _("flow2"));
break;
case PM_LOG_FUNCTION:
/* TODO we should increase the indent level when this occurs so we can see
* program flow easier. It'll be fun
*/
sprintf(str, _("function"));
break;
default:
@ -82,7 +79,7 @@ void cb_log(unsigned short level, char *msg)
#ifdef PACMAN_DEBUG
/* If debug is on, we'll timestamp the output */
if(config->debug&PM_LOG_DEBUG) {
if(alpm_option_get_logmask() & PM_LOG_DEBUG) {
time_t t;
struct tm *tmp;
char timestr[10] = {0};

View File

@ -251,7 +251,7 @@ static int parseargs(int argc, char *argv[])
{"noconfirm", no_argument, 0, 1000},
{"config", required_argument, 0, 1001},
{"ignore", required_argument, 0, 1002},
{"debug", required_argument, 0, 1003},
{"debug", optional_argument, 0, 1003},
{"noprogressbar", no_argument, 0, 1004},
{"noscriptlet", no_argument, 0, 1005},
{"ask", required_argument, 0, 1006},
@ -259,6 +259,7 @@ static int parseargs(int argc, char *argv[])
};
char root[PATH_MAX];
struct stat st;
unsigned short logmask;
while((opt = getopt_long(argc, argv, "ARUFQSTDYr:b:vkhscVfmnoldepiuwyg", opts, &option_index))) {
if(opt < 0) {
@ -277,8 +278,32 @@ static int parseargs(int argc, char *argv[])
config->configfile = strndup(optarg, PATH_MAX);
#endif
break;
case 1002: config->op_s_ignore = alpm_list_add(config->op_s_ignore, strdup(optarg)); break;
case 1003: config->debug = atoi(optarg); break;
case 1002: alpm_option_add_ignorepkg(strdup(optarg)); break;
case 1003:
/* debug levels are made more 'human readable' than using a raw logmask
* here, we will ALWAYS set error and warning for now, though perhaps a
* --quiet option will remove these later */
logmask = PM_LOG_ERROR | PM_LOG_WARNING;
if(optarg) {
unsigned short debug = atoi(optarg);
printf("setting logmask to %s\n", optarg);
switch(debug) {
case 3: logmask |= PM_LOG_FUNCTION; /* fall through */
case 2: logmask |= PM_LOG_DOWNLOAD; /*fall through */
case 1: logmask |= PM_LOG_DEBUG; break;
default:
pm_fprintf(stderr, NL, _("error: '%s' is not a valid debug level"), optarg);
return(1);
}
printf("logmask = %d\n", logmask);
} else {
logmask |= PM_LOG_DEBUG;
}
/* progress bars get wonky with debug on, shut them off */
config->noprogressbar = 1;
alpm_option_set_logmask(logmask);
break;
case 1004: config->noprogressbar = 1; break;
case 1005: config->flags |= PM_TRANS_FLAG_NOSCRIPTLET; break;
case 1006: config->noask = 1; config->ask = atoi(optarg); break;
@ -305,10 +330,9 @@ static int parseargs(int argc, char *argv[])
case 'b':
if(stat(optarg, &st) == -1 || !S_ISDIR(st.st_mode)) {
pm_fprintf(stderr, NL, _("error: '%s' is not a valid db path\n"), optarg);
exit(EXIT_FAILURE);
return(1);
}
alpm_option_set_dbpath(optarg);
config->dbpath = alpm_option_get_dbpath(optarg);
break;
case 'c':
(config->op_s_clean)++;
@ -334,12 +358,11 @@ static int parseargs(int argc, char *argv[])
config->flags |= PM_TRANS_FLAG_PRINTURIS;
break;
case 'r':
printf("setting root path=%s\n", optarg);
if(realpath(optarg, root) == NULL) {
perror(_("bad root path"));
pm_fprintf(stderr, NL, _("error: '%s' is not a valid root path\n"), optarg);
return(1);
}
config->root = strdup(root);
alpm_option_set_root(strdup(root));
break;
case 's':
config->op_s_search = 1;
@ -416,13 +439,17 @@ int main(int argc, char *argv[])
/* init config data */
config = config_new();
config->op = PM_OP_MAIN;
config->debug |= PM_LOG_ERROR;
config->debug |= PM_LOG_WARNING;
/* disable progressbar if the output is redirected */
if(!isatty(1)) {
config->noprogressbar = 1;
}
/* initialize pm library */
if(alpm_initialize() == -1) {
ERR(NL, _("failed to initilize alpm library (%s)\n"), alpm_strerror(pm_errno));
cleanup(1);
}
/* parse the command line */
ret = parseargs(argc, argv);
if(ret != 0) {
@ -447,7 +474,7 @@ int main(int argc, char *argv[])
(config->op_s_search || config->group || config->op_q_list || config->op_q_info
|| config->flags & PM_TRANS_FLAG_PRINTURIS))
|| (config->op == PM_OP_DEPTEST && !config->op_d_resolve)
|| (config->root != NULL)) {
|| (strcmp(alpm_option_get_root(), PM_ROOT) != 0)) {
/* special case: PM_OP_SYNC can be used w/ config->op_s_search by any user */
/* special case: ignore root user check if -r is specified, fall back on
* normal FS checking */
@ -460,18 +487,7 @@ int main(int argc, char *argv[])
}
#endif
if(config->root == NULL) {
config->root = strdup(PM_ROOT);
}
/* initialize pm library */
if(alpm_initialize(config->root) == -1) {
ERR(NL, _("failed to initilize alpm library (%s)\n"), alpm_strerror(pm_errno));
cleanup(1);
}
/* Setup logging as soon as possible, to print out maximum debugging info */
alpm_option_set_logmask(config->debug);
alpm_option_set_logcb(cb_log);
if(config->configfile == NULL) {
@ -486,17 +502,9 @@ int main(int argc, char *argv[])
/* set library parameters */
alpm_option_set_dlcb(log_progress);
config->dbpath = alpm_option_get_dbpath();
config->cachedir = alpm_option_get_cachedir();
alpm_list_t *i;
for(i = config->op_s_ignore; i; i = alpm_list_next(i)) {
alpm_option_add_ignorepkg(alpm_list_getdata(i));
}
if(config->verbose > 0) {
printf("Root : %s\n", config->root);
printf("DBPath: %s\n", config->dbpath);
printf("Root : %s\n", alpm_option_get_root());
printf("DBPath: %s\n", alpm_option_get_dbpath());
list_display(_("Targets:"), pm_targets);
}

View File

@ -260,7 +260,7 @@ int pacman_query(alpm_list_t *targets)
if(config->op_q_changelog) {
char changelog[PATH_MAX];
snprintf(changelog, PATH_MAX, "%s%s/%s/%s-%s/changelog",
config->root, alpm_option_get_dbpath(),
alpm_option_get_root(), alpm_option_get_dbpath(),
alpm_db_get_name(db_local),
alpm_pkg_get_name(info),
alpm_pkg_get_version(info));

View File

@ -77,7 +77,7 @@ int pacman_remove(alpm_list_t *targets)
ERR(NL, _("failed to init transaction (%s)\n"), alpm_strerror(pm_errno));
if(pm_errno == PM_ERR_HANDLE_LOCK) {
MSG(NL, _(" if you're sure a package manager is not already running,\n"
" you can remove %s%s\n"), config->root, PM_LOCK);
" you can remove %s%s\n"), alpm_option_get_root(), PM_LOCK);
}
FREELIST(finaltargs);
return(1);

View File

@ -439,7 +439,7 @@ int pacman_sync(alpm_list_t *targets)
ERR(NL, _("failed to init transaction (%s)\n"), alpm_strerror(pm_errno));
if(pm_errno == PM_ERR_HANDLE_LOCK) {
MSG(NL, _(" if you're sure a package manager is not already running,\n"
" you can remove %s%s\n"), config->root, PM_LOCK);
" you can remove %s%s\n"), alpm_option_get_root(), PM_LOCK);
}
return(1);
}
@ -488,7 +488,7 @@ int pacman_sync(alpm_list_t *targets)
ERR(NL, _("failed to init transaction (%s)\n"), alpm_strerror(pm_errno));
if(pm_errno == PM_ERR_HANDLE_LOCK) {
MSG(NL, _(" if you're sure a package manager is not already running,\n"
" you can remove %s%s\n"), config->root, PM_LOCK);
" you can remove %s%s\n"), alpm_option_get_root(), PM_LOCK);
}
return(1);
}