Imported Upstream version 0.7.11 upstream/0.7.11
authorDongHun Kwak <dh0128.kwak@samsung.com>
Fri, 27 Nov 2020 05:49:10 +0000 (14:49 +0900)
committerDongHun Kwak <dh0128.kwak@samsung.com>
Fri, 27 Nov 2020 05:49:10 +0000 (14:49 +0900)
16 files changed:
CMakeLists.txt
NEWS
README
VERSION.cmake
doc/gen/libsolv-bindings.3
doc/gen/libsolv-pool.3
doc/libsolv-pool.txt
ext/repo_rpmdb.c
ext/repo_rpmdb_bdb.h
ext/repo_rpmdb_librpm.h
ext/solv_zchunk.c
package/libsolv.changes
src/rules.c
src/solver.c
src/solvversion.h.in
src/suse.c

index b7e5d7a..c1ada00 100644 (file)
@@ -17,6 +17,7 @@ OPTION (ENABLE_RPMPKG "Build with rpm package support?" OFF)
 OPTION (ENABLE_PUBKEY "Build with pubkey support?" OFF)
 OPTION (ENABLE_RPMDB_BYRPMHEADER "Build with rpmdb Header support?" OFF)
 OPTION (ENABLE_RPMDB_LIBRPM "Use librpm to access the rpm database?" OFF)
+OPTION (ENABLE_RPMDB_BDB "Use BerkeleyDB to access the rpm database?" OFF)
 OPTION (ENABLE_RPMPKG_LIBRPM "Use librpm to access rpm header information?" OFF)
 OPTION (ENABLE_RPMMD "Build with rpmmd repository support?" OFF)
 OPTION (ENABLE_SUSEREPO "Build with suse repository support?" OFF)
@@ -223,19 +224,26 @@ IF (ENABLE_RPMDB OR ENABLE_RPMPKG_LIBRPM)
     ENDIF (RPMMISC_LIBRARY)
   ENDIF (RPM5)
 
-  # check if rpm contains a bundled berkeley db
-  CHECK_INCLUDE_FILE(rpm/db.h HAVE_RPM_DB_H)
-  IF (NOT ENABLE_RPMDB_LIBRPM)
-    IF (NOT HAVE_RPM_DB_H)
-      FIND_LIBRARY (DB_LIBRARY NAMES db)
-      IF (DB_LIBRARY)
-        SET (RPMDB_LIBRARY ${DB_LIBRARY} ${RPMDB_LIBRARY})
-      ENDIF (DB_LIBRARY)
-      IF (DB_INCLUDE_DIR)
-        INCLUDE_DIRECTORIES (${DB_INCLUDE_DIR})
-      ENDIF (DB_INCLUDE_DIR)
-    ENDIF (NOT HAVE_RPM_DB_H)
-  ENDIF (NOT ENABLE_RPMDB_LIBRPM)
+  IF (ENABLE_RPMDB)
+    IF (NOT ENABLE_RPMDB_BDB)
+      SET (ENABLE_RPMDB_LIBRPM ON)
+    ENDIF (NOT ENABLE_RPMDB_BDB)
+
+    # check if rpm contains a bundled berkeley db
+    CHECK_INCLUDE_FILE(rpm/db.h HAVE_RPM_DB_H)
+    IF (NOT ENABLE_RPMDB_LIBRPM)
+      IF (NOT HAVE_RPM_DB_H)
+        FIND_LIBRARY (DB_LIBRARY NAMES db)
+        IF (DB_LIBRARY)
+          SET (RPMDB_LIBRARY ${DB_LIBRARY} ${RPMDB_LIBRARY})
+        ENDIF (DB_LIBRARY)
+        IF (DB_INCLUDE_DIR)
+          INCLUDE_DIRECTORIES (${DB_INCLUDE_DIR})
+        ENDIF (DB_INCLUDE_DIR)
+      ENDIF (NOT HAVE_RPM_DB_H)
+    ENDIF (NOT ENABLE_RPMDB_LIBRPM)
+  ENDIF (ENABLE_RPMDB)
+
   INCLUDE (CheckLibraryExists)
   CHECK_LIBRARY_EXISTS(rpmio pgpDigGetParams "" HAVE_PGPDIGGETPARAMS)
   CHECK_LIBRARY_EXISTS(rpm rpmdbNextIteratorHeaderBlob "" HAVE_RPMDBNEXTITERATORHEADERBLOB)
diff --git a/NEWS b/NEWS
index ed9be3b..9d2d833 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -2,6 +2,13 @@
 This file contains the major changes between
 libsolv versions:
 
+Version 0.7.11
+- ENABLE_RPMDB_LIBRPM is now the default
+- selected bug fixes:
+  * fixed solv_zchunk decoding error if large chunks are used
+  * treat retracted pathes as irrelevant
+  * made add_update_target work with multiversion installs
+
 Version 0.7.10
 - new features:
   * new rpm_stat_database() function
diff --git a/README b/README
index 59ac1a1..41fe168 100644 (file)
--- a/README
+++ b/README
@@ -13,9 +13,9 @@ The code is based on two major, but independent, blocks:
     resolving package dependencies.
 
 The sat-solver code has been written to aim for the newest packages,
-record the decision tree to provide introspection, and also allows to
-provide the user with suggestions on how to deal with unsolvable
-problems. It also takes advantage of the repository storage to
+record the decision tree to provide introspection, and also provides
+the user with suggestions on how to deal with unsolvable
+problems. It also takes advantage of repository storage to
 minimize memory usage.
 
 Supported package formats:
index 7707dfc..180eda5 100644 (file)
@@ -49,5 +49,5 @@ SET(LIBSOLVEXT_SOVERSION "1")
 
 SET(LIBSOLV_MAJOR "0")
 SET(LIBSOLV_MINOR "7")
-SET(LIBSOLV_PATCH "10")
+SET(LIBSOLV_PATCH "11")
 
index ab9403f..8e6417e 100644 (file)
@@ -2,12 +2,12 @@
 .\"     Title: Libsolv-Bindings
 .\"    Author: [see the "Author" section]
 .\" Generator: DocBook XSL Stylesheets vsnapshot <http://docbook.sf.net/>
-.\"      Date: 07/01/2019
+.\"      Date: 01/21/2020
 .\"    Manual: LIBSOLV
 .\"    Source: libsolv
 .\"  Language: English
 .\"
-.TH "LIBSOLV\-BINDINGS" "3" "07/01/2019" "libsolv" "LIBSOLV"
+.TH "LIBSOLV\-BINDINGS" "3" "01/21/2020" "libsolv" "LIBSOLV"
 .\" -----------------------------------------------------------------
 .\" * Define some portability stuff
 .\" -----------------------------------------------------------------
@@ -866,6 +866,36 @@ Filter list of solvables by repo priority, architecture and version\&.
 .RS 4
 .\}
 .nf
+\fBSolvable *whatcontainsdep(Id\fR \fIkeyname\fR\fB, DepId\fR \fIdep\fR\fB, Id\fR \fImarker\fR \fB= \-1)\fR
+my \fI@solvables\fR \fB=\fR \fI$pool\fR\fB\->whatcontainsdep(\fR\fI$keyname\fR\fB,\fR \fI$dep\fR\fB)\fR
+\fIsolvables\fR \fB=\fR \fIpool\fR\fB\&.whatcontainsdep(\fR\fIkeyname\fR\fB,\fR \fIdep\fR\fB)\fR
+\fIsolvables\fR \fB=\fR \fIpool\fR\fB\&.whatcontainsdep(\fR\fIkeyname\fR\fB,\fR \fIdep\fR\fB)\fR
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+Return all solvables for which keyname contains the dependency\&.
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+\fBSolvable *whatmatchesdep(Id\fR \fIkeyname\fR\fB, DepId\fR \fIdep\fR\fB, Id\fR \fImarker\fR \fB= \-1)\fR
+my \fI@solvables\fR \fB=\fR \fI$pool\fR\fB\->whatmatchesdep(\fR\fI$keyname\fR\fB,\fR \fI$sdep\fR\fB)\fR
+\fIsolvables\fR \fB=\fR \fIpool\fR\fB\&.whatmatchesdep(\fR\fIkeyname\fR\fB,\fR \fIdep\fR\fB)\fR
+\fIsolvables\fR \fB=\fR \fIpool\fR\fB\&.whatmatchesdep(\fR\fIkeyname\fR\fB,\fR \fIdep\fR\fB)\fR
+.fi
+.if n \{\
+.RE
+.\}
+.sp
+Return all solvables that have dependencies in keyname that match the dependency\&.
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
 \fBSolvable *whatmatchessolvable(Id\fR \fIkeyname\fR\fB, Solvable\fR \fIsolvable\fR\fB, Id\fR \fImarker\fR \fB= \-1)\fR
 my \fI@solvables\fR \fB=\fR \fI$pool\fR\fB\->whatmatchessolvable(\fR\fI$keyname\fR\fB,\fR \fI$solvable\fR\fB)\fR
 \fIsolvables\fR \fB=\fR \fIpool\fR\fB\&.whatmatchessolvable(\fR\fIkeyname\fR\fB,\fR \fIsolvable\fR\fB)\fR
@@ -1491,7 +1521,7 @@ Back reference to the pool this dependency belongs to\&.
 .\}
 .sp
 The id of this dependency\&.
-.SH "METHODS"
+.SS "METHODS"
 .sp
 .if n \{\
 .RS 4
index 51dc1a4..6d94939 100644 (file)
@@ -2,12 +2,12 @@
 .\"     Title: Libsolv-Pool
 .\"    Author: [see the "Author" section]
 .\" Generator: DocBook XSL Stylesheets vsnapshot <http://docbook.sf.net/>
-.\"      Date: 10/22/2018
+.\"      Date: 01/21/2020
 .\"    Manual: LIBSOLV
 .\"    Source: libsolv
 .\"  Language: English
 .\"
-.TH "LIBSOLV\-POOL" "3" "10/22/2018" "libsolv" "LIBSOLV"
+.TH "LIBSOLV\-POOL" "3" "01/21/2020" "libsolv" "LIBSOLV"
 .\" -----------------------------------------------------------------
 .\" * Define some portability stuff
 .\" -----------------------------------------------------------------
@@ -1287,7 +1287,7 @@ Vendor in this case means the SOLVABLE_VENDOR string stored in each solvable\&.
 .sp
 There can be multiple equivalence classes, the set of allowed vendor changes for an installed package is calculated by building the union of all of the equivalence classes the vendor of the installed package is part of\&.
 .sp
-You can turn off the architecture replacement checks with the Solver\(cqs SOLVER_FLAG_ALLOW_VENDORCHANGE flag\&.
+You can turn off the vendor replacement checks with the Solver\(cqs SOLVER_FLAG_ALLOW_VENDORCHANGE flag\&.
 .SH "BOOLEAN DEPENDENCIES"
 .sp
 Boolean Dependencies allow to build complex expressions from simple dependencies\&. Note that depending on the package manager only a subset of those may be useful\&. For example, debian currently only allows an "OR" expression\&.
index 0b9bc41..991083f 100644 (file)
@@ -844,7 +844,7 @@ changes for an installed package is calculated by building the union
 of all of the equivalence classes the vendor of the installed package
 is part of.
 
-You can turn off the architecture replacement checks with the Solver's
+You can turn off the vendor replacement checks with the Solver's
 SOLVER_FLAG_ALLOW_VENDORCHANGE flag.
 
 
index 67aa97c..ed98628 100644 (file)
@@ -172,6 +172,15 @@ typedef struct rpmhead {
 } RpmHead;
 
 
+static inline void
+headinit(RpmHead *h, unsigned int cnt, unsigned int dcnt)
+{
+  h->cnt = (int)cnt;
+  h->dcnt = dcnt;
+  h->dp = h->data + 16 * cnt;
+  h->dp[dcnt] = 0;
+}
+
 static inline unsigned char *
 headfindtag(RpmHead *h, int tag)
 {
@@ -1240,7 +1249,7 @@ struct rpmdbstate {
   char *rootdir;
 
   RpmHead *rpmhead;    /* header storage space */
-  int rpmheadsize;
+  unsigned int rpmheadsize;
 };
 
 #endif
@@ -1248,49 +1257,55 @@ struct rpmdbstate {
 
 #ifndef ENABLE_RPMPKG_LIBRPM
 
-static int
-headfromfp(struct rpmdbstate *state, const char *name, FILE *fp, unsigned char *lead, unsigned int cnt, unsigned int dsize, unsigned int pad, Chksum *chk1, Chksum *chk2)
+static inline RpmHead *
+realloc_head(struct rpmdbstate *state, unsigned int len)
 {
-  RpmHead *rpmhead;
-  unsigned int len = 16 * cnt + dsize + pad;
-  if (len + 1 > state->rpmheadsize)
+  if (len > state->rpmheadsize)
     {
       state->rpmheadsize = len + 128;
       state->rpmhead = solv_realloc(state->rpmhead, sizeof(*state->rpmhead) + state->rpmheadsize);
     }
-  rpmhead = state->rpmhead;
+  return state->rpmhead;
+}
+
+static int
+headfromfp(struct rpmdbstate *state, const char *name, FILE *fp, unsigned char *lead, unsigned int cnt, unsigned int dsize, unsigned int pad, Chksum *chk1, Chksum *chk2)
+{
+  unsigned int len = 16 * cnt + dsize + pad;
+  RpmHead *rpmhead = realloc_head(state, len + 1);
   if (fread(rpmhead->data, len, 1, fp) != 1)
     return pool_error(state->pool, 0, "%s: unexpected EOF", name);
   if (chk1)
     solv_chksum_add(chk1, rpmhead->data, len);
   if (chk2)
     solv_chksum_add(chk2, rpmhead->data, len);
-  rpmhead->data[len] = 0;
-  rpmhead->cnt = cnt;
-  rpmhead->dcnt = dsize;
-  rpmhead->dp = rpmhead->data + cnt * 16;
+  headinit(rpmhead, cnt, dsize);
   return 1;
 }
 
-#if defined(ENABLE_RPMDB_BYRPMHEADER)
-static void
-headfromblob(struct rpmdbstate *state, const unsigned char *blob, unsigned int cnt, unsigned int dsize)
+# if defined(ENABLE_RPMDB) && (!defined(ENABLE_RPMDB_LIBRPM) || defined(HAVE_RPMDBNEXTITERATORHEADERBLOB))
+
+static int
+headfromhdrblob(struct rpmdbstate *state, const unsigned char *data, unsigned int size)
 {
+  unsigned int dsize, cnt, len;
   RpmHead *rpmhead;
-  unsigned int len = 16 * cnt + dsize;
-  if (len + 1 > state->rpmheadsize)
-    {
-      state->rpmheadsize = len + 128;
-      state->rpmhead = solv_realloc(state->rpmhead, sizeof(*state->rpmhead) + state->rpmheadsize);
-    }
-  rpmhead = state->rpmhead;
-  memcpy(rpmhead->data, blob, len);
-  rpmhead->data[len] = 0;
-  rpmhead->cnt = cnt;
-  rpmhead->dcnt = dsize;
-  rpmhead->dp = rpmhead->data + cnt * 16;
+  if (size < 8)
+    return pool_error(state->pool, 0, "corrupt rpm database (size)");
+  cnt = getu32(data);
+  dsize = getu32(data + 4);
+  if (cnt >= MAX_HDR_CNT || dsize >= MAX_HDR_DSIZE)
+    return pool_error(state->pool, 0, "corrupt rpm database (cnt/dcnt)");
+  if (8 + cnt * 16 + dsize > size)
+    return pool_error(state->pool, 0, "corrupt rpm database (data size)");
+  len = 16 * cnt + dsize;
+  rpmhead = realloc_head(state, len + 1);
+  memcpy(rpmhead->data, data + 8, len);
+  headinit(rpmhead, cnt, dsize);
+  return 1;
 }
-#endif
+
+# endif
 
 #else
 
@@ -2497,7 +2512,8 @@ rpm_byrpmh(void *rpmstate, Header h)
   struct rpmdbstate *state = rpmstate;
 #ifndef ENABLE_RPMPKG_LIBRPM
   const unsigned char *uh;
-  unsigned int dsize, cnt;
+  unsigned int dsize, cnt, len;
+  RpmHead *rpmhead;
 
   if (!h)
     return 0;
@@ -2515,7 +2531,10 @@ rpm_byrpmh(void *rpmstate, Header h)
       free((void *)uh);
       return 0;
     }
-  headfromblob(state, uh + 8, cnt, dsize);
+  len = 16 * cnt + dsize;
+  rpmhead = realloc_head(state, len + 1);;
+  memcpy(rpmhead->data, uh + 8, len);
+  headinit(rpmhead, cnt, dsize);
   free((void *)uh);
 #else
   if (!h)
index a8b8500..1c83317 100644 (file)
@@ -43,11 +43,11 @@ struct rpmdbstate {
   char *rootdir;
 
   RpmHead *rpmhead;    /* header storage space */
-  int rpmheadsize;
+  unsigned int rpmheadsize;
 
   int dbenvopened;     /* database environment opened */
   int pkgdbopened;     /* package database openend */
-  int is_ostree;       /* read-only db that lives in /usr/share/rpm */
+  const char *dbpath;  /* path to the database */
 
   DB_ENV *dbenv;       /* database environment */
   DB *db;              /* packages database */
@@ -70,17 +70,20 @@ access_rootdir(struct rpmdbstate *state, const char *dir, int mode)
 }
 
 static void
-detect_ostree(struct rpmdbstate *state)
+detect_dbpath(struct rpmdbstate *state)
 {
-  state->is_ostree = access_rootdir(state, "/var/lib/rpm", W_OK) == -1 &&
-                     access_rootdir(state, "/usr/share/rpm/Packages", R_OK) == 0 ? 1 : -1;
+  state->dbpath = access_rootdir(state, "/var/lib/rpm", W_OK) == -1
+                  && access_rootdir(state, "/usr/share/rpm/Packages", R_OK) == 0
+                  ? "/usr/share/rpm" : "/var/lib/rpm";
 }
 
 static int
 stat_database_name(struct rpmdbstate *state, char *dbname, struct stat *statbuf, int seterror)
 {
   char *dbpath;
-  dbpath = solv_dupjoin(state->rootdir, state->is_ostree > 0 ? "/usr/share/rpm/" : "/var/lib/rpm/", dbname);
+  if (!state->dbpath)
+    detect_dbpath(state);
+  dbpath = solv_dupjoin(state->rootdir, state->dbpath, dbname);
   if (stat(dbpath, statbuf))
     {
       if (seterror)
@@ -95,9 +98,7 @@ stat_database_name(struct rpmdbstate *state, char *dbname, struct stat *statbuf,
 static int
 stat_database(struct rpmdbstate *state, struct stat *statbuf)
 {
-  if (!state->is_ostree)
-    detect_ostree(state);
-  return stat_database_name(state, "Packages", statbuf, 1);
+  return stat_database_name(state, "/Packages", statbuf, 1);
 }
 
 
@@ -171,7 +172,6 @@ serialize_dbenv_ops(struct rpmdbstate *state)
 static int
 opendbenv(struct rpmdbstate *state)
 {
-  const char *rootdir = state->rootdir;
   char *dbpath;
   DB_ENV *dbenv = 0;
   int r;
@@ -181,16 +181,16 @@ opendbenv(struct rpmdbstate *state)
 #if (defined(FEDORA) || defined(MAGEIA)) && (DB_VERSION_MAJOR >= 5 || (DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR >= 5))
   dbenv->set_thread_count(dbenv, 8);
 #endif
-  dbpath = solv_dupjoin(rootdir, "/var/lib/rpm", 0);
-  state->is_ostree = -1;
+  state->dbpath = "/var/lib/rpm";
+  dbpath = solv_dupjoin(state->rootdir, state->dbpath, 0);
   if (access(dbpath, W_OK) == -1)
     {
-      free(dbpath);
-      dbpath = solv_dupjoin(rootdir, "/usr/share/rpm/Packages", 0);
-      if (access(dbpath, R_OK) == 0)
-       state->is_ostree = 1;
-      free(dbpath);
-      dbpath = solv_dupjoin(rootdir, state->is_ostree > 0 ? "/usr/share/rpm" : "/var/lib/rpm", 0);
+      if (access_rootdir(state, "/usr/share/rpm/Packages", R_OK) == 0)
+       {
+         state->dbpath = "/usr/share/rpm";
+         free(dbpath);
+         dbpath = solv_dupjoin(state->rootdir, state->dbpath, 0);
+       }
       r = dbenv->open(dbenv, dbpath, DB_CREATE|DB_PRIVATE|DB_INIT_MPOOL, 0);
     }
   else
@@ -387,35 +387,7 @@ getinstalledrpmdbids(struct rpmdbstate *state, const char *index, const char *ma
   return entries;
 }
 
-/* common code, return dbid on success, -1 on error */
-static int
-getrpm_dbdata(struct rpmdbstate *state, DBT *dbdata, int dbid)
-{
-  unsigned int dsize, cnt, l;
-  RpmHead *rpmhead;
-
-  if (dbdata->size < 8)
-    return pool_error(state->pool, -1, "corrupt rpm database (size)");
-  cnt = getu32((const unsigned char *)dbdata->data);
-  dsize = getu32((const unsigned char *)dbdata->data + 4);
-  if (cnt >= MAX_HDR_CNT || dsize >= MAX_HDR_DSIZE)
-    return pool_error(state->pool, -1, "corrupt rpm database (cnt/dcnt)");
-  l = cnt * 16 + dsize;
-  if (8 + l > dbdata->size)
-    return pool_error(state->pool, -1, "corrupt rpm database (data size)");
-  if (l + 1 > state->rpmheadsize)
-    {
-      state->rpmheadsize = l + 128;
-      state->rpmhead = solv_realloc(state->rpmhead, sizeof(*rpmhead) + state->rpmheadsize);
-    }
-  rpmhead = state->rpmhead;
-  rpmhead->cnt = cnt;
-  rpmhead->dcnt = dsize;
-  memcpy(rpmhead->data, (unsigned char *)dbdata->data + 8, l);
-  rpmhead->data[l] = 0;
-  rpmhead->dp = rpmhead->data + cnt * 16;
-  return dbid;
-}
+static int headfromhdrblob(struct rpmdbstate *state, const unsigned char *data, unsigned int size);
 
 /* retrive header by rpmdbid, returns 0 if not found, -1 on error */
 static int
@@ -438,7 +410,9 @@ getrpm_dbid(struct rpmdbstate *state, Id dbid)
   dbdata.size = 0;
   if (state->db->get(state->db, NULL, &dbkey, &dbdata, 0))
     return 0;
-  return getrpm_dbdata(state, &dbdata, dbid);
+  if (!headfromhdrblob(state, (const unsigned char *)dbdata.data, (unsigned int)dbdata.size))
+    return -1;
+  return dbid;
 }
 
 static int
@@ -452,7 +426,7 @@ count_headers(struct rpmdbstate *state)
   DBT dbkey;
   DBT dbdata;
 
-  if (stat_database_name(state, "Name", &statbuf, 0))
+  if (stat_database_name(state, "/Name", &statbuf, 0))
     return 0;
   memset(&dbkey, 0, sizeof(dbkey));
   memset(&dbdata, 0, sizeof(dbdata));
@@ -512,8 +486,11 @@ pkgdb_cursor_getrpm(struct rpmdbstate *state)
       if (dbkey.size != 4)
        return pool_error(state->pool, -1, "corrupt Packages database (key size)");
       dbid = db2rpmdbid(dbkey.data, state->byteswapped);
-      if (dbid)                /* ignore join key */
-        return getrpm_dbdata(state, &dbdata, dbid);
+      if (!dbid)
+       continue;       /* ignore join key */
+      if (!headfromhdrblob(state, (const unsigned char *)dbdata.data, (unsigned int)dbdata.size))
+       return -1;
+      return dbid;
     }
   return 0;    /* no more entries */
 }
@@ -525,7 +502,9 @@ hash_name_index(struct rpmdbstate *state, Chksum *chk)
   int fd, l;
   char buf[4096];
 
-  dbpath = solv_dupjoin(state->rootdir, state->is_ostree > 0 ? "/usr/share/rpm/" : "/var/lib/rpm/", "Name");
+  if (!state->dbpath)
+    detect_dbpath(state);
+  dbpath = solv_dupjoin(state->rootdir, state->dbpath, "/Name");
   if ((fd = open(dbpath, O_RDONLY)) < 0)
     return -1;
   while ((l = read(fd, buf, sizeof(buf))) > 0)
@@ -534,4 +513,3 @@ hash_name_index(struct rpmdbstate *state, Chksum *chk)
   return 0;
 }
 
-
index b50a4b5..34e6698 100644 (file)
@@ -20,10 +20,10 @@ struct rpmdbstate {
   char *rootdir;
 
   RpmHead *rpmhead;    /* header storage space */
-  int rpmheadsize;
+  unsigned int rpmheadsize;
 
   int dbenvopened;     /* database environment opened */
-  int is_ostree;       /* read-only db that lives in /usr/share/rpm */
+  const char *dbpath;  /* path to the database */
 
   rpmts ts;
   rpmdbMatchIterator mi;       /* iterator over packages database */
@@ -43,21 +43,22 @@ access_rootdir(struct rpmdbstate *state, const char *dir, int mode)
 }
 
 static void
-detect_ostree(struct rpmdbstate *state)
+detect_dbpath(struct rpmdbstate *state)
 {
-  state->is_ostree = access_rootdir(state, "/var/lib/rpm", W_OK) == -1 &&
-                     access_rootdir(state, "/usr/share/rpm/Packages", R_OK) == 0 ? 1 : -1;
+  state->dbpath = access_rootdir(state, "/var/lib/rpm", W_OK) == -1
+                  && access_rootdir(state, "/usr/share/rpm/Packages", R_OK) == 0
+                  ? "/usr/share/rpm" : "/var/lib/rpm";
 }
 
 static int
 stat_database(struct rpmdbstate *state, struct stat *statbuf)
 {
   static const char *dbname[] = {
-    "Packages",
-    "Packages.db",
-    "rpmdb.sqlite",
-    "data.mdb",
-    "Packages",                /* for error reporting */
+    "/Packages",
+    "/Packages.db",
+    "/rpmdb.sqlite",
+    "/data.mdb",
+    "/Packages",               /* for error reporting */
     0,
   };
   int i;
@@ -66,11 +67,11 @@ stat_database(struct rpmdbstate *state, struct stat *statbuf)
   if (state->dbenvopened == 1)
     return rpmdbFStat(rpmtsGetRdb(state->ts), statbuf);
 #endif
-  if (!state->is_ostree)
-    detect_ostree(state);
+  if (!state->dbpath)
+    detect_dbpath(state);
   for (i = 0; ; i++)
     {
-      char *dbpath = solv_dupjoin(state->rootdir, state->is_ostree > 0 ? "/usr/share/rpm/" : "/var/lib/rpm/", dbname[i]);
+      char *dbpath = solv_dupjoin(state->rootdir, state->dbpath, dbname[i]);
       if (!stat(dbpath, statbuf))
        {
          free(dbpath);
@@ -92,11 +93,12 @@ stat_database(struct rpmdbstate *state, struct stat *statbuf)
 static int
 opendbenv(struct rpmdbstate *state)
 {
-  const char *rootdir = state->rootdir;
   rpmts ts;
   char *dbpath;
-  detect_ostree(state);
-  dbpath = solv_dupjoin("_dbpath ", rootdir, state->is_ostree > 0 ? "/usr/share/rpm" : "/var/lib/rpm");
+
+  if (!state->dbpath)
+    detect_dbpath(state);
+  dbpath = solv_dupjoin("_dbpath ", state->rootdir, state->dbpath);
   rpmDefineMacro(NULL, dbpath, 0);
   solv_free(dbpath);
   ts = rpmtsCreate();
@@ -194,33 +196,7 @@ getinstalledrpmdbids(struct rpmdbstate *state, const char *index, const char *ma
 }
 
 #if defined(HAVE_RPMDBNEXTITERATORHEADERBLOB) && !defined(ENABLE_RPMPKG_LIBRPM)
-static int
-rpm_byrpmhdrblob(struct rpmdbstate *state, const unsigned char *data, unsigned int size)
-{
-  unsigned int dsize, cnt, len;
-  RpmHead *rpmhead;
-  if (size < 8)
-    return pool_error(state->pool, 0, "corrupt rpm database (size)");
-  cnt = getu32(data);
-  dsize = getu32(data + 4);
-  if (cnt >= MAX_HDR_CNT || dsize >= MAX_HDR_DSIZE)
-    return pool_error(state->pool, 0, "corrupt rpm database (cnt/dcnt)");
-  if (8 + cnt * 16 + dsize > size)
-    return pool_error(state->pool, 0, "corrupt rpm database (data size)");
-  len = 16 * cnt + dsize;
-  if (len + 1 > state->rpmheadsize)
-    {
-      state->rpmheadsize = len + 128;
-      state->rpmhead = solv_realloc(state->rpmhead, sizeof(*state->rpmhead) + state->rpmheadsize);
-    }
-  rpmhead = state->rpmhead;
-  memcpy(rpmhead->data, data + 8, len);
-  rpmhead->data[len] = 0;
-  rpmhead->cnt = cnt;
-  rpmhead->dcnt = dsize;
-  rpmhead->dp = rpmhead->data + cnt * 16;
-  return 1;
-}
+static int headfromhdrblob(struct rpmdbstate *state, const unsigned char *data, unsigned int size);
 #endif
 
 /* retrive header by rpmdbid, returns 0 if not found, -1 on error */
@@ -248,7 +224,7 @@ getrpm_dbid(struct rpmdbstate *state, Id rpmdbid)
       rpmdbFreeIterator(mi);
       return 0;
     }
-  if (!rpm_byrpmhdrblob(state, uh, uhlen))
+  if (!headfromhdrblob(state, uh, uhlen))
     {
       rpmdbFreeIterator(mi);
       return -1;
@@ -307,7 +283,7 @@ pkgdb_cursor_getrpm(struct rpmdbstate *state)
   while ((uh = rpmdbNextIteratorHeaderBlob(state->mi, &uhlen)) != 0)
     {
       Id dbid = rpmdbGetIteratorOffset(state->mi);
-      if (!rpm_byrpmhdrblob(state, uh, uhlen))
+      if (!headfromhdrblob(state, uh, uhlen))
        continue;
       return dbid;
     }
index 664b739..ba3d794 100644 (file)
@@ -75,12 +75,12 @@ getuint(unsigned char *p, unsigned char *endp, unsigned int *dp)
     }
   if (++p < endp && (*p & 0x80) != 0)
     {
-      *dp = p[-3] ^ (p[-2] << 7) ^ (p[1] << 14) ^ ((p[0] ^ 0x80) << 21);
+      *dp = p[-3] ^ (p[-2] << 7) ^ (p[-1] << 14) ^ ((p[0] ^ 0x80) << 21);
       return p + 1;
     }
   if (++p < endp && (*p & 0xf0) == 0x80)
     {
-      *dp = p[-4] ^ (p[-3] << 7) ^ (p[2] << 14) ^ (p[1] << 21) ^ ((p[0] ^ 0x80) << 28);
+      *dp = p[-4] ^ (p[-3] << 7) ^ (p[-2] << 14) ^ (p[-1] << 21) ^ ((p[0] ^ 0x80) << 28);
       return p + 1;
     }
   return 0;
index b638864..253784b 100644 (file)
@@ -1,4 +1,24 @@
 -------------------------------------------------------------------
+Wed Jan 22 13:52:48 CET 2020 - mls@suse.de
+
+- fixed solv_zchunk decoding error if large chunks are used
+- treat retracted pathes as irrelevant
+- made add_update_target work with multiversion installs
+- bump version to 0.7.11
+
+-------------------------------------------------------------------
+Thu Dec 19 16:29:52 CET 2019 - mls@suse.de
+
+- fix solv_zchunk decoding error if large chunks are used
+  [bnc#1159314]
+
+-------------------------------------------------------------------
+Tue Dec 10 21:02:31 CET 2019 - mls@suse.de
+
+- build with -DENABLE_RPMDB_LIBRPM=1 on SUSE to support
+  multiple rpm database backends
+
+-------------------------------------------------------------------
 Tue Dec 10 14:18:36 CET 2019 - mls@suse.de
 
 - added two new function to make libzypp independent of the rpm
index e31fe01..f735e5d 100644 (file)
@@ -1656,13 +1656,16 @@ solver_addinfarchrules(Solver *solv, Map *addedmap)
            }
        }
       if (first)
-       continue;
+       continue;               /* not the first in the group */
+
+      if (!bestscore)
+       continue;               /* did not find a score for this group */
 
       /* speed up common case where installed package already has best arch */
       if (allowedarchs.count == 1 && bests && allowedarchs.elements[0] == bests->arch)
        allowedarchs.count--;   /* installed arch is best */
 
-      if (allowedarchs.count && pool->implicitobsoleteusescolors && installed && bestscore)
+      if (allowedarchs.count && pool->implicitobsoleteusescolors && installed)
        {
          /* need an extra pass for lockstep checking: we only allow to keep an inferior arch
           * if the corresponding installed package is not lock-stepped */
@@ -1707,7 +1710,7 @@ solver_addinfarchrules(Solver *solv, Map *addedmap)
          if (ps->name != s->name || !MAPTST(addedmap, p))
            continue;
          a = pool_arch2score(pool, ps->arch);
-         if (a != 1 && bestscore && ((a ^ bestscore) & 0xffff0000) != 0)
+         if (a != 1 && ((a ^ bestscore) & 0xffff0000) != 0)
            {
              if (installed && ps->repo == installed)
                {
index 6a9d66e..7fcc3fb 100644 (file)
@@ -3106,6 +3106,12 @@ add_update_target(Solver *solv, Id p, Id how)
   if (s->repo == installed)
     {
       queue_push2(solv->update_targets, p, p);
+      FOR_PROVIDES(pi, pip, s->name)
+       {
+         Solvable *si = pool->solvables + pi;
+         if (si->repo == installed && si->name == s->name && pi != p)
+           queue_push2(solv->update_targets, pi, p);
+       }
       return;
     }
   identicalp = 0;
index 11e4aa3..43b566a 100644 (file)
@@ -45,6 +45,7 @@ extern int solv_version_patch;
 #cmakedefine LIBSOLVEXT_FEATURE_LZMA_COMPRESSION
 #cmakedefine LIBSOLVEXT_FEATURE_BZIP2_COMPRESSION
 #cmakedefine LIBSOLVEXT_FEATURE_ZSTD_COMPRESSION
+#cmakedefine LIBSOLVEXT_FEATURE_ZCHUNK_COMPRESSION
 
 /* see tools/common_write.c for toolversion history */
 #define LIBSOLV_TOOLVERSION "1.1"
index 9537a33..2533af9 100644 (file)
@@ -376,7 +376,11 @@ solvable_is_irrelevant_patch(Solvable *s, Map *installedmap)
   Pool *pool = s->repo->pool;
   Id con, *conp;
   int hadpatchpackage = 0;
+  const char *status;
 
+  status = solvable_lookup_str(s, UPDATE_STATUS);
+  if (status && !strcmp(status, "retracted"))
+    return 1;
   if (!s->conflicts)
     return 0;
   conp = s->repo->idarraydata + s->conflicts;