diff options
author | Michael Schroeder <mls@suse.de> | 2013-02-25 15:02:24 +0100 |
---|---|---|
committer | Michael Schroeder <mls@suse.de> | 2013-02-25 15:02:24 +0100 |
commit | b6c702b3fade6c2a9f538da9a6bb37da3198d9e3 (patch) | |
tree | 52155e8cebe16262abdc63dd3fbcde3c60e320e3 | |
parent | d5458e958779f9d9785bef4c5ca93c20a6d1150a (diff) | |
download | libsolv-b6c702b3fade6c2a9f538da9a6bb37da3198d9e3.tar.gz libsolv-b6c702b3fade6c2a9f538da9a6bb37da3198d9e3.tar.bz2 libsolv-b6c702b3fade6c2a9f538da9a6bb37da3198d9e3.zip |
support RPM_ADD_WITH_CHANGELOG in repo_add_rpmdb
For people who want to make their solv file really big...
-rw-r--r-- | ext/repo_rpmdb.c | 65 | ||||
-rw-r--r-- | ext/repo_rpmdb.h | 1 | ||||
-rw-r--r-- | ext/repo_rpmmd.c | 2 | ||||
-rw-r--r-- | src/knownid.h | 2 | ||||
-rw-r--r-- | src/repo_write.c | 2 | ||||
-rw-r--r-- | tools/common_write.c | 2 |
6 files changed, 71 insertions, 3 deletions
diff --git a/ext/repo_rpmdb.c b/ext/repo_rpmdb.c index 57f7f43..8efaa16 100644 --- a/ext/repo_rpmdb.c +++ b/ext/repo_rpmdb.c @@ -86,6 +86,9 @@ #define TAG_TRIGGERNAME 1066 #define TAG_TRIGGERVERSION 1067 #define TAG_TRIGGERFLAGS 1068 +#define TAG_CHANGELOGTIME 1080 +#define TAG_CHANGELOGNAME 1081 +#define TAG_CHANGELOGTEXT 1082 #define TAG_OBSOLETENAME 1090 #define TAG_FILEDEVICES 1095 #define TAG_FILEINODES 1096 @@ -834,6 +837,46 @@ addfileprovides(Pool *pool, Repo *repo, Repodata *data, Solvable *s, RpmHead *rp return olddeps; } +static void +addchangelog(Repodata *data, Id handle, RpmHead *rpmhead) +{ + char **cn; + char **cx; + unsigned int *ct; + int i, cnc, cxc, ctc; + Queue hq; + + ct = headint32array(rpmhead, TAG_CHANGELOGTIME, &ctc); + cx = headstringarray(rpmhead, TAG_CHANGELOGTEXT, &cxc); + cn = headstringarray(rpmhead, TAG_CHANGELOGNAME, &cnc); + if (!ct || !cx || !cn || !ctc || ctc != cxc || ctc != cnc) + { + solv_free(ct); + solv_free(cx); + solv_free(cn); + return; + } + queue_init(&hq); + for (i = 0; i < ctc; i++) + { + Id h = repodata_new_handle(data); + if (ct[i]) + repodata_set_num(data, h, SOLVABLE_CHANGELOG_TIME, ct[i]); + if (cn[i]) + repodata_set_str(data, h, SOLVABLE_CHANGELOG_AUTHOR, cn[i]); + if (cx[i]) + repodata_set_str(data, h, SOLVABLE_CHANGELOG_TEXT, cx[i]); + queue_push(&hq, h); + } + for (i = 0; i < hq.count; i++) + repodata_add_flexarray(data, handle, SOLVABLE_CHANGELOG, hq.elements[i]); + queue_free(&hq); + solv_free(ct); + solv_free(cx); + solv_free(cn); +} + + static int rpm2solv(Pool *pool, Repo *repo, Repodata *data, Solvable *s, RpmHead *rpmhead, int flags) { @@ -1005,6 +1048,8 @@ rpm2solv(Pool *pool, Repo *repo, Repodata *data, Solvable *s, RpmHead *rpmhead, lastid = id; } } + if ((flags & RPM_ADD_WITH_CHANGELOG) != 0) + addchangelog(data, handle, rpmhead); } solv_free(evr); return 1; @@ -1095,6 +1140,7 @@ copydir_complex(Pool *pool, Repodata *data, Stringpool *fromspool, Repodata *fro struct solvable_copy_cbdata { Repodata *data; Id handle; + Id subhandle; Id *dircache; }; @@ -1156,6 +1202,22 @@ solvable_copy_cb(void *vcbdata, Solvable *r, Repodata *fromdata, Repokey *key, K id = copydir(pool, data, fromspool, fromdata, id, cbdata->dircache); repodata_add_dirstr(data, handle, keyname, id, kv->str); break; + case REPOKEY_TYPE_FLEXARRAY: + if (kv->eof == 2) + { + assert(cbdata->subhandle); + cbdata->handle = cbdata->subhandle; + cbdata->subhandle = 0; + break; + } + if (!kv->entry) + { + assert(!cbdata->subhandle); + cbdata->subhandle = cbdata->handle; + } + cbdata->handle = repodata_new_handle(data); + repodata_add_flexarray(data, cbdata->subhandle, keyname, cbdata->handle); + break; default: break; } @@ -1203,8 +1265,9 @@ solvable_copy(Solvable *s, Solvable *r, Repodata *data, Id *dircache) return; cbdata.data = data; cbdata.handle = s - pool->solvables; + cbdata.subhandle = 0; cbdata.dircache = dircache; - repo_search(fromrepo, (r - fromrepo->pool->solvables), 0, 0, SEARCH_NO_STORAGE_SOLVABLE, solvable_copy_cb, &cbdata); + repo_search(fromrepo, (r - fromrepo->pool->solvables), 0, 0, SEARCH_NO_STORAGE_SOLVABLE | SEARCH_SUB | SEARCH_ARRAYSENTINEL, solvable_copy_cb, &cbdata); } /* used to sort entries returned in some database order */ diff --git a/ext/repo_rpmdb.h b/ext/repo_rpmdb.h index 1e12de7..fdc6120 100644 --- a/ext/repo_rpmdb.h +++ b/ext/repo_rpmdb.h @@ -24,6 +24,7 @@ extern Id repo_add_pubkey(Repo *repo, const char *key, int flags); #define RPM_ADD_TRIGGERS (1 << 14) #define RPM_ADD_WITH_HDRID (1 << 15) #define RPM_ADD_WITH_LEADSIGID (1 << 16) +#define RPM_ADD_WITH_CHANGELOG (1 << 17) #define RPM_ITERATE_FILELIST_ONLYDIRS (1 << 0) #define RPM_ITERATE_FILELIST_WITHMD5 (1 << 1) diff --git a/ext/repo_rpmmd.c b/ext/repo_rpmmd.c index 50e5a99..603b27b 100644 --- a/ext/repo_rpmmd.c +++ b/ext/repo_rpmmd.c @@ -1053,7 +1053,7 @@ endElement(void *userData, const char *name) repodata_set_str(pd->data, pd->handle, SOLVABLE_ORDER, pd->content); break; case STATE_CHANGELOG: - repodata_set_str(pd->data, pd->changelog_handle, SOLVABLE_CHANGELOG_DESCRIPTION, pd->content); + repodata_set_str(pd->data, pd->changelog_handle, SOLVABLE_CHANGELOG_TEXT, pd->content); repodata_add_flexarray(pd->data, pd->handle, SOLVABLE_CHANGELOG, pd->changelog_handle); pd->changelog_handle = 0; break; diff --git a/src/knownid.h b/src/knownid.h index 1b680ba..9c8e064 100644 --- a/src/knownid.h +++ b/src/knownid.h @@ -248,7 +248,7 @@ KNOWNID(REPOSITORY_REPOMD_SIZE, "repository:repomd:size"), KNOWNID(SOLVABLE_CHANGELOG, "solvable:changelog"), KNOWNID(SOLVABLE_CHANGELOG_AUTHOR, "solvable:changelog:author"), KNOWNID(SOLVABLE_CHANGELOG_TIME, "solvable:changelog:time"), -KNOWNID(SOLVABLE_CHANGELOG_DESCRIPTION, "solvable:changelog:description"), +KNOWNID(SOLVABLE_CHANGELOG_TEXT, "solvable:changelog:text"), KNOWNID(ID_NUM_INTERNAL, 0) diff --git a/src/repo_write.c b/src/repo_write.c index f6e9fd6..fd8ff40 100644 --- a/src/repo_write.c +++ b/src/repo_write.c @@ -976,6 +976,8 @@ static Id verticals[] = { SOLVABLE_PKGID, SOLVABLE_HDRID, SOLVABLE_LEADSIGID, + SOLVABLE_CHANGELOG_AUTHOR, + SOLVABLE_CHANGELOG_TEXT, 0 }; diff --git a/tools/common_write.c b/tools/common_write.c index 75c75b5..6de8a69 100644 --- a/tools/common_write.c +++ b/tools/common_write.c @@ -27,6 +27,8 @@ static Id verticals[] = { SOLVABLE_EULA, SOLVABLE_DISKUSAGE, SOLVABLE_FILELIST, + SOLVABLE_CHANGELOG_AUTHOR, + SOLVABLE_CHANGELOG_TEXT, 0 }; |