Date: Thursday, March 1, 2007 @ 14:07:39 Author: dan Path: /home/cvs-pacman/pacman-lib Modified: lib/libalpm/alpm.c (1.120 -> 1.121) lib/libalpm/alpm_list.c (1.7 -> 1.8) lib/libalpm/cache.c (1.35 -> 1.36) lib/libalpm/db.h (1.27 -> 1.28) lib/libalpm/package.c (1.80 -> 1.81) lib/libalpm/sync.c (1.105 -> 1.106) pactest/pmenv.py (1.8 -> 1.9) * Modified values of INFRQ_* options so we start at 0x01 and not 0x00. This allows for the same bit operators to be used across the board on pkg_get operations. * Changed name of INFRQ_NONE -> INFRQ_BASE to more clearly reflect what it does (loads pkg name and version). * Added a few missing things on package functions, such as SYMEXPORT and ALPM_LOG_FUNC. * Slight updates to pmenv to print 'pass' and 'fail' instead of 'passed' and 'failed'. Keeps output a bit more concise. * Fixed a doxygen comment spelling error. :P -------------------------+ lib/libalpm/alpm.c | 8 ++++---- lib/libalpm/alpm_list.c | 2 +- lib/libalpm/cache.c | 4 ++-- lib/libalpm/db.h | 10 +++++----- lib/libalpm/package.c | 24 +++++++++++++++++++++--- lib/libalpm/sync.c | 4 ++-- pactest/pmenv.py | 18 +++++++++--------- 7 files changed, 44 insertions(+), 26 deletions(-) Index: pacman-lib/lib/libalpm/alpm.c diff -u pacman-lib/lib/libalpm/alpm.c:1.120 pacman-lib/lib/libalpm/alpm.c:1.121 --- pacman-lib/lib/libalpm/alpm.c:1.120 Mon Feb 26 03:38:48 2007 +++ pacman-lib/lib/libalpm/alpm.c Thu Mar 1 14:07:38 2007 @@ -303,7 +303,7 @@ /* remove the old dir */ _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) { + for(lp = _alpm_db_get_pkgcache(db, INFRQ_BASE); lp; lp = lp->next) { if(_alpm_db_remove(db, lp->data) == -1) { if(lp->data) { _alpm_log(PM_LOG_ERROR, _("could not remove database entry %s/%s"), db->treename, @@ -354,7 +354,7 @@ ASSERT(handle != NULL, return(NULL)); ASSERT(db != NULL, return(NULL)); - return(_alpm_db_get_pkgcache(db, INFRQ_NONE)); + return(_alpm_db_get_pkgcache(db, INFRQ_BASE)); } /** Get the list of packages that a package provides @@ -1085,7 +1085,7 @@ pmpkg_t *spkg = j->data; for(k = spkg->replaces; k; k = k->next) { alpm_list_t *m; - for(m = _alpm_db_get_pkgcache(handle->db_local, INFRQ_NONE); m; m = m->next) { + for(m = _alpm_db_get_pkgcache(handle->db_local, INFRQ_BASE); m; m = m->next) { pmpkg_t *lpkg = m->data; if(strcmp(k->data, lpkg->name) == 0) { _alpm_log(PM_LOG_DEBUG, _("checking replacement '%s' for package '%s'"), k->data, spkg->name); @@ -1135,7 +1135,7 @@ } /* now do normal upgrades */ - for(i = _alpm_db_get_pkgcache(handle->db_local, INFRQ_NONE); i; i = i->next) { + for(i = _alpm_db_get_pkgcache(handle->db_local, INFRQ_BASE); i; i = i->next) { int replace=0; pmpkg_t *local = i->data; pmpkg_t *spkg = NULL; Index: pacman-lib/lib/libalpm/alpm_list.c diff -u pacman-lib/lib/libalpm/alpm_list.c:1.7 pacman-lib/lib/libalpm/alpm_list.c:1.8 --- pacman-lib/lib/libalpm/alpm_list.c:1.7 Thu Mar 1 02:03:05 2007 +++ pacman-lib/lib/libalpm/alpm_list.c Thu Mar 1 14:07:39 2007 @@ -462,7 +462,7 @@ * @note Entries are not duplicated * @param lhs the first list * @param rhs the second list - * @param fn the comparisson function + * @param fn the comparison function * @return a list containing all items in lhs not present in rhs */ alpm_list_t *alpm_list_diff(alpm_list_t *lhs, alpm_list_t *rhs, alpm_list_fn_cmp fn) Index: pacman-lib/lib/libalpm/cache.c diff -u pacman-lib/lib/libalpm/cache.c:1.35 pacman-lib/lib/libalpm/cache.c:1.36 --- pacman-lib/lib/libalpm/cache.c:1.35 Mon Feb 26 03:38:48 2007 +++ pacman-lib/lib/libalpm/cache.c Thu Mar 1 14:07:39 2007 @@ -123,7 +123,7 @@ alpm_list_t *p; for(p = db->pkgcache; p; p = p->next) { pmpkg_t *pkg = (pmpkg_t *)p->data; - if(infolevel != INFRQ_NONE && !(pkg->infolevel & infolevel)) { + if(infolevel != INFRQ_BASE && !(pkg->infolevel & infolevel)) { if(_alpm_db_read(db, pkg, infolevel) == -1) { /* TODO should we actually remove from the filesystem here as well? */ _alpm_db_remove_pkgfromcache(db, pkg); @@ -195,7 +195,7 @@ return(NULL); } - alpm_list_t *pkgcache = _alpm_db_get_pkgcache(db, INFRQ_NONE); + alpm_list_t *pkgcache = _alpm_db_get_pkgcache(db, INFRQ_BASE); if(!pkgcache) { _alpm_log(PM_LOG_DEBUG, _("error: failed to get '%s' from NULL pkgcache"), target); return(NULL); Index: pacman-lib/lib/libalpm/db.h diff -u pacman-lib/lib/libalpm/db.h:1.27 pacman-lib/lib/libalpm/db.h:1.28 --- pacman-lib/lib/libalpm/db.h:1.27 Wed Feb 28 22:08:41 2007 +++ pacman-lib/lib/libalpm/db.h Thu Mar 1 14:07:39 2007 @@ -28,11 +28,11 @@ /* Database entries */ typedef enum _pmdbinfrq_t { - INFRQ_NONE = 0x00, - INFRQ_DESC = 0x01, - INFRQ_DEPENDS = 0x02, - INFRQ_FILES = 0x04, - INFRQ_SCRIPTLET = 0x08, + INFRQ_BASE = 0x01, + INFRQ_DESC = 0x02, + INFRQ_DEPENDS = 0x04, + INFRQ_FILES = 0x08, + INFRQ_SCRIPTLET = 0x16, INFRQ_ALL = 0xFF } pmdbinfrq_t; Index: pacman-lib/lib/libalpm/package.c diff -u pacman-lib/lib/libalpm/package.c:1.80 pacman-lib/lib/libalpm/package.c:1.81 --- pacman-lib/lib/libalpm/package.c:1.80 Thu Mar 1 00:42:53 2007 +++ pacman-lib/lib/libalpm/package.c Thu Mar 1 14:07:39 2007 @@ -567,7 +567,7 @@ } } -const char *alpm_pkg_get_filename(pmpkg_t *pkg) +const char SYMEXPORT *alpm_pkg_get_filename(pmpkg_t *pkg) { ALPM_LOG_FUNC; @@ -577,10 +577,15 @@ if(!strlen(pkg->filename)) { /* construct the file name, it's not in the desc file */ + if(pkg->origin == PKG_FROM_CACHE && !(pkg->infolevel & INFRQ_DESC)) { + _alpm_db_read(pkg->data, pkg, INFRQ_DESC); + } if(pkg->arch && strlen(pkg->arch) > 0) { - snprintf(pkg->filename, PKG_FILENAME_LEN, "%s-%s-%s" PM_EXT_PKG, pkg->name, pkg->version, pkg->arch); + snprintf(pkg->filename, PKG_FILENAME_LEN, "%s-%s-%s" PM_EXT_PKG, + pkg->name, pkg->version, pkg->arch); } else { - snprintf(pkg->filename, PKG_FILENAME_LEN, "%s-%s" PM_EXT_PKG, pkg->name, pkg->version); + snprintf(pkg->filename, PKG_FILENAME_LEN, "%s-%s" PM_EXT_PKG, + pkg->name, pkg->version); } } @@ -589,19 +594,29 @@ const char SYMEXPORT *alpm_pkg_get_name(pmpkg_t *pkg) { + ALPM_LOG_FUNC; + /* Sanity checks */ ASSERT(handle != NULL, return(NULL)); ASSERT(pkg != NULL, return(NULL)); + if(pkg->origin == PKG_FROM_CACHE && !(pkg->infolevel & INFRQ_BASE)) { + _alpm_db_read(pkg->data, pkg, INFRQ_BASE); + } return pkg->name; } const char SYMEXPORT *alpm_pkg_get_version(pmpkg_t *pkg) { + ALPM_LOG_FUNC; + /* Sanity checks */ ASSERT(handle != NULL, return(NULL)); ASSERT(pkg != NULL, return(NULL)); + if(pkg->origin == PKG_FROM_CACHE && !(pkg->infolevel & INFRQ_BASE)) { + _alpm_db_read(pkg->data, pkg, INFRQ_BASE); + } return pkg->version; } @@ -649,6 +664,8 @@ const char SYMEXPORT *alpm_pkg_get_buildtype(pmpkg_t *pkg) { + ALPM_LOG_FUNC; + /* Sanity checks */ ASSERT(handle != NULL, return(NULL)); ASSERT(pkg != NULL, return(NULL)); @@ -929,6 +946,7 @@ return pkg->scriptlet; } +/* TODO this should either be public, or done somewhere else */ int _alpm_pkg_istoonew(pmpkg_t *pkg) { time_t t; Index: pacman-lib/lib/libalpm/sync.c diff -u pacman-lib/lib/libalpm/sync.c:1.105 pacman-lib/lib/libalpm/sync.c:1.106 --- pacman-lib/lib/libalpm/sync.c:1.105 Mon Feb 26 03:38:48 2007 +++ pacman-lib/lib/libalpm/sync.c Thu Mar 1 14:07:39 2007 @@ -137,7 +137,7 @@ for(k = alpm_pkg_get_replaces(spkg); k; k = k->next) { const char *replacement = k->data; /* compare to local DB */ - for(m = _alpm_db_get_pkgcache(db_local, INFRQ_NONE); m; m = m->next) { + for(m = _alpm_db_get_pkgcache(db_local, INFRQ_BASE); m; m = m->next) { pmpkg_t *lpkg = m->data; if(strcmp(replacement, lpkg->name) == 0) { @@ -203,7 +203,7 @@ if( find_replacements(trans, db_local, dbs_sync) == 0 ) { /* match installed packages with the sync dbs and compare versions */ _alpm_log(PM_LOG_DEBUG, _("checking for package upgrades")); - for(i = _alpm_db_get_pkgcache(db_local, INFRQ_NONE); i; i = i->next) { + for(i = _alpm_db_get_pkgcache(db_local, INFRQ_BASE); i; i = i->next) { int replace=0; pmpkg_t *local = i->data; pmpkg_t *spkg = NULL; Index: pacman-lib/pactest/pmenv.py diff -u pacman-lib/pactest/pmenv.py:1.8 pacman-lib/pactest/pmenv.py:1.9 --- pacman-lib/pactest/pmenv.py:1.8 Wed Feb 28 11:37:24 2007 +++ pacman-lib/pactest/pmenv.py Thu Mar 1 14:07:39 2007 @@ -80,9 +80,9 @@ t.check() print "==> Test result" if t.result["fail"] == 0: - print "\tPASSED" + print "\tPASS" else: - print "\tFAILED" + print "\tFAIL" print def results(self): @@ -104,16 +104,16 @@ fail = test.result["fail"] rules = len(test.rules) if fail == 0: - result = "[PASSED]" + result = "[PASS]" else: - result = "[FAILED]" + result = "[FAIL]" print result, print "%s Rules: OK = %2u FAIL = %2u SKIP = %2u" \ - % (test.testname.ljust(32), success, fail, \ + % (test.testname.ljust(34), success, fail, \ rules - (success + fail)) if fail != 0: # print test description if test failed - print " ", test.description + print " ", test.description print "=========="*8 print "Results" @@ -125,10 +125,10 @@ total = len(self.testcases) failed = total - passed - print "TOTAL = %3u" % total + print "TOTAL = %3u" % total if total: - print "PASSED = %3u (%6.2f%%)" % (passed, float(passed) * 100 / total) - print "FAILED = %3u (%6.2f%%)" % (failed, float(failed) * 100 / total) + print "PASS = %3u (%6.2f%%)" % (passed, float(passed) * 100 / total) + print "FAIL = %3u (%6.2f%%)" % (failed, float(failed) * 100 / total) print "" if __name__ == "__main__":