1
0
mirror of https://github.com/moparisthebest/pacman synced 2025-02-28 09:21:53 -05:00

* 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
This commit is contained in:
Dan McGee 2007-03-01 19:07:38 +00:00
parent ca139e9850
commit efca1cc010
7 changed files with 44 additions and 26 deletions

View File

@ -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;

View File

@ -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)

View File

@ -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);

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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__":