Zypp Commits
Threads by month
- ----- 2024 -----
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
June 2009
- 5 participants
- 171 discussions
[zypp-commit] <sat-solver> master : A _count is an unsigned int, not an Id
by Klaus Kämpf 22 Jun '09
by Klaus Kämpf 22 Jun '09
22 Jun '09
ref: refs/heads/master
commit 55e63f23cd016edbd6d45d57274ea1c69d85c7cc
Author: Klaus Kämpf <kkaempf(a)suse.de>
Date: Mon Jun 22 11:47:04 2009 +0200
A _count is an unsigned int, not an Id
---
src/problems.c | 6 +++---
src/problems.h | 6 +++---
2 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/src/problems.c b/src/problems.c
index 57bb545..ccdb54c 100644
--- a/src/problems.c
+++ b/src/problems.c
@@ -606,7 +606,7 @@ create_solutions(Solver *solv, int probnr, int solidx)
/**************************************************************************/
-Id
+unsigned int
solver_problem_count(Solver *solv)
{
return solv->problems.count / 2;
@@ -620,7 +620,7 @@ solver_next_problem(Solver *solv, Id problem)
return (problem + 1) * 2 - 1 < solv->problems.count ? problem + 1 : 0;
}
-Id
+unsigned int
solver_solution_count(Solver *solv, Id problem)
{
Id solidx = solv->problems.elements[problem * 2 - 1];
@@ -638,7 +638,7 @@ solver_next_solution(Solver *solv, Id problem, Id solution)
return solv->solutions.elements[solidx + solution + 1] ? solution + 1 : 0;
}
-Id
+unsigned int
solver_solutionelement_count(Solver *solv, Id problem, Id solution)
{
Id solidx = solv->problems.elements[problem * 2 - 1];
diff --git a/src/problems.h b/src/problems.h
index b2ed55b..fc9ac18 100644
--- a/src/problems.h
+++ b/src/problems.h
@@ -28,11 +28,11 @@ void solver_disableproblem(struct _Solver *solv, Id v);
void solver_enableproblem(struct _Solver *solv, Id v);
int solver_prepare_solutions(struct _Solver *solv);
-Id solver_problem_count(struct _Solver *solv);
+unsigned int solver_problem_count(struct _Solver *solv);
Id solver_next_problem(struct _Solver *solv, Id problem);
-Id solver_solution_count(struct _Solver *solv, Id problem);
+unsigned int solver_solution_count(struct _Solver *solv, Id problem);
Id solver_next_solution(struct _Solver *solv, Id problem, Id solution);
-Id solver_solutionelement_count(struct _Solver *solv, Id problem, Id solution);
+unsigned int solver_solutionelement_count(struct _Solver *solv, Id problem, Id solution);
Id solver_next_solutionelement(struct _Solver *solv, Id problem, Id solution, Id element, Id *p, Id *rp);
void solver_take_solutionelement(struct _Solver *solv, Id p, Id rp, Queue *job);
--
To unsubscribe, e-mail: zypp-commit+unsubscribe(a)opensuse.org
For additional commands, e-mail: zypp-commit+help(a)opensuse.org
1
0
22 Jun '09
ref: refs/heads/master
commit 999f54c0ad876830176f376f60d0770121a7e13b
Author: Michael Schroeder <mls(a)suse.de>
Date: Mon Jun 22 11:25:45 2009 +0200
- add rpm_installedrpmdbids
- fix memleaks
---
tools/pool_fileconflicts.c | 37 +++++++++---
tools/repo_rpmdb.c | 140 +++++++++++++++++++++++++++++++++++++++-----
tools/repo_rpmdb.h | 5 +-
3 files changed, 158 insertions(+), 24 deletions(-)
diff --git a/tools/pool_fileconflicts.c b/tools/pool_fileconflicts.c
index e14d5c4..1858df4 100644
--- a/tools/pool_fileconflicts.c
+++ b/tools/pool_fileconflicts.c
@@ -21,6 +21,9 @@ struct cbdata {
Hashval *dirmap;
Hashmask dirmapn;
unsigned int dirmapused;
+ int dirconflicts;
+
+ Map idxmap;
Hashval idx;
unsigned int hx;
@@ -64,7 +67,7 @@ doublehash(Hashval *map, Hashmask *mapnp)
}
static void
-finddirs_cb(void *cbdatav, char *fn, int fmode, char *md5)
+finddirs_cb(void *cbdatav, const char *fn, int fmode, const char *md5)
{
struct cbdata *cbdata = cbdatav;
Hashmask h, hh, hx, qx;
@@ -99,7 +102,12 @@ finddirs_cb(void *cbdatav, char *fn, int fmode, char *md5)
if (cbdata->dirmap[2 * h + 1] == idx)
return;
/* found a conflict, this dir is used in multiple packages */
- cbdata->dirmap[2 * h + 1] = -1;
+ if (cbdata->dirmap[2 * h + 1] != -1)
+ {
+ cbdata->dirmap[2 * h + 1] = -1;
+ cbdata->dirconflicts++;
+ }
+ MAPSET(&cbdata->idxmap, idx);
}
static inline int
@@ -121,7 +129,7 @@ isindirmap(struct cbdata *cbdata, Hashmask hx)
}
static void
-findfileconflicts_cb(void *cbdatav, char *fn, int fmode, char *md5)
+findfileconflicts_cb(void *cbdatav, const char *fn, int fmode, const char *md5)
{
struct cbdata *cbdata = cbdatav;
int isdir = S_ISDIR(fmode);
@@ -201,7 +209,7 @@ addfilesspace(struct cbdata *cbdata, unsigned char *data, int len)
}
static void
-findfileconflicts2_cb(void *cbdatav, char *fn, int fmode, char *md5)
+findfileconflicts2_cb(void *cbdatav, const char *fn, int fmode, const char *md5)
{
struct cbdata *cbdata = cbdatav;
unsigned int hx = strhash(fn);
@@ -250,11 +258,12 @@ static int conflicts_cmp(const void *ap, const void *bp, void *dp)
int
pool_findfileconflicts(Pool *pool, Queue *pkgs, int cutoff, Queue *conflicts, void *(*handle_cb)(Pool *, Id, void *) , void *handle_cbdata)
{
- int i, j, cflmapn;
+ int i, j, cflmapn, idxmapset;
unsigned int hx;
struct cbdata cbdata;
unsigned int now, start;
void *handle;
+ Id p;
queue_empty(conflicts);
if (!pkgs->count)
@@ -269,6 +278,8 @@ pool_findfileconflicts(Pool *pool, Queue *pkgs, int cutoff, Queue *conflicts, vo
queue_init(&cbdata.lookat);
queue_init(&cbdata.lookat_dir);
queue_init(&cbdata.files);
+ map_init(&cbdata.idxmap, pkgs->count);
+
if (cutoff <= 0)
cutoff = pkgs->count;
@@ -282,20 +293,24 @@ pool_findfileconflicts(Pool *pool, Queue *pkgs, int cutoff, Queue *conflicts, vo
cbdata.dirmap = sat_calloc(cflmapn, 2 * sizeof(Id));
cbdata.dirmapn = cflmapn - 1; /* make it a mask */
cbdata.create = 1;
+ idxmapset = 0;
for (i = 0; i < pkgs->count; i++)
{
- Id p = pkgs->elements[i];
+ p = pkgs->elements[i];
cbdata.idx = i;
if (i == cutoff)
cbdata.create = 0;
handle = (*handle_cb)(pool, p, handle_cbdata);
if (handle)
rpm_iterate_filelist(handle, RPM_ITERATE_FILELIST_ONLYDIRS, finddirs_cb, &cbdata);
+ if (MAPTST(&cbdata.idxmap, i))
+ idxmapset++;
}
POOL_DEBUG(SAT_DEBUG_STATS, "dirmap size: %d used %d\n", cbdata.dirmapn + 1, cbdata.dirmapused);
POOL_DEBUG(SAT_DEBUG_STATS, "dirmap memory usage: %d K\n", (cbdata.dirmapn + 1) * 2 * (int)sizeof(Id) / 1024);
POOL_DEBUG(SAT_DEBUG_STATS, "dirmap creation took %d ms\n", sat_timems(now));
+ POOL_DEBUG(SAT_DEBUG_STATS, "dir conflicts found: %d, idxmap %d of %d\n", cbdata.dirconflicts, idxmapset, pkgs->count);
/* second pass: scan files */
now = sat_timems(0);
@@ -307,7 +322,9 @@ pool_findfileconflicts(Pool *pool, Queue *pkgs, int cutoff, Queue *conflicts, vo
cbdata.create = 1;
for (i = 0; i < pkgs->count; i++)
{
- Id p = pkgs->elements[i];
+ if (!MAPTST(&cbdata.idxmap, i))
+ continue;
+ p = pkgs->elements[i];
cbdata.idx = i;
if (i == cutoff)
cbdata.create = 0;
@@ -326,6 +343,7 @@ pool_findfileconflicts(Pool *pool, Queue *pkgs, int cutoff, Queue *conflicts, vo
cbdata.cflmap = sat_free(cbdata.cflmap);
cbdata.cflmapn = 0;
cbdata.cflmapused = 0;
+ map_free(&cbdata.idxmap);
now = sat_timems(0);
POOL_DEBUG(SAT_DEBUG_STATS, "lookat_dir size: %d\n", cbdata.lookat_dir.count);
@@ -348,8 +366,7 @@ pool_findfileconflicts(Pool *pool, Queue *pkgs, int cutoff, Queue *conflicts, vo
{
int pend, ii, jj;
int pidx = cbdata.lookat.elements[i + 1];
- Id p = pkgs->elements[pidx];
-
+ p = pkgs->elements[pidx];
hx = cbdata.lookat.elements[i];
if (cbdata.lookat.elements[i + 2] != hx)
continue; /* no package left */
@@ -393,6 +410,8 @@ pool_findfileconflicts(Pool *pool, Queue *pkgs, int cutoff, Queue *conflicts, vo
}
cbdata.filesspace = sat_free(cbdata.filesspace);
cbdata.filesspacen = 0;
+ queue_free(&cbdata.lookat);
+ queue_free(&cbdata.files);
POOL_DEBUG(SAT_DEBUG_STATS, "candidate check took %d ms\n", sat_timems(now));
if (conflicts->count > 5)
sat_sort(conflicts->elements, conflicts->count / 5, 5 * sizeof(Id), conflicts_cmp, pool);
diff --git a/tools/repo_rpmdb.c b/tools/repo_rpmdb.c
index ddb6b68..826fa13 100644
--- a/tools/repo_rpmdb.c
+++ b/tools/repo_rpmdb.c
@@ -32,6 +32,7 @@
#include "repo.h"
#include "hash.h"
#include "util.h"
+#include "queue.h"
#include "repo_rpmdb.h"
#define RPMDB_COOKIE_VERSION 2
@@ -977,6 +978,8 @@ copydeps(Pool *pool, Repo *repo, Offset fromoff, Repo *fromrepo)
return ido;
}
+#define COPYDIR_DIRCACHE_SIZE 512
+
static Id copydir_complex(Pool *pool, Repodata *data, Stringpool *fromspool, Repodata *fromdata, Id did, Id *cache);
static inline Id
@@ -1201,7 +1204,7 @@ count_headers(const char *rootdir, DB_ENV *dbenv)
}
if (db->open(db, 0, "Name", 0, DB_UNKNOWN, DB_RDONLY, 0664))
{
- perror("db->open var/lib/rpm/Name");
+ perror("db->open Name index");
exit(1);
}
if (db->get_byteswapped(db, &byteswapped))
@@ -1287,11 +1290,6 @@ repo_add_rpmdb(Repo *repo, Repo *ref, const char *rootdir, int flags)
perror("dbenv open");
exit(1);
}
- if (db_create(&db, dbenv, 0))
- {
- perror("db_create");
- exit(1);
- }
/* XXX: should get ro lock of Packages database! */
snprintf(dbpath, PATH_MAX, "%s/var/lib/rpm/Packages", rootdir);
@@ -1311,9 +1309,14 @@ repo_add_rpmdb(Repo *repo, Repo *ref, const char *rootdir, int flags)
if ((flags & RPMDB_REPORT_PROGRESS) != 0)
count = count_headers(rootdir, dbenv);
+ if (db_create(&db, dbenv, 0))
+ {
+ perror("db_create");
+ exit(1);
+ }
if (db->open(db, 0, "Packages", 0, DB_UNKNOWN, DB_RDONLY, 0664))
{
- perror("db->open var/lib/rpm/Packages");
+ perror("db->open Packages index");
exit(1);
}
if (db->get_byteswapped(db, &byteswapped))
@@ -1425,12 +1428,17 @@ repo_add_rpmdb(Repo *repo, Repo *ref, const char *rootdir, int flags)
}
else
{
- Id dircache[512];
+ Id dircache[COPYDIR_DIRCACHE_SIZE]; /* see copydir */
memset(dircache, 0, sizeof(dircache));
+ if (db_create(&db, dbenv, 0))
+ {
+ perror("db_create");
+ exit(1);
+ }
if (db->open(db, 0, "Name", 0, DB_UNKNOWN, DB_RDONLY, 0664))
{
- perror("db->open var/lib/rpm/Name");
+ perror("db->open Name index");
exit(1);
}
if (db->get_byteswapped(db, &byteswapped))
@@ -1804,14 +1812,16 @@ linkhash(const char *lt, char *hash)
}
void
-rpm_iterate_filelist(void *rpmhandle, int flags, void (*cb)(void *, char *, int, char *), void *cbdata)
+rpm_iterate_filelist(void *rpmhandle, int flags, void (*cb)(void *, const char *, int, const char *), void *cbdata)
{
RpmHead *rpmhead = rpmhandle;
char **bn;
char **dn;
char **md = 0;
char **lt = 0;
- unsigned int *di;
+ unsigned int *di, diidx;
+ unsigned int lastdir;
+ int lastdirl;
unsigned int *fm;
int cnt, dcnt, cnt2;
int i, l1, l;
@@ -1865,11 +1875,14 @@ rpm_iterate_filelist(void *rpmhandle, int flags, void (*cb)(void *, char *, int,
return;
}
}
+ lastdir = dcnt;
+ lastdirl = 0;
for (i = 0; i < cnt; i++)
{
- if (di[i] >= dcnt)
+ diidx = di[i];
+ if (diidx >= dcnt)
continue;
- l1 = strlen(dn[di[i]]);
+ l1 = lastdir == diidx ? lastdirl : strlen(dn[diidx]);
if (l1 == 0)
continue;
l = l1 + strlen(bn[i]) + 1;
@@ -1878,7 +1891,12 @@ rpm_iterate_filelist(void *rpmhandle, int flags, void (*cb)(void *, char *, int,
spacen = l + 16;
space = sat_realloc(space, spacen);
}
- strcpy(space, dn[di[i]]);
+ if (lastdir != diidx)
+ {
+ strcpy(space, dn[diidx]);
+ lastdir = diidx;
+ lastdirl = l1;
+ }
strcpy(space + l1, bn[i]);
if (md)
{
@@ -1903,6 +1921,7 @@ rpm_iterate_filelist(void *rpmhandle, int flags, void (*cb)(void *, char *, int,
}
(*cb)(cbdata, space, fm[i], md5p);
}
+ sat_free(space);
sat_free(lt);
sat_free(md);
sat_free(fm);
@@ -1922,6 +1941,99 @@ struct rpm_by_state {
int byteswapped;
};
+int
+rpm_installedrpmdbids(const char *rootdir, Queue *rpmdbidq)
+{
+ char dbpath[PATH_MAX];
+ DB_ENV *dbenv = 0;
+ DB *db = 0;
+ DBC *dbc = 0;
+ int byteswapped;
+ DBT dbkey;
+ DBT dbdata;
+ Id rpmdbid;
+ unsigned char *dp;
+ int dl, cnt;
+
+ if (rpmdbidq)
+ queue_empty(rpmdbidq);
+ cnt = 0;
+
+ if (db_env_create(&dbenv, 0))
+ {
+ perror("db_env_create");
+ return 0;
+ }
+ snprintf(dbpath, PATH_MAX, "%s/var/lib/rpm", rootdir ? rootdir : "");
+#ifdef FEDORA
+ if (dbenv->open(dbenv, dbpath, DB_CREATE|DB_INIT_CDB|DB_INIT_MPOOL, 0))
+#else
+ if (dbenv->open(dbenv, dbpath, DB_CREATE|DB_PRIVATE|DB_INIT_MPOOL, 0))
+#endif
+ {
+ perror("dbenv open");
+ dbenv->close(dbenv, 0);
+ return 0;
+ }
+ if (db_create(&db, dbenv, 0))
+ {
+ perror("db_create");
+ dbenv->close(dbenv, 0);
+ return 0;
+ }
+ if (db->open(db, 0, "Name", 0, DB_UNKNOWN, DB_RDONLY, 0664))
+ {
+ perror("db->open Name index");
+ db->close(db, 0);
+ dbenv->close(dbenv, 0);
+ return 0;
+ }
+ if (db->get_byteswapped(db, &byteswapped))
+ {
+ perror("db->get_byteswapped");
+ db->close(db, 0);
+ dbenv->close(dbenv, 0);
+ return 0;
+ }
+ if (db->cursor(db, NULL, &dbc, 0))
+ {
+ perror("db->cursor");
+ db->close(db, 0);
+ dbenv->close(dbenv, 0);
+ return 0;
+ }
+ memset(&dbkey, 0, sizeof(dbkey));
+ memset(&dbdata, 0, sizeof(dbdata));
+ while (dbc->c_get(dbc, &dbkey, &dbdata, DB_NEXT) == 0)
+ {
+ if (dbkey.size == 10 && !memcmp(dbkey.data, "gpg-pubkey", 10))
+ continue;
+ dl = dbdata.size;
+ dp = dbdata.data;
+ while(dl >= 8)
+ {
+ if (byteswapped)
+ {
+ ((char *)&rpmdbid)[0] = dp[3];
+ ((char *)&rpmdbid)[1] = dp[2];
+ ((char *)&rpmdbid)[2] = dp[1];
+ ((char *)&rpmdbid)[3] = dp[0];
+ }
+ else
+ memcpy((char *)&rpmdbid, dp, 4);
+ if (rpmdbidq)
+ queue_push(rpmdbidq, rpmdbid);
+ cnt++;
+ dp += 8;
+ dl -= 8;
+ }
+ }
+ dbc->c_close(dbc);
+ db->close(db, 0);
+ dbenv->close(dbenv, 0);
+ return cnt;
+}
+
void *
rpm_byrpmdbid(Id rpmdbid, const char *rootdir, void **statep)
{
diff --git a/tools/repo_rpmdb.h b/tools/repo_rpmdb.h
index 6c907c7..3e80302 100644
--- a/tools/repo_rpmdb.h
+++ b/tools/repo_rpmdb.h
@@ -5,6 +5,8 @@
* for further information
*/
+#include "queue.h"
+
extern void repo_add_rpmdb(Repo *repo, Repo *ref, const char *rootdir, int flags);
extern void repo_add_rpms(Repo *repo, const char **rpms, int nrpms, int flags);
@@ -15,4 +17,5 @@ extern void repo_add_rpms(Repo *repo, const char **rpms, int nrpms, int flags);
void *rpm_byrpmdbid(Id rpmdbid, const char *rootdir, void **statep);
void *rpm_byfp(FILE *fp, const char *name, void **statep);
-void rpm_iterate_filelist(void *rpmhandle, int flags, void (*cb)(void *, char *, int, char *), void *cbdata);
+void rpm_iterate_filelist(void *rpmhandle, int flags, void (*cb)(void *, const char *, int, const char *), void *cbdata);
+int rpm_installedrpmdbids(const char *rootdir, Queue *rpmdbidq);
--
To unsubscribe, e-mail: zypp-commit+unsubscribe(a)opensuse.org
For additional commands, e-mail: zypp-commit+help(a)opensuse.org
1
0
20 Jun '09
ref: refs/heads/master
commit 0957c5406b4fed11fa1143d9e382226596476ed0
Author: Michael Schroeder <mls(a)suse.de>
Date: Sat Jun 20 14:39:52 2009 +0200
- make debug output better
---
tools/findfileconflicts.c | 5 +++++
tools/pool_fileconflicts.c | 4 +++-
2 files changed, 8 insertions(+), 1 deletions(-)
diff --git a/tools/findfileconflicts.c b/tools/findfileconflicts.c
index 4bd41d6..a7286ab 100644
--- a/tools/findfileconflicts.c
+++ b/tools/findfileconflicts.c
@@ -61,9 +61,14 @@ int main()
pool_setdebuglevel(pool, 0);
Solver *solv = solver_create(pool);
solv->fixsystem = 1;
+#if 0
+ solv->allowuninstall = 1;
+#endif
solver_solve(solv, &job);
if (solv->problems.count)
solver_printallsolutions(solv);
+ else
+ solver_printtransaction(solv);
queue_free(&job);
solver_free(solv);
}
diff --git a/tools/pool_fileconflicts.c b/tools/pool_fileconflicts.c
index 8e48d32..e14d5c4 100644
--- a/tools/pool_fileconflicts.c
+++ b/tools/pool_fileconflicts.c
@@ -261,6 +261,7 @@ pool_findfileconflicts(Pool *pool, Queue *pkgs, int cutoff, Queue *conflicts, vo
return 0;
now = start = sat_timems(0);
+ POOL_DEBUG(SAT_DEBUG_STATS, "searching for file conflicts\n");
POOL_DEBUG(SAT_DEBUG_STATS, "packages: %d, cutoff %d\n", pkgs->count, cutoff);
memset(&cbdata, 0, sizeof(cbdata));
@@ -396,7 +397,8 @@ pool_findfileconflicts(Pool *pool, Queue *pkgs, int cutoff, Queue *conflicts, vo
if (conflicts->count > 5)
sat_sort(conflicts->elements, conflicts->count / 5, 5 * sizeof(Id), conflicts_cmp, pool);
(*handle_cb)(pool, 0, handle_cbdata);
- POOL_DEBUG(SAT_DEBUG_STATS, "conflict detection took %d ms\n", sat_timems(start));
+ POOL_DEBUG(SAT_DEBUG_STATS, "found %d file conflicts\n", conflicts->count / 5);
+ POOL_DEBUG(SAT_DEBUG_STATS, "file conflict detection took %d ms\n", sat_timems(start));
return conflicts->count;
}
--
To unsubscribe, e-mail: zypp-commit+unsubscribe(a)opensuse.org
For additional commands, e-mail: zypp-commit+help(a)opensuse.org
1
0
[zypp-commit] <sat-solver> master : - add support for cutoff argument in file conflict checker
by Michael Schroeder 20 Jun '09
by Michael Schroeder 20 Jun '09
20 Jun '09
ref: refs/heads/master
commit 3ced6e058b6cf193ab2ee7e1540ea83afe07114e
Author: Michael Schroeder <mls(a)suse.de>
Date: Sat Jun 20 14:08:55 2009 +0200
- add support for cutoff argument in file conflict checker
---
src/pool.c | 3 +-
src/pool.h | 2 +
tools/findfileconflicts.c | 3 +-
tools/pool_fileconflicts.c | 62 +++++++++++++++++++++++++++++---------------
tools/pool_fileconflicts.h | 2 +-
5 files changed, 48 insertions(+), 24 deletions(-)
diff --git a/src/pool.c b/src/pool.c
index 4fa4e25..ec87a4b 100644
--- a/src/pool.c
+++ b/src/pool.c
@@ -751,7 +751,7 @@ pool_debug(Pool *pool, int type, const char *format, ...)
va_start(args, format);
if (!pool->debugcallback)
{
- if ((type & (SAT_FATAL|SAT_ERROR)) == 0)
+ if ((type & (SAT_FATAL|SAT_ERROR)) == 0 || !(pool->debugmask & SAT_DEBUG_TO_STDERR))
vprintf(format, args);
else
vfprintf(stderr, format, args);
@@ -775,6 +775,7 @@ pool_setdebuglevel(Pool *pool, int level)
mask |= SAT_DEBUG_RULE_CREATION;
if (level > 4)
mask |= SAT_DEBUG_SCHUBI;
+ mask |= pool->debugmask & SAT_DEBUG_TO_STDERR; /* keep bit */
pool->debugmask = mask;
}
diff --git a/src/pool.h b/src/pool.h
index e985211..e8b0fe0 100644
--- a/src/pool.h
+++ b/src/pool.h
@@ -135,6 +135,8 @@ struct _Pool {
#define SAT_DEBUG_SOLVER (1<<13)
#define SAT_DEBUG_TRANSACTION (1<<14)
+#define SAT_DEBUG_TO_STDERR (1<<30)
+
//-----------------------------------------------
diff --git a/tools/findfileconflicts.c b/tools/findfileconflicts.c
index 88833d5..4bd41d6 100644
--- a/tools/findfileconflicts.c
+++ b/tools/findfileconflicts.c
@@ -39,6 +39,7 @@ int main()
void *state = 0;
pool = pool_create();
+ pool_setdebuglevel(pool, 1);
installed = repo_create(pool, "@System");
pool_set_installed(pool, installed);
repo_add_rpmdb(installed, 0, 0, 0);
@@ -46,7 +47,7 @@ int main()
queue_init(&conflicts);
FOR_REPO_SOLVABLES(installed, p, s)
queue_push(&todo, p);
- pool_findfileconflicts(pool, &todo, &conflicts, &iterate_handle, (void *)&state);
+ pool_findfileconflicts(pool, &todo, 0, &conflicts, &iterate_handle, (void *)&state);
queue_free(&todo);
for (i = 0; i < conflicts.count; i += 5)
printf("%s: %s[%s] %s[%s]\n", id2str(pool, conflicts.elements[i]), solvid2str(pool, conflicts.elements[i + 1]), id2str(pool, conflicts.elements[i + 2]), solvid2str(pool, conflicts.elements[i + 3]), id2str(pool, conflicts.elements[i + 4]));
diff --git a/tools/pool_fileconflicts.c b/tools/pool_fileconflicts.c
index 5b1c4a0..8e48d32 100644
--- a/tools/pool_fileconflicts.c
+++ b/tools/pool_fileconflicts.c
@@ -5,9 +5,12 @@
#include "repo.h"
#include "hash.h"
#include "repo_rpmdb.h"
+#include "pool_fileconflicts.h"
struct cbdata {
Pool *pool;
+ int create;
+
Queue lookat;
Queue lookat_dir;
@@ -84,6 +87,8 @@ finddirs_cb(void *cbdatav, char *fn, int fmode, char *md5)
if (!qx)
{
/* a miss */
+ if (!cbdata->create)
+ return;
cbdata->dirmap[2 * h] = hx;
cbdata->dirmap[2 * h + 1] = idx;
cbdata->dirmapused++;
@@ -154,6 +159,9 @@ findfileconflicts_cb(void *cbdatav, char *fn, int fmode, char *md5)
}
if (!qx)
{
+ /* a miss */
+ if (!cbdata->create)
+ return;
cbdata->cflmap[2 * h] = hx;
cbdata->cflmap[2 * h + 1] = (isdir ? ~idx : idx);
cbdata->cflmapused++;
@@ -240,7 +248,7 @@ static int conflicts_cmp(const void *ap, const void *bp, void *dp)
}
int
-pool_findfileconflicts(Pool *pool, Queue *pkgs, Queue *conflicts, void *(*handle_cb)(Pool *, Id, void *) , void *handle_cbdata)
+pool_findfileconflicts(Pool *pool, Queue *pkgs, int cutoff, Queue *conflicts, void *(*handle_cb)(Pool *, Id, void *) , void *handle_cbdata)
{
int i, j, cflmapn;
unsigned int hx;
@@ -253,55 +261,63 @@ pool_findfileconflicts(Pool *pool, Queue *pkgs, Queue *conflicts, void *(*handle
return 0;
now = start = sat_timems(0);
- printf("packages: %d\n", pkgs->count);
+ POOL_DEBUG(SAT_DEBUG_STATS, "packages: %d, cutoff %d\n", pkgs->count, cutoff);
memset(&cbdata, 0, sizeof(cbdata));
cbdata.pool = pool;
queue_init(&cbdata.lookat);
queue_init(&cbdata.lookat_dir);
queue_init(&cbdata.files);
+ if (cutoff <= 0)
+ cutoff = pkgs->count;
/* avarage file list size: 200 files per package */
/* avarage dir count: 20 dirs per package */
/* first pass: scan dirs */
- cflmapn = pkgs->count * 64;
+ cflmapn = (cutoff + 3) * 64;
while ((cflmapn & (cflmapn - 1)) != 0)
cflmapn = cflmapn & (cflmapn - 1);
cbdata.dirmap = sat_calloc(cflmapn, 2 * sizeof(Id));
cbdata.dirmapn = cflmapn - 1; /* make it a mask */
+ cbdata.create = 1;
for (i = 0; i < pkgs->count; i++)
{
Id p = pkgs->elements[i];
- cbdata.idx = p;
+ cbdata.idx = i;
+ if (i == cutoff)
+ cbdata.create = 0;
handle = (*handle_cb)(pool, p, handle_cbdata);
if (handle)
rpm_iterate_filelist(handle, RPM_ITERATE_FILELIST_ONLYDIRS, finddirs_cb, &cbdata);
}
- printf("dirmap size: %d used %d\n", cbdata.dirmapn + 1, cbdata.dirmapused);
- printf("dirmap memory usage: %d K\n", (cbdata.dirmapn + 1) * 2 * (int)sizeof(Id) / 1024);
- printf("dirmap creation took %d ms\n", sat_timems(now));
+ POOL_DEBUG(SAT_DEBUG_STATS, "dirmap size: %d used %d\n", cbdata.dirmapn + 1, cbdata.dirmapused);
+ POOL_DEBUG(SAT_DEBUG_STATS, "dirmap memory usage: %d K\n", (cbdata.dirmapn + 1) * 2 * (int)sizeof(Id) / 1024);
+ POOL_DEBUG(SAT_DEBUG_STATS, "dirmap creation took %d ms\n", sat_timems(now));
/* second pass: scan files */
now = sat_timems(0);
- cflmapn = pkgs->count * 128;
+ cflmapn = (cutoff + 3) * 128;
while ((cflmapn & (cflmapn - 1)) != 0)
cflmapn = cflmapn & (cflmapn - 1);
cbdata.cflmap = sat_calloc(cflmapn, 2 * sizeof(Id));
cbdata.cflmapn = cflmapn - 1; /* make it a mask */
+ cbdata.create = 1;
for (i = 0; i < pkgs->count; i++)
{
Id p = pkgs->elements[i];
- cbdata.idx = p;
+ cbdata.idx = i;
+ if (i == cutoff)
+ cbdata.create = 0;
handle = (*handle_cb)(pool, p, handle_cbdata);
if (handle)
rpm_iterate_filelist(handle, 0, findfileconflicts_cb, &cbdata);
}
- printf("filemap size: %d used %d\n", cbdata.cflmapn + 1, cbdata.cflmapused);
- printf("filemap memory usage: %d K\n", (cbdata.cflmapn + 1) * 2 * (int)sizeof(Id) / 1024);
- printf("filemap creation took %d ms\n", sat_timems(now));
+ POOL_DEBUG(SAT_DEBUG_STATS, "filemap size: %d used %d\n", cbdata.cflmapn + 1, cbdata.cflmapused);
+ POOL_DEBUG(SAT_DEBUG_STATS, "filemap memory usage: %d K\n", (cbdata.cflmapn + 1) * 2 * (int)sizeof(Id) / 1024);
+ POOL_DEBUG(SAT_DEBUG_STATS, "filemap creation took %d ms\n", sat_timems(now));
cbdata.dirmap = sat_free(cbdata.dirmap);
cbdata.dirmapn = 0;
@@ -311,26 +327,27 @@ pool_findfileconflicts(Pool *pool, Queue *pkgs, Queue *conflicts, void *(*handle
cbdata.cflmapused = 0;
now = sat_timems(0);
- printf("lookat_dir size: %d\n", cbdata.lookat_dir.count);
+ POOL_DEBUG(SAT_DEBUG_STATS, "lookat_dir size: %d\n", cbdata.lookat_dir.count);
queue_free(&cbdata.lookat_dir);
sat_sort(cbdata.lookat.elements, cbdata.lookat.count / 2, sizeof(Id) * 2, &cand_sort, pool);
/* unify */
for (i = j = 0; i < cbdata.lookat.count; i += 2)
{
hx = cbdata.lookat.elements[i];
- Id p = cbdata.lookat.elements[i + 1];
- if (j && hx == cbdata.lookat.elements[j - 2] && p == cbdata.lookat.elements[j - 1])
+ Id idx = cbdata.lookat.elements[i + 1];
+ if (j && hx == cbdata.lookat.elements[j - 2] && idx == cbdata.lookat.elements[j - 1])
continue;
cbdata.lookat.elements[j++] = hx;
- cbdata.lookat.elements[j++] = p;
+ cbdata.lookat.elements[j++] = idx;
}
- printf("candidates: %d\n", cbdata.lookat.count / 2);
+ POOL_DEBUG(SAT_DEBUG_STATS, "candidates: %d\n", cbdata.lookat.count / 2);
/* third pass: scan candidates */
for (i = 0; i < cbdata.lookat.count - 2; i += 2)
{
int pend, ii, jj;
- Id p = cbdata.lookat.elements[i + 1];
+ int pidx = cbdata.lookat.elements[i + 1];
+ Id p = pkgs->elements[pidx];
hx = cbdata.lookat.elements[i];
if (cbdata.lookat.elements[i + 2] != hx)
@@ -349,7 +366,10 @@ pool_findfileconflicts(Pool *pool, Queue *pkgs, Queue *conflicts, void *(*handle
pend = cbdata.files.count;
for (j = i + 2; j < cbdata.lookat.count && cbdata.lookat.elements[j] == hx; j++)
{
- Id q = cbdata.lookat.elements[j + 1];
+ int qidx = cbdata.lookat.elements[j + 1];
+ Id q = pkgs->elements[qidx];
+ if (pidx >= cutoff && qidx >= cutoff)
+ continue; /* no conflicts between packages with idx >= cutoff */
cbdata.idx = q;
handle = (*handle_cb)(pool, q, handle_cbdata);
if (!handle)
@@ -372,11 +392,11 @@ pool_findfileconflicts(Pool *pool, Queue *pkgs, Queue *conflicts, void *(*handle
}
cbdata.filesspace = sat_free(cbdata.filesspace);
cbdata.filesspacen = 0;
- printf("candidate check took %d ms\n", sat_timems(now));
+ POOL_DEBUG(SAT_DEBUG_STATS, "candidate check took %d ms\n", sat_timems(now));
if (conflicts->count > 5)
sat_sort(conflicts->elements, conflicts->count / 5, 5 * sizeof(Id), conflicts_cmp, pool);
(*handle_cb)(pool, 0, handle_cbdata);
- printf("conflict detection took %d ms\n", sat_timems(start));
+ POOL_DEBUG(SAT_DEBUG_STATS, "conflict detection took %d ms\n", sat_timems(start));
return conflicts->count;
}
diff --git a/tools/pool_fileconflicts.h b/tools/pool_fileconflicts.h
index cb080f2..f1c2282 100644
--- a/tools/pool_fileconflicts.h
+++ b/tools/pool_fileconflicts.h
@@ -3,6 +3,6 @@
#include "pool.h"
-extern int pool_findfileconflicts(Pool *pool, Queue *pkgs, Queue *conflicts, void *(*handle_cb)(Pool *, Id, void *) , void *handle_cbdata);
+extern int pool_findfileconflicts(Pool *pool, Queue *pkgs, int cutoff, Queue *conflicts, void *(*handle_cb)(Pool *, Id, void *) , void *handle_cbdata);
#endif
--
To unsubscribe, e-mail: zypp-commit+unsubscribe(a)opensuse.org
For additional commands, e-mail: zypp-commit+help(a)opensuse.org
1
0
[zypp-commit] <sat-solver> master : - clean up ugly products handling
by Michael Schroeder 20 Jun '09
by Michael Schroeder 20 Jun '09
20 Jun '09
ref: refs/heads/master
commit 74b7ef329450d67ddb6bcffd206383deba9fef57
Author: Michael Schroeder <mls(a)suse.de>
Date: Sat Jun 20 13:04:36 2009 +0200
- clean up ugly products handling
---
tools/CMakeLists.txt | 1 +
tools/repo_products.c | 270 +++++++++++++------------------------
tools/repo_products.h | 3 +-
tools/repo_releasefile_products.c | 156 +++++++++++++++++++++
tools/repo_releasefile_products.h | 8 +
tools/repo_zyppdb.c | 69 +++++-----
tools/repo_zyppdb.h | 2 +-
tools/rpmdb2solv.c | 2 +-
8 files changed, 296 insertions(+), 215 deletions(-)
diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt
index 741bb10..576dae4 100644
--- a/tools/CMakeLists.txt
+++ b/tools/CMakeLists.txt
@@ -10,6 +10,7 @@ SET(rpmdb2solv_REPOS
repo_rpmdb.c
repo_products.c
repo_zyppdb.c
+ repo_releasefile_products.c
)
ADD_EXECUTABLE( rpmdb2solv ${rpmdb2solv_REPOS} )
diff --git a/tools/repo_products.c b/tools/repo_products.c
index a974f71..5cdcc19 100644
--- a/tools/repo_products.c
+++ b/tools/repo_products.c
@@ -31,6 +31,7 @@
#include "tools_util.h"
#include "repo_content.h"
#include "repo_zyppdb.h"
+#include "repo_releasefile_products.h"
//#define DUMPOUT 0
@@ -385,7 +386,7 @@ characterData(void *userData, const XML_Char *s, int len)
*/
static void
-repo_add_product(struct parsedata *pd, FILE *fp, int code11)
+add_code11_product(struct parsedata *pd, FILE *fp)
{
char buf[BUFF_SIZE];
int l;
@@ -403,162 +404,101 @@ repo_add_product(struct parsedata *pd, FILE *fp, int code11)
pd->ctime = 0;
}
- if (code11)
- {
- XML_Parser parser = XML_ParserCreate(NULL);
- XML_SetUserData(parser, pd);
- XML_SetElementHandler(parser, startElement, endElement);
- XML_SetCharacterDataHandler(parser, characterData);
+ XML_Parser parser = XML_ParserCreate(NULL);
+ XML_SetUserData(parser, pd);
+ XML_SetElementHandler(parser, startElement, endElement);
+ XML_SetCharacterDataHandler(parser, characterData);
- for (;;)
- {
- l = fread(buf, 1, sizeof(buf), fp);
- if (XML_Parse(parser, buf, l, l == 0) == XML_STATUS_ERROR)
- {
- pool_debug(pd->pool, SAT_ERROR, "%s: %s at line %u:%u\n", pd->filename, XML_ErrorString(XML_GetErrorCode(parser)), (unsigned int)XML_GetCurrentLineNumber(parser), (unsigned int)XML_GetCurrentColumnNumber(parser));
- pool_debug(pd->pool, SAT_ERROR, "Skipping this product\n");
- XML_ParserFree(parser);
- return;
- }
- if (l == 0)
- break;
- }
- XML_ParserFree(parser);
- }
- else
+ for (;;)
{
- Id name = 0;
- Id arch = 0;
- Id version = 0;
- int lnum = 0; /* line number */
- char *ptr, *ptr1;
- /* parse /etc/<xyz>-release file */
- while (fgets(buf, sizeof(buf), fp))
- {
- /* remove trailing \n */
- int l = strlen(buf);
- if (*(buf + l - 1) == '\n')
- {
- --l;
- *(buf + l) = 0;
- }
- ++lnum;
-
- if (lnum == 1)
- {
- /* 1st line, <name> [(<arch>)] */
- ptr = strchr(buf, '(');
- if (ptr)
- {
- ptr1 = ptr - 1;
- *ptr++ = 0;
- }
- else
- ptr1 = buf + l - 1;
-
- /* track back until non-blank, non-digit */
- while (ptr1 > buf
- && (*ptr1 == ' ' || isdigit(*ptr1) || *ptr1 == '.'))
- --ptr1;
- *(++ptr1) = 0;
- name = str2id(pd->pool, join2("product", ":", buf), 1);
-
- if (ptr)
- {
- /* have arch */
- char *ptr1 = strchr(ptr, ')');
- if (ptr1)
- {
- *ptr1 = 0;
- /* downcase arch */
- ptr1 = ptr;
- while (*ptr1)
- {
- if (isupper(*ptr1)) *ptr1 = tolower(*ptr1);
- ++ptr1;
- }
- arch = str2id(pd->pool, ptr, 1);
- }
- }
- }
- else if (strncmp(buf, "VERSION", 7) == 0)
- {
- ptr = strchr(buf+7, '=');
- if (ptr)
- {
- while (*++ptr == ' ');
- version = makeevr(pd->pool, ptr);
- }
- }
- }
- if (name)
+ l = fread(buf, 1, sizeof(buf), fp);
+ if (XML_Parse(parser, buf, l, l == 0) == XML_STATUS_ERROR)
{
- Solvable *s = pd->solvable = pool_id2solvable(pd->pool, repo_add_solvable(pd->repo));
- s->name = name;
- if (version)
- s->evr = version;
- if (arch)
- s->arch = arch;
- if (s->arch != ARCH_SRC && s->arch != ARCH_NOSRC)
- s->provides = repo_addid_dep(pd->repo, s->provides, rel2id(pd->pool, s->name, s->evr, REL_EQ, 1), 0);
+ pool_debug(pd->pool, SAT_ERROR, "%s: %s at line %u:%u\n", pd->filename, XML_ErrorString(XML_GetErrorCode(parser)), (unsigned int)XML_GetCurrentLineNumber(parser), (unsigned int)XML_GetCurrentColumnNumber(parser));
+ pool_debug(pd->pool, SAT_ERROR, "skipping this product\n");
+ XML_ParserFree(parser);
+ return;
}
+ if (l == 0)
+ break;
}
+ XML_ParserFree(parser);
}
+void
+repo_add_code11_products(Repo *repo, const char *dirpath, int flags)
+{
+ Repodata *data;
+ struct parsedata pd;
+ struct stateswitch *sw;
+ DIR *dir;
+ int i;
-/*
- * parse dir looking for files ending in suffix
- */
+ if (!(flags & REPO_REUSE_REPODATA))
+ data = repo_add_repodata(repo, 0);
+ else
+ data = repo_last_repodata(repo);
-static void
-parse_dir(DIR *dir, const char *path, struct parsedata *pd, int code11)
-{
- struct dirent *entry;
- char *suffix = code11 ? ".prod" : "-release";
- int slen = code11 ? 5 : 8; /* strlen(".prod") : strlen("-release") */
- struct stat st;
+ memset(&pd, 0, sizeof(pd));
+ pd.repo = repo;
+ pd.pool = repo->pool;
+ pd.data = data;
+
+ pd.content = sat_malloc(256);
+ pd.acontent = 256;
- /* check for <productsdir>/baseproduct on code11 and remember its target inode */
- if (code11
- && stat(join2(path, "/", "baseproduct"), &st) == 0) /* follow symlink */
+ for (i = 0, sw = stateswitches; sw->from != NUMSTATES; i++, sw++)
{
- pd->baseproduct = st.st_ino;
+ if (!pd.swtab[sw->from])
+ pd.swtab[sw->from] = sw;
+ pd.sbtab[sw->to] = sw->from;
}
- else
- pd->baseproduct = 0;
- while ((entry = readdir(dir)))
+ dir = opendir(dirpath);
+ if (dir)
{
- int len;
- len = strlen(entry->d_name);
+ struct dirent *entry;
+ struct stat st;
+ char *fullpath;
- /* skip /etc/lsb-release, thats not a product per-se */
- if (!code11
- && strcmp(entry->d_name, "lsb-release") == 0)
- {
- continue;
- }
+ /* check for <productsdir>/baseproduct on code11 and remember its target inode */
+ if (stat(join2(dirpath, "/", "baseproduct"), &st) == 0) /* follow symlink */
+ pd.baseproduct = st.st_ino;
+ else
+ pd.baseproduct = 0;
- if (len > slen
- && strcmp(entry->d_name + len - slen, suffix) == 0)
+ while ((entry = readdir(dir)))
{
- char *fullpath = join2(path, "/", entry->d_name);
+ int len = strlen(entry->d_name);
+ if (len <= 5 || strcmp(entry->d_name + len - 5, ".prod") != 0)
+ continue;
+ fullpath = join2(dirpath, "/", entry->d_name);
FILE *fp = fopen(fullpath, "r");
if (!fp)
{
perror(fullpath);
- break;
+ continue;
}
- pd->filename = fullpath;
- pd->basename = entry->d_name;
- repo_add_product(pd, fp, code11);
+ pd.filename = fullpath;
+ pd.basename = entry->d_name;
+ add_code11_product(&pd, fp);
fclose(fp);
}
+ closedir(dir);
}
+ sat_free((void *)pd.tmplang);
+ sat_free(pd.content);
+ join_freemem();
+
+ if (!(flags & REPO_NO_INTERNALIZE))
+ repodata_internalize(data);
}
+/******************************************************************************************/
+
+
/*
* read all installed products
*
@@ -573,70 +513,44 @@ parse_dir(DIR *dir, const char *path, struct parsedata *pd, int code11)
void
repo_add_products(Repo *repo, const char *proddir, const char *root, int flags)
{
- const char *fullpath = proddir;
+ const char *fullpath;
DIR *dir;
- int i;
- struct parsedata pd;
- struct stateswitch *sw;
- Repodata *data;
-
- if (!(flags & REPO_REUSE_REPODATA))
- data = repo_add_repodata(repo, 0);
- else
- data = repo_last_repodata(repo);
- memset(&pd, 0, sizeof(pd));
- pd.repo = repo;
- pd.pool = repo->pool;
- pd.data = data;
-
- pd.content = sat_malloc(256);
- pd.acontent = 256;
-
- for (i = 0, sw = stateswitches; sw->from != NUMSTATES; i++, sw++)
+ dir = opendir(proddir);
+ if (dir)
{
- if (!pd.swtab[sw->from])
- pd.swtab[sw->from] = sw;
- pd.sbtab[sw->to] = sw->from;
+ /* assume code11 stype products */
+ closedir(dir);
+ repo_add_code11_products(repo, proddir, flags);
+ return;
}
+ /* code11 didn't work, try old zyppdb */
+ fullpath = root ? join2(root, "", "/var/lib/zypp/db/products") : "/var/lib/zypp/db/products";
dir = opendir(fullpath);
if (dir)
{
- parse_dir(dir, fullpath, &pd, 1); /* assume 'code11' products */
closedir(dir);
+ /* assume code10 style products */
+ repo_add_zyppdb_products(repo, fullpath, flags);
+ join_freemem();
+ return;
}
- else
+
+ /* code11 didn't work, try -release files parsing */
+ fullpath = root ? join2(root, "", "/etc") : "/etc";
+ dir = opendir(fullpath);
+ if (dir)
{
- fullpath = root ? join2(root, "", "/var/lib/zypp/db/products") : "/var/lib/zypp/db/products";
- dir = opendir(fullpath);
- if (dir)
- {
- repo_add_zyppdb_products(repo, data, fullpath, dir); /* assume 'code10' zypp-style products */
- closedir(dir);
- }
- else
- {
- fullpath = root ? join2(root, "", "/etc") : "/etc";
- dir = opendir(fullpath);
- if (dir)
- {
- parse_dir(dir, fullpath, &pd, 0); /* fall back to /etc/<xyz>-release parsing */
- closedir(dir);
- }
- else
- {
- perror(fullpath);
- }
- }
+ closedir(dir);
+ repo_add_releasefile_products(repo, fullpath, flags);
+ join_freemem();
+ return;
}
- sat_free((void *)pd.tmplang);
- sat_free(pd.content);
+ /* no luck. print an error message in case the root argument is wrong */
+ perror(fullpath);
join_freemem();
-
- if (!(flags & REPO_NO_INTERNALIZE))
- repodata_internalize(data);
}
/* EOF */
diff --git a/tools/repo_products.h b/tools/repo_products.h
index aa0c2d9..6f4ce85 100644
--- a/tools/repo_products.h
+++ b/tools/repo_products.h
@@ -1,8 +1,9 @@
/*
- * Copyright (c) 2007, Novell Inc.
+ * Copyright (c) 2007-2009, Novell Inc.
*
* This program is licensed under the BSD license, read LICENSE.BSD
* for further information
*/
+void repo_add_code11_products(Repo *repo, const char *dirpath, int flags);
void repo_add_products(Repo *repo, const char *proddir, const char *root, int flags);
diff --git a/tools/repo_releasefile_products.c b/tools/repo_releasefile_products.c
new file mode 100644
index 0000000..2413d20
--- /dev/null
+++ b/tools/repo_releasefile_products.c
@@ -0,0 +1,156 @@
+/*
+ * repo_products.c
+ *
+ * Parses all files below 'proddir'
+ * See http://en.opensuse.org/Product_Management/Code11
+ *
+ *
+ * Copyright (c) 2008, Novell Inc.
+ *
+ * This program is licensed under the BSD license, read LICENSE.BSD
+ * for further information
+ */
+
+#include <sys/types.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <assert.h>
+#include <dirent.h>
+#include <ctype.h>
+
+#include "pool.h"
+#include "repo.h"
+#include "util.h"
+#define DISABLE_SPLIT
+#include "tools_util.h"
+#include "repo_releasefile_products.h"
+
+#define BUFF_SIZE 8192
+
+static void
+add_releasefile_product(Repo *repo, FILE *fp)
+{
+ Pool *pool = repo->pool;
+ char buf[BUFF_SIZE];
+ Id name = 0;
+ Id arch = 0;
+ Id version = 0;
+ int lnum = 0; /* line number */
+ char *ptr, *ptr1;
+
+ /* parse /etc/<xyz>-release file */
+ while (fgets(buf, sizeof(buf), fp))
+ {
+ /* remove trailing \n */
+ int l = strlen(buf);
+ if (l && buf[l - 1] == '\n')
+ buf[--l] = 0;
+ ++lnum;
+
+ if (lnum == 1)
+ {
+ /* 1st line, <name> [(<arch>)] */
+ ptr = strchr(buf, '(');
+ if (ptr)
+ {
+ ptr1 = ptr - 1;
+ *ptr++ = 0;
+ }
+ else
+ ptr1 = buf + l - 1;
+
+ /* track back until non-blank, non-digit */
+ while (ptr1 > buf
+ && (*ptr1 == ' ' || isdigit(*ptr1) || *ptr1 == '.'))
+ --ptr1;
+ *(++ptr1) = 0;
+ name = str2id(pool, join2("product", ":", buf), 1);
+
+ if (ptr)
+ {
+ /* have arch */
+ char *ptr1 = strchr(ptr, ')');
+ if (ptr1)
+ {
+ *ptr1 = 0;
+ /* downcase arch */
+ ptr1 = ptr;
+ while (*ptr1)
+ {
+ if (isupper(*ptr1))
+ *ptr1 = tolower(*ptr1);
+ ++ptr1;
+ }
+ arch = str2id(pool, ptr, 1);
+ }
+ }
+ }
+ else if (strncmp(buf, "VERSION", 7) == 0)
+ {
+ ptr = strchr(buf + 7, '=');
+ if (ptr)
+ {
+ while (*++ptr == ' ')
+ ;
+ version = makeevr(pool, ptr);
+ }
+ }
+ }
+ if (name)
+ {
+ Solvable *s = pool_id2solvable(pool, repo_add_solvable(repo));
+ s->name = name;
+ if (version)
+ s->evr = version;
+ if (arch)
+ s->arch = arch;
+ if (s->arch != ARCH_SRC && s->arch != ARCH_NOSRC)
+ s->provides = repo_addid_dep(repo, s->provides, rel2id(pool, s->name, s->evr, REL_EQ, 1), 0);
+ }
+}
+
+
+void
+repo_add_releasefile_products(Repo *repo, const char *dirpath, int flags)
+{
+ DIR *dir;
+ struct dirent *entry;
+ FILE *fp;
+ char *fullpath;
+
+ dir = opendir(dirpath);
+ if (!dir)
+ return;
+
+ while ((entry = readdir(dir)))
+ {
+ int len = strlen(entry->d_name);
+ if (len > 8 && !strcmp(entry->d_name + len - 8, "-release"))
+ {
+ /* skip /etc/lsb-release, thats not a product per-se */
+ if (strcmp(entry->d_name, "lsb-release") == 0)
+ continue;
+ fullpath = join2(dirpath, "/", entry->d_name);
+ if ((fp = fopen(fullpath, "r")) == 0)
+ {
+ perror(fullpath);
+ continue;
+ }
+ add_releasefile_product(repo, fp);
+ }
+ }
+ closedir(dir);
+ join_freemem();
+
+ if (!(flags & REPO_NO_INTERNALIZE))
+ {
+ if (!(flags & REPO_REUSE_REPODATA))
+ {
+ Repodata *data = repo_add_repodata(repo, 0);
+ repodata_internalize(data);
+ }
+ }
+}
+
diff --git a/tools/repo_releasefile_products.h b/tools/repo_releasefile_products.h
new file mode 100644
index 0000000..34311ac
--- /dev/null
+++ b/tools/repo_releasefile_products.h
@@ -0,0 +1,8 @@
+/*
+ * Copyright (c) 2007, Novell Inc.
+ *
+ * This program is licensed under the BSD license, read LICENSE.BSD
+ * for further information
+ */
+
+void repo_add_releasefile_products(Repo *repo, const char *dirpath, int flags);
diff --git a/tools/repo_zyppdb.c b/tools/repo_zyppdb.c
index dc94281..13086d9 100644
--- a/tools/repo_zyppdb.c
+++ b/tools/repo_zyppdb.c
@@ -1,8 +1,8 @@
/*
* repo_zyppdb.c
*
- * Parses /var/lib/zypp/db/products/...
- * The are old (pre Code11) products. See bnc#429177
+ * Parses legacy /var/lib/zypp/db/products/... files.
+ * They are old (pre Code11) product descriptions. See bnc#429177
*
*
* Copyright (c) 2008, Novell Inc.
@@ -302,7 +302,7 @@ characterData(void *userData, const XML_Char *s, int len)
*/
static void
-repo_add_product(struct parsedata *pd, Repodata *data, FILE *fp)
+add_zyppdb_product(struct parsedata *pd, FILE *fp)
{
char buf[BUFF_SIZE];
int l;
@@ -327,34 +327,6 @@ repo_add_product(struct parsedata *pd, Repodata *data, FILE *fp)
}
-
-/*
- * parse dir for products
- */
-
-static void
-parse_dir(DIR *dir, const char *path, struct parsedata *pd, Repodata *repodata)
-{
- struct dirent *entry;
-
- while ((entry = readdir(dir)))
- {
- int len = strlen(entry->d_name);
- if (len < 3) /* skip '.' and '..' */
- continue;
- char *fullpath = join2(path, "/", entry->d_name);
- FILE *fp = fopen(fullpath, "r");
- if (!fp)
- {
- perror(fullpath);
- break;
- }
- repo_add_product(pd, repodata, fp);
- fclose(fp);
- }
-}
-
-
/*
* read all installed products
*
@@ -362,16 +334,26 @@ parse_dir(DIR *dir, const char *path, struct parsedata *pd, Repodata *repodata)
*/
void
-repo_add_zyppdb_products(Repo *repo, Repodata *repodata, const char *fullpath, DIR *dir)
+repo_add_zyppdb_products(Repo *repo, const char *dirpath, int flags)
{
int i;
struct parsedata pd;
struct stateswitch *sw;
+ struct dirent *entry;
+ char *fullpath;
+ DIR *dir;
+ FILE *fp;
+ Repodata *data;
+
+ if (!(flags & REPO_REUSE_REPODATA))
+ data = repo_add_repodata(repo, 0);
+ else
+ data = repo_last_repodata(repo);
memset(&pd, 0, sizeof(pd));
pd.repo = repo;
pd.pool = repo->pool;
- pd.data = repodata;
+ pd.data = data;
pd.content = malloc(256);
pd.acontent = 256;
@@ -383,11 +365,30 @@ repo_add_zyppdb_products(Repo *repo, Repodata *repodata, const char *fullpath, D
pd.sbtab[sw->to] = sw->from;
}
- parse_dir(dir, fullpath, &pd, repodata);
+ dir = opendir(dirpath);
+ if (dir)
+ {
+ while ((entry = readdir(dir)))
+ {
+ if (strlen(entry->d_name) < 3)
+ continue; /* skip '.' and '..' */
+ fullpath = join2(dirpath, "/", entry->d_name);
+ if ((fp = fopen(fullpath, "r")) == 0)
+ {
+ perror(fullpath);
+ continue;
+ }
+ add_zyppdb_product(&pd, fp);
+ fclose(fp);
+ }
+ }
+ closedir(dir);
sat_free((void *)pd.tmplang);
free(pd.content);
join_freemem();
+ if (!(flags & REPO_NO_INTERNALIZE))
+ repodata_internalize(data);
}
/* EOF */
diff --git a/tools/repo_zyppdb.h b/tools/repo_zyppdb.h
index 1e2ac1e..8c4a5da 100644
--- a/tools/repo_zyppdb.h
+++ b/tools/repo_zyppdb.h
@@ -5,4 +5,4 @@
* for further information
*/
-void repo_add_zyppdb_products(Repo *repo, Repodata *repodata, const char *fullpath, DIR *dir);
+void repo_add_zyppdb_products(Repo *repo, const char *dirpath, int flags);
diff --git a/tools/rpmdb2solv.c b/tools/rpmdb2solv.c
index f4bea47..515a8e7 100644
--- a/tools/rpmdb2solv.c
+++ b/tools/rpmdb2solv.c
@@ -159,7 +159,7 @@ main(int argc, char **argv)
strcpy(buf + rootlen, proddir);
}
}
- repo_add_products(repo, proddir, root, REPO_REUSE_REPODATA | REPO_NO_INTERNALIZE);
+ repo_add_products(repo, buf, root, REPO_REUSE_REPODATA | REPO_NO_INTERNALIZE);
if (buf != proddir)
sat_free(buf);
}
--
To unsubscribe, e-mail: zypp-commit+unsubscribe(a)opensuse.org
For additional commands, e-mail: zypp-commit+help(a)opensuse.org
1
0
[zypp-commit] <sat-solver> master : Adapt to new solver api for Jobs and Problems
by Klaus Kämpf 20 Jun '09
by Klaus Kämpf 20 Jun '09
20 Jun '09
ref: refs/heads/master
commit 989acc8280ba2bc229acfb62c01143552b386e00
Author: Klaus Kämpf <kkaempf(a)suse.de>
Date: Sat Jun 20 07:37:59 2009 +0200
Adapt to new solver api for Jobs and Problems
new requests: update and lock
prepare for more satsolver-like problem/solution handling
---
applayer/request.c | 38 ++++--------------------
applayer/request.h | 10 ++----
bindings/job.i | 30 ++++++++++++++----
bindings/problem.i | 26 +++++++++-------
bindings/request.i | 80 +++++++++++++++++++++++++++++++++++++++++++++++----
bindings/solution.i | 7 ++++
6 files changed, 128 insertions(+), 63 deletions(-)
diff --git a/applayer/request.c b/applayer/request.c
index b82206f..fe0425e 100644
--- a/applayer/request.c
+++ b/applayer/request.c
@@ -47,52 +47,26 @@ request_size( Request *t )
void
-request_install_xsolvable( Request *t, XSolvable *xs )
+request_xsolvable( Request *t, XSolvable *xs, int what )
{
- queue_push( &(t->queue), SOLVER_INSTALL|SOLVER_SOLVABLE );
+ queue_push( &(t->queue), what|SOLVER_SOLVABLE );
/* FIXME: check: s->repo->pool == $self->pool */
queue_push( &(t->queue), xs->id );
}
void
-request_remove_xsolvable( Request *t, XSolvable *xs )
+request_name( Request *t, const char *name, int what )
{
- queue_push( &(t->queue), SOLVER_ERASE|SOLVER_SOLVABLE );
- /* FIXME: check: s->repo->pool == $self->pool */
- queue_push( &(t->queue), xs->id );
-}
-
-
-void
-request_install_name( Request *t, const char *name )
-{
- queue_push( &(t->queue), SOLVER_INSTALL|SOLVER_SOLVABLE_NAME );
- queue_push( &(t->queue), str2id( t->pool, name, 1 ));
-}
-
-
-void
-request_remove_name( Request *t, const char *name )
-{
- queue_push( &(t->queue), SOLVER_ERASE|SOLVER_SOLVABLE_NAME );
+ queue_push( &(t->queue), what|SOLVER_SOLVABLE_NAME );
queue_push( &(t->queue), str2id( t->pool, name, 1 ));
}
void
-request_install_relation( Request *t, const Relation *rel )
-{
- queue_push( &(t->queue), SOLVER_INSTALL|SOLVER_SOLVABLE_PROVIDES );
- /* FIXME: check: rel->pool == $self->pool */
- queue_push( &(t->queue), rel->id );
-}
-
-
-void
-request_remove_relation( Request *t, const Relation *rel )
+request_relation( Request *t, const Relation *rel, int what )
{
- queue_push( &(t->queue), SOLVER_ERASE|SOLVER_SOLVABLE_PROVIDES );
+ queue_push( &(t->queue), what|SOLVER_SOLVABLE_PROVIDES );
/* FIXME: check: rel->pool == $self->pool */
queue_push( &(t->queue), rel->id );
}
diff --git a/applayer/request.h b/applayer/request.h
index 777221e..e411d9f 100644
--- a/applayer/request.h
+++ b/applayer/request.h
@@ -27,12 +27,10 @@ typedef struct _Request {
Request *request_new( Pool *pool );
void request_free( Request *t );
-void request_install_xsolvable( Request *t, XSolvable *xs );
-void request_remove_xsolvable( Request *t, XSolvable *xs );
-void request_install_name( Request *t, const char *name );
-void request_remove_name( Request *t, const char *name );
-void request_install_relation( Request *t, const Relation *rel );
-void request_remove_relation( Request *t, const Relation *rel );
+void request_xsolvable( Request *t, XSolvable *xs, int what );
+void request_name( Request *t, const char *name, int what );
+void request_relation( Request *t, const Relation *rel, int what );
+
int request_size( Request *t );
Job *request_job_get( Request *t, int i );
diff --git a/bindings/job.i b/bindings/job.i
index 79868f3..d87ef46 100644
--- a/bindings/job.i
+++ b/bindings/job.i
@@ -14,13 +14,29 @@ typedef struct _Job {} Job;
%extend Job {
- %constant int INSTALL_SOLVABLE = SOLVER_INSTALL_SOLVABLE;
- %constant int REMOVE_SOLVABLE = SOLVER_ERASE_SOLVABLE;
- %constant int INSTALL_SOLVABLE_NAME = SOLVER_INSTALL_SOLVABLE_NAME;
- %constant int REMOVE_SOLVABLE_NAME = SOLVER_ERASE_SOLVABLE_NAME;
- %constant int INSTALL_SOLVABLE_PROVIDES = SOLVER_INSTALL_SOLVABLE_PROVIDES;
- %constant int REMOVE_SOLVABLE_PROVIDES = SOLVER_ERASE_SOLVABLE_PROVIDES;
-
+ %constant int INSTALL_SOLVABLE = (SOLVER_INSTALL|SOLVER_SOLVABLE);
+ %constant int UPDATE_SOLVABLE = (SOLVER_UPDATE|SOLVER_SOLVABLE);
+ %constant int REMOVE_SOLVABLE = (SOLVER_ERASE|SOLVER_SOLVABLE);
+ %constant int WEAKEN_SOLVABLE = (SOLVER_WEAKENDEPS|SOLVER_SOLVABLE);
+ %constant int LOCK_SOLVABLE = (SOLVER_LOCK|SOLVER_SOLVABLE);
+
+ %constant int INSTALL_SOLVABLE_NAME = (SOLVER_INSTALL|SOLVER_SOLVABLE_NAME);
+ %constant int UPDATE_SOLVABLE_NAME = (SOLVER_UPDATE|SOLVER_SOLVABLE_NAME);
+ %constant int REMOVE_SOLVABLE_NAME = (SOLVER_ERASE|SOLVER_SOLVABLE_NAME);
+ %constant int WEAKEN_SOLVABLE_NAME = (SOLVER_WEAKENDEPS|SOLVER_SOLVABLE_NAME);
+ %constant int LOCK_SOLVABLE_NAME = (SOLVER_LOCK|SOLVER_SOLVABLE_NAME);
+
+ %constant int INSTALL_SOLVABLE_PROVIDES = (SOLVER_INSTALL|SOLVER_SOLVABLE_PROVIDES);
+ %constant int UPDATE_SOLVABLE_PROVIDES = (SOLVER_UPDATE|SOLVER_SOLVABLE_PROVIDES);
+ %constant int REMOVE_SOLVABLE_PROVIDES = (SOLVER_ERASE|SOLVER_SOLVABLE_PROVIDES);
+ %constant int WEAKEN_SOLVABLE_PROVIDES = (SOLVER_WEAKENDEPS|SOLVER_SOLVABLE_PROVIDES);
+ %constant int LOCK_SOLVABLE_PROVIDES = (SOLVER_LOCK|SOLVER_SOLVABLE_PROVIDES);
+
+ %constant int INSTALL_ONE_OF = (SOLVER_INSTALL|SOLVER_SOLVABLE_ONE_OF);
+ %constant int UPDATE_ONE_OF = (SOLVER_UPDATE|SOLVER_SOLVABLE_ONE_OF);
+ %constant int REMOVE_ONE_OF = (SOLVER_ERASE|SOLVER_SOLVABLE_ONE_OF);
+ %constant int LOCK_ONE_OF = (SOLVER_LOCK|SOLVER_SOLVABLE_ONE_OF);
+
~Job()
{ job_free( $self ); }
diff --git a/bindings/problem.i b/bindings/problem.i
index 164ec31..ddd3d14 100644
--- a/bindings/problem.i
+++ b/bindings/problem.i
@@ -37,28 +37,30 @@ typedef struct _Problem {} Problem;
%extend Problem {
/* The problem is caused by an update rule (i.e. 'better' Solvable available) */
- %constant int SOLVER_PROBLEM_UPDATE_RULE = SOLVER_PROBLEM_UPDATE_RULE;
+ %constant int SOLVER_PROBLEM_UPDATE_RULE = SOLVER_RULE_UPDATE;
/* The problem is caused by a Job inside the Request */
- %constant int SOLVER_PROBLEM_JOB_RULE = SOLVER_PROBLEM_JOB_RULE;
+ %constant int SOLVER_PROBLEM_JOB_RULE = SOLVER_RULE_JOB;
/* A Job based on a Relation could not be fulfilled because there is no Solvable in the Pool providing it. */
- %constant int SOLVER_PROBLEM_JOB_NOTHING_PROVIDES_DEP = SOLVER_PROBLEM_JOB_NOTHING_PROVIDES_DEP;
+ %constant int SOLVER_PROBLEM_JOB_NOTHING_PROVIDES_DEP = SOLVER_RULE_JOB_NOTHING_PROVIDES_DEP;
/* The Solvable is not installable (wrong architecture, etc.) */
- %constant int SOLVER_PROBLEM_NOT_INSTALLABLE = SOLVER_PROBLEM_NOT_INSTALLABLE;
+ %constant int SOLVER_PROBLEM_NOT_INSTALLABLE = SOLVER_RULE_RPM_NOT_INSTALLABLE;
/* A requirement could not be fulfilled because there is no Solvable in the Pool providing it. */
- %constant int SOLVER_PROBLEM_NOTHING_PROVIDES_DEP = SOLVER_PROBLEM_NOTHING_PROVIDES_DEP;
+ %constant int SOLVER_PROBLEM_NOTHING_PROVIDES_DEP = SOLVER_RULE_RPM_NOTHING_PROVIDES_DEP;
/* Same name */
- %constant int SOLVER_PROBLEM_SAME_NAME = SOLVER_PROBLEM_SAME_NAME;
+ %constant int SOLVER_PROBLEM_SAME_NAME = SOLVER_RULE_RPM_SAME_NAME;
/* Packages conflict */
- %constant int SOLVER_PROBLEM_PACKAGE_CONFLICT = SOLVER_PROBLEM_PACKAGE_CONFLICT;
+ %constant int SOLVER_PROBLEM_PACKAGE_CONFLICT = SOLVER_RULE_RPM_PACKAGE_CONFLICT;
/* Package is obsoleted */
- %constant int SOLVER_PROBLEM_PACKAGE_OBSOLETES = SOLVER_PROBLEM_PACKAGE_OBSOLETES;
+ %constant int SOLVER_PROBLEM_PACKAGE_OBSOLETES = SOLVER_RULE_RPM_PACKAGE_OBSOLETES;
/* A requirement is fulfilled by an uninstallable Solvable */
- %constant int SOLVER_PROBLEM_DEP_PROVIDERS_NOT_INSTALLABLE = SOLVER_PROBLEM_DEP_PROVIDERS_NOT_INSTALLABLE;
+ %constant int SOLVER_PROBLEM_DEP_PROVIDERS_NOT_INSTALLABLE = SOLVER_RULE_RPM_PACKAGE_REQUIRES;
/* The Solvable conflicts with itself. */
- %constant int SOLVER_PROBLEM_SELF_CONFLICT = SOLVER_PROBLEM_SELF_CONFLICT;
+ %constant int SOLVER_PROBLEM_SELF_CONFLICT = SOLVER_RULE_RPM_SELF_CONFLICT;
/* A dependency of an already installed Solvable could not be fulfilled (broken system) */
- %constant int SOLVER_PROBLEM_RPM_RULE = SOLVER_PROBLEM_RPM_RULE;
-
+ %constant int SOLVER_PROBLEM_RPM_RULE = SOLVER_RULE_RPM;
+ %constant int SOLVER_RULE_DISTUPGRADE = SOLVER_RULE_DISTUPGRADE;
+ %constant int SOLVER_RULE_INFARCH = SOLVER_RULE_INFARCH;
+
~Problem()
{ problem_free ($self); }
diff --git a/bindings/request.i b/bindings/request.i
index 901db55..f6cb61d 100644
--- a/bindings/request.i
+++ b/bindings/request.i
@@ -61,7 +61,7 @@ typedef struct _Request {} Request;
*
*/
void install( XSolvable *xs )
- { request_install_xsolvable( $self, xs ); }
+ { request_xsolvable( $self, xs, SOLVER_INSTALL ); }
/*
* Remove request
@@ -81,34 +81,102 @@ typedef struct _Request {} Request;
*
*/
void remove( XSolvable *xs )
- { request_remove_xsolvable( $self, xs ); }
+ { request_xsolvable( $self, xs, SOLVER_ERASE ); }
+
+ /*
+ * Update request
+ *
+ * Ensure update of a solvable by either
+ * * specifying it directly
+ * * specify it by name
+ * * specify a required relation
+ *
+ * Except when specified directly, the solver is free to choose any
+ * solvable matching the request (by name, by relation)
+ *
+ * call-seq:
+ * request.update(solvable) -> void
+ * request.update("kernel") -> void
+ * request.update(relation) -> void
+ *
+ */
+ void update( XSolvable *xs )
+ { request_xsolvable( $self, xs, SOLVER_UPDATE ); }
+
+ /*
+ * Lock request
+ *
+ * Ensure solvable stays installed/uninstalled
+ * * specifying it directly
+ * * specify it by name
+ * * specify a required relation
+ *
+ * Except when specified directly, the solver is free to choose any
+ * solvable matching the request (by name, by relation)
+ *
+ * call-seq:
+ * request.lock(solvable) -> void
+ * request.lock("kernel") -> void
+ * request.lock(relation) -> void
+ *
+ */
+ void lock( XSolvable *xs )
+ { request_xsolvable( $self, xs, SOLVER_LOCK ); }
/*
* Install solvable by name
*/
void install( const char *name )
- { request_install_name( $self, name ); }
+ { request_name( $self, name, SOLVER_INSTALL ); }
/*
* Remove solvable by name
*
*/
void remove( const char *name )
- { request_remove_name( $self, name ); }
+ { request_name( $self, name, SOLVER_ERASE ); }
+
+ /*
+ * Update solvable by name
+ *
+ */
+ void update( const char *name )
+ { request_name( $self, name, SOLVER_UPDATE ); }
+
+ /*
+ * Lock solvable by name
+ *
+ */
+ void lock( const char *name )
+ { request_name( $self, name, SOLVER_LOCK ); }
/*
* Install solvable by relation
*
*/
void install( const Relation *rel )
- { request_install_relation( $self, rel ); }
+ { request_relation( $self, rel, SOLVER_INSTALL ); }
/*
* Remove solvable by relation
*
*/
void remove( const Relation *rel )
- { return request_remove_relation( $self, rel ); }
+ { return request_relation( $self, rel, SOLVER_ERASE ); }
+
+ /*
+ * Update solvable by relation
+ *
+ */
+ void update( const Relation *rel )
+ { return request_relation( $self, rel, SOLVER_UPDATE ); }
+
+ /*
+ * Lock solvable by relation
+ *
+ */
+ void lock( const Relation *rel )
+ { return request_relation( $self, rel, SOLVER_LOCK ); }
#if defined(SWIGRUBY)
%rename("empty?") empty();
diff --git a/bindings/solution.i b/bindings/solution.i
index 810a393..599a437 100644
--- a/bindings/solution.i
+++ b/bindings/solution.i
@@ -2,6 +2,13 @@
* Document-class: Solution
* Solutions are attached to Problems and give hints on how to solve problems.
*
+ * Solutions as coming from satsolver are 'raw' as they only tell you
+ * which jobs to change. Thats either job items to remove (from the
+ * Request) or new job items to add.
+ *
+ * How this relates to the application view is up to the application
+ * using the bindings.
+ *
* === Constructor
* There is no constructor defined for Solution. Solution are part of Problem and can be
* accessed through Problem.each_solution
--
To unsubscribe, e-mail: zypp-commit+unsubscribe(a)opensuse.org
For additional commands, e-mail: zypp-commit+help(a)opensuse.org
1
0
[zypp-commit] <sat-solver> master : - add support for REL_FILECONFLICT
by Michael Schroeder 19 Jun '09
by Michael Schroeder 19 Jun '09
19 Jun '09
ref: refs/heads/master
commit 5665c9c4aa70beb854ad9aa8ba1202b8cb935c8b
Author: Michael Schroeder <mls(a)suse.de>
Date: Fri Jun 19 18:52:23 2009 +0200
- add support for REL_FILECONFLICT
- add findfileconflicts.c demo app
---
src/pool.c | 56 ++++++++++++++++++++++++++++++++++-
src/pool.h | 4 ++
src/poolid.c | 7 ++++
tools/findfileconflicts.c | 71 +++++++++++++++++++++++++++++++++++++++++++++
4 files changed, 137 insertions(+), 1 deletions(-)
diff --git a/src/pool.c b/src/pool.c
index 73fc1c2..4fa4e25 100644
--- a/src/pool.c
+++ b/src/pool.c
@@ -620,10 +620,27 @@ pool_addrelproviders(Pool *pool, Id d)
}
if (wp)
{
+ /* all solvables match, no need to create a new list */
pool->whatprovides_rel[d] = wp;
return wp;
}
break;
+ case REL_FILECONFLICT:
+ pp = pool_whatprovides_ptr(pool, name);
+ while ((p = *pp++) != 0)
+ {
+ Id origd = MAKERELDEP(d);
+ Solvable *s = pool->solvables + p;
+ if (!s->provides)
+ continue;
+ pidp = s->repo->idarraydata + s->provides;
+ while ((pid = *pidp++) != 0)
+ if (pid == origd)
+ break;
+ if (pid)
+ queue_push(&plist, p);
+ }
+ break;
default:
break;
}
@@ -810,6 +827,11 @@ pool_addfileprovides_dep(Pool *pool, Id *ida, struct searchfiles *sf, struct sea
}
dep = rd->evr;
}
+ else if (rd->flags == REL_FILECONFLICT)
+ {
+ dep = 0;
+ break;
+ }
else
{
Id ids[2];
@@ -1709,4 +1731,36 @@ pool_lookup_checksum(Pool *pool, Id entry, Id keyname, Id *typep)
return solvable_lookup_checksum(pool->solvables + entry, keyname, typep);
}
-// EOF
+void
+pool_add_fileconflicts_deps(Pool *pool, Queue *conflicts)
+{
+ int hadhashes = pool->relhashtbl ? 1 : 0;
+ Solvable *s;
+ Id fn, p, q, md5;
+ Id id;
+ int i;
+
+ if (!conflicts->count)
+ return;
+ pool_freewhatprovides(pool);
+ for (i = 0; i < conflicts->count; i += 5)
+ {
+ fn = conflicts->elements[i];
+ p = conflicts->elements[i + 1];
+ md5 = conflicts->elements[i + 2];
+ q = conflicts->elements[i + 3];
+ id = rel2id(pool, fn, md5, REL_FILECONFLICT, 1);
+ s = pool->solvables + p;
+ if (!s->repo)
+ continue;
+ s->provides = repo_addid_dep(s->repo, s->provides, id, SOLVABLE_FILEMARKER);
+ s = pool->solvables + q;
+ if (!s->repo)
+ continue;
+ s->conflicts = repo_addid_dep(s->repo, s->conflicts, id, 0);
+ }
+ if (!hadhashes)
+ pool_freeidhashes(pool);
+}
+
+/* EOF */
diff --git a/src/pool.h b/src/pool.h
index 2e657ad..e985211 100644
--- a/src/pool.h
+++ b/src/pool.h
@@ -154,6 +154,7 @@ struct _Pool {
#define REL_WITH 18
#define REL_NAMESPACE 19
#define REL_ARCH 20
+#define REL_FILECONFLICT 21
#if !defined(__GNUC__) && !defined(__attribute__)
# define __attribute__(x)
@@ -316,6 +317,9 @@ int pool_lookup_void(Pool *pool, Id entry, Id keyname);
const unsigned char *pool_lookup_bin_checksum(Pool *pool, Id entry, Id keyname, Id *typep);
const char *pool_lookup_checksum(Pool *pool, Id entry, Id keyname, Id *typep);
+void pool_add_fileconflicts_deps(Pool *pool, Queue *conflicts);
+
+
/* loop over all providers of d */
#define FOR_PROVIDES(v, vp, d) \
diff --git a/src/poolid.c b/src/poolid.c
index cd5f4d7..a0059e2 100644
--- a/src/poolid.c
+++ b/src/poolid.c
@@ -168,6 +168,8 @@ id2rel(Pool *pool, Id id)
return " NAMESPACE "; /* actually not used in dep2str */
case REL_ARCH:
return ".";
+ case REL_FILECONFLICT:
+ return " FILECONFLICT ";
default:
break;
}
@@ -232,6 +234,11 @@ dep2strcpy(Pool *pool, char *p, Id id, int oldrel)
strcat(p, ")");
return;
}
+ if (rd->flags == REL_FILECONFLICT)
+ {
+ *p = 0;
+ return;
+ }
strcpy(p, id2rel(pool, id));
p += strlen(p);
id = rd->evr;
diff --git a/tools/findfileconflicts.c b/tools/findfileconflicts.c
new file mode 100644
index 0000000..88833d5
--- /dev/null
+++ b/tools/findfileconflicts.c
@@ -0,0 +1,71 @@
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "pool.h"
+#include "repo.h"
+#include "solver.h"
+#include "solverdebug.h"
+#include "hash.h"
+#include "repo_rpmdb.h"
+#include "pool_fileconflicts.h"
+
+static void *
+iterate_handle(Pool *pool, Id p, void *cbdata)
+{
+ Solvable *s = pool->solvables + p;
+ Id rpmdbid;
+
+ if (!p)
+ {
+ rpm_byrpmdbid(0, 0, (void **)cbdata);
+ return 0;
+ }
+ if (!s->repo->rpmdbid)
+ return 0;
+ rpmdbid = s->repo->rpmdbid[p - s->repo->start];
+ if (!rpmdbid)
+ return 0;
+ return rpm_byrpmdbid(rpmdbid, 0, (void **)cbdata);
+}
+
+int main()
+{
+ Pool *pool;
+ Repo *installed;
+ Solvable *s;
+ Id p;
+ int i;
+ Queue todo, conflicts;
+ void *state = 0;
+
+ pool = pool_create();
+ installed = repo_create(pool, "@System");
+ pool_set_installed(pool, installed);
+ repo_add_rpmdb(installed, 0, 0, 0);
+ queue_init(&todo);
+ queue_init(&conflicts);
+ FOR_REPO_SOLVABLES(installed, p, s)
+ queue_push(&todo, p);
+ pool_findfileconflicts(pool, &todo, &conflicts, &iterate_handle, (void *)&state);
+ queue_free(&todo);
+ for (i = 0; i < conflicts.count; i += 5)
+ printf("%s: %s[%s] %s[%s]\n", id2str(pool, conflicts.elements[i]), solvid2str(pool, conflicts.elements[i + 1]), id2str(pool, conflicts.elements[i + 2]), solvid2str(pool, conflicts.elements[i + 3]), id2str(pool, conflicts.elements[i + 4]));
+ if (conflicts.count)
+ {
+ Queue job;
+ queue_init(&job);
+ pool_add_fileconflicts_deps(pool, &conflicts);
+ pool_addfileprovides(pool);
+ pool_createwhatprovides(pool);
+ pool_setdebuglevel(pool, 0);
+ Solver *solv = solver_create(pool);
+ solv->fixsystem = 1;
+ solver_solve(solv, &job);
+ if (solv->problems.count)
+ solver_printallsolutions(solv);
+ queue_free(&job);
+ solver_free(solv);
+ }
+ queue_free(&conflicts);
+ exit(0);
+}
--
To unsubscribe, e-mail: zypp-commit+unsubscribe(a)opensuse.org
For additional commands, e-mail: zypp-commit+help(a)opensuse.org
1
0
[zypp-commit] <sat-solver> master : - start with fileconflicts detection support
by Michael Schroeder 19 Jun '09
by Michael Schroeder 19 Jun '09
19 Jun '09
ref: refs/heads/master
commit d09a22ac39ef6325f212caa73c4a9c449b455ace
Author: Michael Schroeder <mls(a)suse.de>
Date: Fri Jun 19 17:35:24 2009 +0200
- start with fileconflicts detection support
---
src/hash.h | 10 ++
tools/CMakeLists.txt | 4 +
tools/pool_fileconflicts.c | 382 ++++++++++++++++++++++++++++++++++++++++++++
tools/pool_fileconflicts.h | 8 +
tools/repo_rpmdb.c | 365 +++++++++++++++++++++++++++++++++++++++++-
tools/repo_rpmdb.h | 7 +
6 files changed, 773 insertions(+), 3 deletions(-)
diff --git a/src/hash.h b/src/hash.h
index 829085d..b1b9199 100644
--- a/src/hash.h
+++ b/src/hash.h
@@ -51,6 +51,16 @@ strnhash(const char *str, unsigned len)
return r;
}
+static inline Hashval
+strhash_cont(const char *str, Hashval r)
+{
+ unsigned int c;
+ while ((c = *(const unsigned char *)str++) != 0)
+ r += (r << 3) + c;
+ return r;
+}
+
+
/* hash for rel
* rel -> hash
*/
diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt
index 5f20cf0..741bb10 100644
--- a/tools/CMakeLists.txt
+++ b/tools/CMakeLists.txt
@@ -57,6 +57,10 @@ TARGET_LINK_LIBRARIES( dumpsolv satsolver)
ADD_EXECUTABLE( mergesolv mergesolv.c )
TARGET_LINK_LIBRARIES( mergesolv satsolver toolstuff)
+SET(findfileconflicts_SOURCES findfileconflicts.c pool_fileconflicts.c repo_rpmdb.c )
+ADD_EXECUTABLE( findfileconflicts ${findfileconflicts_SOURCES} )
+TARGET_LINK_LIBRARIES( findfileconflicts satsolver ${RPMDB_LIBRARY} ${EXPAT_LIBRARY} )
+
install(TARGETS
mergesolv
dumpsolv
diff --git a/tools/pool_fileconflicts.c b/tools/pool_fileconflicts.c
new file mode 100644
index 0000000..5b1c4a0
--- /dev/null
+++ b/tools/pool_fileconflicts.c
@@ -0,0 +1,382 @@
+#include <stdio.h>
+#include <sys/stat.h>
+
+#include "pool.h"
+#include "repo.h"
+#include "hash.h"
+#include "repo_rpmdb.h"
+
+struct cbdata {
+ Pool *pool;
+ Queue lookat;
+ Queue lookat_dir;
+
+ Hashval *cflmap;
+ Hashmask cflmapn;
+ unsigned int cflmapused;
+
+ Hashval *dirmap;
+ Hashmask dirmapn;
+ unsigned int dirmapused;
+
+ Hashval idx;
+ unsigned int hx;
+
+ Queue files;
+ unsigned char *filesspace;
+ unsigned int filesspacen;
+};
+
+#define FILESSPACE_BLOCK 255
+
+static Hashval *
+doublehash(Hashval *map, Hashmask *mapnp)
+{
+ Hashmask mapn = *mapnp;
+ Hashmask i, hx, qx, h, hh;
+ Hashmask nn = (mapn + 1) * 2 - 1;
+ Hashmask *m;
+
+ m = sat_calloc(nn + 1, 2 * sizeof(Id));
+ for (i = 0; i <= mapn; i++)
+ {
+ hx = map[2 * i];
+ if (!hx)
+ continue;
+ h = hx & nn;
+ hh = HASHCHAIN_START;
+ for (;;)
+ {
+ qx = m[2 * h];
+ if (!qx)
+ break;
+ h = HASHCHAIN_NEXT(h, hh, nn);
+ }
+ m[2 * h] = hx;
+ m[2 * h + 1] = map[2 * i + 1];
+ }
+ sat_free(map);
+ *mapnp = nn;
+ return m;
+}
+
+static void
+finddirs_cb(void *cbdatav, char *fn, int fmode, char *md5)
+{
+ struct cbdata *cbdata = cbdatav;
+ Hashmask h, hh, hx, qx;
+ Hashval idx = cbdata->idx;
+
+ hx = strhash(fn);
+ if (!hx)
+ hx = strlen(fn) + 1;
+ h = hx & cbdata->dirmapn;
+ hh = HASHCHAIN_START;
+ for (;;)
+ {
+ qx = cbdata->dirmap[2 * h];
+ if (!qx)
+ break;
+ if (qx == hx)
+ break;
+ h = HASHCHAIN_NEXT(h, hh, cbdata->dirmapn);
+ }
+ if (!qx)
+ {
+ /* a miss */
+ cbdata->dirmap[2 * h] = hx;
+ cbdata->dirmap[2 * h + 1] = idx;
+ cbdata->dirmapused++;
+ if (cbdata->dirmapused * 2 > cbdata->dirmapn)
+ cbdata->dirmap = doublehash(cbdata->dirmap, &cbdata->dirmapn);
+ return;
+ }
+ if (cbdata->dirmap[2 * h + 1] == idx)
+ return;
+ /* found a conflict, this dir is used in multiple packages */
+ cbdata->dirmap[2 * h + 1] = -1;
+}
+
+static inline int
+isindirmap(struct cbdata *cbdata, Hashmask hx)
+{
+ Hashmask h, hh, qx;
+
+ h = hx & cbdata->dirmapn;
+ hh = HASHCHAIN_START;
+ for (;;)
+ {
+ qx = cbdata->dirmap[2 * h];
+ if (!qx)
+ return 0;
+ if (qx == hx)
+ return cbdata->dirmap[2 * h + 1] == -1 ? 1 : 0;
+ h = HASHCHAIN_NEXT(h, hh, cbdata->dirmapn);
+ }
+}
+
+static void
+findfileconflicts_cb(void *cbdatav, char *fn, int fmode, char *md5)
+{
+ struct cbdata *cbdata = cbdatav;
+ int isdir = S_ISDIR(fmode);
+ char *dp;
+ Hashval idx, qidx;
+ Hashmask qx, h, hx, hh, dhx;
+
+ idx = cbdata->idx;
+
+ dp = strrchr(fn, '/');
+ if (!dp)
+ return;
+ dhx = strnhash(fn, dp + 1 - fn);
+ if (!dhx)
+ dhx = 1 + dp + 1 - fn;
+#if 1
+ if (!isindirmap(cbdata, dhx))
+ return;
+#endif
+
+ hx = strhash_cont(dp + 1, dhx);
+ if (!hx)
+ hx = strlen(fn) + 1;
+
+ h = hx & cbdata->cflmapn;
+ hh = HASHCHAIN_START;
+ for (;;)
+ {
+ qx = cbdata->cflmap[2 * h];
+ if (!qx)
+ break;
+ if (qx == hx)
+ break;
+ h = HASHCHAIN_NEXT(h, hh, cbdata->cflmapn);
+ }
+ if (!qx)
+ {
+ cbdata->cflmap[2 * h] = hx;
+ cbdata->cflmap[2 * h + 1] = (isdir ? ~idx : idx);
+ cbdata->cflmapused++;
+ if (cbdata->cflmapused * 2 > cbdata->cflmapn)
+ cbdata->cflmap = doublehash(cbdata->cflmap, &cbdata->cflmapn);
+ return;
+ }
+ qidx = cbdata->cflmap[2 * h + 1];
+ if ((int)qidx < 0)
+ {
+ int i;
+ qidx = ~qidx;
+ if (isdir)
+ {
+ /* delay the conflict */
+ queue_push2(&cbdata->lookat_dir, hx, qidx);
+ queue_push2(&cbdata->lookat_dir, hx, idx);
+ return;
+ }
+ cbdata->cflmap[2 * h + 1] = qidx;
+ for (i = 0; i < cbdata->lookat_dir.count; i += 2)
+ if (cbdata->lookat_dir.elements[i] == hx)
+ queue_push2(&cbdata->lookat, hx, cbdata->lookat_dir.elements[i + 1]);
+ }
+ if (qidx == idx)
+ return; /* no conflicts with ourself, please */
+ queue_push2(&cbdata->lookat, hx, qidx);
+ queue_push2(&cbdata->lookat, hx, idx);
+}
+
+static inline void
+addfilesspace(struct cbdata *cbdata, unsigned char *data, int len)
+{
+ cbdata->filesspace = sat_extend(cbdata->filesspace, cbdata->filesspacen, len, 1, FILESSPACE_BLOCK);
+ memcpy(cbdata->filesspace + cbdata->filesspacen, data, len);
+ cbdata->filesspacen += len;
+}
+
+static void
+findfileconflicts2_cb(void *cbdatav, char *fn, int fmode, char *md5)
+{
+ struct cbdata *cbdata = cbdatav;
+ unsigned int hx = strhash(fn);
+ char md5padded[33];
+
+ if (!hx)
+ hx = strlen(fn) + 1;
+ if (hx != cbdata->hx)
+ return;
+ strncpy(md5padded, md5, 32);
+ md5padded[32] = 0;
+ // printf("%d, hx %x -> %s %d %s\n", cbdata->idx, hx, fn, fmode, md5);
+ queue_push(&cbdata->files, cbdata->filesspacen);
+ addfilesspace(cbdata, (unsigned char *)md5padded, 33);
+ addfilesspace(cbdata, (unsigned char *)fn, strlen(fn) + 1);
+}
+
+static int cand_sort(const void *ap, const void *bp, void *dp)
+{
+ const Id *a = ap;
+ const Id *b = bp;
+
+ unsigned int ax = (unsigned int)a[0];
+ unsigned int bx = (unsigned int)b[0];
+ if (ax < bx)
+ return -1;
+ if (ax > bx)
+ return 1;
+ return (a[1] < 0 ? -a[1] : a[1]) - (b[1] < 0 ? -b[1] : b[1]);
+}
+
+static int conflicts_cmp(const void *ap, const void *bp, void *dp)
+{
+ Pool *pool = dp;
+ const Id *a = ap;
+ const Id *b = bp;
+ if (a[0] != b[0])
+ return strcmp(id2str(pool, a[0]), id2str(pool, b[0]));
+ if (a[1] != b[1])
+ return a[1] - b[1];
+ if (a[3] != b[3])
+ return a[3] - b[3];
+ return 0;
+}
+
+int
+pool_findfileconflicts(Pool *pool, Queue *pkgs, Queue *conflicts, void *(*handle_cb)(Pool *, Id, void *) , void *handle_cbdata)
+{
+ int i, j, cflmapn;
+ unsigned int hx;
+ struct cbdata cbdata;
+ unsigned int now, start;
+ void *handle;
+
+ queue_empty(conflicts);
+ if (!pkgs->count)
+ return 0;
+
+ now = start = sat_timems(0);
+ printf("packages: %d\n", pkgs->count);
+
+ memset(&cbdata, 0, sizeof(cbdata));
+ cbdata.pool = pool;
+ queue_init(&cbdata.lookat);
+ queue_init(&cbdata.lookat_dir);
+ queue_init(&cbdata.files);
+
+ /* avarage file list size: 200 files per package */
+ /* avarage dir count: 20 dirs per package */
+
+ /* first pass: scan dirs */
+ cflmapn = pkgs->count * 64;
+ while ((cflmapn & (cflmapn - 1)) != 0)
+ cflmapn = cflmapn & (cflmapn - 1);
+ cbdata.dirmap = sat_calloc(cflmapn, 2 * sizeof(Id));
+ cbdata.dirmapn = cflmapn - 1; /* make it a mask */
+ for (i = 0; i < pkgs->count; i++)
+ {
+ Id p = pkgs->elements[i];
+ cbdata.idx = p;
+ handle = (*handle_cb)(pool, p, handle_cbdata);
+ if (handle)
+ rpm_iterate_filelist(handle, RPM_ITERATE_FILELIST_ONLYDIRS, finddirs_cb, &cbdata);
+ }
+
+ printf("dirmap size: %d used %d\n", cbdata.dirmapn + 1, cbdata.dirmapused);
+ printf("dirmap memory usage: %d K\n", (cbdata.dirmapn + 1) * 2 * (int)sizeof(Id) / 1024);
+ printf("dirmap creation took %d ms\n", sat_timems(now));
+
+ /* second pass: scan files */
+ now = sat_timems(0);
+ cflmapn = pkgs->count * 128;
+ while ((cflmapn & (cflmapn - 1)) != 0)
+ cflmapn = cflmapn & (cflmapn - 1);
+ cbdata.cflmap = sat_calloc(cflmapn, 2 * sizeof(Id));
+ cbdata.cflmapn = cflmapn - 1; /* make it a mask */
+ for (i = 0; i < pkgs->count; i++)
+ {
+ Id p = pkgs->elements[i];
+ cbdata.idx = p;
+ handle = (*handle_cb)(pool, p, handle_cbdata);
+ if (handle)
+ rpm_iterate_filelist(handle, 0, findfileconflicts_cb, &cbdata);
+ }
+
+ printf("filemap size: %d used %d\n", cbdata.cflmapn + 1, cbdata.cflmapused);
+ printf("filemap memory usage: %d K\n", (cbdata.cflmapn + 1) * 2 * (int)sizeof(Id) / 1024);
+ printf("filemap creation took %d ms\n", sat_timems(now));
+
+ cbdata.dirmap = sat_free(cbdata.dirmap);
+ cbdata.dirmapn = 0;
+ cbdata.dirmapused = 0;
+ cbdata.cflmap = sat_free(cbdata.cflmap);
+ cbdata.cflmapn = 0;
+ cbdata.cflmapused = 0;
+
+ now = sat_timems(0);
+ printf("lookat_dir size: %d\n", cbdata.lookat_dir.count);
+ queue_free(&cbdata.lookat_dir);
+ sat_sort(cbdata.lookat.elements, cbdata.lookat.count / 2, sizeof(Id) * 2, &cand_sort, pool);
+ /* unify */
+ for (i = j = 0; i < cbdata.lookat.count; i += 2)
+ {
+ hx = cbdata.lookat.elements[i];
+ Id p = cbdata.lookat.elements[i + 1];
+ if (j && hx == cbdata.lookat.elements[j - 2] && p == cbdata.lookat.elements[j - 1])
+ continue;
+ cbdata.lookat.elements[j++] = hx;
+ cbdata.lookat.elements[j++] = p;
+ }
+ printf("candidates: %d\n", cbdata.lookat.count / 2);
+
+ /* third pass: scan candidates */
+ for (i = 0; i < cbdata.lookat.count - 2; i += 2)
+ {
+ int pend, ii, jj;
+ Id p = cbdata.lookat.elements[i + 1];
+
+ hx = cbdata.lookat.elements[i];
+ if (cbdata.lookat.elements[i + 2] != hx)
+ continue; /* no package left */
+ queue_empty(&cbdata.files);
+ cbdata.filesspace = sat_free(cbdata.filesspace);
+ cbdata.filesspacen = 0;
+
+ cbdata.idx = p;
+ cbdata.hx = cbdata.lookat.elements[i];
+ handle = (*handle_cb)(pool, p, handle_cbdata);
+ if (!handle)
+ continue;
+ rpm_iterate_filelist(handle, RPM_ITERATE_FILELIST_WITHMD5, findfileconflicts2_cb, &cbdata);
+
+ pend = cbdata.files.count;
+ for (j = i + 2; j < cbdata.lookat.count && cbdata.lookat.elements[j] == hx; j++)
+ {
+ Id q = cbdata.lookat.elements[j + 1];
+ cbdata.idx = q;
+ handle = (*handle_cb)(pool, q, handle_cbdata);
+ if (!handle)
+ continue;
+ rpm_iterate_filelist(handle, RPM_ITERATE_FILELIST_WITHMD5, findfileconflicts2_cb, &cbdata);
+ for (ii = 0; ii < pend; ii++)
+ for (jj = pend; jj < cbdata.files.count; jj++)
+ {
+ if (strcmp((char *)cbdata.filesspace + cbdata.files.elements[ii] + 33, (char *)cbdata.filesspace + cbdata.files.elements[jj] + 33))
+ continue;
+ if (!strcmp((char *)cbdata.filesspace + cbdata.files.elements[ii], (char *)cbdata.filesspace + cbdata.files.elements[jj]))
+ continue;
+ queue_push(conflicts, str2id(pool, (char *)cbdata.filesspace + cbdata.files.elements[ii] + 33, 1));
+ queue_push(conflicts, p);
+ queue_push(conflicts, str2id(pool, (char *)cbdata.filesspace + cbdata.files.elements[ii], 1));
+ queue_push(conflicts, q);
+ queue_push(conflicts, str2id(pool, (char *)cbdata.filesspace + cbdata.files.elements[jj], 1));
+ }
+ }
+ }
+ cbdata.filesspace = sat_free(cbdata.filesspace);
+ cbdata.filesspacen = 0;
+ printf("candidate check took %d ms\n", sat_timems(now));
+ if (conflicts->count > 5)
+ sat_sort(conflicts->elements, conflicts->count / 5, 5 * sizeof(Id), conflicts_cmp, pool);
+ (*handle_cb)(pool, 0, handle_cbdata);
+ printf("conflict detection took %d ms\n", sat_timems(start));
+ return conflicts->count;
+}
+
diff --git a/tools/pool_fileconflicts.h b/tools/pool_fileconflicts.h
new file mode 100644
index 0000000..cb080f2
--- /dev/null
+++ b/tools/pool_fileconflicts.h
@@ -0,0 +1,8 @@
+#ifndef POOL_FILECONFLICTS_H
+#define POOL_FILECONFLICTS_H
+
+#include "pool.h"
+
+extern int pool_findfileconflicts(Pool *pool, Queue *pkgs, Queue *conflicts, void *(*handle_cb)(Pool *, Id, void *) , void *handle_cbdata);
+
+#endif
diff --git a/tools/repo_rpmdb.c b/tools/repo_rpmdb.c
index bdd58d2..ddb6b68 100644
--- a/tools/repo_rpmdb.c
+++ b/tools/repo_rpmdb.c
@@ -55,6 +55,8 @@
#define TAG_ARCH 1022
#define TAG_FILESIZES 1028
#define TAG_FILEMODES 1030
+#define TAG_FILEMD5S 1035
+#define TAG_FILELINKTOS 1036
#define TAG_SOURCERPM 1044
#define TAG_PROVIDENAME 1047
#define TAG_REQUIREFLAGS 1048
@@ -1358,7 +1360,10 @@ repo_add_rpmdb(Repo *repo, Repo *ref, const char *rootdir, int flags)
exit(1);
}
if (dbdata.size > rpmheadsize)
- rpmhead = sat_realloc(rpmhead, sizeof(*rpmhead) + dbdata.size);
+ {
+ rpmheadsize = dbdata.size + 128;
+ rpmhead = sat_realloc(rpmhead, sizeof(*rpmhead) + rpmheadsize);
+ }
memcpy(buf, dbdata.data, 8);
rpmhead->cnt = buf[0] << 24 | buf[1] << 16 | buf[2] << 8 | buf[3];
rpmhead->dcnt = buf[4] << 24 | buf[5] << 16 | buf[6] << 8 | buf[7];
@@ -1585,7 +1590,10 @@ repo_add_rpmdb(Repo *repo, Repo *ref, const char *rootdir, int flags)
exit(1);
}
if (dbdata.size > rpmheadsize)
- rpmhead = sat_realloc(rpmhead, sizeof(*rpmhead) + dbdata.size);
+ {
+ rpmheadsize = dbdata.size + 128;
+ rpmhead = sat_realloc(rpmhead, sizeof(*rpmhead) + rpmheadsize);
+ }
memcpy(buf, dbdata.data, 8);
rpmhead->cnt = buf[0] << 24 | buf[1] << 16 | buf[2] << 8 | buf[3];
rpmhead->dcnt = buf[4] << 24 | buf[5] << 16 | buf[6] << 8 | buf[7];
@@ -1736,7 +1744,10 @@ repo_add_rpms(Repo *repo, const char **rpms, int nrpms, int flags)
l = sigdsize + sigcnt * 16;
headerend = headerstart + 16 + l;
if (l > rpmheadsize)
- rpmhead = sat_realloc(rpmhead, sizeof(*rpmhead) + l);
+ {
+ rpmheadsize = l + 128;
+ rpmhead = sat_realloc(rpmhead, sizeof(*rpmhead) + rpmheadsize);
+ }
if (fread(rpmhead->data, l, 1, fp) != 1)
{
fprintf(stderr, "%s: unexpected EOF\n", rpms[i]);
@@ -1775,3 +1786,351 @@ repo_add_rpms(Repo *repo, const char **rpms, int nrpms, int flags)
if (!(flags & REPO_NO_INTERNALIZE))
repodata_internalize(data);
}
+
+static inline void
+linkhash(const char *lt, char *hash)
+{
+ unsigned int r = 0;
+ const unsigned char *str = (const unsigned char *)lt;
+ int l, c;
+
+ l = strlen(lt);
+ while ((c = *str++) != 0)
+ r += (r << 3) + c;
+ sprintf(hash, "%08x", r);
+ sprintf(hash + 8, "%08x", l);
+ sprintf(hash + 16, "%08x", 0);
+ sprintf(hash + 24, "%08x", 0);
+}
+
+void
+rpm_iterate_filelist(void *rpmhandle, int flags, void (*cb)(void *, char *, int, char *), void *cbdata)
+{
+ RpmHead *rpmhead = rpmhandle;
+ char **bn;
+ char **dn;
+ char **md = 0;
+ char **lt = 0;
+ unsigned int *di;
+ unsigned int *fm;
+ int cnt, dcnt, cnt2;
+ int i, l1, l;
+ char *space = 0;
+ int spacen = 0;
+ char md5[33], *md5p = 0;
+
+ dn = headstringarray(rpmhead, TAG_DIRNAMES, &dcnt);
+ if (!dn)
+ return;
+ if ((flags & RPM_ITERATE_FILELIST_ONLYDIRS) != 0)
+ {
+ for (i = 0; i < dcnt; i++)
+ (*cb)(cbdata, dn[i], 0, (char *)0);
+ sat_free(dn);
+ return;
+ }
+ bn = headstringarray(rpmhead, TAG_BASENAMES, &cnt);
+ if (!bn)
+ {
+ sat_free(dn);
+ return;
+ }
+ di = headint32array(rpmhead, TAG_DIRINDEXES, &cnt2);
+ if (!di || cnt != cnt2)
+ {
+ sat_free(di);
+ sat_free(bn);
+ sat_free(dn);
+ return;
+ }
+ fm = headint16array(rpmhead, TAG_FILEMODES, &cnt2);
+ if (!fm || cnt != cnt2)
+ {
+ sat_free(fm);
+ sat_free(di);
+ sat_free(bn);
+ sat_free(dn);
+ return;
+ }
+ if ((flags & RPM_ITERATE_FILELIST_WITHMD5) != 0)
+ {
+ md = headstringarray(rpmhead, TAG_FILEMD5S, &cnt2);
+ if (!md || cnt != cnt2)
+ {
+ sat_free(md);
+ sat_free(fm);
+ sat_free(di);
+ sat_free(bn);
+ sat_free(dn);
+ return;
+ }
+ }
+ for (i = 0; i < cnt; i++)
+ {
+ if (di[i] >= dcnt)
+ continue;
+ l1 = strlen(dn[di[i]]);
+ if (l1 == 0)
+ continue;
+ l = l1 + strlen(bn[i]) + 1;
+ if (l > spacen)
+ {
+ spacen = l + 16;
+ space = sat_realloc(space, spacen);
+ }
+ strcpy(space, dn[di[i]]);
+ strcpy(space + l1, bn[i]);
+ if (md)
+ {
+ md5p = md[i];
+ if (S_ISLNK(fm[i]))
+ {
+ md5p = 0;
+ if (!lt)
+ {
+ lt = headstringarray(rpmhead, TAG_FILELINKTOS, &cnt2);
+ if (cnt != cnt2)
+ lt = sat_free(lt);
+ }
+ if (lt)
+ {
+ linkhash(lt[i], md5);
+ md5p = md5;
+ }
+ }
+ if (!md5p)
+ md5p = "";
+ }
+ (*cb)(cbdata, space, fm[i], md5p);
+ }
+ sat_free(lt);
+ sat_free(md);
+ sat_free(fm);
+ sat_free(di);
+ sat_free(bn);
+ sat_free(dn);
+}
+
+
+struct rpm_by_state {
+ RpmHead *rpmhead;
+ int rpmheadsize;
+
+ int dbopened;
+ DB_ENV *dbenv;
+ DB *db;
+ int byteswapped;
+};
+
+void *
+rpm_byrpmdbid(Id rpmdbid, const char *rootdir, void **statep)
+{
+ struct rpm_by_state *state = *statep;
+ unsigned char buf[16];
+ DBT dbkey;
+ DBT dbdata;
+ RpmHead *rpmhead;
+
+ if (!rpmdbid)
+ {
+ /* close down */
+ if (!state)
+ return 0;
+ if (state->db)
+ state->db->close(state->db, 0);
+ if (state->dbenv)
+ state->dbenv->close(state->dbenv, 0);
+ sat_free(state->rpmhead);
+ sat_free(state);
+ *statep = (void *)0;
+ return 0;
+ }
+
+ if (!state)
+ {
+ state = sat_calloc(1, sizeof(*state));
+ *statep = state;
+ }
+ if (!state->dbopened)
+ {
+ char dbpath[PATH_MAX];
+ state->dbopened = 1;
+ if (db_env_create(&state->dbenv, 0))
+ {
+ perror("db_env_create");
+ state->dbenv = 0;
+ return 0;
+ }
+ if (!rootdir)
+ rootdir = "";
+ snprintf(dbpath, PATH_MAX, "%s/var/lib/rpm", rootdir);
+#ifdef FEDORA
+ if (state->dbenv->open(state->dbenv, dbpath, DB_CREATE|DB_INIT_CDB|DB_INIT_MPOOL, 0))
+#else
+ if (state->dbenv->open(state->dbenv, dbpath, DB_CREATE|DB_PRIVATE|DB_INIT_MPOOL, 0))
+#endif
+ {
+ perror("dbenv open");
+ state->dbenv->close(state->dbenv, 0);
+ state->dbenv = 0;
+ return 0;
+ }
+ if (db_create(&state->db, state->dbenv, 0))
+ {
+ perror("db_create");
+ state->db = 0;
+ state->dbenv->close(state->dbenv, 0);
+ state->dbenv = 0;
+ return 0;
+ }
+ if (state->db->open(state->db, 0, "Packages", 0, DB_UNKNOWN, DB_RDONLY, 0664))
+ {
+ perror("db->open var/lib/rpm/Packages");
+ state->db->close(state->db, 0);
+ state->db = 0;
+ state->dbenv->close(state->dbenv, 0);
+ state->dbenv = 0;
+ return 0;
+ }
+ if (state->db->get_byteswapped(state->db, &state->byteswapped))
+ {
+ perror("db->get_byteswapped");
+ state->db->close(state->db, 0);
+ state->db = 0;
+ state->dbenv->close(state->dbenv, 0);
+ state->dbenv = 0;
+ return 0;
+ }
+ }
+ memcpy(buf, &rpmdbid, 4);
+ if (state->byteswapped)
+ {
+ unsigned char bx;
+ bx = buf[0]; buf[0] = buf[3]; buf[3] = bx;
+ bx = buf[1]; buf[1] = buf[2]; buf[2] = bx;
+ }
+ memset(&dbkey, 0, sizeof(dbkey));
+ memset(&dbdata, 0, sizeof(dbdata));
+ dbkey.data = buf;
+ dbkey.size = 4;
+ dbdata.data = 0;
+ dbdata.size = 0;
+ if (state->db->get(state->db, NULL, &dbkey, &dbdata, 0))
+ {
+ perror("db->get");
+ return 0;
+ }
+ if (dbdata.size < 8)
+ {
+ fprintf(stderr, "corrupt rpm database (size)\n");
+ return 0;
+ }
+ if (dbdata.size > state->rpmheadsize)
+ {
+ state->rpmheadsize = dbdata.size + 128;
+ state->rpmhead = sat_realloc(state->rpmhead, sizeof(*rpmhead) + state->rpmheadsize);
+ }
+ rpmhead = state->rpmhead;
+ memcpy(buf, dbdata.data, 8);
+ rpmhead->cnt = buf[0] << 24 | buf[1] << 16 | buf[2] << 8 | buf[3];
+ rpmhead->dcnt = buf[4] << 24 | buf[5] << 16 | buf[6] << 8 | buf[7];
+ if (8 + rpmhead->cnt * 16 + rpmhead->dcnt > dbdata.size)
+ {
+ fprintf(stderr, "corrupt rpm database (data size)\n");
+ return 0;
+ }
+ memcpy(rpmhead->data, (unsigned char *)dbdata.data + 8, rpmhead->cnt * 16 + rpmhead->dcnt);
+ rpmhead->dp = rpmhead->data + rpmhead->cnt * 16;
+ return rpmhead;
+}
+
+void *
+rpm_byfp(FILE *fp, const char *name, void **statep)
+{
+ struct rpm_by_state *state = *statep;
+ int headerstart, headerend;
+ RpmHead *rpmhead;
+ int sigdsize, sigcnt, l;
+ unsigned char lead[4096];
+
+ if (!fp)
+ return rpm_byrpmdbid(0, 0, statep);
+ if (!state)
+ {
+ state = sat_calloc(1, sizeof(*state));
+ *statep = state;
+ }
+ if (fread(lead, 96 + 16, 1, fp) != 1 || getu32(lead) != 0xedabeedb)
+ {
+ fprintf(stderr, "%s: not a rpm\n", name);
+ return 0;
+ }
+ if (lead[78] != 0 || lead[79] != 5)
+ {
+ fprintf(stderr, "%s: not a V5 header\n", name);
+ return 0;
+ }
+ if (getu32(lead + 96) != 0x8eade801)
+ {
+ fprintf(stderr, "%s: bad signature header\n", name);
+ return 0;
+ }
+ sigcnt = getu32(lead + 96 + 8);
+ sigdsize = getu32(lead + 96 + 12);
+ if (sigcnt >= 0x4000000 || sigdsize >= 0x40000000)
+ {
+ fprintf(stderr, "%s: bad signature header\n", name);
+ return 0;
+ }
+ sigdsize += sigcnt * 16;
+ sigdsize = (sigdsize + 7) & ~7;
+ headerstart = 96 + 16 + sigdsize;
+ while (sigdsize)
+ {
+ l = sigdsize > 4096 ? 4096 : sigdsize;
+ if (fread(lead, l, 1, fp) != 1)
+ {
+ fprintf(stderr, "%s: unexpected EOF\n", name);
+ return 0;
+ }
+ sigdsize -= l;
+ }
+ if (fread(lead, 16, 1, fp) != 1)
+ {
+ fprintf(stderr, "%s: unexpected EOF\n", name);
+ return 0;
+ }
+ if (getu32(lead) != 0x8eade801)
+ {
+ fprintf(stderr, "%s: bad header\n", name);
+ fclose(fp);
+ return 0;
+ }
+ sigcnt = getu32(lead + 8);
+ sigdsize = getu32(lead + 12);
+ if (sigcnt >= 0x4000000 || sigdsize >= 0x40000000)
+ {
+ fprintf(stderr, "%s: bad header\n", name);
+ fclose(fp);
+ return 0;
+ }
+ l = sigdsize + sigcnt * 16;
+ headerend = headerstart + 16 + l;
+ if (l > state->rpmheadsize)
+ {
+ state->rpmheadsize = l + 128;
+ state->rpmhead = sat_realloc(state->rpmhead, sizeof(*state->rpmhead) + state->rpmheadsize);
+ }
+ rpmhead = state->rpmhead;
+ if (fread(rpmhead->data, l, 1, fp) != 1)
+ {
+ fprintf(stderr, "%s: unexpected EOF\n", name);
+ fclose(fp);
+ return 0;
+ }
+ rpmhead->cnt = sigcnt;
+ rpmhead->dcnt = sigdsize;
+ rpmhead->dp = rpmhead->data + rpmhead->cnt * 16;
+ return rpmhead;
+}
+
diff --git a/tools/repo_rpmdb.h b/tools/repo_rpmdb.h
index bd416c8..6c907c7 100644
--- a/tools/repo_rpmdb.h
+++ b/tools/repo_rpmdb.h
@@ -9,3 +9,10 @@ extern void repo_add_rpmdb(Repo *repo, Repo *ref, const char *rootdir, int flags
extern void repo_add_rpms(Repo *repo, const char **rpms, int nrpms, int flags);
#define RPMDB_REPORT_PROGRESS (1 << 8)
+
+#define RPM_ITERATE_FILELIST_ONLYDIRS (1 << 0)
+#define RPM_ITERATE_FILELIST_WITHMD5 (1 << 1)
+
+void *rpm_byrpmdbid(Id rpmdbid, const char *rootdir, void **statep);
+void *rpm_byfp(FILE *fp, const char *name, void **statep);
+void rpm_iterate_filelist(void *rpmhandle, int flags, void (*cb)(void *, char *, int, char *), void *cbdata);
--
To unsubscribe, e-mail: zypp-commit+unsubscribe(a)opensuse.org
For additional commands, e-mail: zypp-commit+help(a)opensuse.org
1
0
[zypp-commit] <libzypp> master : Let --root detect and load testcases or testsetups.
by Michael Andres 18 Jun '09
by Michael Andres 18 Jun '09
18 Jun '09
ref: refs/heads/master
commit 94e3d320095a8dd12746baf046edd143cd7144c7
Author: Michael Andres <ma(a)suse.de>
Date: Thu Jun 18 14:08:52 2009 +0200
Let --root detect and load testcases or testsetups.
---
tools/NameReqPrv.cc | 108 +++++++++++++++++++++++++++++++++++++--------------
1 files changed, 79 insertions(+), 29 deletions(-)
diff --git a/tools/NameReqPrv.cc b/tools/NameReqPrv.cc
index 94bdc04..f21f8af 100644
--- a/tools/NameReqPrv.cc
+++ b/tools/NameReqPrv.cc
@@ -11,6 +11,17 @@ void message( const std::string & msg_r )
cerr << "*** " << msg_r << endl;
}
+int errexit( const std::string & msg_r = std::string(), int exit_r = 100 )
+{
+ if ( ! msg_r.empty() )
+ {
+ cerr << endl;
+ message( msg_r );
+ cerr << endl;
+ }
+ return exit_r;
+}
+
int usage( const std::string & msg_r = std::string(), int exit_r = 100 )
{
if ( ! msg_r.empty() )
@@ -19,14 +30,18 @@ int usage( const std::string & msg_r = std::string(), int exit_r = 100 )
message( msg_r );
cerr << endl;
}
- cerr << "Usage: " << appname << " [OPTIONS] NAME... [[OPTIONS] NAME...]..." << endl;
+ cerr << "Usage: " << appname << " [--root ROOTDIR] [OPTIONS] NAME... [[OPTIONS] NAME...]..." << endl;
cerr << " Load all enabled repositories (no refresh) and search for" << endl;
cerr << " occurrences of NAME (substring) in package names, provides or" << endl;
cerr << " requires." << endl;
+ cerr << " --root Load repos from the system located below ROOTDIR. If ROOTDIR" << endl;
+ cerr << " denotes a sover testcase, the testcase is loaded." << endl;
cerr << " -i/-I turn on/off case insensitive search (default on)" << endl;
cerr << " -n/-N turn on/off looking for names (default on)" << endl;
cerr << " -p/-P turn on/off looking for provides (default off)" << endl;
cerr << " -r/-R turn on/off looking for requires (default off)" << endl;
+ cerr << " -a short for -n -p -r" << endl;
+ cerr << " -A short for -n -P -R" << endl;
cerr << "TODO: Waiting for PoolQuery::allMatches switch and need to beautify output." << endl;
cerr << "" << endl;
return exit_r;
@@ -51,42 +66,72 @@ int main( int argc, char * argv[] )
///////////////////////////////////////////////////////////////////
ZConfig::instance();
- Pathname sysRoot( "/" );
+ Pathname sysRoot("/");
- if ( 1 )
+ if ( (*argv) == std::string("--root") )
{
- message( "*** load target" );
- getZYpp()->initializeTarget( sysRoot );
- getZYpp()->target()->load();
+ --argc,++argv;
+ if ( ! argc )
+ return errexit("--root requires an argument.");
+
+ if ( ! PathInfo( *argv ).isDir() )
+ return errexit("--root requires a directory.");
+
+ sysRoot = *argv;
+ --argc,++argv;
}
- if ( 1 )
+ if ( TestSetup::isTestcase( sysRoot ) )
{
- RepoManager repoManager( sysRoot );
- RepoInfoList repos = repoManager.knownRepositories();
- for_( it, repos.begin(), repos.end() )
+ message( str::form( "*** Load Testcase from '%s'", sysRoot.c_str() ) );
+ TestSetup test;
+ test.loadTestcaseRepos( sysRoot );
+ }
+ else if ( TestSetup::isTestSetup( sysRoot ) )
+ {
+ message( str::form( "*** Load TestSetup from '%s'", sysRoot.c_str() ) );
+ TestSetup test( sysRoot );
+ test.loadRepos();
+ }
+ else
+ {
+ // a system
+ message( str::form( "*** Load system at '%s'", sysRoot.c_str() ) );
+ if ( 1 )
{
- RepoInfo & nrepo( *it );
-
- if ( ! nrepo.enabled() )
- continue;
-
- if ( ! repoManager.isCached( nrepo ) )
- {
- message( str::form( "*** omit uncached repo '%s' (do 'zypper refresh')", nrepo.name().c_str() ) );
- continue;
- }
+ message( "*** load target" );
+ getZYpp()->initializeTarget( sysRoot );
+ getZYpp()->target()->load();
+ }
- message( str::form( "*** load repo '%s'", nrepo.name().c_str() ) );
- try
- {
- repoManager.loadFromCache( nrepo );
- }
- catch ( const Exception & exp )
+ if ( 1 )
+ {
+ RepoManager repoManager( sysRoot );
+ RepoInfoList repos = repoManager.knownRepositories();
+ for_( it, repos.begin(), repos.end() )
{
- message( exp.asString() + "\n" + exp.historyAsString() );
- message( str::form( "*** omit broken repo '%s' (do 'zypper refresh')", nrepo.name().c_str() ) );
- continue;
+ RepoInfo & nrepo( *it );
+
+ if ( ! nrepo.enabled() )
+ continue;
+
+ if ( ! repoManager.isCached( nrepo ) )
+ {
+ message( str::form( "*** omit uncached repo '%s' (do 'zypper refresh')", nrepo.name().c_str() ) );
+ continue;
+ }
+
+ message( str::form( "*** load repo '%s'", nrepo.name().c_str() ) );
+ try
+ {
+ repoManager.loadFromCache( nrepo );
+ }
+ catch ( const Exception & exp )
+ {
+ message( exp.asString() + "\n" + exp.historyAsString() );
+ message( str::form( "*** omit broken repo '%s' (do 'zypper refresh')", nrepo.name().c_str() ) );
+ continue;
+ }
}
}
}
@@ -106,6 +151,8 @@ int main( int argc, char * argv[] )
{
switch ( (*argv)[1] )
{
+ case 'a': names = true, requires = provides = true; break;
+ case 'A': names = true, requires = provides = false; break;
case 'i': ignorecase = true; break;
case 'I': ignorecase = false; break;
case 'n': names = true; break;
@@ -130,6 +177,9 @@ int main( int argc, char * argv[] )
if ( requires )
q.addDependency( sat::SolvAttr::requires );
+// q.begin();
+// cerr << q << endl;
+
cerr << *argv << " [" << (ignorecase?'i':'_') << (names?'n':'_') << (requires?'r':'_') << (provides?'p':'_') << "] {" << endl;
for_( it, q.begin(), q.end() )
--
To unsubscribe, e-mail: zypp-commit+unsubscribe(a)opensuse.org
For additional commands, e-mail: zypp-commit+help(a)opensuse.org
1
0
[zypp-commit] <libzypp> master : Add test for directories containing testcase or testsetup.
by Michael Andres 18 Jun '09
by Michael Andres 18 Jun '09
18 Jun '09
ref: refs/heads/master
commit f78e85a1ba3ace4f64b6ae37befc29d7a31a3317
Author: Michael Andres <ma(a)suse.de>
Date: Thu Jun 18 14:08:01 2009 +0200
Add test for directories containing testcase or testsetup.
---
tests/lib/TestSetup.h | 13 +++++++++++++
1 files changed, 13 insertions(+), 0 deletions(-)
diff --git a/tests/lib/TestSetup.h b/tests/lib/TestSetup.h
index 2839db4..b371712 100644
--- a/tests/lib/TestSetup.h
+++ b/tests/lib/TestSetup.h
@@ -93,6 +93,19 @@ class TestSetup
{ USR << (_tmprootdir.path() == _rootdir ? "DELETE" : "KEEP") << " TESTSETUP below " << _rootdir << endl; }
public:
+ /** Whether directory \a path_r contains a solver testcase. */
+ static bool isTestcase( const Pathname & path_r )
+ {
+ return filesystem::PathInfo( path_r / "solver-test.xml" ).isFile();
+ }
+
+ /** Whether directory \a path_r contains a testsetup. */
+ static bool isTestSetup( const Pathname & path_r )
+ {
+ return filesystem::PathInfo( path_r / "repos.d" ).isDir() && filesystem::PathInfo( path_r / "raw" ).isDir();
+ }
+
+ public:
const Pathname & root() const { return _rootdir; }
Target & target() { if ( ! getZYpp()->getTarget() ) getZYpp()->initializeTarget( _rootdir ); return *getZYpp()->getTarget(); }
--
To unsubscribe, e-mail: zypp-commit+unsubscribe(a)opensuse.org
For additional commands, e-mail: zypp-commit+help(a)opensuse.org
1
0