From eef58960087e9d7b347e77629b0da03b656b8377 Mon Sep 17 00:00:00 2001 From: Michael Schroeder Date: Fri, 23 Nov 2012 14:27:02 +0100 Subject: [PATCH] support medianr in lookup_deltalocation, change lookup_location to return medianr 0 if the media number was not set --- bindings/solv.i | 4 ++-- examples/pysolv | 2 +- examples/solv.c | 2 +- src/pool.c | 12 +++++++----- src/pool.h | 2 +- src/solvable.c | 7 +++++-- 6 files changed, 17 insertions(+), 12 deletions(-) diff --git a/bindings/solv.i b/bindings/solv.i index 2dc04bb..4d7624e 100644 --- a/bindings/solv.i +++ b/bindings/solv.i @@ -1647,12 +1647,12 @@ typedef struct { pool->pos = oldpos; return seq; } - const char *lookup_deltalocation() { + const char *lookup_deltalocation(unsigned int *OUTPUT) { Pool *pool = $self->repo->pool; Datapos oldpos = pool->pos; const char *loc; pool->pos = *$self; - loc = pool_lookup_deltalocation(pool, SOLVID_POS); + loc = pool_lookup_deltalocation(pool, SOLVID_POS, OUTPUT); pool->pos = oldpos; return loc; } diff --git a/examples/pysolv b/examples/pysolv index 41f5cda..bcc8bec 100755 --- a/examples/pysolv +++ b/examples/pysolv @@ -867,7 +867,7 @@ if cmd == 'install' or cmd == 'erase' or cmd == 'up' or cmd == 'dup' or cmd == ' chksum = dp.lookup_checksum(solv.DELTA_CHECKSUM) if not chksum: continue - dloc = dp.lookup_deltalocation() + dloc, dmedianr = dp.lookup_deltalocation() dloc = repo.packagespath() + dloc f = repo.download(dloc, False, chksum) if not f: diff --git a/examples/solv.c b/examples/solv.c index cbe121c..e489872 100644 --- a/examples/solv.c +++ b/examples/solv.c @@ -3029,7 +3029,7 @@ rerunsolver: chksum = pool_lookup_bin_checksum(pool, SOLVID_POS, DELTA_CHECKSUM, &chksumtype); if (!chksumtype) continue; /* no way! */ - dloc = pool_lookup_deltalocation(pool, SOLVID_POS); + dloc = pool_lookup_deltalocation(pool, SOLVID_POS, 0); if (!dloc) continue; if (cinfo->type == TYPE_SUSETAGS) diff --git a/src/pool.c b/src/pool.c index 60b26ff..4b6ab43 100644 --- a/src/pool.c +++ b/src/pool.c @@ -2073,15 +2073,17 @@ pool_lookup_checksum(Pool *pool, Id entry, Id keyname, Id *typep) } const char * -pool_lookup_deltalocation(Pool *pool, Id entry) +pool_lookup_deltalocation(Pool *pool, Id entry, unsigned int *medianrp) { const char *loc; + if (medianrp) + *medianrp = 0; if (entry != SOLVID_POS) return 0; - loc = pool_lookup_str(pool, SOLVID_POS, DELTA_LOCATION_DIR); - loc = pool_tmpjoin(pool, loc, loc ? "/" : 0, pool_lookup_str(pool, SOLVID_POS, DELTA_LOCATION_NAME)); - loc = pool_tmpappend(pool, loc, "-", pool_lookup_str(pool, SOLVID_POS, DELTA_LOCATION_EVR)); - loc = pool_tmpappend(pool, loc, ".", pool_lookup_str(pool, SOLVID_POS, DELTA_LOCATION_SUFFIX)); + loc = pool_lookup_str(pool, entry, DELTA_LOCATION_DIR); + loc = pool_tmpjoin(pool, loc, loc ? "/" : 0, pool_lookup_str(pool, entry, DELTA_LOCATION_NAME)); + loc = pool_tmpappend(pool, loc, "-", pool_lookup_str(pool, entry, DELTA_LOCATION_EVR)); + loc = pool_tmpappend(pool, loc, ".", pool_lookup_str(pool, entry, DELTA_LOCATION_SUFFIX)); return loc; } diff --git a/src/pool.h b/src/pool.h index 5e55110..cb83800 100644 --- a/src/pool.h +++ b/src/pool.h @@ -333,7 +333,7 @@ unsigned long long pool_lookup_num(Pool *pool, Id entry, Id keyname, unsigned lo 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); -const char *pool_lookup_deltalocation(Pool *pool, Id entry); +const char *pool_lookup_deltalocation(Pool *pool, Id entry, unsigned int *medianrp); void pool_add_fileconflicts_deps(Pool *pool, Queue *conflicts); diff --git a/src/solvable.c b/src/solvable.c index d0b4a2b..536c1b0 100644 --- a/src/solvable.c +++ b/src/solvable.c @@ -282,7 +282,7 @@ solvable_lookup_location(Solvable *s, unsigned int *medianrp) return 0; pool = s->repo->pool; if (medianrp) - *medianrp = solvable_lookup_num(s, SOLVABLE_MEDIANR, 1); + *medianrp = solvable_lookup_num(s, SOLVABLE_MEDIANR, 0); if (solvable_lookup_void(s, SOLVABLE_MEDIADIR)) mediadir = pool_id2str(pool, s->arch); else @@ -319,7 +319,10 @@ solvable_lookup_location(Solvable *s, unsigned int *medianrp) const char * solvable_get_location(Solvable *s, unsigned int *medianrp) { - return solvable_lookup_location(s, medianrp); + const char *loc = solvable_lookup_location(s, medianrp); + if (medianrp && *medianrp == 0) + *medianrp = 1; /* compat, to be removed */ + return loc; } const char * -- 2.7.4