Author: mlandres Date: Tue Sep 9 11:44:45 2008 New Revision: 10968 URL: http://svn.opensuse.org/viewcvs/zypp?rev=10968&view=rev Log: - Fix reading of Traget::targetDistribution. - Allow to configure default answers in signature verification workflow. Modified: trunk/libzypp/devel/devel.ma/NewPool.cc trunk/libzypp/package/libzypp.changes trunk/libzypp/zypp/KeyRing.cc trunk/libzypp/zypp/KeyRing.h trunk/libzypp/zypp/target/TargetImpl.cc Modified: trunk/libzypp/devel/devel.ma/NewPool.cc URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/devel/devel.ma/NewPool.cc... ============================================================================== --- trunk/libzypp/devel/devel.ma/NewPool.cc (original) +++ trunk/libzypp/devel/devel.ma/NewPool.cc Tue Sep 9 11:44:45 2008 @@ -445,15 +445,21 @@ ResPool pool( ResPool::instance() ); sat::Pool satpool( sat::Pool::instance() ); + Edition e("1.a"); + DBG << e.copmpare( Edition("1a") ) << endl; + DBG << e.copmpare( Edition("1=a") ) << endl; + DBG << e.copmpare( Edition("1#$%^&*()_a") ) << endl; +return 0; if ( 1 ) { Measure x( "INIT TARGET" ); { { - //zypp::base::LogControl::TmpLineWriter shutUp; + zypp::base::LogControl::TmpLineWriter shutUp; getZYpp()->initializeTarget( sysRoot ); } getZYpp()->target()->load(); + USR << getZYpp()->target()->targetDistribution() << endl; } } @@ -479,7 +485,7 @@ repoManager.cleanCache( nrepo ); } SEC << "refreshMetadata" << endl; - repoManager.refreshMetadata( nrepo ); + //repoManager.refreshMetadata( nrepo ); SEC << "buildCache" << endl; repoManager.buildCache( nrepo ); } @@ -529,39 +535,6 @@ /////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////// - // access to the Pool of Selectables - ResPoolProxy selectablePool( ResPool::instance().proxy() ); - - // Iterate it's Products... - for_( it, selectablePool.byKindBegin<Product>(), selectablePool.byKindEnd<Product>() ) - { - // The current Product Selectable - ui::Selectable::Ptr prodSel( *it ); - MIL << dump( prodSel ) << endl; - - // It's candiate as Product pointer - Product::constPtr prod( prodSel->candidateAsKind<Product>() ); - if ( prod ) - { - // Not NULL, so there is an available Product. - // Get the installed Products it would replace. - Product::ReplacedProducts prodReplaces( prod->replacedProducts() ); - - // Iterate the replaced Products... - for_( it, prodReplaces.begin(), prodReplaces.end() ) - { - // The current replaced Product - Product::constPtr replacedProduct( *it ); - DBG << replacedProduct << endl; - - // and this is how you would get the Selectable that contains - // this replacedProduct, in case you need it .. - ui::Selectable::Ptr replacedProductsSelectable( ui::Selectable::get( replacedProduct ) ); - DBG << replacedProductsSelectable << endl; - } - } - - } /////////////////////////////////////////////////////////////////// Modified: trunk/libzypp/package/libzypp.changes URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/package/libzypp.changes?r... ============================================================================== --- trunk/libzypp/package/libzypp.changes (original) +++ trunk/libzypp/package/libzypp.changes Tue Sep 9 11:44:45 2008 @@ -1,4 +1,11 @@ ------------------------------------------------------------------- +Tue Sep 9 11:40:42 CEST 2008 - ma@suse.de + +- Fix reading of Traget::targetDistribution. +- Allow to configure default answers in signature verification workflow. +- revision 10968 + +------------------------------------------------------------------- Mon Sep 8 17:11:02 CEST 2008 - jkupec@suse.cz - CredentialManager added to manage stored credentials Modified: trunk/libzypp/zypp/KeyRing.cc URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/KeyRing.cc?rev=10968... ============================================================================== --- trunk/libzypp/zypp/KeyRing.cc (original) +++ trunk/libzypp/zypp/KeyRing.cc Tue Sep 9 11:44:45 2008 @@ -51,25 +51,38 @@ return true; } + /////////////////////////////////////////////////////////////////// + namespace { - bool _keyRingDefaultAccept( getenv("ZYPP_KEYRING_DEFAULT_ACCEPT_ALL") ); + KeyRingReport::DefaultAccept _keyRingDefaultAccept( KeyRingReport::ACCEPT_NOTHING ); } - bool KeyRingReport::askUserToAcceptUnsignedFile( const string &file ) + KeyRingReport::DefaultAccept KeyRingReport::defaultAccept() { return _keyRingDefaultAccept; } + void KeyRingReport::setDefaultAccept( DefaultAccept value_r ) + { + MIL << "Set new default accept: " << value_r << endl; + _keyRingDefaultAccept = value_r; + } + + /////////////////////////////////////////////////////////////////// + + bool KeyRingReport::askUserToAcceptUnsignedFile( const string &file ) + { return _keyRingDefaultAccept.testFlag( ACCEPT_UNSIGNED_FILE ); } + bool KeyRingReport::askUserToAcceptUnknownKey( const string &file, const string &id ) - { return _keyRingDefaultAccept; } + { return _keyRingDefaultAccept.testFlag( ACCEPT_UNKNOWNKEY ); } bool KeyRingReport::askUserToTrustKey( const PublicKey &key ) - { return _keyRingDefaultAccept; } + { return _keyRingDefaultAccept.testFlag( TRUST_KEY ); } bool KeyRingReport::askUserToImportKey( const PublicKey &key) - { return _keyRingDefaultAccept; } + { return _keyRingDefaultAccept.testFlag( IMPORT_KEY ); } bool KeyRingReport::askUserToAcceptVerificationFailed( const string &file, const PublicKey &key ) - { return _keyRingDefaultAccept; } + { return _keyRingDefaultAccept.testFlag( ACCEPT_VERIFICATION_FAILED ); } /////////////////////////////////////////////////////////////////// // Modified: trunk/libzypp/zypp/KeyRing.h URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/KeyRing.h?rev=10968&... ============================================================================== --- trunk/libzypp/zypp/KeyRing.h (original) +++ trunk/libzypp/zypp/KeyRing.h Tue Sep 9 11:44:45 2008 @@ -19,6 +19,7 @@ #include <string> #include "zypp/base/ReferenceCounted.h" +#include "zypp/base/Flags.h" #include "zypp/Callback.h" #include "zypp/base/PtrTypes.h" #include "zypp/Locale.h" @@ -30,6 +31,10 @@ DEFINE_PTR_TYPE(KeyRing); + /** Callbacks from signature verification workflow. + * + * Per default all methods answer \c false. + */ struct KeyRingReport : public callback::ReportBase { @@ -59,7 +64,30 @@ */ virtual bool askUserToImportKey( const PublicKey &key); virtual bool askUserToAcceptVerificationFailed( const std::string &file, const PublicKey &key ); + + public: + /** \name Query/change the default values. + * Per default all methods answer \c false. + */ + //@{ + enum DefaultAcceptBits + { + ACCEPT_NOTHING = 0x0000, + ACCEPT_UNSIGNED_FILE = 0x0001, + ACCEPT_UNKNOWNKEY = 0x0002, + TRUST_KEY = 0x0004, + IMPORT_KEY = 0x0008, + ACCEPT_VERIFICATION_FAILED = 0x0010, + }; + ZYPP_DECLARE_FLAGS(DefaultAccept,DefaultAcceptBits); + + /** Get the active accept bits. */ + static DefaultAccept defaultAccept(); + /** Set the active accept bits. */ + static void setDefaultAccept( DefaultAccept value_r ); + //@} }; + ZYPP_DECLARE_OPERATORS_FOR_FLAGS(KeyRingReport::DefaultAccept); struct KeyRingSignals : public callback::ReportBase { @@ -167,20 +195,29 @@ /** * Follows a signature verification interacting with the user. * The bool returned depends on user decision to trust or not. + * + * To propagate user decisions, either connect to the \ref KeyRingReport + * or use its static methods to set the desired defaults. + * + * \code + * struct KeyRingReportReceive : public callback::ReceiveReport<KeyRingReport> + * { + * KeyRingReportReceive() { connect(); } + * + * // Overload the virtual methods to return the appropriate values. + * virtual bool askUserToAcceptUnsignedFile( const std::string &file ); + * ... + * }; + * \endcode + * \see \ref KeyRingReport */ bool verifyFileSignatureWorkflow( const Pathname &file, const std::string filedesc, const Pathname &signature); bool verifyFileSignature( const Pathname &file, const Pathname &signature); bool verifyFileTrustedSignature( const Pathname &file, const Pathname &signature); -/** Dtor */ + /** Dtor */ ~KeyRing(); - public: - - /** Synonym for \ref text */ - //std::string asString() const - //{} - private: /** Pointer to implementation */ RWCOW_pointer<Impl> _pimpl; Modified: trunk/libzypp/zypp/target/TargetImpl.cc URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/target/TargetImpl.cc... ============================================================================== --- trunk/libzypp/zypp/target/TargetImpl.cc (original) +++ trunk/libzypp/zypp/target/TargetImpl.cc Tue Sep 9 11:44:45 2008 @@ -879,25 +879,24 @@ std::string TargetImpl::targetDistribution() const { - std::ifstream baseProduct( (_root / "/etc/products.d/baseproduct").c_str() ); - for( iostr::EachLine in( baseProduct ); in; in.next() ) + std::ostringstream cmd; + cmd << "rpmdb2solv"; + cmd << " -n"; + if ( ! _root.empty() ) + cmd << " -r '" << _root << "'"; + cmd << " -p '" << Pathname::assertprefix( _root, "/etc/products.d" ) << "'"; + cmd << " -a distribution.target"; + + MIL << "Executing: " << cmd << endl; + ExternalProgram prog( cmd.str(), ExternalProgram::Discard_Stderr ); + for ( std::string output( prog.receiveLine() ); output.length(); output = prog.receiveLine() ) { - std::string line( str::trim( *in ) ); - if ( str::hasPrefix( line, "distribution" ) ) - { - std::string::size_type pos( line.find( '=', 12 ) ); - if ( pos == std::string::npos ) - continue; // no '=' on line - pos = line.find_first_not_of( " \t", pos+1 ); - if ( pos == std::string::npos ) - continue; // empty value - line.erase( 0, pos ); - line += "-"; - line += ZConfig::instance().systemArchitecture().asString(); - return line; - } + return str::trim(output); } - WAR << "No distribution in " << PathInfo(_root / "/etc/products.d/baseproduct") << endl; + + int ret = prog.close(); + WAR << "Got no output from rpmdb2solv (returned " << ret << ")." << endl; + return std::string(); } -- To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org For additional commands, e-mail: zypp-commit+help@opensuse.org