From 01226ce8a0d8cdcb27a15ed0f4362723ee71dcf7 Mon Sep 17 00:00:00 2001 From: Michael Schroeder Date: Fri, 2 Nov 2012 15:01:53 +0100 Subject: [PATCH] add pool_lookup_deltalocation helper so we can change the way the location is encoded --- bindings/solv.i | 24 +++++++++++++++++++++++- examples/pysolv | 4 ++-- examples/solv.c | 11 +++++------ src/libsolv.ver | 2 ++ src/pool.c | 13 +++++++++++++ src/pool.h | 1 + src/solvable.c | 8 +++++++- src/solvable.h | 3 ++- 8 files changed, 55 insertions(+), 11 deletions(-) diff --git a/bindings/solv.i b/bindings/solv.i index 0046253..1fbe23a 100644 --- a/bindings/solv.i +++ b/bindings/solv.i @@ -1509,6 +1509,28 @@ typedef struct { pool->pos = oldpos; return solv_chksum_create_from_bin(type, b); } + const char *lookup_deltaseq() { + Pool *pool = $self->repo->pool; + Datapos oldpos = pool->pos; + const char *seq; + pool->pos = *$self; + seq = pool_lookup_str(pool, SOLVID_POS, DELTA_SEQ_NAME); + if (seq) { + seq = pool_tmpjoin(pool, seq, "-", pool_lookup_str(pool, SOLVID_POS, DELTA_SEQ_EVR)); + seq = pool_tmpappend(pool, seq, "-", pool_lookup_str(pool, SOLVID_POS, DELTA_SEQ_NUM)); + } + pool->pos = oldpos; + return seq; + } + const char *lookup_deltalocation() { + Pool *pool = $self->repo->pool; + Datapos oldpos = pool->pos; + const char *loc; + pool->pos = *$self; + loc = pool_lookup_deltalocation(pool, SOLVID_POS); + pool->pos = oldpos; + return loc; + } } %extend Datamatch { @@ -1846,7 +1868,7 @@ typedef struct { return r; } const char *lookup_location(unsigned int *OUTPUT) { - return solvable_get_location($self->pool->solvables + $self->id, OUTPUT); + return solvable_lookup_location($self->pool->solvables + $self->id, OUTPUT); } #ifdef SWIGRUBY %rename("installable?") installable; diff --git a/examples/pysolv b/examples/pysolv index a9dc144..d3e7d81 100755 --- a/examples/pysolv +++ b/examples/pysolv @@ -874,14 +874,14 @@ if cmd == 'install' or cmd == 'erase' or cmd == 'up' or cmd == 'dup' or cmd == ' candidate = installedp if not candidate: continue - seq = dp.lookup_str(solv.DELTA_SEQ_NAME) + '-' + dp.lookup_str(solv.DELTA_SEQ_EVR) + '-' + dp.lookup_str(solv.DELTA_SEQ_NUM) + seq = dp.lookup_deltaseq() st = subprocess.call(['/usr/bin/applydeltarpm', '-a', p.arch, '-c', '-s', seq]) if st: continue chksum = dp.lookup_checksum(solv.DELTA_CHECKSUM) if not chksum: continue - dloc = dp.lookup_str(solv.DELTA_LOCATION_DIR) + '/' + dp.lookup_str(solv.DELTA_LOCATION_NAME) + '-' + dp.lookup_str(solv.DELTA_LOCATION_EVR) + '.' + dp.lookup_str(solv.DELTA_LOCATION_SUFFIX) + dloc = 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 f728432..63e6c49 100644 --- a/examples/solv.c +++ b/examples/solv.c @@ -2951,7 +2951,7 @@ rerunsolver: s = pool_id2solvable(pool, p); if (s->repo == commandlinerepo) { - loc = solvable_get_location(s, &medianr); + loc = solvable_lookup_location(s, &medianr); if (!(newpkgsfps[i] = fopen(loc, "r"))) { perror(loc); @@ -2966,7 +2966,7 @@ rerunsolver: printf("%s: no repository information\n", s->repo->name); exit(1); } - loc = solvable_get_location(s, &medianr); + loc = solvable_lookup_location(s, &medianr); if (!loc) continue; @@ -3027,10 +3027,9 @@ rerunsolver: chksum = pool_lookup_bin_checksum(pool, SOLVID_POS, DELTA_CHECKSUM, &chksumtype); if (!chksumtype) continue; /* no way! */ - dloc = pool_lookup_str(pool, SOLVID_POS, DELTA_LOCATION_DIR); - dloc = pool_tmpappend(pool, dloc, "/", pool_lookup_str(pool, SOLVID_POS, DELTA_LOCATION_NAME)); - dloc = pool_tmpappend(pool, dloc, "-", pool_lookup_str(pool, SOLVID_POS, DELTA_LOCATION_EVR)); - dloc = pool_tmpappend(pool, dloc, ".", pool_lookup_str(pool, SOLVID_POS, DELTA_LOCATION_SUFFIX)); + dloc = pool_lookup_deltalocation(pool, SOLVID_POS); + if (!dloc) + continue; if (cinfo->type == TYPE_SUSETAGS) { const char *datadir = repo_lookup_str(cinfo->repo, SOLVID_META, SUSETAGS_DATADIR); diff --git a/src/libsolv.ver b/src/libsolv.ver index 1b21ea4..f0bb650 100644 --- a/src/libsolv.ver +++ b/src/libsolv.ver @@ -75,6 +75,7 @@ SOLV_1.0 { pool_job2str; pool_lookup_bin_checksum; pool_lookup_checksum; + pool_lookup_deltalocation; pool_lookup_id; pool_lookup_num; pool_lookup_str; @@ -270,6 +271,7 @@ SOLV_1.0 { solvable_lookup_deparray; solvable_lookup_id; solvable_lookup_idarray; + solvable_lookup_location; solvable_lookup_num; solvable_lookup_sizek; solvable_lookup_sourcepkg; diff --git a/src/pool.c b/src/pool.c index 6116f02..b5b50d1 100644 --- a/src/pool.c +++ b/src/pool.c @@ -2072,6 +2072,19 @@ pool_lookup_checksum(Pool *pool, Id entry, Id keyname, Id *typep) return solvable_lookup_checksum(pool->solvables + entry, keyname, typep); } +const char * +pool_lookup_deltalocation(Pool *pool, Id entry) +{ + const char *loc; + 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)); + return loc; +} + void pool_add_fileconflicts_deps(Pool *pool, Queue *conflicts) { diff --git a/src/pool.h b/src/pool.h index 77ee7ec..5e55110 100644 --- a/src/pool.h +++ b/src/pool.h @@ -333,6 +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); void pool_add_fileconflicts_deps(Pool *pool, Queue *conflicts); diff --git a/src/solvable.c b/src/solvable.c index 71ffa71..63cc9f2 100644 --- a/src/solvable.c +++ b/src/solvable.c @@ -269,7 +269,7 @@ evrid2vrstr(Pool *pool, Id evrid) } const char * -solvable_get_location(Solvable *s, unsigned int *medianrp) +solvable_lookup_location(Solvable *s, unsigned int *medianrp) { Pool *pool; int l = 0; @@ -317,6 +317,12 @@ solvable_get_location(Solvable *s, unsigned int *medianrp) } const char * +solvable_get_location(Solvable *s, unsigned int *medianrp) +{ + return solvable_lookup_location(s, medianrp); +} + +const char * solvable_lookup_sourcepkg(Solvable *s) { Pool *pool; diff --git a/src/solvable.h b/src/solvable.h index fce2b2f..955464e 100644 --- a/src/solvable.h +++ b/src/solvable.h @@ -52,7 +52,8 @@ const char *solvable_lookup_str_poollang(Solvable *s, Id keyname); const char *solvable_lookup_str_lang(Solvable *s, Id keyname, const char *lang, int usebase); int solvable_lookup_bool(Solvable *s, Id keyname); int solvable_lookup_void(Solvable *s, Id keyname); -const char *solvable_get_location(Solvable *s, unsigned int *medianrp); +const char *solvable_get_location(Solvable *s, unsigned int *medianrp); /* old name */ +const char *solvable_lookup_location(Solvable *s, unsigned int *medianrp); const char *solvable_lookup_sourcepkg(Solvable *s); const unsigned char *solvable_lookup_bin_checksum(Solvable *s, Id keyname, Id *typep); const char *solvable_lookup_checksum(Solvable *s, Id keyname, Id *typep); -- 2.7.4