support medianr in lookup_deltalocation, change lookup_location to return medianr...
authorMichael Schroeder <mls@suse.de>
Fri, 23 Nov 2012 13:27:02 +0000 (14:27 +0100)
committerMichael Schroeder <mls@suse.de>
Fri, 23 Nov 2012 13:27:02 +0000 (14:27 +0100)
bindings/solv.i
examples/pysolv
examples/solv.c
src/pool.c
src/pool.h
src/solvable.c

index 2dc04bb..4d7624e 100644 (file)
@@ -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;
   }
index 41f5cda..bcc8bec 100755 (executable)
@@ -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:
index cbe121c..e489872 100644 (file)
@@ -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)
index 60b26ff..4b6ab43 100644 (file)
@@ -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;
 }
 
index 5e55110..cb83800 100644 (file)
@@ -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);
 
index d0b4a2b..536c1b0 100644 (file)
@@ -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 *