From: Duncan Mac-Vicar P Date: Fri, 1 Aug 2008 17:29:01 +0000 (+0000) Subject: while trying to support package metadata extensions realized that X-Git-Tag: BASE-SuSE-Code-12_1-Branch~592 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=bb490b5d7befbbb0a1863c744d10f43f9690dae8;p=platform%2Fupstream%2Flibsolv.git while trying to support package metadata extensions realized that checksums were not saved. So forward port the fix. insert the checksum in rpmmd generated solv files (bnc#414002) --- diff --git a/VERSION.cmake b/VERSION.cmake index f4f6bf0..285a6b2 100644 --- a/VERSION.cmake +++ b/VERSION.cmake @@ -46,5 +46,5 @@ SET(LIBSATSOLVER_MAJOR "0") SET(LIBSATSOLVER_MINOR "10") -SET(LIBSATSOLVER_PATCH "2") +SET(LIBSATSOLVER_PATCH "3") diff --git a/package/libsatsolver.changes b/package/libsatsolver.changes index f1aadb1..f48dd6c 100644 --- a/package/libsatsolver.changes +++ b/package/libsatsolver.changes @@ -1,4 +1,11 @@ ------------------------------------------------------------------- +Fri Aug 1 18:59:22 CEST 2008 - dmacvicar@suse.de + +- insert the checksum in rpmmd generated solv files + (bnc#414002) +- 0.10.3 + +------------------------------------------------------------------- Tue Jul 29 10:53:22 CEST 2008 - mls@suse.de - resolve job rules before installing system packages [#411086] diff --git a/tools/repo_rpmmd.c b/tools/repo_rpmmd.c index 9807d2b..f88c273 100644 --- a/tools/repo_rpmmd.c +++ b/tools/repo_rpmmd.c @@ -199,6 +199,7 @@ struct parsedata { const char *tmpattr; Repodata *data; Id handle; + XML_Parser *parser; }; static Id @@ -483,9 +484,59 @@ startElement(void *userData, const char *name, const char **atts) else if (name[2] == 't' && name[3] == 'c') pd->kind = "patch"; - pd->solvable = pool_id2solvable(pool, repo_add_solvable(pd->common.repo)); - pd->freshens = 0; - repodata_extend(pd->data, pd->solvable - pool->solvables); + /** + * now we have two cases, one is that we are in the package tag of a new package + * and the other is that we are in the tag of an extension file like other.xml or + * filelist.xml. + * We identify it by looking the attributes + * + * new package + * + * ... + * + * + * extension package: + * + * For other.xml + * + * + * + */ + + /* first check if there is a pkgid attribute */ + const char *pkgid = find_attr( "pkgid", atts); + + if ( pkgid == NULL ) + { + /* this is a new package */ + /*fprintf(stderr, "new package\n");*/ + pd->solvable = pool_id2solvable(pool, repo_add_solvable(pd->common.repo)); + pd->freshens = 0; + repodata_extend(pd->data, pd->solvable - pool->solvables); + } + else + { + /* we need to look for the package based on the pkgid */ + Dataiterator di; + dataiterator_init(&di, pd->common.repo, -1, SOLVABLE_CHECKSUM, pkgid, SEARCH_STRING); + if (dataiterator_step(&di)) + { + /* we found it */ + /*fprintf(stderr, "package found '%i'\n", di.solvid);*/ + pd->solvable = pool_id2solvable(pool, di.solvid); + } + else + { + /* this is bad, here we should ignore the whole solvable */ + fprintf(stderr, "can't find package with checksum '%s'\n", pkgid); + //exit(1); + } + } + pd->handle = repodata_get_handle(pd->data, (pd->solvable - pool->solvables) - pd->data->start); #if 0 fprintf(stderr, "package #%d\n", pd->solvable - pool->solvables); @@ -669,6 +720,27 @@ endElement(void *userData, const char *name) case STATE_RPM_LICENSE: repodata_set_poolstr(pd->data, handle, SOLVABLE_LICENSE, pd->content); break; + case STATE_CHECKSUM: + { + int l; + Id type; + if (!strcasecmp (pd->tmpattr, "sha") || !strcasecmp (pd->tmpattr, "sha1")) + l = SIZEOF_SHA1 * 2, type = REPOKEY_TYPE_SHA1; + else if (!strcasecmp (pd->tmpattr, "md5")) + l = SIZEOF_MD5 * 2, type = REPOKEY_TYPE_MD5; + else + { + fprintf(stderr, "Unknown checksum type: %d: %s\n", (unsigned int)XML_GetCurrentLineNumber(*pd->parser), pd->tmpattr); + exit(1); + } + if (strlen(pd->content) != l) + { + fprintf(stderr, "Invalid checksum length: %d: for %s\n", (unsigned int)XML_GetCurrentLineNumber(*pd->parser), pd->tmpattr); + exit(1); + } + repodata_set_checksum(pd->data, handle, SOLVABLE_CHECKSUM, type, pd->content); + } + break; case STATE_FILE: #if 0 id = str2id(pool, pd->content, 1); @@ -769,6 +841,7 @@ repo_add_rpmmd(Repo *repo, FILE *fp, int flags) pd.kind = 0; XML_Parser parser = XML_ParserCreate(NULL); XML_SetUserData(parser, &pd); + pd.parser = &parser; XML_SetElementHandler(parser, startElement, endElement); XML_SetCharacterDataHandler(parser, characterData); for (;;)