From 6c237170164cbcd4cda1d07bdd1faab5eb5bc2c3 Mon Sep 17 00:00:00 2001 From: DongHun Kwak Date: Tue, 1 Nov 2016 10:32:44 +0900 Subject: [PATCH] Imported Upstream version 14.37.1 Change-Id: I665032401f2bf8bf8c8f3fd41137785115f62952 Signed-off-by: DongHun Kwak --- VERSION.cmake | 4 +-- doc/autoinclude/FeatureTest.doc | 5 ++++ doc/autoinclude/RepoVariables.doc | 33 +++++++++++++++++++++++++ libzypp.spec.cmake | 1 + package/libzypp.changes | 6 +++++ tests/zypp/CheckSum_test.cc | 36 ++++++++++++++++++++++++--- zypp/CheckSum.cc | 52 ++++++++++++++++++++++++++++++++++++--- zypp/CheckSum.h | 15 +++++++++++ zypp/Digest.cc | 9 +++++++ zypp/Digest.h | 6 +++++ zypp/sat/LookupAttr.cc | 12 +++++++++ zypp/sat/Solvable.cc | 3 +++ 12 files changed, 172 insertions(+), 10 deletions(-) create mode 100644 doc/autoinclude/RepoVariables.doc diff --git a/VERSION.cmake b/VERSION.cmake index 42e8095..c6ee35c 100644 --- a/VERSION.cmake +++ b/VERSION.cmake @@ -61,8 +61,8 @@ SET(LIBZYPP_MAJOR "14") SET(LIBZYPP_COMPATMINOR "30") SET(LIBZYPP_MINOR "37") -SET(LIBZYPP_PATCH "0") +SET(LIBZYPP_PATCH "1") # -# LAST RELEASED: 14.37.0 (30) +# LAST RELEASED: 14.37.1 (30) # (The number in parenthesis is LIBZYPP_COMPATMINOR) #======= diff --git a/doc/autoinclude/FeatureTest.doc b/doc/autoinclude/FeatureTest.doc index 6e57b93..3ebf429 100644 --- a/doc/autoinclude/FeatureTest.doc +++ b/doc/autoinclude/FeatureTest.doc @@ -51,6 +51,11 @@ Packages requiring a feature may use the corresponding \c Requires: in their .sp
\see \ref plugin-url-resolver
+
repovarexpand
+
+
version 0
+
Also support braced variables, shell like default and alternate values. \see \ref zypp-repovars
+
*/ diff --git a/doc/autoinclude/RepoVariables.doc b/doc/autoinclude/RepoVariables.doc new file mode 100644 index 0000000..470bd72 --- /dev/null +++ b/doc/autoinclude/RepoVariables.doc @@ -0,0 +1,33 @@ +/** + +\page zypp-repovars Repository Variables + +\author Michael Andres + +\section zypp-repovars-intro Repository Variables + +Within a \c .repo or \c .serivce file, the name and URLs are subject to variable substitution. + +Variables are e.g. usefull for related repositories like packman (http://ftp.gwdg.de/pub/linux/packman/suse/$releasever<\tt>), which shall always fit the installed distribution, even after a distribution upgrade. To help performing a distribution upgrade, the value of \c $releasever can be overwritten in zypper using the \c --releasever global option. This way you can easily switch all repositories using \c $releasever to the new version (provided the server layouts did not change and new repos are already available). + +The variable expander also supports shell like definition of default and alternate values. + +\see \ref zypp::repo::RepoVarExpand Variable expander + + +\subsection zypp-repoars-builtin Builtin repository variables + +\li \c $arch - + The system's CPU architecture. + +\li \c $basearch - + The base architecture of the system. For example, iX86 machines have a base architecture of \c i386, while AMD64 and Intel64 have \c x86_64. + +\li \c $releasever - + The version of your openSUSE or SUSE Linux. The value is obtained from the /product/version XML-node in /etc/products.d/baseproduct. + +\li \c $releasever_minor +\li \c $releasever_major - + \c $releasever_major will be set to the leading portion up to (but not including) the 1st dot; \c $releasever_minor to the trailing portion after the 1st dot. If there's no dot in \c $releasever, \c $releasever_major is the same as \c $releasever and \c $releasever_minor is empty. + +*/ diff --git a/libzypp.spec.cmake b/libzypp.spec.cmake index b40ef03..b4a1d5a 100644 --- a/libzypp.spec.cmake +++ b/libzypp.spec.cmake @@ -38,6 +38,7 @@ Provides: libzypp(plugin:commit) = 1 Provides: libzypp(plugin:services) = 0 Provides: libzypp(plugin:system) = 0 Provides: libzypp(plugin:urlresolver) = 0 +Provides: libzypp(repovarexpand) = 0 %if 0%{?suse_version} Recommends: logrotate diff --git a/package/libzypp.changes b/package/libzypp.changes index bc824fc..75859a8 100644 --- a/package/libzypp.changes +++ b/package/libzypp.changes @@ -1,4 +1,10 @@ ------------------------------------------------------------------- +Mon Mar 16 14:05:28 CET 2015 - ma@suse.de + +- add support for SHA224/384/512 +- version 14.37.1 (30) + +------------------------------------------------------------------- Wed Mar 11 09:22:46 CET 2015 - ma@suse.de - New RepoVarExpand: Functor expanding repo variables in a diff --git a/tests/zypp/CheckSum_test.cc b/tests/zypp/CheckSum_test.cc index d875e61..b12f722 100644 --- a/tests/zypp/CheckSum_test.cc +++ b/tests/zypp/CheckSum_test.cc @@ -1,4 +1,3 @@ - #include #include #include @@ -9,17 +8,46 @@ #include "zypp/base/Logger.h" #include "zypp/base/Exception.h" #include "zypp/ZYppFactory.h" +#include "zypp/Digest.h" #include "zypp/ZYpp.h" + using boost::unit_test::test_case; using namespace std; using namespace zypp; +void chksumtest( const std::string & type_r, const std::string & sum_r ) +{ + BOOST_CHECK_EQUAL( type_r, CheckSum( sum_r ).type() ); // autodetect type + BOOST_CHECK_EQUAL( type_r, CheckSum( type_r, sum_r ).type() ); + BOOST_CHECK_EQUAL( sum_r, Digest::digest( type_r, "" ) ); + for ( const std::string & t : { "md5", "sha1", "sha224", "sha256", "sha384", "sha512", } ) + { + if ( t != type_r ) + { + BOOST_CHECK_THROW( CheckSum( t, sum_r ), Exception ); // wrong type/size + } + } +} // most frequently you implement test cases as a free functions BOOST_AUTO_TEST_CASE(checksum_test) { - BOOST_CHECK_THROW( CheckSum( "sha1", "dsdsads" ), Exception ); // wrong size - BOOST_CHECK_THROW( CheckSum( "sha256", "dsdsads" ), Exception ); // wrong size - BOOST_CHECK_THROW( CheckSum( "md5", "dsdsads" ), Exception ); // wrong size + CheckSum e; + BOOST_CHECK( e.empty() ); + BOOST_CHECK( e.type().empty() ); + BOOST_CHECK( e.checksum().empty() ); + // sum for "" + // md5 32 d41d8cd98f00b204e9800998ecf8427e + // 1 40 da39a3ee5e6b4b0d3255bfef95601890afd80709 + // 224 56 d14a028c2a3a2bc9476102bb288234c415a2b01f828ea62ac5b3e42f + // 256 64 e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 + // 384 96 38b060a751ac96384cd9327eb1b1e36a21fdb71114be07434c0cc7bf63f6e1da274edebfe76f65fbd51ad2f14898b95b + // 512 128 cf83e1357eefb8bdf1542850d66d8007d620e4050b5715dc83f4a921d36ce9ce47d0d13c5d85f2b0ff8318d2877eec2f63b931bd47417a81a538327af927da3e + chksumtest( CheckSum::md5Type(), "d41d8cd98f00b204e9800998ecf8427e" ); + chksumtest( CheckSum::sha1Type(), "da39a3ee5e6b4b0d3255bfef95601890afd80709" ); + chksumtest( CheckSum::sha224Type(), "d14a028c2a3a2bc9476102bb288234c415a2b01f828ea62ac5b3e42f" ); + chksumtest( CheckSum::sha256Type(), "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" ); + chksumtest( CheckSum::sha384Type(), "38b060a751ac96384cd9327eb1b1e36a21fdb71114be07434c0cc7bf63f6e1da274edebfe76f65fbd51ad2f14898b95b" ); + chksumtest( CheckSum::sha512Type(), "cf83e1357eefb8bdf1542850d66d8007d620e4050b5715dc83f4a921d36ce9ce47d0d13c5d85f2b0ff8318d2877eec2f63b931bd47417a81a538327af927da3e" ); } diff --git a/zypp/CheckSum.cc b/zypp/CheckSum.cc index bd94b2d..921efb7 100644 --- a/zypp/CheckSum.cc +++ b/zypp/CheckSum.cc @@ -26,17 +26,25 @@ namespace zypp { ///////////////////////////////////////////////////////////////// const std::string & CheckSum::md5Type() - { static std::string _type( "md5" ); return _type; } + { return Digest::md5(); } const std::string & CheckSum::shaType() { static std::string _type( "sha" ); return _type; } const std::string & CheckSum::sha1Type() - { static std::string _type( "sha1" ); return _type; } + { return Digest::sha1(); } + + const std::string & CheckSum::sha224Type() + { return Digest::sha224(); } const std::string & CheckSum::sha256Type() - { static std::string _type( "sha256" ); return _type; } + { return Digest::sha256(); } + + const std::string & CheckSum::sha384Type() + { return Digest::sha384(); } + const std::string & CheckSum::sha512Type() + { return Digest::sha512(); } CheckSum::CheckSum( const std::string & type, const std::string & checksum ) : _type( str::toLower( type ) ) @@ -44,6 +52,28 @@ namespace zypp { switch ( checksum.size() ) { + case 128: + if ( _type == sha512Type() ) + return; + if ( _type.empty() || _type == shaType() ) + { + _type = sha512Type(); + return; + } + // else: dubious + break; + + case 96: + if ( _type == sha384Type() ) + return; + if ( _type.empty() || _type == shaType() ) + { + _type = sha384Type(); + return; + } + // else: dubious + break; + case 64: if ( _type == sha256Type() ) return; @@ -55,6 +85,17 @@ namespace zypp // else: dubious break; + case 56: + if ( _type == sha224Type() ) + return; + if ( _type.empty() || _type == shaType() ) + { + _type = sha224Type(); + return; + } + // else: dubious + break; + case 40: if ( _type == sha1Type() ) return; @@ -97,7 +138,10 @@ namespace zypp if ( _type == md5Type() || _type == shaType() || _type == sha1Type() - || _type == sha256Type() ) + || _type == sha224Type() + || _type == sha256Type() + || _type == sha384Type() + || _type == sha512Type() ) { ZYPP_THROW( CheckSumException( msg ) ); } diff --git a/zypp/CheckSum.h b/zypp/CheckSum.h index ed539d4..fb73099 100644 --- a/zypp/CheckSum.h +++ b/zypp/CheckSum.h @@ -65,14 +65,20 @@ namespace zypp static const std::string & md5Type(); static const std::string & shaType(); static const std::string & sha1Type(); + static const std::string & sha224Type(); static const std::string & sha256Type(); + static const std::string & sha384Type(); + static const std::string & sha512Type(); /** \name Creates a checksum for algorithm \param type. */ //@{ static CheckSum md5( const std::string & checksum ) { return CheckSum( md5Type(), checksum); } static CheckSum sha( const std::string & checksum ) { return CheckSum( shaType(), checksum); } static CheckSum sha1( const std::string & checksum ) { return CheckSum( sha1Type(), checksum); } + static CheckSum sha224( const std::string & checksum ) { return CheckSum( sha224Type(), checksum); } static CheckSum sha256( const std::string & checksum ) { return CheckSum( sha256Type(), checksum); } + static CheckSum sha384( const std::string & checksum ) { return CheckSum( sha384Type(), checksum); } + static CheckSum sha512( const std::string & checksum ) { return CheckSum( sha512Type(), checksum); } //@} /** \name Reads the content of \param input_r and computes the checksum. */ @@ -80,12 +86,18 @@ namespace zypp static CheckSum md5( std::istream & input_r ) { return CheckSum( md5Type(), input_r ); } static CheckSum sha( std::istream & input_r ) { return CheckSum( sha1Type(), input_r ); } static CheckSum sha1( std::istream & input_r ) { return CheckSum( sha1Type(), input_r ); } + static CheckSum sha224( std::istream & input_r ) { return CheckSum( sha224Type(), input_r ); } static CheckSum sha256( std::istream & input_r ) { return CheckSum( sha256Type(), input_r ); } + static CheckSum sha384( std::istream & input_r ) { return CheckSum( sha384Type(), input_r ); } + static CheckSum sha512( std::istream & input_r ) { return CheckSum( sha512Type(), input_r ); } #ifndef SWIG // Swig treats it as syntax error static CheckSum md5( std::istream && input_r ) { return CheckSum( md5Type(), input_r ); } static CheckSum sha( std::istream && input_r ) { return CheckSum( sha1Type(), input_r ); } static CheckSum sha1( std::istream && input_r ) { return CheckSum( sha1Type(), input_r ); } + static CheckSum sha224( std::istream && input_r ) { return CheckSum( sha224Type(), input_r ); } static CheckSum sha256( std::istream && input_r ) { return CheckSum( sha256Type(), input_r ); } + static CheckSum sha384( std::istream && input_r ) { return CheckSum( sha384Type(), input_r ); } + static CheckSum sha512( std::istream && input_r ) { return CheckSum( sha512Type(), input_r ); } #endif //@} @@ -94,7 +106,10 @@ namespace zypp static CheckSum md5FromString( const std::string & input_r ) { return md5( std::stringstream( input_r ) ); } static CheckSum shaFromString( const std::string & input_r ) { return sha( std::stringstream( input_r ) ); } static CheckSum sha1FromString( const std::string & input_r ) { return sha1( std::stringstream( input_r ) ); } + static CheckSum sha224FromString( const std::string & input_r ) { return sha224( std::stringstream( input_r ) ); } static CheckSum sha256FromString( const std::string & input_r ) { return sha256( std::stringstream( input_r ) ); } + static CheckSum sha384FromString( const std::string & input_r ) { return sha384( std::stringstream( input_r ) ); } + static CheckSum sha512FromString( const std::string & input_r ) { return sha512( std::stringstream( input_r ) ); } //@} public: diff --git a/zypp/Digest.cc b/zypp/Digest.cc index 8135cb1..9a34c3b 100644 --- a/zypp/Digest.cc +++ b/zypp/Digest.cc @@ -46,9 +46,18 @@ namespace zypp { const std::string & Digest::sha1() { static std::string _type( "sha1" ); return _type; } + const std::string & Digest::sha224() + { static std::string _type( "sha224" ); return _type; } + const std::string & Digest::sha256() { static std::string _type( "sha256" ); return _type; } + const std::string & Digest::sha384() + { static std::string _type( "sha384" ); return _type; } + + const std::string & Digest::sha512() + { static std::string _type( "sha512" ); return _type; } + // private data class Digest::P { diff --git a/zypp/Digest.h b/zypp/Digest.h index 2673fbd..9756354 100644 --- a/zypp/Digest.h +++ b/zypp/Digest.h @@ -60,8 +60,14 @@ namespace zypp { static const std::string & md5(); /** sha1 */ static const std::string & sha1(); + /** sha224 */ + static const std::string & sha224(); /** sha256 */ static const std::string & sha256(); + /** sha384 */ + static const std::string & sha384(); + /** sha512 */ + static const std::string & sha512(); //@} public: diff --git a/zypp/sat/LookupAttr.cc b/zypp/sat/LookupAttr.cc index 627b3e4..d3fb410 100644 --- a/zypp/sat/LookupAttr.cc +++ b/zypp/sat/LookupAttr.cc @@ -695,9 +695,21 @@ namespace zypp return CheckSum::sha1( ::repodata_chk2str( _dip->data, solvAttrType(), (unsigned char *)_dip->kv.str ) ); break; + case REPOKEY_TYPE_SHA224: + return CheckSum::sha224( ::repodata_chk2str( _dip->data, solvAttrType(), (unsigned char *)_dip->kv.str ) ); + break; + case REPOKEY_TYPE_SHA256: return CheckSum::sha256( ::repodata_chk2str( _dip->data, solvAttrType(), (unsigned char *)_dip->kv.str ) ); break; + + case REPOKEY_TYPE_SHA384: + return CheckSum::sha384( ::repodata_chk2str( _dip->data, solvAttrType(), (unsigned char *)_dip->kv.str ) ); + break; + + case REPOKEY_TYPE_SHA512: + return CheckSum::sha512( ::repodata_chk2str( _dip->data, solvAttrType(), (unsigned char *)_dip->kv.str ) ); + break; } } return CheckSum(); diff --git a/zypp/sat/Solvable.cc b/zypp/sat/Solvable.cc index 0e84a0b..bd700ae 100644 --- a/zypp/sat/Solvable.cc +++ b/zypp/sat/Solvable.cc @@ -196,7 +196,10 @@ namespace zypp { case REPOKEY_TYPE_MD5: return CheckSum::md5( s ); case REPOKEY_TYPE_SHA1: return CheckSum::sha1( s ); + case REPOKEY_TYPE_SHA224: return CheckSum::sha224( s ); case REPOKEY_TYPE_SHA256: return CheckSum::sha256( s ); + case REPOKEY_TYPE_SHA384: return CheckSum::sha384( s ); + case REPOKEY_TYPE_SHA512: return CheckSum::sha512( s ); } return CheckSum( std::string(), s ); // try to autodetect } -- 2.7.4