ref: refs/heads/master
commit 9e9cb2a7d22bec3da94d7eb2bc35152c3f44ce65
Author: Michael Schroeder
Date: Fri Jul 3 13:06:29 2009 +0200
- beautify
---
examples/solv.c | 26 ++++++++++++++++++--------
src/solverdebug.c | 40 ++++++++++++++++++++--------------------
2 files changed, 38 insertions(+), 28 deletions(-)
diff --git a/examples/solv.c b/examples/solv.c
index 182b7d1..d2f0c59 100644
--- a/examples/solv.c
+++ b/examples/solv.c
@@ -163,7 +163,10 @@ read_repoinfos(Pool *pool, const char *reposdir, int *nrepoinfosp)
else if (!strcmp(kp, "baseurl"))
cinfo->baseurl = strdup(vp);
else if (!strcmp(kp, "path"))
- cinfo->path = strdup(vp);
+ {
+ if (vp && strcmp(vp, "/") != 0)
+ cinfo->path = strdup(vp);
+ }
else if (!strcmp(kp, "type"))
{
if (!strcmp(vp, "yast2"))
@@ -223,13 +226,14 @@ myfopen(const char *fn)
}
FILE *
-curlfopen(const char *baseurl, const char *file, int uncompress)
+curlfopen(struct repoinfo *cinfo, const char *file, int uncompress)
{
pid_t pid;
int fd, l;
int status;
char tmpl[100];
char url[4096];
+ const char *baseurl = cinfo->baseurl;
l = strlen(baseurl);
if (l && baseurl[l - 1] == '/')
@@ -478,12 +482,18 @@ read_repos(Pool *pool, struct repoinfo *repoinfos, int nrepoinfos)
repo->appdata = cinfo;
repo->priority = 99 - cinfo->priority;
+ if (!cinfo->autorefresh && usecachedrepo(repo, 0))
+ {
+ printf("repo '%s':", cinfo->alias);
+ printf(" cached\n");
+ continue;
+ }
switch (cinfo->type)
{
case TYPE_RPMMD:
printf("rpmmd repo '%s':", cinfo->alias);
fflush(stdout);
- if ((fp = curlfopen(cinfo->baseurl, "repodata/repomd.xml", 0)) == 0)
+ if ((fp = curlfopen(cinfo, "repodata/repomd.xml", 0)) == 0)
{
printf(" no data, skipped\n");
repo_free(repo, 1);
@@ -511,7 +521,7 @@ read_repos(Pool *pool, struct repoinfo *repoinfos, int nrepoinfos)
dataiterator_free(&di);
if (!primaryfile)
primaryfile = "repodata/primary.xml.gz";
- if ((fp = curlfopen(cinfo->baseurl, primaryfile, 1)) == 0)
+ if ((fp = curlfopen(cinfo, primaryfile, 1)) == 0)
continue;
repo_add_rpmmd(repo, fp, 0, 0);
fclose(fp);
@@ -526,7 +536,7 @@ read_repos(Pool *pool, struct repoinfo *repoinfos, int nrepoinfos)
repo->priority = 99 - cinfo->priority;
descrdir = 0;
defvendor = 0;
- if ((fp = curlfopen(cinfo->baseurl, "content", 0)) != 0)
+ if ((fp = curlfopen(cinfo, "content", 0)) != 0)
{
calc_checksum_fp(fp, REPOKEY_TYPE_SHA256, cookie);
if (usecachedrepo(repo, cookie))
@@ -544,8 +554,8 @@ read_repos(Pool *pool, struct repoinfo *repoinfos, int nrepoinfos)
if (!descrdir)
descrdir = "suse/setup/descr";
printf(" reading\n");
- if ((fp = curlfopen(cinfo->baseurl, pool_tmpjoin(pool, descrdir, "/packages.gz", 0), 1)) == 0)
- if ((fp = curlfopen(cinfo->baseurl, pool_tmpjoin(pool, descrdir, "/packages", 0), 0)) == 0)
+ if ((fp = curlfopen(cinfo, pool_tmpjoin(pool, descrdir, "/packages.gz", 0), 1)) == 0)
+ if ((fp = curlfopen(cinfo, pool_tmpjoin(pool, descrdir, "/packages", 0), 0)) == 0)
break;
repo_add_susetags(repo, fp, defvendor, 0, 0);
fclose(fp);
@@ -950,7 +960,7 @@ rerunsolver:
const char *datadir = repo_lookup_str(cinfo->repo, SOLVID_META, SUSETAGS_DATADIR);
loc = pool_tmpjoin(pool, datadir ? datadir : "suse", "/", loc);
}
- if ((newpkgsfps[i] = curlfopen(cinfo->baseurl, loc, 0)) == 0)
+ if ((newpkgsfps[i] = curlfopen(cinfo, loc, 0)) == 0)
{
printf("%s: %s not found in repository\n", s->repo->name, loc);
exit(1);
diff --git a/src/solverdebug.c b/src/solverdebug.c
index f636a98..cb62f32 100644
--- a/src/solverdebug.c
+++ b/src/solverdebug.c
@@ -580,28 +580,28 @@ solver_printsolution(Solver *solv, Id problem, Id solution)
{
case SOLVER_INSTALL:
if (select == SOLVER_SOLVABLE && solv->installed && pool->solvables[what].repo == solv->installed)
- POOL_DEBUG(SAT_DEBUG_RESULT, "- do not keep %s installed\n", solvid2str(pool, what));
+ POOL_DEBUG(SAT_DEBUG_RESULT, " - do not keep %s installed\n", solvid2str(pool, what));
else if (select == SOLVER_SOLVABLE_PROVIDES)
- POOL_DEBUG(SAT_DEBUG_RESULT, "- do not install a solvable %s\n", solver_select2str(solv, select, what));
+ POOL_DEBUG(SAT_DEBUG_RESULT, " - do not install a solvable %s\n", solver_select2str(solv, select, what));
else
- POOL_DEBUG(SAT_DEBUG_RESULT, "- do not install %s\n", solver_select2str(solv, select, what));
+ POOL_DEBUG(SAT_DEBUG_RESULT, " - do not install %s\n", solver_select2str(solv, select, what));
break;
case SOLVER_ERASE:
if (select == SOLVER_SOLVABLE && !(solv->installed && pool->solvables[what].repo == solv->installed))
- POOL_DEBUG(SAT_DEBUG_RESULT, "- do not forbid installation of %s\n", solvid2str(pool, what));
+ POOL_DEBUG(SAT_DEBUG_RESULT, " - do not forbid installation of %s\n", solvid2str(pool, what));
else if (select == SOLVER_SOLVABLE_PROVIDES)
- POOL_DEBUG(SAT_DEBUG_RESULT, "- do not deinstall all solvables %s\n", solver_select2str(solv, select, what));
+ POOL_DEBUG(SAT_DEBUG_RESULT, " - do not deinstall all solvables %s\n", solver_select2str(solv, select, what));
else
- POOL_DEBUG(SAT_DEBUG_RESULT, "- do not deinstall %s\n", solver_select2str(solv, select, what));
+ POOL_DEBUG(SAT_DEBUG_RESULT, " - do not deinstall %s\n", solver_select2str(solv, select, what));
break;
case SOLVER_UPDATE:
- POOL_DEBUG(SAT_DEBUG_RESULT, "- do not install most recent version of %s\n", solver_select2str(solv, select, what));
+ POOL_DEBUG(SAT_DEBUG_RESULT, " - do not install most recent version of %s\n", solver_select2str(solv, select, what));
break;
case SOLVER_LOCK:
- POOL_DEBUG(SAT_DEBUG_RESULT, "- do not lock %s\n", solver_select2str(solv, select, what));
+ POOL_DEBUG(SAT_DEBUG_RESULT, " - do not lock %s\n", solver_select2str(solv, select, what));
break;
default:
- POOL_DEBUG(SAT_DEBUG_RESULT, "- do something different\n");
+ POOL_DEBUG(SAT_DEBUG_RESULT, " - do something different\n");
break;
}
}
@@ -609,17 +609,17 @@ solver_printsolution(Solver *solv, Id problem, Id solution)
{
s = pool->solvables + rp;
if (solv->installed && s->repo == solv->installed)
- POOL_DEBUG(SAT_DEBUG_RESULT, "- keep %s despite the inferior architecture\n", solvable2str(pool, s));
+ POOL_DEBUG(SAT_DEBUG_RESULT, " - keep %s despite the inferior architecture\n", solvable2str(pool, s));
else
- POOL_DEBUG(SAT_DEBUG_RESULT, "- install %s despite the inferior architecture\n", solvable2str(pool, s));
+ POOL_DEBUG(SAT_DEBUG_RESULT, " - install %s despite the inferior architecture\n", solvable2str(pool, s));
}
else if (p == SOLVER_SOLUTION_DISTUPGRADE)
{
s = pool->solvables + rp;
if (solv->installed && s->repo == solv->installed)
- POOL_DEBUG(SAT_DEBUG_RESULT, "- keep obsolete %s\n", solvable2str(pool, s));
+ POOL_DEBUG(SAT_DEBUG_RESULT, " - keep obsolete %s\n", solvable2str(pool, s));
else
- POOL_DEBUG(SAT_DEBUG_RESULT, "- install %s from excluded repository\n", solvable2str(pool, s));
+ POOL_DEBUG(SAT_DEBUG_RESULT, " - install %s from excluded repository\n", solvable2str(pool, s));
}
else
{
@@ -628,35 +628,35 @@ solver_printsolution(Solver *solv, Id problem, Id solution)
sd = rp ? pool->solvables + rp : 0;
if (s == sd && solv->distupgrade)
{
- POOL_DEBUG(SAT_DEBUG_RESULT, "- keep obsolete %s\n", solvable2str(pool, s));
+ POOL_DEBUG(SAT_DEBUG_RESULT, " - keep obsolete %s\n", solvable2str(pool, s));
}
else if (sd)
{
int gotone = 0;
if (!solv->allowdowngrade && evrcmp(pool, s->evr, sd->evr, EVRCMP_MATCH_RELEASE) > 0)
{
- POOL_DEBUG(SAT_DEBUG_RESULT, "- allow downgrade of %s to %s\n", solvable2str(pool, s), solvable2str(pool, sd));
+ POOL_DEBUG(SAT_DEBUG_RESULT, " - allow downgrade of %s to %s\n", solvable2str(pool, s), solvable2str(pool, sd));
gotone = 1;
}
if (!solv->allowarchchange && s->name == sd->name && s->arch != sd->arch && policy_illegal_archchange(solv, s, sd))
{
- POOL_DEBUG(SAT_DEBUG_RESULT, "- allow architecture change of %s to %s\n", solvable2str(pool, s), solvable2str(pool, sd));
+ POOL_DEBUG(SAT_DEBUG_RESULT, " - allow architecture change of %s to %s\n", solvable2str(pool, s), solvable2str(pool, sd));
gotone = 1;
}
if (!solv->allowvendorchange && s->name == sd->name && s->vendor != sd->vendor && policy_illegal_vendorchange(solv, s, sd))
{
if (sd->vendor)
- POOL_DEBUG(SAT_DEBUG_RESULT, "- allow vendor change from '%s' (%s) to '%s' (%s)\n", id2str(pool, s->vendor), solvable2str(pool, s), id2str(pool, sd->vendor), solvable2str(pool, sd));
+ POOL_DEBUG(SAT_DEBUG_RESULT, " - allow vendor change from '%s' (%s) to '%s' (%s)\n", id2str(pool, s->vendor), solvable2str(pool, s), id2str(pool, sd->vendor), solvable2str(pool, sd));
else
- POOL_DEBUG(SAT_DEBUG_RESULT, "- allow vendor change from '%s' (%s) to no vendor (%s)\n", id2str(pool, s->vendor), solvable2str(pool, s), solvable2str(pool, sd));
+ POOL_DEBUG(SAT_DEBUG_RESULT, " - allow vendor change from '%s' (%s) to no vendor (%s)\n", id2str(pool, s->vendor), solvable2str(pool, s), solvable2str(pool, sd));
gotone = 1;
}
if (!gotone)
- POOL_DEBUG(SAT_DEBUG_RESULT, "- allow replacement of %s with %s\n", solvable2str(pool, s), solvable2str(pool, sd));
+ POOL_DEBUG(SAT_DEBUG_RESULT, " - allow replacement of %s with %s\n", solvable2str(pool, s), solvable2str(pool, sd));
}
else
{
- POOL_DEBUG(SAT_DEBUG_RESULT, "- allow deinstallation of %s\n", solvable2str(pool, s));
+ POOL_DEBUG(SAT_DEBUG_RESULT, " - allow deinstallation of %s\n", solvable2str(pool, s));
}
}
--
To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org
For additional commands, e-mail: zypp-commit+help@opensuse.org