add pool_lookup_deltalocation helper so we can change the way the location is encoded
authorMichael Schroeder <mls@suse.de>
Fri, 2 Nov 2012 14:01:53 +0000 (15:01 +0100)
committerMichael Schroeder <mls@suse.de>
Fri, 2 Nov 2012 14:01:53 +0000 (15:01 +0100)
bindings/solv.i
examples/pysolv
examples/solv.c
src/libsolv.ver
src/pool.c
src/pool.h
src/solvable.c
src/solvable.h

index 0046253..1fbe23a 100644 (file)
@@ -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;
index a9dc144..d3e7d81 100755 (executable)
@@ -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:
index f728432..63e6c49 100644 (file)
@@ -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);
index 1b21ea4..f0bb650 100644 (file)
@@ -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;
index 6116f02..b5b50d1 100644 (file)
@@ -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)
 {
index 77ee7ec..5e55110 100644 (file)
@@ -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);
 
index 71ffa71..63cc9f2 100644 (file)
@@ -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;
index fce2b2f..955464e 100644 (file)
@@ -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);