diff options
author | Dan McGee <dan@archlinux.org> | 2007-03-01 20:07:38 +0100 |
---|---|---|
committer | Dan McGee <dan@archlinux.org> | 2007-03-01 20:07:38 +0100 |
commit | efca1cc0106fd4b1eea795b6ff8ae208e1196042 (patch) | |
tree | 6fe6a4b5689a5d239ffb568a673c17b6cc66caf7 | |
parent | ca139e985017652fa1d25b2ff8ac4a8ebbe4c648 (diff) | |
download | pacman-efca1cc0106fd4b1eea795b6ff8ae208e1196042.tar.gz pacman-efca1cc0106fd4b1eea795b6ff8ae208e1196042.tar.xz |
* 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
-rw-r--r-- | lib/libalpm/alpm.c | 8 | ||||
-rw-r--r-- | lib/libalpm/alpm_list.c | 2 | ||||
-rw-r--r-- | lib/libalpm/cache.c | 4 | ||||
-rw-r--r-- | lib/libalpm/db.h | 10 | ||||
-rw-r--r-- | lib/libalpm/package.c | 24 | ||||
-rw-r--r-- | lib/libalpm/sync.c | 4 | ||||
-rwxr-xr-x | pactest/pmenv.py | 18 |
7 files changed, 44 insertions, 26 deletions
diff --git a/lib/libalpm/alpm.c b/lib/libalpm/alpm.c index fe7a369f..f01e0da5 100644 --- a/lib/libalpm/alpm.c +++ b/lib/libalpm/alpm.c @@ -303,7 +303,7 @@ int SYMEXPORT alpm_db_update(int force, pmdb_t *db) /* 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 @@ alpm_list_t SYMEXPORT *alpm_db_getpkgcache(pmdb_t *db) 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 @@ alpm_list_t *alpm_get_upgrades() 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 @@ alpm_list_t *alpm_get_upgrades() } /* 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; diff --git a/lib/libalpm/alpm_list.c b/lib/libalpm/alpm_list.c index 8c387eed..36517fd2 100644 --- a/lib/libalpm/alpm_list.c +++ b/lib/libalpm/alpm_list.c @@ -462,7 +462,7 @@ int alpm_list_find_str(alpm_list_t *haystack, const char *needle) * @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) diff --git a/lib/libalpm/cache.c b/lib/libalpm/cache.c index 8e043096..74299061 100644 --- a/lib/libalpm/cache.c +++ b/lib/libalpm/cache.c @@ -123,7 +123,7 @@ int _alpm_db_ensure_pkgcache(pmdb_t *db, pmdbinfrq_t infolevel) 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 @@ pmpkg_t *_alpm_db_get_pkgfromcache(pmdb_t *db, const char *target) 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); diff --git a/lib/libalpm/db.h b/lib/libalpm/db.h index 4f3c1bf0..81c15f50 100644 --- a/lib/libalpm/db.h +++ b/lib/libalpm/db.h @@ -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; diff --git a/lib/libalpm/package.c b/lib/libalpm/package.c index e979af63..f7753d7c 100644 --- a/lib/libalpm/package.c +++ b/lib/libalpm/package.c @@ -567,7 +567,7 @@ void _alpm_pkg_update_requiredby(pmpkg_t *pkg) } } -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 @@ const char *alpm_pkg_get_filename(pmpkg_t *pkg) 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 *alpm_pkg_get_filename(pmpkg_t *pkg) 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_builddate(pmpkg_t *pkg) 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 @@ unsigned short SYMEXPORT alpm_pkg_has_scriptlet(pmpkg_t *pkg) return pkg->scriptlet; } +/* TODO this should either be public, or done somewhere else */ int _alpm_pkg_istoonew(pmpkg_t *pkg) { time_t t; diff --git a/lib/libalpm/sync.c b/lib/libalpm/sync.c index 0e4c6c04..81d2a738 100644 --- a/lib/libalpm/sync.c +++ b/lib/libalpm/sync.c @@ -137,7 +137,7 @@ static int find_replacements(pmtrans_t *trans, pmdb_t *db_local, 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 @@ int _alpm_sync_sysupgrade(pmtrans_t *trans, pmdb_t *db_local, alpm_list_t *dbs_s 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; diff --git a/pactest/pmenv.py b/pactest/pmenv.py index 56af2e9a..bff32e98 100755 --- a/pactest/pmenv.py +++ b/pactest/pmenv.py @@ -80,9 +80,9 @@ class pmenv: 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 @@ class pmenv: 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 @@ class pmenv: 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__": |