diff options
author | Michael Schroeder <mls@suse.de> | 2014-04-04 16:18:06 +0200 |
---|---|---|
committer | Michael Schroeder <mls@suse.de> | 2014-04-04 16:18:06 +0200 |
commit | c8164bfecf2ba8bcf4c24329534d3104f19da73c (patch) | |
tree | 8063c2f9807984df9b17a0489661a09db456d86a /src | |
parent | fdff34f4855b84438b5bff3f79cba33d6bf35865 (diff) | |
download | libsolv-c8164bfecf2ba8bcf4c24329534d3104f19da73c.tar.gz libsolv-c8164bfecf2ba8bcf4c24329534d3104f19da73c.tar.bz2 libsolv-c8164bfecf2ba8bcf4c24329534d3104f19da73c.zip |
[ABI BREAKAGE] add support for SHA224/384/512
We also use this to reorder knownid.h, thus breaking
the libsolv ABI. Next step is to bump the version.
Diffstat (limited to 'src')
-rw-r--r-- | src/chksum.c | 57 | ||||
-rw-r--r-- | src/knownid.h | 55 | ||||
-rw-r--r-- | src/repo_write.c | 9 | ||||
-rw-r--r-- | src/repodata.c | 41 | ||||
-rw-r--r-- | src/repodata.h | 3 | ||||
-rw-r--r-- | src/repopack.h | 12 | ||||
-rw-r--r-- | src/rules.c | 8 |
7 files changed, 147 insertions, 38 deletions
diff --git a/src/chksum.c b/src/chksum.c index 81b8d57..2f27621 100644 --- a/src/chksum.c +++ b/src/chksum.c @@ -26,7 +26,10 @@ struct _Chksum { union { MD5_CTX md5; SHA1_CTX sha1; + SHA224_CTX sha224; SHA256_CTX sha256; + SHA384_CTX sha384; + SHA512_CTX sha512; } c; }; @@ -44,9 +47,18 @@ solv_chksum_create(Id type) case REPOKEY_TYPE_SHA1: solv_SHA1_Init(&chk->c.sha1); return chk; + case REPOKEY_TYPE_SHA224: + solv_SHA224_Init(&chk->c.sha224); + return chk; case REPOKEY_TYPE_SHA256: solv_SHA256_Init(&chk->c.sha256); return chk; + case REPOKEY_TYPE_SHA384: + solv_SHA384_Init(&chk->c.sha384); + return chk; + case REPOKEY_TYPE_SHA512: + solv_SHA512_Init(&chk->c.sha512); + return chk; default: break; } @@ -69,8 +81,14 @@ solv_chksum_len(Id type) return 16; case REPOKEY_TYPE_SHA1: return 20; + case REPOKEY_TYPE_SHA224: + return 28; case REPOKEY_TYPE_SHA256: return 32; + case REPOKEY_TYPE_SHA384: + return 48; + case REPOKEY_TYPE_SHA512: + return 64; default: return 0; } @@ -103,9 +121,18 @@ solv_chksum_add(Chksum *chk, const void *data, int len) case REPOKEY_TYPE_SHA1: solv_SHA1_Update(&chk->c.sha1, data, len); return; + case REPOKEY_TYPE_SHA224: + solv_SHA224_Update(&chk->c.sha224, data, len); + return; case REPOKEY_TYPE_SHA256: solv_SHA256_Update(&chk->c.sha256, data, len); return; + case REPOKEY_TYPE_SHA384: + solv_SHA384_Update(&chk->c.sha384, data, len); + return; + case REPOKEY_TYPE_SHA512: + solv_SHA512_Update(&chk->c.sha512, data, len); + return; default: return; } @@ -134,12 +161,30 @@ solv_chksum_get(Chksum *chk, int *lenp) if (lenp) *lenp = 20; return chk->result; + case REPOKEY_TYPE_SHA224: + solv_SHA224_Final(chk->result, &chk->c.sha224); + chk->done = 1; + if (lenp) + *lenp = 28; + return chk->result; case REPOKEY_TYPE_SHA256: solv_SHA256_Final(chk->result, &chk->c.sha256); chk->done = 1; if (lenp) *lenp = 32; return chk->result; + case REPOKEY_TYPE_SHA384: + solv_SHA384_Final(chk->result, &chk->c.sha384); + chk->done = 1; + if (lenp) + *lenp = 48; + return chk->result; + case REPOKEY_TYPE_SHA512: + solv_SHA512_Final(chk->result, &chk->c.sha512); + chk->done = 1; + if (lenp) + *lenp = 64; + return chk->result; default: if (lenp) *lenp = 0; @@ -168,8 +213,14 @@ solv_chksum_type2str(Id type) return "md5"; case REPOKEY_TYPE_SHA1: return "sha1"; + case REPOKEY_TYPE_SHA224: + return "sha224"; case REPOKEY_TYPE_SHA256: return "sha256"; + case REPOKEY_TYPE_SHA384: + return "sha384"; + case REPOKEY_TYPE_SHA512: + return "sha512"; default: return 0; } @@ -182,8 +233,14 @@ solv_chksum_str2type(const char *str) return REPOKEY_TYPE_MD5; if (!strcasecmp(str, "sha") || !strcasecmp(str, "sha1")) return REPOKEY_TYPE_SHA1; + if (!strcasecmp(str, "sha224")) + return REPOKEY_TYPE_SHA224; if (!strcasecmp(str, "sha256")) return REPOKEY_TYPE_SHA256; + if (!strcasecmp(str, "sha384")) + return REPOKEY_TYPE_SHA384; + if (!strcasecmp(str, "sha512")) + return REPOKEY_TYPE_SHA512; return 0; } diff --git a/src/knownid.h b/src/knownid.h index e9aa053..b6a8a49 100644 --- a/src/knownid.h +++ b/src/knownid.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, Novell Inc. + * Copyright (c) 2007-2014, Novell Inc. * * This program is licensed under the BSD license, read LICENSE.BSD * for further information @@ -50,19 +50,24 @@ KNOWNID(RPM_RPMDBID, "rpm:dbid"), KNOWNID(SOLVABLE_PREREQMARKER, "solvable:prereqmarker"), /* normal provides before this, generated file provides after this */ KNOWNID(SOLVABLE_FILEMARKER, "solvable:filemarker"), + KNOWNID(NAMESPACE_INSTALLED, "namespace:installed"), KNOWNID(NAMESPACE_MODALIAS, "namespace:modalias"), KNOWNID(NAMESPACE_SPLITPROVIDES, "namespace:splitprovides"), KNOWNID(NAMESPACE_LANGUAGE, "namespace:language"), KNOWNID(NAMESPACE_FILESYSTEM, "namespace:filesystem"), KNOWNID(NAMESPACE_OTHERPROVIDERS, "namespace:otherproviders"), + KNOWNID(SYSTEM_SYSTEM, "system:system"), + +/* special solvable architectures */ KNOWNID(ARCH_SRC, "src"), KNOWNID(ARCH_NOSRC, "nosrc"), KNOWNID(ARCH_NOARCH, "noarch"), KNOWNID(ARCH_ALL, "all"), KNOWNID(ARCH_ANY, "any"), +/* the meta tags used in solv file storage */ KNOWNID(REPOSITORY_SOLVABLES, "repository:solvables"), KNOWNID(REPOSITORY_DELTAINFO, "repository:deltainfo"), @@ -76,12 +81,7 @@ KNOWNID(REPOSITORY_ADDEDFILEPROVIDES, "repository:addedfileprovides"), /* inode of the rpm database for rpm --rebuilddb detection */ KNOWNID(REPOSITORY_RPMDBCOOKIE, "repository:rpmdbcookie"), -/* The void type is usable to encode one-valued attributes, they have - no associated data. This is useful to encode values which many solvables - have in common, and whose overall set is relatively limited. A prime - example would be the media number. The actual value is encoded in the - SIZE member of the key structure. Be warned: careless use of this - leads to combinatoric explosion of number of schemas. */ +/* the known data types */ KNOWNID(REPOKEY_TYPE_VOID, "repokey:type:void"), KNOWNID(REPOKEY_TYPE_CONSTANT, "repokey:type:constant"), KNOWNID(REPOKEY_TYPE_CONSTANTID, "repokey:type:constantid"), @@ -97,10 +97,13 @@ KNOWNID(REPOKEY_TYPE_DIRSTRARRAY, "repokey:type:dirstrarray"), KNOWNID(REPOKEY_TYPE_DIRNUMNUMARRAY, "repokey:type:dirnumnumarray"), KNOWNID(REPOKEY_TYPE_MD5, "repokey:type:md5"), KNOWNID(REPOKEY_TYPE_SHA1, "repokey:type:sha1"), +KNOWNID(REPOKEY_TYPE_SHA224, "repokey:type:sha224"), KNOWNID(REPOKEY_TYPE_SHA256, "repokey:type:sha256"), +KNOWNID(REPOKEY_TYPE_SHA384, "repokey:type:sha384"), +KNOWNID(REPOKEY_TYPE_SHA512, "repokey:type:sha512"), KNOWNID(REPOKEY_TYPE_FIXARRAY, "repokey:type:fixarray"), KNOWNID(REPOKEY_TYPE_FLEXARRAY, "repokey:type:flexarray"), -KNOWNID(REPOKEY_TYPE_DELETED, "repokey:type:deleted"), +KNOWNID(REPOKEY_TYPE_DELETED, "repokey:type:deleted"), /* internal only */ KNOWNID(SOLVABLE_SUMMARY, "solvable:summary"), KNOWNID(SOLVABLE_DESCRIPTION, "solvable:description"), @@ -124,6 +127,7 @@ KNOWNID(SOLVABLE_INSTALLTIME, "solvable:installtime"), KNOWNID(SOLVABLE_MEDIADIR, "solvable:mediadir"), KNOWNID(SOLVABLE_MEDIAFILE, "solvable:mediafile"), KNOWNID(SOLVABLE_MEDIANR, "solvable:medianr"), +KNOWNID(SOLVABLE_MEDIABASE, "solvable:mediabase"), /* <location xml:base=... > */ KNOWNID(SOLVABLE_DOWNLOADSIZE, "solvable:downloadsize"), KNOWNID(SOLVABLE_SOURCEARCH, "solvable:sourcearch"), KNOWNID(SOLVABLE_SOURCENAME, "solvable:sourcename"), @@ -142,7 +146,6 @@ KNOWNID(SOLVABLE_CHANGELOG_AUTHOR, "solvable:changelog:author"), KNOWNID(SOLVABLE_CHANGELOG_TIME, "solvable:changelog:time"), KNOWNID(SOLVABLE_CHANGELOG_TEXT, "solvable:changelog:text"), - /* stuff for solvables of type pattern */ KNOWNID(SOLVABLE_CATEGORY, "solvable:category"), KNOWNID(SOLVABLE_INCLUDES, "solvable:includes"), @@ -150,6 +153,7 @@ KNOWNID(SOLVABLE_EXTENDS, "solvable:extends"), KNOWNID(SOLVABLE_ICON, "solvable:icon"), KNOWNID(SOLVABLE_ORDER, "solvable:order"), +/* extra definitions for updates (i.e. patch: solvables) */ KNOWNID(UPDATE_REBOOT, "update:reboot"), /* reboot suggested (kernel update) */ KNOWNID(UPDATE_RESTART, "update:restart"), /* restart suggested (update stack update) */ KNOWNID(UPDATE_RELOGIN, "update:relogin"), /* relogin suggested */ @@ -172,7 +176,7 @@ KNOWNID(UPDATE_REFERENCE_HREF, "update:reference:href"), /* href, e.g. 'http:/ KNOWNID(UPDATE_REFERENCE_ID, "update:reference:id"), /* id, e.g. bug number */ KNOWNID(UPDATE_REFERENCE_TITLE, "update:reference:title"), /* title, e.g. "the bla forz scribs on fuggle" */ -/* name */ +/* extra definitions for products */ KNOWNID(PRODUCT_REFERENCEFILE, "product:referencefile"), /* installed product only */ KNOWNID(PRODUCT_SHORTLABEL, "product:shortlabel"), /* not in repomd? */ KNOWNID(PRODUCT_DISTPRODUCT, "product:distproduct"), /* obsolete */ @@ -184,8 +188,11 @@ KNOWNID(PRODUCT_FLAGS, "product:flags"), /* e.g. 'update', 'no_you' */ KNOWNID(PRODUCT_PRODUCTLINE, "product:productline"), /* installed product only */ KNOWNID(PRODUCT_REGISTER_TARGET, "product:regtarget"), /* installed product only */ KNOWNID(PRODUCT_REGISTER_RELEASE, "product:regrelease"), /* installed product only */ +KNOWNID(PRODUCT_UPDATES_REPOID, "product:updates:repoid"), +KNOWNID(PRODUCT_UPDATES, "product:updates"), +KNOWNID(PRODUCT_ENDOFLIFE, "product:endoflife"), -/* argh */ +/* argh, should rename to repository and unify with REPOMD */ KNOWNID(SUSETAGS_DATADIR, "susetags:datadir"), KNOWNID(SUSETAGS_DESCRDIR, "susetags:descrdir"), KNOWNID(SUSETAGS_DEFAULTVENDOR, "susetags:defaultvendor"), @@ -197,24 +204,17 @@ KNOWNID(SUSETAGS_SHARE_NAME, "susetags:share:name"), KNOWNID(SUSETAGS_SHARE_EVR, "susetags:share:evr"), KNOWNID(SUSETAGS_SHARE_ARCH, "susetags:share:arch"), - /* timestamp then the repository was generated */ KNOWNID(REPOSITORY_TIMESTAMP, "repository:timestamp"), -/* hint when the metadata could be outdated - w/respect to generated timestamp */ +/* hint when the metadata could be outdated w/respect to generated timestamp */ KNOWNID(REPOSITORY_EXPIRE, "repository:expire"), - /* which things does this repo provides updates for, if it does (array) */ -KNOWNID(REPOSITORY_UPDATES, "repository:updates"), -/* for the repository:update label and cpeid, use the repository:product - sub attributes */ - +KNOWNID(REPOSITORY_UPDATES, "repository:updates"), /* obsolete? */ /* which products this repository is supposed to be for (array) */ KNOWNID(REPOSITORY_DISTROS, "repository:distros"), KNOWNID(REPOSITORY_PRODUCT_LABEL, "repository:product:label"), KNOWNID(REPOSITORY_PRODUCT_CPEID, "repository:product:cpeid"), KNOWNID(REPOSITORY_REPOID, "repository:repoid"), /* obsolete? */ - /* keyword (tags) for this repository */ KNOWNID(REPOSITORY_KEYWORDS, "repository:keywords"), /* revision of the repository. arbitrary string */ @@ -234,9 +234,7 @@ KNOWNID(DELTA_BASE_EVR, "delta:baseevr"), KNOWNID(DELTA_SEQ_NAME, "delta:seqname"), KNOWNID(DELTA_SEQ_EVR, "delta:seqevr"), KNOWNID(DELTA_SEQ_NUM, "delta:seqnum"), - -/* XXX: shouldn't use a real ID */ -KNOWNID(NAMESPACE_PRODUCTBUDDY, "namespace:productbuddy"), /* obsolete */ +KNOWNID(DELTA_LOCATION_BASE, "delta:locbase"), /* <location xml:base=... > */ KNOWNID(REPOSITORY_REPOMD, "repository:repomd"), KNOWNID(REPOSITORY_REPOMD_TYPE, "repository:repomd:type"), @@ -250,23 +248,14 @@ KNOWNID(PUBKEY_KEYID, "pubkey:keyid"), KNOWNID(PUBKEY_FINGERPRINT, "pubkey:fingerprint"), KNOWNID(PUBKEY_EXPIRES, "pubkey:expires"), KNOWNID(PUBKEY_SIGNATURES, "pubkey:signatures"), -KNOWNID(SOLVABLE_MEDIABASE, "solvable:mediabase"), /* <location xml:base=... > */ - KNOWNID(PUBKEY_DATA, "pubkey:data"), +KNOWNID(PUBKEY_SUBKEYOF, "pubkey:subkeyof"), KNOWNID(SIGNATURE_ISSUER, "signature:issuer"), KNOWNID(SIGNATURE_TIME, "signature:time"), KNOWNID(SIGNATURE_EXPIRES, "signature:expires"), KNOWNID(SIGNATURE_DATA, "signature:data"), -KNOWNID(PUBKEY_SUBKEYOF, "pubkey:subkeyof"), - -KNOWNID(DELTA_LOCATION_BASE, "delta:locbase"), /* <location xml:base=... > */ - -KNOWNID(PRODUCT_UPDATES_REPOID, "product:updates:repoid"), -KNOWNID(PRODUCT_UPDATES, "product:updates"), -KNOWNID(PRODUCT_ENDOFLIFE, "product:endoflife"), - KNOWNID(ID_NUM_INTERNAL, 0) #ifdef KNOWNID_INITIALIZE diff --git a/src/repo_write.c b/src/repo_write.c index 9f314cb..2900b44 100644 --- a/src/repo_write.c +++ b/src/repo_write.c @@ -812,9 +812,18 @@ repo_write_adddata(struct cbdata *cbdata, Repodata *data, Repokey *key, KeyValue case REPOKEY_TYPE_SHA1: data_addblob(xd, (unsigned char *)kv->str, SIZEOF_SHA1); break; + case REPOKEY_TYPE_SHA224: + data_addblob(xd, (unsigned char *)kv->str, SIZEOF_SHA224); + break; case REPOKEY_TYPE_SHA256: data_addblob(xd, (unsigned char *)kv->str, SIZEOF_SHA256); break; + case REPOKEY_TYPE_SHA384: + data_addblob(xd, (unsigned char *)kv->str, SIZEOF_SHA384); + break; + case REPOKEY_TYPE_SHA512: + data_addblob(xd, (unsigned char *)kv->str, SIZEOF_SHA512); + break; case REPOKEY_TYPE_U32: u32 = kv->num; v[0] = u32 >> 24; diff --git a/src/repodata.c b/src/repodata.c index fbe8654..7ef29f8 100644 --- a/src/repodata.c +++ b/src/repodata.c @@ -741,8 +741,18 @@ repodata_lookup_bin_checksum(Repodata *data, Id solvid, Id keyname, Id *typep) dp = find_key_data(data, solvid, keyname, &key); if (!dp) return 0; - if (!(key->type == REPOKEY_TYPE_MD5 || key->type == REPOKEY_TYPE_SHA1 || key->type == REPOKEY_TYPE_SHA256)) - return 0; + switch (key->type) + { + case REPOKEY_TYPE_MD5: + case REPOKEY_TYPE_SHA1: + case REPOKEY_TYPE_SHA224: + case REPOKEY_TYPE_SHA256: + case REPOKEY_TYPE_SHA384: + case REPOKEY_TYPE_SHA512: + break; + default: + return 0; + } *typep = key->type; return dp; } @@ -884,7 +894,10 @@ repodata_stringify(Pool *pool, Repodata *data, Repokey *key, KeyValue *kv, int f return 1; case REPOKEY_TYPE_MD5: case REPOKEY_TYPE_SHA1: + case REPOKEY_TYPE_SHA224: case REPOKEY_TYPE_SHA256: + case REPOKEY_TYPE_SHA384: + case REPOKEY_TYPE_SHA512: if (!(flags & SEARCH_CHECKSUMS)) return 0; /* skip em */ if (kv->num) @@ -1985,7 +1998,10 @@ dataiterator_strdup(Dataiterator *di) { case REPOKEY_TYPE_MD5: case REPOKEY_TYPE_SHA1: + case REPOKEY_TYPE_SHA224: case REPOKEY_TYPE_SHA256: + case REPOKEY_TYPE_SHA384: + case REPOKEY_TYPE_SHA512: case REPOKEY_TYPE_DIRSTRARRAY: if (di->kv.num) /* was it stringified into tmp space? */ l = strlen(di->kv.str) + 1; @@ -2007,9 +2023,18 @@ dataiterator_strdup(Dataiterator *di) case REPOKEY_TYPE_SHA1: l = SIZEOF_SHA1; break; + case REPOKEY_TYPE_SHA224: + l = SIZEOF_SHA224; + break; case REPOKEY_TYPE_SHA256: l = SIZEOF_SHA256; break; + case REPOKEY_TYPE_SHA384: + l = SIZEOF_SHA384; + break; + case REPOKEY_TYPE_SHA512: + l = SIZEOF_SHA512; + break; case REPOKEY_TYPE_BINARY: l = di->kv.num; break; @@ -2941,9 +2966,18 @@ repodata_serialize_key(Repodata *data, struct extdata *newincore, case REPOKEY_TYPE_SHA1: data_addblob(xd, data->attrdata + val, SIZEOF_SHA1); break; + case REPOKEY_TYPE_SHA224: + data_addblob(xd, data->attrdata + val, SIZEOF_SHA224); + break; case REPOKEY_TYPE_SHA256: data_addblob(xd, data->attrdata + val, SIZEOF_SHA256); break; + case REPOKEY_TYPE_SHA384: + data_addblob(xd, data->attrdata + val, SIZEOF_SHA384); + break; + case REPOKEY_TYPE_SHA512: + data_addblob(xd, data->attrdata + val, SIZEOF_SHA512); + break; case REPOKEY_TYPE_NUM: if (val & 0x80000000) { @@ -3395,7 +3429,10 @@ repodata_create_stubs(Repodata *data) break; case REPOKEY_TYPE_MD5: case REPOKEY_TYPE_SHA1: + case REPOKEY_TYPE_SHA224: case REPOKEY_TYPE_SHA256: + case REPOKEY_TYPE_SHA384: + case REPOKEY_TYPE_SHA512: repodata_set_bin_checksum(sdata, SOLVID_META, di.key->name, di.key->type, (const unsigned char *)di.kv.str); break; case REPOKEY_TYPE_IDARRAY: diff --git a/src/repodata.h b/src/repodata.h index f38ed4a..31d0158 100644 --- a/src/repodata.h +++ b/src/repodata.h @@ -29,7 +29,10 @@ extern "C" { #define SIZEOF_MD5 16 #define SIZEOF_SHA1 20 +#define SIZEOF_SHA224 28 #define SIZEOF_SHA256 32 +#define SIZEOF_SHA384 48 +#define SIZEOF_SHA512 64 struct _Repo; struct _KeyValue; diff --git a/src/repopack.h b/src/repopack.h index d75e61a..f7828ab 100644 --- a/src/repopack.h +++ b/src/repopack.h @@ -171,10 +171,22 @@ data_fetch(unsigned char *dp, KeyValue *kv, Repokey *key) kv->num = 0; /* not stringified yet */ kv->str = (const char *)dp; return dp + SIZEOF_SHA1; + case REPOKEY_TYPE_SHA224: + kv->num = 0; /* not stringified yet */ + kv->str = (const char *)dp; + return dp + SIZEOF_SHA224; case REPOKEY_TYPE_SHA256: kv->num = 0; /* not stringified yet */ kv->str = (const char *)dp; return dp + SIZEOF_SHA256; + case REPOKEY_TYPE_SHA384: + kv->num = 0; /* not stringified yet */ + kv->str = (const char *)dp; + return dp + SIZEOF_SHA384; + case REPOKEY_TYPE_SHA512: + kv->num = 0; /* not stringified yet */ + kv->str = (const char *)dp; + return dp + SIZEOF_SHA512; case REPOKEY_TYPE_BINARY: dp = data_read_id(dp, (Id *)&kv->num); kv->str = (const char *)dp; diff --git a/src/rules.c b/src/rules.c index 94824ce..3ba5a0e 100644 --- a/src/rules.c +++ b/src/rules.c @@ -3578,12 +3578,14 @@ solver_createcleandepsmap(Solver *solv, Map *cleandepsmap, int unneeded) if (!strncmp("product:", pool_id2str(pool, s->name), 8)) { MAPSET(&userinstalled, p - installed->start); - if (pool->nscallback) +#ifdef ENABLE_LINKED_PKGS + if (solv->instbuddy && solv->instbuddy[p - installed->start] > 1) { - Id buddy = pool->nscallback(pool, pool->nscallbackdata, NAMESPACE_PRODUCTBUDDY, p); - if (buddy >= installed->start && buddy < installed->end && pool->solvables[buddy].repo == installed) + Id buddy = solv->instbuddy[p - installed->start]; + if (buddy >= installed->start && buddy < installed->end) MAPSET(&userinstalled, buddy - installed->start); } +#endif } } } |