summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorDongHun Kwak <dh0128.kwak@samsung.com>2021-12-23 14:46:59 +0900
committerDongHun Kwak <dh0128.kwak@samsung.com>2021-12-23 14:46:59 +0900
commitde92b8ea19562961f973960c0f8f5aec7f6d9c75 (patch)
tree4d5cf84b1adf5ba72a35b68d28514e202f18b83f /ext
parent99023ce80ad7daa0f6462861dac71e17aac694b8 (diff)
downloadlibsolv-de92b8ea19562961f973960c0f8f5aec7f6d9c75.tar.gz
libsolv-de92b8ea19562961f973960c0f8f5aec7f6d9c75.tar.bz2
libsolv-de92b8ea19562961f973960c0f8f5aec7f6d9c75.zip
Imported Upstream version 0.7.17upstream/0.7.17
Diffstat (limited to 'ext')
-rw-r--r--ext/repo_comps.c37
-rw-r--r--ext/repo_rpmdb.c2
-rw-r--r--ext/repo_rpmdb_bdb.h1
-rw-r--r--ext/repo_rpmdb_librpm.h31
-rw-r--r--ext/repo_updateinfoxml.c38
-rw-r--r--ext/testcase.c21
6 files changed, 116 insertions, 14 deletions
diff --git a/ext/repo_comps.c b/ext/repo_comps.c
index 6991656..014f89a 100644
--- a/ext/repo_comps.c
+++ b/ext/repo_comps.c
@@ -29,7 +29,6 @@
* TODO:
*
* what's the difference between group/category?
- * handle "default" and "langonly".
*
* maybe handle REL_COND in solver recommends handling?
*/
@@ -97,10 +96,26 @@ struct parsedata {
Solvable *solvable;
const char *kind;
+ int isdefault;
+ int isvisible;
Id handle;
};
+#define COMPS_DEFAULT_ISVISIBLE 1
+#define COMPS_DEFAULT_ISDEFAULT 0
+
+/* Return true if "true", false if "false", default_value otherwise */
+static int
+parse_boolean(char *content, int default_value)
+{
+ if (!strcmp(content, "true"))
+ return 1;
+ if (!strcmp(content, "false"))
+ return 0;
+ return default_value;
+}
+
static void
startElement(struct solv_xmlparser *xmlp, int state, const char *name, const char **atts)
@@ -116,6 +131,8 @@ startElement(struct solv_xmlparser *xmlp, int state, const char *name, const cha
s = pd->solvable = pool_id2solvable(pool, repo_add_solvable(pd->repo));
pd->handle = s - pool->solvables;
pd->kind = state == STATE_GROUP ? "group" : "category";
+ pd->isvisible = COMPS_DEFAULT_ISVISIBLE;
+ pd->isdefault = COMPS_DEFAULT_ISDEFAULT;
break;
case STATE_NAME:
@@ -166,6 +183,10 @@ endElement(struct solv_xmlparser *xmlp, int state, char *content)
s->evr = ID_EMPTY;
if (s->name && s->arch != ARCH_SRC && s->arch != ARCH_NOSRC)
s->provides = repo_addid_dep(pd->repo, s->provides, pool_rel2id(pd->pool, s->name, s->evr, REL_EQ, 1), 0);
+ if (pd->isvisible)
+ repodata_set_void(pd->data, pd->handle, SOLVABLE_ISVISIBLE);
+ if (pd->isdefault)
+ repodata_set_void(pd->data, pd->handle, SOLVABLE_ISDEFAULT);
pd->solvable = 0;
break;
@@ -194,7 +215,19 @@ endElement(struct solv_xmlparser *xmlp, int state, char *content)
break;
case STATE_USERVISIBLE:
- repodata_set_void(pd->data, pd->handle, SOLVABLE_ISVISIBLE);
+ pd->isvisible = parse_boolean(content, COMPS_DEFAULT_ISVISIBLE);
+ break;
+
+ case STATE_DEFAULT:
+ pd->isdefault = parse_boolean(content, COMPS_DEFAULT_ISDEFAULT);
+ break;
+
+ case STATE_LANG_ONLY:
+ repodata_set_str(pd->data, pd->handle, SOLVABLE_LANGONLY, content);
+ break;
+
+ case STATE_LANGONLY:
+ repodata_set_str(pd->data, pd->handle, SOLVABLE_LANGONLY, content);
break;
case STATE_DISPLAY_ORDER:
diff --git a/ext/repo_rpmdb.c b/ext/repo_rpmdb.c
index 67ce81d..d78893e 100644
--- a/ext/repo_rpmdb.c
+++ b/ext/repo_rpmdb.c
@@ -1349,6 +1349,8 @@ freestate(struct rpmdbstate *state)
#ifdef ENABLE_RPMDB
if (state->dbenvopened)
closedbenv(state);
+ if (state->dbpath_allocated)
+ solv_free((char *)state->dbpath);
#endif
if (state->rootdir)
solv_free(state->rootdir);
diff --git a/ext/repo_rpmdb_bdb.h b/ext/repo_rpmdb_bdb.h
index 1c83317..4043ef1 100644
--- a/ext/repo_rpmdb_bdb.h
+++ b/ext/repo_rpmdb_bdb.h
@@ -48,6 +48,7 @@ struct rpmdbstate {
int dbenvopened; /* database environment opened */
int pkgdbopened; /* package database openend */
const char *dbpath; /* path to the database */
+ int dbpath_allocated; /* do we need to free the path? */
DB_ENV *dbenv; /* database environment */
DB *db; /* packages database */
diff --git a/ext/repo_rpmdb_librpm.h b/ext/repo_rpmdb_librpm.h
index 35a46fa..3f9798c 100644
--- a/ext/repo_rpmdb_librpm.h
+++ b/ext/repo_rpmdb_librpm.h
@@ -12,6 +12,7 @@
*
*/
+#include <rpm/rpmlib.h>
#include <rpm/rpmts.h>
#include <rpm/rpmmacro.h>
@@ -24,6 +25,7 @@ struct rpmdbstate {
int dbenvopened; /* database environment opened */
const char *dbpath; /* path to the database */
+ int dbpath_allocated; /* do we need to free the path? */
rpmts ts;
rpmdbMatchIterator mi; /* iterator over packages database */
@@ -45,6 +47,13 @@ access_rootdir(struct rpmdbstate *state, const char *dir, int mode)
static void
detect_dbpath(struct rpmdbstate *state)
{
+ state->dbpath = rpmExpand("%{?_dbpath}", NULL);
+ if (state->dbpath && *state->dbpath)
+ {
+ state->dbpath_allocated = 1;
+ return;
+ }
+ solv_free((char *)state->dbpath);
state->dbpath = access_rootdir(state, "/var/lib/rpm", W_OK) == -1
&& (access_rootdir(state, "/usr/share/rpm/Packages", R_OK) == 0 || access_rootdir(state, "/usr/share/rpm/rpmdb.sqlite", R_OK) == 0)
? "/usr/share/rpm" : "/var/lib/rpm";
@@ -90,6 +99,24 @@ stat_database(struct rpmdbstate *state, struct stat *statbuf)
return 0;
}
+/* rpm-4.16.0 cannot read the database if _db_backend is not set */
+#ifndef HAVE_RPMDBNEXTITERATORHEADERBLOB
+static void
+set_db_backend()
+{
+ static int db_backend_set;
+ char *db_backend;
+
+ if (db_backend_set)
+ return;
+ db_backend_set = 1;
+ db_backend = rpmExpand("%{?_db_backend}", NULL);
+ if (!db_backend || !*db_backend)
+ rpmReadConfigFiles(NULL, NULL);
+ solv_free(db_backend);
+}
+#endif
+
static int
opendbenv(struct rpmdbstate *state)
{
@@ -108,6 +135,10 @@ opendbenv(struct rpmdbstate *state)
delMacro(NULL, "_dbpath");
return 0;
}
+#ifndef HAVE_RPMDBNEXTITERATORHEADERBLOB
+ if (!strcmp(RPMVERSION, "4.16.0"))
+ set_db_backend();
+#endif
if (rpmtsOpenDB(ts, O_RDONLY))
{
pool_error(state->pool, 0, "rpmtsOpenDB failed: %s", strerror(errno));
diff --git a/ext/repo_updateinfoxml.c b/ext/repo_updateinfoxml.c
index 36d76b5..22f7093 100644
--- a/ext/repo_updateinfoxml.c
+++ b/ext/repo_updateinfoxml.c
@@ -110,9 +110,10 @@ struct parsedata {
Id handle;
Solvable *solvable;
time_t buildtime;
- Id collhandle;
+ Id pkghandle;
struct solv_xmlparser xmlp;
struct joindata jd;
+ Id collhandle;
};
/*
@@ -287,6 +288,12 @@ startElement(struct solv_xmlparser *xmlp, int state, const char *name, const cha
}
break;
+ case STATE_COLLECTION:
+ {
+ pd->collhandle = repodata_new_handle(pd->data);
+ }
+ break;
+
/* <package arch="ppc64" name="imlib-debuginfo" release="6.fc8"
* src="http://download.fedoraproject.org/pub/fedora/linux/updates/8/ppc64/imlib-debuginfo-1.9.15-6.fc8.ppc64.rpm"
* version="1.9.15">
@@ -326,12 +333,12 @@ startElement(struct solv_xmlparser *xmlp, int state, const char *name, const cha
solvable->conflicts = repo_addid_dep(pd->repo, solvable->conflicts, id, 0);
}
- /* who needs the collection anyway? */
- pd->collhandle = repodata_new_handle(pd->data);
- repodata_set_id(pd->data, pd->collhandle, UPDATE_COLLECTION_NAME, n);
- repodata_set_id(pd->data, pd->collhandle, UPDATE_COLLECTION_EVR, evr);
+ /* UPDATE_COLLECTION is misnamed, it should have been UPDATE_PACKAGE */
+ pd->pkghandle = repodata_new_handle(pd->data);
+ repodata_set_id(pd->data, pd->pkghandle, UPDATE_COLLECTION_NAME, n);
+ repodata_set_id(pd->data, pd->pkghandle, UPDATE_COLLECTION_EVR, evr);
if (a)
- repodata_set_id(pd->data, pd->collhandle, UPDATE_COLLECTION_ARCH, a);
+ repodata_set_id(pd->data, pd->pkghandle, UPDATE_COLLECTION_ARCH, a);
break;
}
case STATE_MODULE:
@@ -364,6 +371,7 @@ startElement(struct solv_xmlparser *xmlp, int state, const char *name, const cha
if (arch)
repodata_set_poolstr(pd->data, module_handle, UPDATE_MODULE_ARCH, arch);
repodata_add_flexarray(pd->data, pd->handle, UPDATE_MODULE, module_handle);
+ repodata_add_flexarray(pd->data, pd->collhandle, UPDATE_MODULE, module_handle);
break;
}
@@ -427,15 +435,21 @@ endElement(struct solv_xmlparser *xmlp, int state, char *content)
repodata_set_str(pd->data, pd->handle, UPDATE_MESSAGE, content);
break;
- case STATE_PACKAGE:
- repodata_add_flexarray(pd->data, pd->handle, UPDATE_COLLECTION, pd->collhandle);
+ case STATE_COLLECTION:
+ repodata_add_flexarray(pd->data, pd->handle, UPDATE_COLLECTIONLIST, pd->collhandle);
pd->collhandle = 0;
break;
+ case STATE_PACKAGE:
+ repodata_add_flexarray(pd->data, pd->handle, UPDATE_COLLECTION, pd->pkghandle);
+ repodata_add_flexarray(pd->data, pd->collhandle, UPDATE_COLLECTION, pd->pkghandle);
+ pd->pkghandle = 0;
+ break;
+
/* <filename>libntlm-0.4.2-1.fc8.x86_64.rpm</filename> */
/* <filename>libntlm-0.4.2-1.fc8.x86_64.rpm</filename> */
case STATE_FILENAME:
- repodata_set_str(pd->data, pd->collhandle, UPDATE_COLLECTION_FILENAME, content);
+ repodata_set_str(pd->data, pd->pkghandle, UPDATE_COLLECTION_FILENAME, content);
break;
/* <reboot_suggested>True</reboot_suggested> */
@@ -444,7 +458,7 @@ endElement(struct solv_xmlparser *xmlp, int state, char *content)
{
/* FIXME: this is per-package, the global flag should be computed at runtime */
repodata_set_void(pd->data, pd->handle, UPDATE_REBOOT);
- repodata_set_void(pd->data, pd->collhandle, UPDATE_REBOOT);
+ repodata_set_void(pd->data, pd->pkghandle, UPDATE_REBOOT);
}
break;
@@ -454,7 +468,7 @@ endElement(struct solv_xmlparser *xmlp, int state, char *content)
{
/* FIXME: this is per-package, the global flag should be computed at runtime */
repodata_set_void(pd->data, pd->handle, UPDATE_RESTART);
- repodata_set_void(pd->data, pd->collhandle, UPDATE_RESTART);
+ repodata_set_void(pd->data, pd->pkghandle, UPDATE_RESTART);
}
break;
@@ -464,7 +478,7 @@ endElement(struct solv_xmlparser *xmlp, int state, char *content)
{
/* FIXME: this is per-package, the global flag should be computed at runtime */
repodata_set_void(pd->data, pd->handle, UPDATE_RELOGIN);
- repodata_set_void(pd->data, pd->collhandle, UPDATE_RELOGIN);
+ repodata_set_void(pd->data, pd->pkghandle, UPDATE_RELOGIN);
}
break;
default:
diff --git a/ext/testcase.c b/ext/testcase.c
index 0be7a21..8fb6d79 100644
--- a/ext/testcase.c
+++ b/ext/testcase.c
@@ -1991,6 +1991,7 @@ testcase_read(Pool *pool, FILE *fp, const char *testcase, Queue *job, char **res
Id *genid = 0;
int ngenid = 0;
Queue autoinstq;
+ int oldjobsize = job ? job->count : 0;
if (resultp)
*resultp = 0;
@@ -2065,6 +2066,21 @@ testcase_read(Pool *pool, FILE *fp, const char *testcase, Queue *job, char **res
int prio, subprio;
const char *rdata;
+ if (pool->considered)
+ {
+ pool_error(pool, 0, "testcase_read: cannot add repos after packages were disabled");
+ continue;
+ }
+ if (solv)
+ {
+ pool_error(pool, 0, "testcase_read: cannot add repos after the solver was created");
+ continue;
+ }
+ if (job && job->count != oldjobsize)
+ {
+ pool_error(pool, 0, "testcase_read: cannot add repos after jobs have been created");
+ continue;
+ }
prepared = 0;
if (!poolflagsreset)
{
@@ -2125,6 +2141,11 @@ testcase_read(Pool *pool, FILE *fp, const char *testcase, Queue *job, char **res
int i;
/* must set the disttype before the arch */
+ if (job && job->count != oldjobsize)
+ {
+ pool_error(pool, 0, "testcase_read: cannot change the system after jobs have been created");
+ continue;
+ }
prepared = 0;
if (strcmp(pieces[2], "*") != 0)
{