ref: refs/heads/master
commit 7a5c9d36d716d06810e7ff12267566950902de92
Author: Michael Schroeder
Date: Thu Jul 30 14:41:23 2009 +0200
- fix memory leak
- add changes, bump version
- fix pubkey handling
---
VERSION.cmake | 4 +-
examples/solv.c | 28 +++++++++++++++++++++-
ext/repo_rpmdb.c | 51 +++++++++++++++++++-----------------------
package/libsatsolver.changes | 9 +++++++
package/libsatsolver.spec.in | 8 +++++-
src/repo.c | 1 +
6 files changed, 68 insertions(+), 33 deletions(-)
diff --git a/VERSION.cmake b/VERSION.cmake
index cb22768..ea533d8 100644
--- a/VERSION.cmake
+++ b/VERSION.cmake
@@ -46,6 +46,6 @@
SET(LIBSATSOLVER_MAJOR "0")
SET(LIBSATSOLVER_MINOR "14")
-SET(LIBSATSOLVER_PATCH "3")
+SET(LIBSATSOLVER_PATCH "4")
-# last released 0.14.3
+# last released 0.14.4
diff --git a/examples/solv.c b/examples/solv.c
index 328aff5..1646da3 100644
--- a/examples/solv.c
+++ b/examples/solv.c
@@ -96,13 +96,22 @@ char *
yum_substitute(Pool *pool, char *line)
{
char *p, *p2;
+ static char *releaseevr;
+ static char *basearch;
+ if (!line)
+ {
+ sat_free(releaseevr);
+ releaseevr = 0;
+ sat_free(basearch);
+ basearch = 0;
+ return 0;
+ }
p = line;
while ((p2 = strchr(p, '$')) != 0)
{
if (!strncmp(p2, "$releasever", 11))
{
- static char *releaseevr;
if (!releaseevr)
{
Queue q;
@@ -132,7 +141,6 @@ yum_substitute(Pool *pool, char *line)
}
if (!strncmp(p2, "$basearch", 9))
{
- static char *basearch;
if (!basearch)
{
struct utsname un;
@@ -355,8 +363,10 @@ verify_checksum(int fd, const char *file, const unsigned char *chksum, Id chksum
if (memcmp(sum, chksum, l))
{
printf("%s: checksum mismatch\n", file);
+ sat_chksum_free(h, 0);
return 0;
}
+ sat_chksum_free(h, 0);
return 1;
}
@@ -647,6 +657,14 @@ curlfopen(struct repoinfo *cinfo, const char *file, int uncompress, const unsign
fclose(fp);
if (!cinfo->baseurl)
return 0;
+#ifdef FEDORA
+ if (strchr(cinfo->baseurl, '$'))
+ {
+ char *b = yum_substitute(cinfo->repo->pool, cinfo->baseurl);
+ free(cinfo->baseurl);
+ cinfo->baseurl = strdup(b);
+ }
+#endif
if (!chksumtype && mlchksumtype && !strcmp(file, "repodata/repomd.xml"))
{
chksumtype = mlchksumtype;
@@ -2333,6 +2351,9 @@ main(int argc, char **argv)
pool_free(pool);
free_repoinfos(repoinfos, nrepoinfos);
sat_free(commandlinepkgs);
+#ifdef FEDORA
+ yum_substitute(pool, 0);
+#endif
exit(0);
}
@@ -2776,5 +2797,8 @@ rerunsolver:
pool_free(pool);
free_repoinfos(repoinfos, nrepoinfos);
sat_free(commandlinepkgs);
+#ifdef FEDORA
+ yum_substitute(pool, 0);
+#endif
exit(0);
}
diff --git a/ext/repo_rpmdb.c b/ext/repo_rpmdb.c
index 117e850..8947f9a 100644
--- a/ext/repo_rpmdb.c
+++ b/ext/repo_rpmdb.c
@@ -2100,10 +2100,8 @@ struct rpmdbentry {
#define ENTRIES_BLOCK 255
#define NAMEDATA_BLOCK 1023
-#define FLAGS_GET_PUBKEYS 1
-
static struct rpmdbentry *
-getinstalledrpmdbids(struct rpm_by_state *state, const char *index, const char *match, int *nentriesp, char **namedatap, int flags)
+getinstalledrpmdbids(struct rpm_by_state *state, const char *index, const char *match, int *nentriesp, char **namedatap)
{
DB_ENV *dbenv = 0;
DB *db = 0;
@@ -2156,19 +2154,8 @@ getinstalledrpmdbids(struct rpm_by_state *state, const char *index, const char *
}
while (dbc->c_get(dbc, &dbkey, &dbdata, match ? DB_SET : DB_NEXT) == 0)
{
- if (!match)
- {
- if ((flags & FLAGS_GET_PUBKEYS))
- {
- if (dbkey.size != 10 || memcmp(dbkey.data, "gpg-pubkey", 10))
- continue;
- }
- else
- {
- if (dbkey.size == 10 && !memcmp(dbkey.data, "gpg-pubkey", 10))
- continue;
- }
- }
+ if (!match && dbkey.size == 10 && !memcmp(dbkey.data, "gpg-pubkey", 10))
+ continue;
dl = dbdata.size;
dp = dbdata.data;
while(dl >= 8)
@@ -2203,6 +2190,19 @@ getinstalledrpmdbids(struct rpm_by_state *state, const char *index, const char *
return entries;
}
+static void
+freestate(struct rpm_by_state *state)
+{
+ /* close down */
+ if (!state)
+ return;
+ if (state->db)
+ state->db->close(state->db, 0);
+ if (state->dbenv)
+ state->dbenv->close(state->dbenv, 0);
+ sat_free(state->rpmhead);
+}
+
int
rpm_installedrpmdbids(const char *rootdir, const char *index, const char *match, Queue *rpmdbidq)
{
@@ -2218,13 +2218,13 @@ rpm_installedrpmdbids(const char *rootdir, const char *index, const char *match,
memset(&state, 0, sizeof(state));
if (!(state.dbenv = opendbenv(rootdir)))
return 0;
- entries = getinstalledrpmdbids(&state, index, match, &nentries, &namedata, 0);
+ entries = getinstalledrpmdbids(&state, index, match, &nentries, &namedata);
if (rpmdbidq)
for (i = 0; i < nentries; i++)
queue_push(rpmdbidq, entries[i].rpmdbid);
sat_free(entries);
sat_free(namedata);
- rpm_byrpmdbid(0, 0, (void **)&state);
+ freestate(&state);
return nentries;
}
@@ -2240,13 +2240,7 @@ rpm_byrpmdbid(Id rpmdbid, const char *rootdir, void **statep)
if (!rpmdbid)
{
/* close down */
- if (!state)
- return 0;
- if (state->db)
- state->db->close(state->db, 0);
- if (state->dbenv)
- state->dbenv->close(state->dbenv, 0);
- sat_free(state->rpmhead);
+ freestate(state);
sat_free(state);
*statep = (void *)0;
return 0;
@@ -2964,10 +2958,11 @@ repo_add_rpmdb_pubkeys(Repo *repo, const char *rootdir, int flags)
memset(&state, 0, sizeof(state));
if (!(state.dbenv = opendbenv(rootdir)))
return;
- entries = getinstalledrpmdbids(&state, "Name", 0, &nentries, &namedata, FLAGS_GET_PUBKEYS);
+ entries = getinstalledrpmdbids(&state, "Name", "gpg-pubkey", &nentries, &namedata);
for (i = 0 ; i < nentries; i++)
{
- RpmHead *rpmhead = rpm_byrpmdbid(entries[i].rpmdbid, rootdir, (void **)&state);
+ void *statep = &state;
+ RpmHead *rpmhead = rpm_byrpmdbid(entries[i].rpmdbid, rootdir, &statep);
if (!rpmhead)
continue;
str = headstring(rpmhead, TAG_DESCRIPTION);
@@ -2982,7 +2977,7 @@ repo_add_rpmdb_pubkeys(Repo *repo, const char *rootdir, int flags)
repo->rpmdbid = repo_sidedata_create(repo, sizeof(Id));
repo->rpmdbid[s - pool->solvables - repo->start] = entries[i].rpmdbid;
}
- rpm_byrpmdbid(0, 0, (void **)&state);
+ freestate(&state);
if (!(flags & REPO_NO_INTERNALIZE))
repodata_internalize(data);
}
diff --git a/package/libsatsolver.changes b/package/libsatsolver.changes
index c1303a8..cd2399f 100644
--- a/package/libsatsolver.changes
+++ b/package/libsatsolver.changes
@@ -1,4 +1,13 @@
-------------------------------------------------------------------
+Thu Jul 30 12:49:38 CEST 2009 - mls@suse.de
+
+- speed up file list parsing
+- speed up addfileprovides
+- fix bugs in pubkey handling
+- fix bug in filelist handling when there are no abs paths
+- 0.14.4
+
+-------------------------------------------------------------------
Fri Jul 17 14:07:07 CEST 2009 - mls@suse.de
- add satversion.h header file
diff --git a/package/libsatsolver.spec.in b/package/libsatsolver.spec.in
index 4713f0f..0568b85 100644
--- a/package/libsatsolver.spec.in
+++ b/package/libsatsolver.spec.in
@@ -93,7 +93,13 @@ A new approach to package dependency solving.
%package demo
Summary: Applications demoing the satsolver library
Group: System/Management
-Requires: gpg2 curl
+Requires: curl
+%if 0%{?fedora_version}
+Requires: gnupg2
+%endif
+%if 0%{?suse_version}
+Requires: gpg2
+%endif
%description demo
Applications demoing the satsolver library.
diff --git a/src/repo.c b/src/repo.c
index 44d8790..af8357d 100644
--- a/src/repo.c
+++ b/src/repo.c
@@ -103,6 +103,7 @@ repo_empty(Repo *repo, int reuseids)
repo->rpmdbid = sat_free(repo->rpmdbid);
for (i = 0; i < repo->nrepodata; i++)
repodata_freedata(repo->repodata + i);
+ sat_free(repo->repodata);
repo->repodata = 0;
repo->nrepodata = 0;
}
--
To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org
For additional commands, e-mail: zypp-commit+help@opensuse.org