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)
#=======
<DD>\see \ref plugin-url-resolver </DD>
</DL></DD>
+ <DT>repovarexpand</DT>
+ <DD><DL>
+ <DT>version 0</DT>
+ <DD>Also support braced variables, shell like default and alternate values. \see \ref zypp-repovars</DD>
+ </DL></DD>
</DL>
*/
--- /dev/null
+/**
+
+\page zypp-repovars Repository Variables
+
+\author Michael Andres <ma@suse.de>
+
+\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 (<tt>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 <tt>/product/version</tt> XML-node in <tt>/etc/products.d/baseproduct</tt>.
+
+\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.
+
+*/
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
-------------------------------------------------------------------
+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
-
#include <iostream>
#include <list>
#include <string>
#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" );
}
{ /////////////////////////////////////////////////////////////////
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 ) )
{
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;
// 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;
if ( _type == md5Type()
|| _type == shaType()
|| _type == sha1Type()
- || _type == sha256Type() )
+ || _type == sha224Type()
+ || _type == sha256Type()
+ || _type == sha384Type()
+ || _type == sha512Type() )
{
ZYPP_THROW( CheckSumException( msg ) );
}
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. */
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
//@}
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:
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
{
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:
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();
{
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
}