Zypp Commits
Threads by month
- ----- 2024 -----
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
September 2008
- 7 participants
- 315 discussions
[zypp-commit] r11218 - in /trunk/libzypp: VERSION.cmake devel/devel.ma/MaTest.cc devel/devel.ma/NewPool.cc package/libzypp.changes zypp/DiskUsageCounter.cc zypp/DiskUsageCounter.h
by mlandres@svn.opensuse.org 30 Sep '08
by mlandres@svn.opensuse.org 30 Sep '08
30 Sep '08
Author: mlandres
Date: Tue Sep 30 17:41:42 2008
New Revision: 11218
URL: http://svn.opensuse.org/viewcvs/zypp?rev=11218&view=rev
Log:
- Allow computation of disk usage per solvable.
Modified:
trunk/libzypp/VERSION.cmake
trunk/libzypp/devel/devel.ma/MaTest.cc
trunk/libzypp/devel/devel.ma/NewPool.cc
trunk/libzypp/package/libzypp.changes
trunk/libzypp/zypp/DiskUsageCounter.cc
trunk/libzypp/zypp/DiskUsageCounter.h
Modified: trunk/libzypp/VERSION.cmake
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/VERSION.cmake?rev=11218&…
==============================================================================
--- trunk/libzypp/VERSION.cmake (original)
+++ trunk/libzypp/VERSION.cmake Tue Sep 30 17:41:42 2008
@@ -60,8 +60,8 @@
#
SET(LIBZYPP_MAJOR "5")
SET(LIBZYPP_COMPATMINOR "13")
-SET(LIBZYPP_MINOR "13")
-SET(LIBZYPP_PATCH "2")
+SET(LIBZYPP_MINOR "14")
+SET(LIBZYPP_PATCH "0")
#
# LAST RELEASED: 5.13.1 (13)
# (The number in parenthesis is LIBZYPP_COMPATMINOR)
Modified: trunk/libzypp/devel/devel.ma/MaTest.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/devel/devel.ma/MaTest.cc…
==============================================================================
--- trunk/libzypp/devel/devel.ma/MaTest.cc (original)
+++ trunk/libzypp/devel/devel.ma/MaTest.cc Tue Sep 30 17:41:42 2008
@@ -1,121 +1,596 @@
-#include <iostream>
+#include "Tools.h"
-#include <boost/signal.hpp>
-#include <boost/bind.hpp>
+#include "zypp/PoolQueryResult.h"
+#include <zypp/base/PtrTypes.h>
+#include <zypp/base/Exception.h>
+#include <zypp/base/Gettext.h>
#include <zypp/base/LogTools.h>
-#include <zypp/base/Easy.h>
+#include <zypp/base/Debug.h>
+#include <zypp/base/Functional.h>
+#include <zypp/base/IOStream.h>
+#include <zypp/base/InputStream.h>
+#include <zypp/base/ProvideNumericId.h>
+#include <zypp/base/Flags.h>
+#include <zypp/AutoDispose.h>
+
+#include "zypp/ResPoolProxy.h"
+
+#include "zypp/ZYppCallbacks.h"
+#include "zypp/ResPool.h"
+#include "zypp/ResFilters.h"
+#include "zypp/ResObjects.h"
+#include "zypp/Digest.h"
+#include "zypp/PackageKeyword.h"
+#include "zypp/TmpPath.h"
+#include "zypp/ManagedFile.h"
+#include "zypp/NameKindProxy.h"
+#include "zypp/pool/GetResolvablesToInsDel.h"
+
+#include "zypp/RepoManager.h"
+#include "zypp/Repository.h"
+#include "zypp/RepoInfo.h"
+
+#include "zypp/repo/PackageProvider.h"
+
+#include "zypp/ResPoolProxy.h"
+
+#include "zypp/sat/Pool.h"
+#include "zypp/sat/LocaleSupport.h"
+#include "zypp/sat/LookupAttr.h"
+#include "zypp/sat/SolvableSet.h"
+#include "zypp/sat/SolvIterMixin.h"
+#include "zypp/sat/detail/PoolImpl.h"
+#include "zypp/sat/WhatObsoletes.h"
+#include "zypp/PoolQuery.h"
+#include "zypp/ServiceInfo.h"
-using std::endl;
-using std::cout;
+#include "zypp/parser/ProductConfReader.h"
-namespace boost
+#include <boost/mpl/int.hpp>
+
+using namespace std;
+using namespace zypp;
+using namespace zypp::functor;
+using namespace zypp::ui;
+
+///////////////////////////////////////////////////////////////////
+
+static const Pathname sysRoot( getenv("SYSROOT") ? getenv("SYSROOT") : "/Local/ROOT" );
+
+///////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////
+namespace zypp
+{ /////////////////////////////////////////////////////////////////
+
+bool queryInstalledEditionHelper( const std::string & name_r,
+ const Edition & ed_r,
+ const Arch & arch_r )
+{
+ if ( ed_r == Edition::noedition )
+ return true;
+ if ( name_r == "kernel-default" && ed_r == Edition("2.6.22.5-10") )
+ return true;
+ if ( name_r == "update-test-affects-package-manager" && ed_r == Edition("1.1-6") )
+ return true;
+
+ return false;
+}
+
+
+ManagedFile repoProvidePackage( const PoolItem & pi )
+{
+ ResPool _pool( getZYpp()->pool() );
+ repo::RepoMediaAccess _access;
+
+ // Redirect PackageProvider queries for installed editions
+ // (in case of patch/delta rpm processing) to rpmDb.
+ repo::PackageProviderPolicy packageProviderPolicy;
+ packageProviderPolicy.queryInstalledCB( queryInstalledEditionHelper );
+
+ Package::constPtr p = asKind<Package>(pi.resolvable());
+
+ // Build a repository list for repos
+ // contributing to the pool
+ repo::DeltaCandidates deltas( repo::makeDeltaCandidates( _pool.knownRepositoriesBegin(),
+ _pool.knownRepositoriesEnd() ) );
+ repo::PackageProvider pkgProvider( _access, p, deltas, packageProviderPolicy );
+ return pkgProvider.providePackage();
+}
+
+ /////////////////////////////////////////////////////////////////
+} // namespace zypp
+///////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////
+
+namespace zypp
+{
+ template <class _LIterator, class _RIterator, class _Function>
+ inline int invokeOnEach( _LIterator lbegin_r, _LIterator lend_r,
+ _RIterator rbegin_r, _RIterator rend_r,
+ _Function fnc_r )
+ {
+ int cnt = 0;
+ for ( _LIterator lit = lbegin_r; lit != lend_r; ++lit )
+ {
+ for ( _RIterator rit = rbegin_r; rit != rend_r; ++rit )
+ {
+ ++cnt;
+ if ( ! fnc_r( *lit, *rit ) )
+ return -cnt;
+ }
+ }
+ return cnt;
+ }
+}
+
+
+void dbgDu( Selectable::Ptr sel )
{
- template<class Tp>
- std::ostream & operator<<( std::ostream & str, const signal<Tp> & obj )
+ if ( sel->installedObj() )
+ {
+ DBG << "i: " << sel->installedObj() << endl
+ << sel->installedObj()->diskusage() << endl;
+ }
+ if ( sel->candidateObj() )
{
- return str << "Connected slots: " << obj.num_slots();
+ DBG << "c: " << sel->candidateObj() << endl
+ << sel->candidateObj()->diskusage() << endl;
}
+ INT << sel << endl
+ << getZYpp()->diskUsage() << endl;
+}
+
+///////////////////////////////////////////////////////////////////
- namespace signals
+std::ostream & testDump( std::ostream & str, const PoolItem & pi )
+{
+ str << pi << endl;
+ Package::constPtr p( asKind<Package>(pi) );
+ if ( p )
{
- std::ostream & operator<<( std::ostream & str, const connection & obj )
- {
- return str << "Connection: "
- << ( obj.connected() ? '*' : '_' )
- << ( obj.blocked() ? 'B' : '_' )
- ;
- }
+#define OUTS(V) str << str::form("%-25s: ",#V) << p->V() << endl
+ Locale l( "de" );
+ str << str::form("%-25s: ",l.code().c_str()) << p->summary(l) << endl;
+ l = Locale( "fr" );
+ str << str::form("%-25s: ",l.code().c_str()) << p->summary(l) << endl;
+ l = Locale( "dsdf" );
+ str << str::form("%-25s: ",l.code().c_str()) << p->summary(l) << endl;
+ OUTS( summary );
+ OUTS( installsize );
+ OUTS( downloadSize );
+ OUTS( sourcePkgName );
+ OUTS( sourcePkgEdition );
+ OUTS( checksum );
+ OUTS( location );
+#undef OUTS
+
+
}
+ return str;
}
-using namespace zypp;
+struct Xprint
+{
+ bool operator()( const PoolItem & obj_r )
+ {
+ //MIL << obj_r << endl;
+ //DBG << " -> " << obj_r->satSolvable() << endl;
+
+ return true;
+ }
-using boost::signal;
-using boost::signals::connection;
-using boost::signals::trackable;
+ bool operator()( const sat::Solvable & obj_r )
+ {
+ //dumpOn( MIL, obj_r ) << endl;
+ return true;
+ }
+};
-struct HelloWorld
+///////////////////////////////////////////////////////////////////
+struct SetTransactValue
{
- HelloWorld() {++i;}
- HelloWorld(const HelloWorld &) {++i;}
- ~HelloWorld() { --i;}
+ SetTransactValue( ResStatus::TransactValue newVal_r, ResStatus::TransactByValue causer_r )
+ : _newVal( newVal_r )
+ , _causer( causer_r )
+ {}
- void operator()(unsigned) const
+ ResStatus::TransactValue _newVal;
+ ResStatus::TransactByValue _causer;
+
+ bool operator()( const PoolItem & pi ) const
{
- USR << "Hello, World! " << i << std::endl;
+ bool ret = pi.status().setTransactValue( _newVal, _causer );
+ if ( ! ret )
+ ERR << _newVal << _causer << " " << pi << endl;
+ return ret;
}
+};
- static int i;
+struct StatusReset : public SetTransactValue
+{
+ StatusReset()
+ : SetTransactValue( ResStatus::KEEP_STATE, ResStatus::USER )
+ {}
+};
+
+struct StatusInstall : public SetTransactValue
+{
+ StatusInstall()
+ : SetTransactValue( ResStatus::TRANSACT, ResStatus::USER )
+ {}
};
-int HelloWorld::i = 0;
+inline bool g( const NameKindProxy & nkp, Arch arch = Arch() )
+{
+ if ( nkp.availableEmpty() )
+ {
+ ERR << "No Item to select: " << nkp << endl;
+ return false;
+ ZYPP_THROW( Exception("No Item to select") );
+ }
+
+ if ( arch != Arch() )
+ {
+ typeof( nkp.availableBegin() ) it = nkp.availableBegin();
+ for ( ; it != nkp.availableEnd(); ++it )
+ {
+ if ( (*it)->arch() == arch )
+ return (*it).status().setTransact( true, ResStatus::USER );
+ }
+ }
+
+ return nkp.availableBegin()->status().setTransact( true, ResStatus::USER );
+}
+
+///////////////////////////////////////////////////////////////////
-struct M
+bool solve()
{
- void ping() const
+ bool rres = false;
+ {
+ //zypp::base::LogControl::TmpLineWriter shutUp;
+ rres = getZYpp()->resolver()->resolvePool();
+ }
+ if ( ! rres )
{
- static unsigned i = 0;
- ++i;
- MIL << i << " -> " << _sigA << endl;
- _sigA( i );
+ ERR << "resolve " << rres << endl;
+ getZYpp()->resolver()->problems();
+ return false;
}
+ MIL << "resolve " << rres << endl;
+ return true;
+}
- typedef signal<void(unsigned)> SigA;
+bool install()
+{
+ ZYppCommitPolicy pol;
+ pol.dryRun(true);
+ pol.rpmInstFlags( pol.rpmInstFlags().setFlag( target::rpm::RPMINST_JUSTDB ) );
+ SEC << getZYpp()->commit( pol ) << endl;
+ return true;
+}
- SigA & siga() const { return _sigA; }
+void testcase()
+{
+ getZYpp()->resolver()->createSolverTestcase( "./solverTestcase" );
+}
+
+///////////////////////////////////////////////////////////////////
+
+struct DigestReceive : public callback::ReceiveReport<DigestReport>
+{
+ DigestReceive()
+ {
+ connect();
+ }
- mutable SigA _sigA;
+ virtual bool askUserToAcceptNoDigest( const zypp::Pathname &file )
+ {
+ USR << endl;
+ return false;
+ }
+ virtual bool askUserToAccepUnknownDigest( const Pathname &file, const std::string &name )
+ {
+ USR << endl;
+ return false;
+ }
+ virtual bool askUserToAcceptWrongDigest( const Pathname &file, const std::string &requested, const std::string &found )
+ {
+ USR << "fle " << PathInfo(file) << endl;
+ USR << "req " << requested << endl;
+ USR << "fnd " << found << endl;
+ return false;
+ }
};
-struct X : public trackable
+struct KeyRingSignalsReceive : public callback::ReceiveReport<KeyRingSignals>
{
- X() {_s=++s;}
- X( const X & ) {_s=++s;}
- X& operator=( const X & ) { return *this; }
- virtual ~X() {_s=-_s;}
- static int s;
- int _s;
+ KeyRingSignalsReceive()
+ {
+ connect();
+ }
+ virtual void trustedKeyAdded( const PublicKey &/*key*/ )
+ {
+ USR << endl;
+ }
+ virtual void trustedKeyRemoved( const PublicKey &/*key*/ )
+ {
+ USR << endl;
+ }
+};
- void pong( unsigned i ) const
+///////////////////////////////////////////////////////////////////
+
+struct MediaChangeReceive : public callback::ReceiveReport<media::MediaChangeReport>
+{
+ virtual Action requestMedia( Url & source
+ , unsigned mediumNr
+ , const std::string & label
+ , Error error
+ , const std::string & description
+ , const std::vector<std::string> & devices
+ , unsigned int & dev_current )
{
- DBG << _s << ' ' << i << endl;
+ SEC << __FUNCTION__ << endl
+ << " " << source << endl
+ << " " << mediumNr << endl
+ << " " << label << endl
+ << " " << error << endl
+ << " " << description << endl
+ << " " << devices << endl
+ << " " << dev_current << endl;
+ return IGNORE;
}
};
-int X::s;
+///////////////////////////////////////////////////////////////////
+
+namespace container
+{
+ template<class _Tp>
+ bool isIn( const std::set<_Tp> & cont, const typename std::set<_Tp>::value_type & val )
+ { return cont.find( val ) != cont.end(); }
+}
+///////////////////////////////////////////////////////////////////
+
+void itCmp( const sat::Pool::SolvableIterator & l, const sat::Pool::SolvableIterator & r )
+{
+ SEC << *l << " - " << *r << endl;
+ INT << "== " << (l==r) << endl;
+ INT << "!= " << (l!=r) << endl;
+}
+
+bool isTrue() { return true; }
+bool isFalse() { return false; }
+
+void dumpIdStr()
+{
+ for ( int i = -3; i < 30; ++i )
+ {
+ DBG << i << '\t' << IdString( i ) << endl;
+ }
+}
+
+void ttt( const char * lhs, const char * rhs )
+{
+ DBG << lhs << " <=> " << rhs << " --> " << ::strcmp( lhs, rhs ) << endl;
+}
+
+namespace zypp
+{
+namespace filter
+{
+ template <class _MemFun, class _Value>
+ class HasValue
+ {
+ public:
+ HasValue( _MemFun fun_r, _Value val_r )
+ : _fun( fun_r ), _val( val_r )
+ {}
+ template <class _Tp>
+ bool operator()( const _Tp & obj_r ) const
+ { return( _fun && (obj_r.*_fun)() == _val ); }
+ private:
+ _MemFun _fun;
+ _Value _val;
+ };
+
+ template <class _MemFun, class _Value>
+ HasValue<_MemFun, _Value> byValue( _MemFun fun_r, _Value val_r )
+ { return HasValue<_MemFun, _Value>( fun_r, val_r ); }
+}
+
+}
+
+template <class L>
+struct _TestO { _TestO( const L & lhs ) : _lhs( lhs ) {} const L & _lhs; };
+
+template <class L>
+std::ostream & operator<<( std::ostream & str, const _TestO<L> & obj )
+{ const L & lhs( obj._lhs); return str << (lhs?'_':'*') << (lhs.empty()?'e':'_') << "'" << lhs << "'"; }
+
+template <class L>
+_TestO<L> testO( const L & lhs )
+{ return _TestO<L>( lhs ); }
+
+template <class L, class R>
+void testCMP( const L & lhs, const R & rhs )
+{
+ MIL << "LHS " << testO(lhs) << endl;
+ MIL << "RHS " << rhs << endl;
+
+#define OUTS(S) DBG << #S << ": " << (S) << endl
+ OUTS( lhs.compare(rhs) );
+ OUTS( lhs != rhs );
+ OUTS( lhs < rhs );
+ OUTS( lhs <= rhs );
+ OUTS( lhs == rhs );
+ OUTS( lhs >= rhs );
+ OUTS( lhs > rhs );
+#undef OUTS
+}
+
+inline bool useRepo( RepoInfo & repo )
+{
+ return repo.alias() == "matest";
+ return repo.enabled();
+}
/******************************************************************
**
** FUNCTION NAME : main
** FUNCTION TYPE : int
*/
-int main( int argc, const char * argv[] )
-{
- --argc; ++argv; // skip arg 0
+int main( int argc, char * argv[] )
+try {
+ --argc;
+ ++argv;
+ zypp::base::LogControl::instance().logToStdErr();
+ INT << "===[START]==========================================" << endl;
+ ZConfig::instance();
- M m;
- m.ping();
- X xx;
- m.siga().connect( boost::bind( &X::pong, &xx, _1 ) );
- m.ping();
+ ResPool pool( ResPool::instance() );
+ sat::Pool satpool( sat::Pool::instance() );
+
+ if ( 0 )
+ {
+ Measure x( "INIT TARGET" );
+ {
+ {
+ zypp::base::LogControl::TmpLineWriter shutUp;
+ getZYpp()->initializeTarget( sysRoot );
+ }
+ getZYpp()->target()->load();
+ USR << getZYpp()->target()->targetDistribution() << endl;
+ USR << getZYpp()->target()->targetDistributionRelease() << endl;
+ }
+ }
+ if ( 1 )
{
- X x;
- m.siga().connect( boost::bind( &X::pong, boost::ref(x), _1 ) );
- m.ping();
+ RepoManager repoManager( makeRepoManager( sysRoot ) );
+ RepoInfoList repos = repoManager.knownRepositories();
+
+ // launch repos
+ for ( RepoInfoList::iterator it = repos.begin(); it != repos.end(); ++it )
+ {
+ RepoInfo & nrepo( *it );
+ SEC << nrepo << endl;
+
+ if ( ! useRepo( nrepo ) )
+ continue;
- X y;
- m.siga().connect( boost::bind( &X::pong, &y, _1 ) );
- m.ping();
+ if ( ! repoManager.isCached( nrepo ) || nrepo.type() == repo::RepoType::RPMPLAINDIR )
+ {
+ if ( repoManager.isCached( nrepo ) )
+ {
+ SEC << "cleanCache" << endl;
+ repoManager.cleanCache( nrepo );
+ }
+ SEC << "refreshMetadata" << endl;
+ //repoManager.refreshMetadata( nrepo );
+ SEC << "buildCache" << endl;
+ repoManager.buildCache( nrepo );
+ }
+ }
+
+ // create from cache:
+ {
+ Measure x( "CREATE FROM CACHE" );
+ for ( RepoInfoList::iterator it = repos.begin(); it != repos.end(); ++it )
+ {
+ RepoInfo & nrepo( *it );
+ if ( ! useRepo( nrepo ) )
+ continue;
+
+ Measure x( "CREATE FROM CACHE "+nrepo.alias() );
+ try
+ {
+ repoManager.loadFromCache( nrepo );
+ }
+ catch ( const Exception & exp )
+ {
+ MIL << "Try to rebuild cache..." << endl;
+ SEC << "cleanCache" << endl;
+ repoManager.cleanCache( nrepo );
+ SEC << "buildCache" << endl;
+ repoManager.buildCache( nrepo );
+ SEC << "Create from cache" << endl;
+ repoManager.loadFromCache( nrepo );
+ }
+ USR << "pool: " << pool << endl;
+ }
+ }
}
- m.ping();
+ dumpRange( USR, satpool.reposBegin(), satpool.reposEnd() );
+ USR << "pool: " << pool << endl;
+
+ ///////////////////////////////////////////////////////////////////
- ///////////////////////////////////////////
+ if ( 0 )
+ {
+ Measure x( "Upgrade" );
+ UpgradeStatistics u;
+ getZYpp()->resolver()->doUpgrade( u );
+ }
- INT << "---STOP" << endl;
+ ///////////////////////////////////////////////////////////////////
+ ///////////////////////////////////////////////////////////////////
+// UNTh_(2)product:openSUSE-11.1.x86_64(openSUSE-dvd-11.1)
+// U_Th_(583)yast2-ntp-client-2.17.1-1.26.noarch(openSUSE-dvd-11.1)
+// U_Th_(1652)kernel-default-2.6.27-7.2.x86_64(openSUSE-dvd-11.1)
+// U_Th_(2490)ntp-4.2.4p5-1.6.x86_64(openSUSE-dvd-11.1)
+// UNTh_(2545)openSUSE-release-11.1-1.4.x86_64(openSUSE-dvd-11.1)
+// USTh_(3462)pattern:base-11.1-46.1.x86_64(openSUSE-dvd-11.1)
+// USTh_(3672)pattern:x11-11.1-46.1.x86_64(openSUSE-dvd-11.1)
+// USTu_(3680)pattern:xfce-11.1-46.1.x86_64(openSUSE-dvd-11.1)
+
+
+ getZYpp()->resolver()->addRequire( Capability("product:openSUSE") );
+ getZYpp()->resolver()->addRequire( Capability("yast2-ntp-client") );
+ getZYpp()->resolver()->addRequire( Capability("kernel-default") );
+ getZYpp()->resolver()->addRequire( Capability("ntp") );
+ getZYpp()->resolver()->addRequire( Capability("openSUSE-release") );
+ getZYpp()->resolver()->addRequire( Capability("pattern:base") );
+ getZYpp()->resolver()->addRequire( Capability("pattern:x11") );
+ getZYpp()->resolver()->addRequire( Capability("pattern:xfce") );
+
+ solve();
+
+ vdumpPoolStats( USR << "Transacting:"<< endl,
+ make_filter_begin<resfilter::ByTransact>(pool),
+ make_filter_end<resfilter::ByTransact>(pool) ) << endl;
+
+ ByteCount sze;
+ ByteCount dusze;
+ DiskUsageCounter ducounter( DiskUsageCounter::justRootPartition() );
+ for_( it, make_filter_begin<resfilter::ByTransact>(pool), make_filter_end<resfilter::ByTransact>(pool) )
+ {
+ USR << *it << endl;
+ ByteCount csze( ducounter.disk_usage( *it ).begin()->commitDiff() );
+ sze += (*it)->installSize();
+ dusze += csze;
+ DBG <<(*it)->installSize() << " vs. " << csze << " | " << ByteCount( dusze-sze ) << endl;
+
+ }
+ SEC << sze << endl;
+ SEC << dusze << endl;
+
+ SEC << zypp::getZYpp()->diskUsage() << endl;
+
+ ///////////////////////////////////////////////////////////////////
+ INT << "===[END]============================================" << endl << endl;
+ zypp::base::LogControl::instance().logNothing();
return 0;
}
+catch ( const Exception & exp )
+{
+ INT << exp << endl << exp.historyAsString();
+}
+catch (...)
+{}
+
Modified: trunk/libzypp/devel/devel.ma/NewPool.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/devel/devel.ma/NewPool.c…
==============================================================================
--- trunk/libzypp/devel/devel.ma/NewPool.cc (original)
+++ trunk/libzypp/devel/devel.ma/NewPool.cc Tue Sep 30 17:41:42 2008
@@ -443,22 +443,6 @@
INT << "===[START]==========================================" << endl;
ZConfig::instance();
- {
- Capability cap("flavor(dvd9)");
- DBG << cap.detail().isSimple() << endl;
- DBG << cap.detail().isNamed() << endl;
- DBG << cap.detail().name() << endl;
- std::string capstr = str::stripPrefix( cap.asString(), "flavor(" );
- DBG << capstr << endl;
- capstr.erase(capstr.size()-1);
- DBG << capstr << endl;
- }
-
-
- ///////////////////////////////////////////////////////////////////
- INT << "===[END]============================================" << endl << endl;
- zypp::base::LogControl::instance().logNothing();
- return 0;
#if 0
@@ -510,7 +494,7 @@
ResPool pool( ResPool::instance() );
sat::Pool satpool( sat::Pool::instance() );
- if ( 1 )
+ if ( 0 )
{
Measure x( "INIT TARGET" );
{
@@ -629,13 +613,11 @@
}
}
-
- PoolItem pi ( getPi<Package>("amarok") );
- MIL << pi << endl;
- MIL << pi->asKind<Package>() << endl;
- MIL << pi->asKind<Product>() << endl;
- if ( pi->isKind<Package>() )
- SEC << pi->asKind<Package>() << endl;
+ getZYpp()->resolver()->addRequire( Capability("amarok") );
+ solve();
+ vdumpPoolStats( USR << "Transacting:"<< endl,
+ make_filter_begin<resfilter::ByTransact>(pool),
+ make_filter_end<resfilter::ByTransact>(pool) ) << endl;
//////////////////////////////////////////////////////////////////
INT << "===[END]============================================" << endl << endl;
Modified: trunk/libzypp/package/libzypp.changes
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/package/libzypp.changes?…
==============================================================================
--- trunk/libzypp/package/libzypp.changes (original)
+++ trunk/libzypp/package/libzypp.changes Tue Sep 30 17:41:42 2008
@@ -1,4 +1,10 @@
-------------------------------------------------------------------
+Tue Sep 30 17:23:48 CEST 2008 - ma(a)suse.de
+
+- Allow computation of disk usage per solvable.
+- revision 11218
+
+-------------------------------------------------------------------
Mon Sep 29 23:59:10 CEST 2008 - dmacvicar(a)suse.de
- Merge aria2c Media handler code from Google SOC 2008
Modified: trunk/libzypp/zypp/DiskUsageCounter.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/DiskUsageCounter.cc…
==============================================================================
--- trunk/libzypp/zypp/DiskUsageCounter.cc (original)
+++ trunk/libzypp/zypp/DiskUsageCounter.cc Tue Sep 30 17:41:42 2008
@@ -31,71 +31,110 @@
namespace zypp
{ /////////////////////////////////////////////////////////////////
- DiskUsageCounter::MountPointSet DiskUsageCounter::disk_usage( const ResPool & pool_r )
- {
- DiskUsageCounter::MountPointSet result = mps;
+ ///////////////////////////////////////////////////////////////////
+ namespace
+ { /////////////////////////////////////////////////////////////////
- if ( result.empty() )
+ struct SatMap : private base::NonCopyable
{
- // partitioning is not set
- return result;
- }
+ SatMap( unsigned capacity_r = 1 )
+ {
+ ::map_init( &_installedmap, sat::Pool::instance().capacity() );
+ }
- sat::Pool satpool( sat::Pool::instance() );
- if ( ! satpool.findSystemRepo() )
- {
- // take care we have at least an empty stystem repo.
- // ::pool_calc_duchanges requires it.
- satpool.systemRepo();
- satpool.prepare();
- }
+ void add( sat::Solvable solv_r )
+ {
+ MAPSET( &_installedmap, solv_r.id() );
+ }
+
+ void add( const PoolItem & pi_r )
+ { add( pi_r->satSolvable() ); }
- // init satsolver result vector with mountpoints
- static const ::DUChanges _initdu = { 0, 0, 0 };
- std::vector< ::DUChanges> duchanges( result.size(), _initdu );
+ void add( const ResObject::constPtr & obj_r )
+ { add( obj_r->satSolvable() ); }
+
+ mutable ::Map _installedmap;
+ };
+
+ DiskUsageCounter::MountPointSet calcDiskUsage( const DiskUsageCounter::MountPointSet & mps_r, const SatMap & installedmap_r )
{
- unsigned idx = 0;
- for_( it, result.begin(), result.end() )
+ DiskUsageCounter::MountPointSet result = mps_r;
+
+ if ( result.empty() )
{
- duchanges[idx].path = it->dir.c_str();
- ++idx;
+ // partitioning is not set
+ return result;
}
- }
- // build installedmap (installed != transact)
- // stays installed or gets installed
- ::Map installedmap;
- ::map_init( &installedmap, satpool.capacity() );
- for_( it, pool_r.begin(), pool_r.end() )
- {
- if ( it->status().isInstalled() != it->status().transacts() )
+ sat::Pool satpool( sat::Pool::instance() );
+ if ( ! satpool.findSystemRepo() )
{
- MAPSET( &installedmap, it->satSolvable().id() );
+ // take care we have at least an empty stystem repo.
+ // ::pool_calc_duchanges requires it.
+ satpool.systemRepo();
+ satpool.prepare();
}
+
+ // init satsolver result vector with mountpoints
+ static const ::DUChanges _initdu = { 0, 0, 0 };
+ std::vector< ::DUChanges> duchanges( result.size(), _initdu );
+ {
+ unsigned idx = 0;
+ for_( it, result.begin(), result.end() )
+ {
+ duchanges[idx].path = it->dir.c_str();
+ ++idx;
+ }
+ }
+
+ // now calc...
+ ::pool_calc_duchanges( satpool.get(),
+ satpool.systemRepo().get(),
+ &installedmap_r._installedmap,
+ &duchanges[0],
+ duchanges.size() );
+
+ // and process the result
+ {
+ unsigned idx = 0;
+ for_( it, result.begin(), result.end() )
+ {
+ static const ByteCount blockAdjust( 2, ByteCount::K ); // (files * blocksize) / (2 * 1K)
+
+ it->pkg_size = it->used_size // current usage
+ + duchanges[idx].kbytes // package data size
+ + ( duchanges[idx].files * it->block_size / blockAdjust ); // half block per file
+ ++idx;
+ }
+ }
+
+ return result;
}
- // now calc...
- ::pool_calc_duchanges( satpool.get(),
- satpool.systemRepo().get(),
- &installedmap,
- &duchanges[0],
- duchanges.size() );
+ /////////////////////////////////////////////////////////////////
+ } // namespace
+ ///////////////////////////////////////////////////////////////////
- // and process the result
+ DiskUsageCounter::MountPointSet DiskUsageCounter::disk_usage( const ResPool & pool_r )
+ {
+ SatMap installedmap( sat::Pool::instance().capacity() );
+ // build installedmap (installed != transact)
+ // stays installed or gets installed
+ for_( it, pool_r.begin(), pool_r.end() )
{
- unsigned idx = 0;
- for_( it, result.begin(), result.end() )
+ if ( it->status().isInstalled() != it->status().transacts() )
{
- static const ByteCount blockAdjust( 2, ByteCount::K ); // (files * blocksize) / (2 * 1K)
-
- it->pkg_size = it->used_size // current usage
- + duchanges[idx].kbytes // package data size
- + ( duchanges[idx].files * it->block_size / blockAdjust ); // half block per file
- ++idx;
+ installedmap.add( *it );
}
}
+ return calcDiskUsage( mps, installedmap );
+ }
- return result;
+ DiskUsageCounter::MountPointSet DiskUsageCounter::disk_usage( sat::Solvable solv_r )
+ {
+ SatMap installedmap;
+ installedmap.add( solv_r );
+ return calcDiskUsage( mps, installedmap );
}
DiskUsageCounter::MountPointSet DiskUsageCounter::detectMountPoints(const std::string &rootdir)
@@ -237,15 +276,23 @@
return ret;
}
+ DiskUsageCounter::MountPointSet DiskUsageCounter::justRootPartition()
+ {
+ DiskUsageCounter::MountPointSet ret;
+ ret.insert( DiskUsageCounter::MountPoint() );
+ return ret;
+ }
+
std::ostream & operator<<( std::ostream & str, const DiskUsageCounter::MountPoint & obj )
{
- str << "dir:[" << obj.dir << "] [ bs: " << obj.block_size
- << " ts: " << obj.total_size
- << " us: " << obj.used_size
- << " (+-: " << (obj.pkg_size-obj.used_size)
+ str << "dir:[" << obj.dir << "] [ bs: " << obj.blockSize()
+ << " ts: " << obj.totalSize()
+ << " us: " << obj.usedSize()
+ << " (+-: " << obj.commitDiff()
<< ")]";
return str;
}
+ /////////////////////////////////////////////////////////////////
} // namespace zypp
///////////////////////////////////////////////////////////////////
Modified: trunk/libzypp/zypp/DiskUsageCounter.h
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/DiskUsageCounter.h?…
==============================================================================
--- trunk/libzypp/zypp/DiskUsageCounter.h (original)
+++ trunk/libzypp/zypp/DiskUsageCounter.h Tue Sep 30 17:41:42 2008
@@ -48,12 +48,12 @@
long long total_size;
/**
- * Used size in (1024)
+ * Used size in K (1024)
**/
long long used_size;
/**
- * Used size after commiting the pool (in kB)
+ * Used size after commiting the pool (in K)
**/
mutable long long pkg_size;
@@ -63,36 +63,80 @@
* Ctor - initialize directory and package size
**/
MountPoint(std::string d = "/", long long bs = 0LL, long long total = 0LL, long long used = 0LL, long long pkg = 0LL, bool ro=false) :
- dir(d), block_size(bs), total_size(total), used_size(used), pkg_size(pkg), readonly(ro) {}
+ dir(d), block_size(bs), total_size(total), used_size(used), pkg_size(pkg), readonly(ro)
+ {}
// sort by directory name
bool operator<( const MountPoint & rhs ) const
{
return dir < rhs.dir;
}
+
+ ByteCount blockSize() const
+ { return ByteCount( block_size, ByteCount::B ); }
+
+ ByteCount totalSize() const
+ { return ByteCount( total_size, ByteCount::K ); }
+
+ ByteCount usedSize() const
+ { return ByteCount( used_size, ByteCount::K ); }
+
+ ByteCount freeSize() const
+ { return ByteCount( total_size-used_size, ByteCount::K ); }
+
+ ByteCount usedAfterCommit() const
+ { return ByteCount( pkg_size, ByteCount::K ); }
+
+ ByteCount freeAfterCommit() const
+ { return ByteCount( total_size-pkg_size, ByteCount::K ); }
+
+ ByteCount commitDiff() const
+ { return ByteCount( pkg_size-used_size, ByteCount::K ); }
};
typedef std::set<MountPoint> MountPointSet;
- DiskUsageCounter() {}
+ DiskUsageCounter()
+ {}
- bool setMountPoints(const MountPointSet &m)
+ DiskUsageCounter( const MountPointSet & m )
+ : mps( m )
+ {}
+
+ bool setMountPoints( const MountPointSet & m )
{
mps = m;
return true;
}
- MountPointSet getMountPoints() const
+ const MountPointSet & getMountPoints() const
{
return mps;
}
static MountPointSet detectMountPoints(const std::string &rootdir = "/");
+ static MountPointSet justRootPartition();
+
/**
* Compute disk usage of the pool
**/
- MountPointSet disk_usage(const ResPool &pool);
+ MountPointSet disk_usage( const ResPool & pool );
+
+ /**
+ * Compute disk usage of one solvable
+ */
+ MountPointSet disk_usage( sat::Solvable solv_r );
+ /** \overload */
+ MountPointSet disk_usage( const PoolItem & pi_r )
+ { return disk_usage( pi_r.satSolvable() ); }
+ /** \overload */
+ MountPointSet disk_usage( const ResObject::constPtr & obj_r )
+ {
+ if ( ! obj_r )
+ return MountPointSet();
+ return disk_usage( obj_r->satSolvable() );
+ }
private:
--
To unsubscribe, e-mail: zypp-commit+unsubscribe(a)opensuse.org
For additional commands, e-mail: zypp-commit+help(a)opensuse.org
1
0
[zypp-commit] r11217 - in /trunk/zypper: doc/zypper.8 package/zypper.changes
by jkupec@svn.opensuse.org 30 Sep '08
by jkupec@svn.opensuse.org 30 Sep '08
30 Sep '08
Author: jkupec
Date: Tue Sep 30 17:13:09 2008
New Revision: 11217
URL: http://svn.opensuse.org/viewcvs/zypp?rev=11217&view=rev
Log:
- changes and man page
Modified:
trunk/zypper/doc/zypper.8
trunk/zypper/package/zypper.changes
Modified: trunk/zypper/doc/zypper.8
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/zypper/doc/zypper.8?rev=11217&r1…
==============================================================================
--- trunk/zypper/doc/zypper.8 (original)
+++ trunk/zypper/doc/zypper.8 Tue Sep 30 17:13:09 2008
@@ -800,13 +800,16 @@
are not available here, though. You can use repository handling commands
to manipulate them.
+
.TP
.B addservice (as) [options] <URI> <alias>
Adds a service specified by \fBURI\fR to the system. The \fBalias\fR must be
unique and serves to identify the service.
Newly added services are not refereshed automatically. Use the
-\fBrefresh-services\fR command to refresh them.
+\fBrefresh-services\fR command to refresh them. Zypper does not access the
+service URI when adding the service, so the type of the services is unknown
+until it is refreshed.
This command also allows to add also ordinary repositories when used with
--type option, where you specify the type of the repository. See the addrepo
@@ -1113,16 +1116,25 @@
.TP
.B /etc/zypp/repos.d
Directory containing repository definition (*.repo) files.
-You can use the \fBrepo\fR commands to manipulate these files, or you can edit
-them yourself. In either case, after doing the modifications, executing
-\fBzypper refresh\fR is strongly recommended.
+You can use the Repository Management Commands to manipulate these files,
+or you can edit them yourself. In either case, after doing the modifications,
+executing \fBzypper refresh\fR is strongly recommended.
You can use the \-\-reposd\-dir global option to use an alternative directory
for this purpose or the \-\-root option to make this directory relative to the
specified root directory.
.TP
+.B /etc/zypp/services.d
+Directory containing service definition (*.service) files.
+You can use the Service Management Commands to manipulate theese files, or
+you can edit them youself. Running \fBzypper refs\fR is recommended after
+modifications have been done.
+.TP
.B /etc/zypp/zypp.conf
-ZYpp configuration file.
+ZYpp configuration file affecting all ZYpp-based applications.
+See the comments in the file for desciption of configurable properties.
+Many of locations of files and directories listed in this section are
+also configurable via zypp.conf.
.TP
.B /etc/zypp/locks
File with package lock definitions, see locks(5) manual page for details.
@@ -1142,6 +1154,9 @@
will be kept here. See also the \fBclean\fR command for cleaning these
cache directories.
.TP
+.B /var/log/zypp/history
+Installation history log.
+.TP
.B ~/.zypper_history
Command history for the shell.
@@ -1197,28 +1212,37 @@
.LP
zypper is designed to be compatible with rug, which is a command\-line interface to the ZENworks Linux Management (ZLM) agent. Compared to rug, zypper does not need the ZLM daemon to run, and is intented to provide more and improved functionality. Following is a list of zypper-rug command aliases, supported rug command line options, and compatibility notes. See also compatibility notes in descriptions of zypper commands.
.LP
-To enable rug-compatible behavior, use the \-r or \-\-rug\-compatible global option with each command.
+To enable rug-compatible behavior, use the \fI\-r or \-\-rug\-compatible\fR global option with each command.
.SS Service Management Commands
.LP
-ZENworks distinguishes services and catalogs. A service is
-added by URI and contains one or more catalogs. Libzypp does not have
-this distinction (yet) but for compatibility it is able to use the same command
-and option names (service-add, \-\-catalog) as rug. TODO this info is out-of-date now
-.LP
-Currently, a Repository in zypper is a synonym for both Service and Catalog in ZLM.
+ZENworks uses different terminology than ZYpp. ZLM \fBservices\fR are ZYpp's
+repositories and services. Additionally some ZLM services can contain
+\fBcatalogs\fR (rpmmd-type repositories in ZYpp speak).
+
+Zypper tries to mimick rug's behavior in its service handling commands when
+used with the -r global option. It also supports the \fI\-\-catalog\fR option
+for specifying catalogs to work with in current operation (this is an alias
+for zypper's \-\-repo option).
+
.TP
.I rug service-add (sa)
-zypper addrepo (ar)
+zypper addservice (as)
+When used with -r global option, this command probes the type of service
+or repository at the specified URI, if not explicitly specified. Without
+-r option the URI is not accessed at all and the URI is added as ZYpp service.
.TP
.I rug service-delete (sd)
-zypper removerepo (rr)
+zypper removeservice (rs)
.TP
.I rug service-list (sl)
-zypper repos (lr)
+zypper services (ls)
+.TP
+.I rug catalogs (ca)
+zypper repos (lr)
.IP
zypper doesn't include 'Enabled' and 'Refresh' columns and prints rug's 'Status' column with values "Active" or "Disabled" instead.
Modified: trunk/zypper/package/zypper.changes
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/zypper/package/zypper.changes?re…
==============================================================================
--- trunk/zypper/package/zypper.changes (original)
+++ trunk/zypper/package/zypper.changes Tue Sep 30 17:13:09 2008
@@ -1,4 +1,11 @@
-------------------------------------------------------------------
+Tue Sep 30 17:03:18 CEST 2008 - jkupec(a)suse.cz
+
+- addservice: probe for repository/service type if in rug-compatible
+ mode (bnc #429620)
+- r11216
+
+-------------------------------------------------------------------
Mon Sep 29 12:08:12 CEST 2008 - jkupec(a)suse.cz
- show in 'lu' what will 'up' actually propose to install
--
To unsubscribe, e-mail: zypp-commit+unsubscribe(a)opensuse.org
For additional commands, e-mail: zypp-commit+help(a)opensuse.org
1
0
Author: jkupec
Date: Tue Sep 30 16:33:35 2008
New Revision: 11216
URL: http://svn.opensuse.org/viewcvs/zypp?rev=11216&view=rev
Log:
- addservice: probe for repository/service type if in rug-compatible
mode (bnc #429620)
Modified:
trunk/zypper/src/Zypper.cc
Modified: trunk/zypper/src/Zypper.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/zypper/src/Zypper.cc?rev=11216&r…
==============================================================================
--- trunk/zypper/src/Zypper.cc (original)
+++ trunk/zypper/src/Zypper.cc Tue Sep 30 16:33:35 2008
@@ -2342,13 +2342,50 @@
return;
}
+ initRepoManager();
+ RepoManager & rm = repoManager();
+
// force specific repository type.
string type = copts.count("type") ? copts["type"].front() : "";
// check for valid service type
bool isservice = false;
if (type.empty())
- isservice = true;
+ {
+ // rug does not make difference between services and repos, so service-add
+ // must be able to handle them both (bnc #429620)
+ if (globalOpts().is_rug_compatible)
+ {
+ repo::ServiceType stype = rm.probeService(url);
+ // is it a service?
+ if (stype != repo::ServiceType::NONE)
+ {
+ isservice = true;
+ type = stype.asString();
+ }
+ // is it a repo?
+ else
+ {
+ repo::RepoType rtype = rm.probe(url);
+ if (rtype != repo::RepoType::NONE)
+ type = rtype.asString();
+ // complain & exit
+ else
+ {
+ out().error(
+ _("Can't find a valid repository at given location:"),
+ _("Could not determine the type of the repository."
+ " Check if the specified URI points to a valid repository."));
+ setExitCode(ZYPPER_EXIT_ERR_ZYPP);
+ return;
+ }
+ }
+ }
+ // zypper does not access net when adding repos/services, thus for zypper
+ // the URI is always service unless --type is explicitely specified.
+ else
+ isservice = true;
+ }
else
{
try { repo::ServiceType stype(type); isservice = true; }
@@ -2357,8 +2394,6 @@
warn_if_zmd();
- initRepoManager();
-
if (isservice)
add_service_by_url(*this, url, _arguments[1], type, enabled);
else
--
To unsubscribe, e-mail: zypp-commit+unsubscribe(a)opensuse.org
For additional commands, e-mail: zypp-commit+help(a)opensuse.org
1
0
Author: jkupec
Date: Tue Sep 30 13:53:58 2008
New Revision: 11215
URL: http://svn.opensuse.org/viewcvs/zypp?rev=11215&view=rev
Log:
- typo in the help text
Modified:
trunk/zypper/src/Zypper.cc
Modified: trunk/zypper/src/Zypper.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/zypper/src/Zypper.cc?rev=11215&r…
==============================================================================
--- trunk/zypper/src/Zypper.cc (original)
+++ trunk/zypper/src/Zypper.cc Tue Sep 30 13:53:58 2008
@@ -913,7 +913,7 @@
"\n"
" Command options:\n"
"-r, --repo <alias|#|URI> Operate only with packages from the specified repository.\n"
- "-t, --type <type> Type of resolvable (%s).\n"
+ "-t, --type <type> Type of package (%s).\n"
" Default: %s.\n"
"-n, --name Select packages by plain name, not by capability.\n"
"-C, --capability Select packages by capability.\n"
--
To unsubscribe, e-mail: zypp-commit+unsubscribe(a)opensuse.org
For additional commands, e-mail: zypp-commit+help(a)opensuse.org
1
0
[zypp-commit] r11214 - in /trunk/sat-solver: package/libsatsolver.changes tools/repo_content.c
by mlandres@svn.opensuse.org 30 Sep '08
by mlandres@svn.opensuse.org 30 Sep '08
30 Sep '08
Author: mlandres
Date: Tue Sep 30 13:05:26 2008
New Revision: 11214
URL: http://svn.opensuse.org/viewcvs/zypp?rev=11214&view=rev
Log:
- repo_content.c: fix broken dependency parsing.
Modified:
trunk/sat-solver/package/libsatsolver.changes
trunk/sat-solver/tools/repo_content.c
Modified: trunk/sat-solver/package/libsatsolver.changes
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/sat-solver/package/libsatsolver.…
==============================================================================
--- trunk/sat-solver/package/libsatsolver.changes (original)
+++ trunk/sat-solver/package/libsatsolver.changes Tue Sep 30 13:05:26 2008
@@ -1,4 +1,10 @@
-------------------------------------------------------------------
+Tue Sep 30 13:03:10 CEST 2008 - ma(a)suse.de
+
+- repo_content.c: fix broken dependency parsing.
+- revision 11214
+
+-------------------------------------------------------------------
Mon Sep 29 14:53:09 CEST 2008 - ma(a)suse.de
- rpms2solv failed to write out most solvable data (bnc #422338).
Modified: trunk/sat-solver/tools/repo_content.c
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/sat-solver/tools/repo_content.c?…
==============================================================================
--- trunk/sat-solver/tools/repo_content.c (original)
+++ trunk/sat-solver/tools/repo_content.c Tue Sep 30 13:05:26 2008
@@ -118,6 +118,7 @@
/*
* add dependency to pool
+ * OBSOLETES product:SUSE_LINUX product:openSUSE < 11.0 package:openSUSE < 11.0
*/
static unsigned int
@@ -125,7 +126,7 @@
{
char *name;
Id id;
-
+
while ((name = splitword(&line)) != 0)
{
/* Hack, as the content file adds 'package:' for package
@@ -133,7 +134,7 @@
if (!strncmp (name, "package:", 8))
name += 8;
id = str2id(pool, name, 1);
- if (strpbrk(line, "<>="))
+ if (strpbrk(line, "<>=") == line) /* next(!) word is rel */
{
char *rel = splitword(&line);
char *evr = splitword(&line);
@@ -214,11 +215,11 @@
we use the first architecture in BASEARCHS or noarch
for the product. At the end we create (clone) the product
for each one of the remaining architectures
- we allow max 4 archs
+ we allow max 4 archs
*/
unsigned int numotherarchs = 0;
Id *otherarchs = 0;
-
+
memset(&pd, 0, sizeof(pd));
line = sat_malloc(1024);
aline = 1024;
@@ -256,7 +257,7 @@
/* expect "key value" lines */
value = line;
key = splitword(&value);
-
+
if (key)
{
#if 0
@@ -419,7 +420,7 @@
if (code10)
s->supplements = repo_fix_supplements(repo, s->provides, s->supplements, 0);
}
-
+
/* now for every other arch, clone the product except the architecture */
for (i = 0; i < numotherarchs; ++i)
{
@@ -438,7 +439,7 @@
/* now merge the attributes */
repodata_merge_attrs(data, p - pool->solvables - repo->start, s - pool->solvables- repo->start);
}
-
+
if (data)
repodata_internalize(data);
--
To unsubscribe, e-mail: zypp-commit+unsubscribe(a)opensuse.org
For additional commands, e-mail: zypp-commit+help(a)opensuse.org
1
0
[zypp-commit] r11213 - in /trunk/libzypp/zypp/media: MediaAria2c.cc MediaAria2c.h
by dmacvicar@svn.opensuse.org 30 Sep '08
by dmacvicar@svn.opensuse.org 30 Sep '08
30 Sep '08
Author: dmacvicar
Date: Tue Sep 30 08:56:02 2008
New Revision: 11213
URL: http://svn.opensuse.org/viewcvs/zypp?rev=11213&view=rev
Log:
forgot to add those
Added:
trunk/libzypp/zypp/media/MediaAria2c.cc
trunk/libzypp/zypp/media/MediaAria2c.h
Added: trunk/libzypp/zypp/media/MediaAria2c.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/media/MediaAria2c.c…
==============================================================================
--- trunk/libzypp/zypp/media/MediaAria2c.cc (added)
+++ trunk/libzypp/zypp/media/MediaAria2c.cc Tue Sep 30 08:56:02 2008
@@ -0,0 +1,1795 @@
+/*---------------------------------------------------------------------\
+| ____ _ __ __ ___ |
+| |__ / \ / / . \ . \ |
+| / / \ V /| _/ _/ |
+| / /__ | | | | | | |
+| /_____||_| |_| |_| |
+| |
+\---------------------------------------------------------------------*/
+/** \file zypp/media/MediaAria2c.cc
+ *
+*/
+
+#include <iostream>
+#include <list>
+
+#include "zypp/base/Logger.h"
+#include "zypp/ExternalProgram.h"
+#include "zypp/ProgressData.h"
+#include "zypp/base/String.h"
+#include "zypp/base/Gettext.h"
+#include "zypp/base/Sysconfig.h"
+#include "zypp/base/Gettext.h"
+#include "zypp/ZYppCallbacks.h"
+
+#include "zypp/media/MediaAria2c.h"
+#include "zypp/media/proxyinfo/ProxyInfos.h"
+#include "zypp/media/ProxyInfo.h"
+#include "zypp/media/MediaUserAuth.h"
+//#include "zypp/media/CurlConfig.h"
+#include "zypp/thread/Once.h"
+#include <cstdlib>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <sys/mount.h>
+#include <errno.h>
+#include <dirent.h>
+#include <unistd.h>
+#include <boost/format.hpp>
+
+#define DETECT_DIR_INDEX 0
+#define CONNECT_TIMEOUT 60
+#define TRANSFER_TIMEOUT 60 * 3
+#define TRANSFER_TIMEOUT_MAX 60 * 60
+
+
+using namespace std;
+using namespace zypp::base;
+
+namespace
+{
+ //zypp::thread::OnceFlag g_InitOnceFlag = PTHREAD_ONCE_INIT;
+ //zypp::thread::OnceFlag g_FreeOnceFlag = PTHREAD_ONCE_INIT;
+ /*
+ extern "C" void _do_aria2c_free_once()
+ {
+ curl_global_cleanup();
+ }
+
+ extern "C" void globalAria2cFreeOnce()
+ {
+ zypp::thread::callOnce(g_FreeOnceFlag, _do_aria2c_free_once);
+ }
+
+ extern "C" void _do_aria2c_init_once()
+ {
+ CURLcode ret = curl_global_init( CURL_GLOBAL_ALL );
+ if ( ret != 0 )
+ {
+ WAR << "curl global init failed" << endl;
+ }
+
+ //
+ // register at exit handler ?
+ // this may cause trouble, because we can protect it
+ // against ourself only.
+ // if the app sets an atexit handler as well, it will
+ // cause a double free while the second of them runs.
+ //
+ //std::atexit( globalFreeOnce);
+ }
+
+
+ inline void globalInitOnce()
+ {
+ zypp::thread::callOnce(g_InitOnceFlag, _do_aria2c_init_once);
+ }
+*/
+/*
+ int log_curl(CURL *curl, curl_infotype info,
+ char *ptr, size_t len, void *max_lvl)
+ {
+ std::string pfx(" ");
+ long lvl = 0;
+ switch( info)
+ {
+ case CURLINFO_TEXT: lvl = 1; pfx = "*"; break;
+ case CURLINFO_HEADER_IN: lvl = 2; pfx = "<"; break;
+ case CURLINFO_HEADER_OUT: lvl = 2; pfx = ">"; break;
+ default: break;
+ }
+ if( lvl > 0 && max_lvl != NULL && lvl <= *((long *)max_lvl))
+ {
+ std::string msg(ptr, len);
+ std::list<std::string> lines;
+ std::list<std::string>::const_iterator line;
+ zypp::str::split(msg, std::back_inserter(lines), "\r\n");
+ for(line = lines.begin(); line != lines.end(); ++line)
+ {
+ DBG << pfx << " " << *line << endl;
+ }
+ }
+ return 0;
+ }
+ */
+}
+
+namespace zypp {
+ namespace media {
+
+ namespace {
+ /*
+ struct ProgressData
+ {
+ ProgressData(const long _timeout, const zypp::Url &_url = zypp::Url(),
+ callback::SendReport<DownloadProgressReport> *_report=NULL)
+ : timeout(_timeout)
+ , reached(false)
+ , report(_report)
+ , drate_period(-1)
+ , dload_period(0)
+ , secs(0)
+ , drate_avg(-1)
+ , ltime( time(NULL))
+ , dload( 0)
+ , uload( 0)
+ , url(_url)
+ {}
+ long timeout;
+ bool reached;
+ callback::SendReport<DownloadProgressReport> *report;
+ // download rate of the last period (cca 1 sec)
+ double drate_period;
+ // bytes downloaded at the start of the last period
+ double dload_period;
+ // seconds from the start of the download
+ long secs;
+ // average download rate
+ double drate_avg;
+ // last time the progress was reported
+ time_t ltime;
+ // bytes downloaded at the moment the progress was last reported
+ double dload;
+ // bytes uploaded at the moment the progress was last reported
+ double uload;
+ zypp::Url url;
+ };
+ */
+
+ ///////////////////////////////////////////////////////////////////
+
+ inline void escape( string & str_r,
+ const char char_r, const string & escaped_r ) {
+ for ( string::size_type pos = str_r.find( char_r );
+ pos != string::npos; pos = str_r.find( char_r, pos ) ) {
+ str_r.replace( pos, 1, escaped_r );
+ }
+ }
+
+ inline string escapedPath( string path_r ) {
+ escape( path_r, ' ', "%20" );
+ return path_r;
+ }
+
+ inline string unEscape( string text_r ) {
+ char * tmp = curl_unescape( text_r.c_str(), 0 );
+ string ret( tmp );
+ curl_free( tmp );
+ return ret;
+ }
+
+ }
+
+///////////////////////////////////////////////////////////////////
+//
+// CLASS NAME : MediaAria2c
+//
+///////////////////////////////////////////////////////////////////
+
+Pathname MediaAria2c::_cookieFile = "/var/lib/YaST2/cookies";
+Pathname MediaAria2c::_aria2cPath = "/usr/local/bin/aria2c";
+std::string MediaAria2c::_aria2cVersion = "WE DON'T KNOW ARIA2C VERSION";
+
+//check if aria2c is present in the system
+bool
+MediaAria2c::existsAria2cmd()
+{
+ const char* argv[] =
+ {
+ "whereis",
+ "-b",
+ "aria2c",
+ NULL
+ };
+
+ ExternalProgram aria(argv, ExternalProgram::Stderr_To_Stdout);
+
+ std::string ariaResponse( aria.receiveLine());
+ string::size_type pos = ariaResponse.find('/', 0 );
+ if( pos != string::npos )
+ return true;
+ else
+ return false;
+}
+
+const char *const MediaAria2c::agentString()
+{
+ static const std::string _value( str::form( "ZYpp %s (with %s)", VERSION, MediaAria2c::_aria2cVersion.c_str() ));
+ return _value.c_str();
+
+}
+
+MediaAria2c::MediaAria2c( const Url & url_r,
+ const Pathname & attach_point_hint_r )
+ : MediaHandler( url_r, attach_point_hint_r,
+ "/", // urlpath at attachpoint
+ true ) // does_download
+ //_curl( NULL )
+{
+ /*
+ _curlError[0] = '\0';
+ _curlDebug = 0L;
+ */
+
+ MIL << "MediaAria2c::MediaAria2c(" << url_r << ", " << attach_point_hint_r << ")" << endl;
+
+ //globalInitOnce();
+
+ if( !attachPoint().empty())
+ {
+ PathInfo ainfo(attachPoint());
+ Pathname apath(attachPoint() + "XXXXXX");
+ char *atemp = ::strdup( apath.asString().c_str());
+ char *atest = NULL;
+ if( !ainfo.isDir() || !ainfo.userMayRWX() ||
+ atemp == NULL || (atest=::mkdtemp(atemp)) == NULL)
+ {
+ WAR << "attach point " << ainfo.path()
+ << " is not useable for " << url_r.getScheme() << endl;
+ setAttachPoint("", true);
+ }
+ else if( atest != NULL)
+ ::rmdir(atest);
+
+ if( atemp != NULL)
+ ::free(atemp);
+ }
+
+ //At this point, we initialize aria2c path
+ _aria2cPath = Pathname( whereisAria2c().asString() );
+
+ //Get aria2c version
+ _aria2cVersion = getAria2cVersion();
+}
+
+/*
+void MediaAria2c::setCookieFile( const Pathname &fileName )
+{
+ _cookieFile = fileName;
+}*/
+
+
+///////////////////////////////////////////////////////////////////
+//
+//
+// METHOD NAME : MediaAria2c::attachTo
+// METHOD TYPE : PMError
+//
+// DESCRIPTION : Asserted that not already attached, and attachPoint is a directory.
+//
+void MediaAria2c::attachTo (bool next)
+{
+
+ if ( next )
+ ZYPP_THROW(MediaNotSupportedException(_url));
+
+ if ( !_url.isValid() )
+ ZYPP_THROW(MediaBadUrlException(_url));
+
+/*
+ CurlConfig curlconf;
+ CurlConfig::parseConfig(curlconf); // parse ~/.curlrc
+
+ curl_version_info_data *curl_info = NULL;
+ curl_info = curl_version_info(CURLVERSION_NOW);
+ // curl_info does not need any free (is static)
+ if (curl_info->protocols)
+ {
+ const char * const *proto;
+ std::string scheme( _url.getScheme());
+ bool found = false;
+ for(proto=curl_info->protocols; !found && *proto; ++proto)
+ {
+ if( scheme == std::string((const char *)*proto))
+ found = true;
+ }
+ if( !found)
+ {
+ std::string msg("Unsupported protocol '");
+ msg += scheme;
+ msg += "'";
+ ZYPP_THROW(MediaBadUrlException(_url, msg));
+ }
+ }*/
+
+ if( !isUseableAttachPoint(attachPoint()))
+ {
+ std::string mountpoint = createAttachPoint().asString();
+
+ if( mountpoint.empty())
+ ZYPP_THROW( MediaBadAttachPointException(url()));
+
+ setAttachPoint( mountpoint, true);
+ }
+
+ disconnectFrom(); // clean _curl if needed
+/*
+ _curl = curl_easy_init();
+ if ( !_curl ) {
+ ZYPP_THROW(MediaAria2cInitException(_url));
+ }
+
+ {
+ char *ptr = getenv("ZYPP_MEDIA_CURL_DEBUG");
+ _curlDebug = (ptr && *ptr) ? str::strtonum<long>( ptr) : 0L;
+ if( _curlDebug > 0)
+ {
+ curl_easy_setopt( _curl, CURLOPT_VERBOSE, 1);
+ curl_easy_setopt( _curl, CURLOPT_DEBUGFUNCTION, log_curl);
+ curl_easy_setopt( _curl, CURLOPT_DEBUGDATA, &_curlDebug);
+ }
+ }
+
+ CURLcode ret = curl_easy_setopt( _curl, CURLOPT_ERRORBUFFER, _curlError );
+ if ( ret != 0 ) {
+ disconnectFrom();
+ ZYPP_THROW(MediaAria2cSetOptException(_url, "Error setting error buffer"));
+ }
+
+ ret = curl_easy_setopt( _curl, CURLOPT_FAILONERROR, true );
+ if ( ret != 0 ) {
+ disconnectFrom();
+ ZYPP_THROW(MediaAria2cSetOptException(_url, _curlError));
+ }
+
+ ret = curl_easy_setopt( _curl, CURLOPT_NOSIGNAL, 1 );
+ if ( ret != 0 ) {
+ disconnectFrom();
+ ZYPP_THROW(MediaAria2cSetOptException(_url, _curlError));
+ }
+
+
+ * Transfer timeout
+
+ {
+ _xfer_timeout = TRANSFER_TIMEOUT;
+
+ std::string param(_url.getQueryParam("timeout"));
+ if( !param.empty())
+ {
+ long num = str::strtonum<long>( param);
+ if( num >= 0 && num <= TRANSFER_TIMEOUT_MAX)
+ _xfer_timeout = num;
+ }
+ }
+
+
+ ** Connect timeout
+
+ ret = curl_easy_setopt( _curl, CURLOPT_CONNECTTIMEOUT, CONNECT_TIMEOUT);
+ if ( ret != 0 ) {
+ disconnectFrom();
+ ZYPP_THROW(MediaAria2cSetOptException(_url, _curlError));
+ }
+
+ if ( _url.getScheme() == "http" ) {
+ // follow any Location: header that the server sends as part of
+ // an HTTP header (#113275)
+ ret = curl_easy_setopt ( _curl, CURLOPT_FOLLOWLOCATION, true );
+ if ( ret != 0) {
+ disconnectFrom();
+ ZYPP_THROW(MediaAria2cSetOptException(_url, _curlError));
+ }
+ ret = curl_easy_setopt ( _curl, CURLOPT_MAXREDIRS, 3L );
+ if ( ret != 0) {
+ disconnectFrom();
+ ZYPP_THROW(MediaAria2cSetOptException(_url, _curlError));
+ }
+
+ ret = curl_easy_setopt ( _curl, CURLOPT_USERAGENT, agentString() );
+
+
+ if ( ret != 0) {
+ disconnectFrom();
+ ZYPP_THROW(MediaAria2cSetOptException(_url, _curlError));
+ }
+ }
+
+ if ( _url.getScheme() == "https" )
+ {
+ bool verify_peer = false;
+ bool verify_host = false;
+
+ std::string verify( _url.getQueryParam("ssl_verify"));
+ if( verify.empty() ||
+ verify == "yes")
+ {
+ verify_peer = true;
+ verify_host = true;
+ }
+ else
+ if( verify == "no")
+ {
+ verify_peer = false;
+ verify_host = false;
+ }
+ else
+ {
+ std::vector<std::string> flags;
+ std::vector<std::string>::const_iterator flag;
+ str::split( verify, std::back_inserter(flags), ",");
+ for(flag = flags.begin(); flag != flags.end(); ++flag)
+ {
+ if( *flag == "host")
+ {
+ verify_host = true;
+ }
+ else
+ if( *flag == "peer")
+ {
+ verify_peer = true;
+ }
+ else
+ {
+ disconnectFrom();
+ ZYPP_THROW(MediaBadUrlException(_url, "Unknown ssl_verify flag"));
+ }
+ }
+ }
+
+ _ca_path = Pathname(_url.getQueryParam("ssl_capath")).asString();
+ if( _ca_path.empty())
+ {
+ _ca_path = "/etc/ssl/certs/";
+ }
+ else
+ if( !PathInfo(_ca_path).isDir() || !Pathname(_ca_path).absolute())
+ {
+ disconnectFrom();
+ ZYPP_THROW(MediaBadUrlException(_url, "Invalid ssl_capath path"));
+ }
+
+ if( verify_peer || verify_host)
+ {
+ ret = curl_easy_setopt( _curl, CURLOPT_CAPATH, _ca_path.c_str());
+ if ( ret != 0 ) {
+ disconnectFrom();
+ ZYPP_THROW(MediaAria2cSetOptException(_url, _curlError));
+ }
+ }
+
+ ret = curl_easy_setopt( _curl, CURLOPT_SSL_VERIFYPEER, verify_peer ? 1L : 0L);
+ if ( ret != 0 ) {
+ disconnectFrom();
+ ZYPP_THROW(MediaAria2cSetOptException(_url, _curlError));
+ }
+ ret = curl_easy_setopt( _curl, CURLOPT_SSL_VERIFYHOST, verify_host ? 2L : 0L);
+ if ( ret != 0 ) {
+ disconnectFrom();
+ ZYPP_THROW(MediaAria2cSetOptException(_url, _curlError));
+ }
+
+ ret = curl_easy_setopt ( _curl, CURLOPT_USERAGENT, agentString() );
+ if ( ret != 0) {
+ disconnectFrom();
+ ZYPP_THROW(MediaAria2cSetOptException(_url, _curlError));
+ }
+ }
+
+
+ ---------------------------------------------------------------*
+ CURLOPT_USERPWD: [user name]:[password]
+
+ Url::username/password -> CURLOPT_USERPWD
+ If not provided, anonymous FTP identification
+ *---------------------------------------------------------------
+
+ if ( _url.getUsername().empty() ) {
+ if ( _url.getScheme() == "ftp" ) {
+ string id = "yast2@";
+ id += VERSION;
+ DBG << "Anonymous FTP identification: '" << id << "'" << endl;
+ _userpwd = "anonymous:" + id;
+ }
+ } else {
+ _userpwd = _url.getUsername();
+ if ( _url.getPassword().size() ) {
+ _userpwd += ":" + _url.getPassword();
+ }
+ }
+
+ if ( _userpwd.size() ) {
+ _userpwd = unEscape( _userpwd );
+ ret = curl_easy_setopt( _curl, CURLOPT_USERPWD, _userpwd.c_str() );
+ if ( ret != 0 ) {
+ disconnectFrom();
+ ZYPP_THROW(MediaAria2cSetOptException(_url, _curlError));
+ }
+
+ // HTTP authentication type
+ if(_url.getScheme() == "http" || _url.getScheme() == "https")
+ {
+ string use_auth = _url.getQueryParam("auth");
+ if( use_auth.empty())
+ use_auth = "digest,basic";
+
+ try
+ {
+ long auth = CurlAuthData::auth_type_str2long(use_auth);
+ if( auth != CURLAUTH_NONE)
+ {
+ DBG << "Enabling HTTP authentication methods: " << use_auth
+ << " (CURLOPT_HTTPAUTH=" << auth << ")" << std::endl;
+
+ ret = curl_easy_setopt( _curl, CURLOPT_HTTPAUTH, auth);
+ if ( ret != 0 ) {
+ disconnectFrom();
+ ZYPP_THROW(MediaAria2cSetOptException(_url, _curlError));
+ }
+ }
+ }
+ catch (MediaException & ex_r)
+ {
+ string auth_hint = getAuthHint();
+
+ DBG << "Rethrowing as MediaUnauthorizedException. auth hint: '"
+ << auth_hint << "'" << endl;
+
+ ZYPP_THROW(MediaUnauthorizedException(
+ _url, ex_r.msg(), _curlError, auth_hint
+ ));
+ }
+ }
+ }
+
+ ---------------------------------------------------------------*
+ CURLOPT_PROXY: host[:port]
+
+ Url::option(proxy and proxyport) -> CURLOPT_PROXY
+ If not provided, /etc/sysconfig/proxy is evaluated
+ *---------------------------------------------------------------*
+
+ _proxy = _url.getQueryParam( "proxy" );
+
+ if ( ! _proxy.empty() ) {
+ string proxyport( _url.getQueryParam( "proxyport" ) );
+ if ( ! proxyport.empty() ) {
+ _proxy += ":" + proxyport;
+ }
+ } else {
+
+ ProxyInfo proxy_info (ProxyInfo::ImplPtr(new ProxyInfoSysconfig("proxy")));
+
+ if ( proxy_info.enabled())
+ {
+ bool useproxy = true;
+
+ std::list<std::string> nope = proxy_info.noProxy();
+ for (ProxyInfo::NoProxyIterator it = proxy_info.noProxyBegin();
+ it != proxy_info.noProxyEnd();
+ it++)
+ {
+ std::string host( str::toLower(_url.getHost()));
+ std::string temp( str::toLower(*it));
+
+ // no proxy if it points to a suffix
+ // preceeded by a '.', that maches
+ // the trailing portion of the host.
+ if( temp.size() > 1 && temp.at(0) == '.')
+ {
+ if(host.size() > temp.size() &&
+ host.compare(host.size() - temp.size(), temp.size(), temp) == 0)
+ {
+ DBG << "NO_PROXY: '" << *it << "' matches host '"
+ << host << "'" << endl;
+ useproxy = false;
+ break;
+ }
+ }
+ else
+ // no proxy if we have an exact match
+ if( host == temp)
+ {
+ DBG << "NO_PROXY: '" << *it << "' matches host '"
+ << host << "'" << endl;
+ useproxy = false;
+ break;
+ }
+ }
+
+ if ( useproxy ) {
+ _proxy = proxy_info.proxy(_url.getScheme());
+ }
+ }
+ }
+
+
+ DBG << "Proxy: " << (_proxy.empty() ? "-none-" : _proxy) << endl;
+
+ if ( ! _proxy.empty() ) {
+
+ ret = curl_easy_setopt( _curl, CURLOPT_PROXY, _proxy.c_str() );
+ if ( ret != 0 ) {
+ disconnectFrom();
+ ZYPP_THROW(MediaAria2cSetOptException(_url, _curlError));
+ }
+
+ *---------------------------------------------------------------*
+ CURLOPT_PROXYUSERPWD: [user name]:[password]
+
+ Url::option(proxyuser and proxypassword) -> CURLOPT_PROXYUSERPWD
+ If not provided, $HOME/.curlrc is evaluated
+ *---------------------------------------------------------------*
+
+ _proxyuserpwd = _url.getQueryParam( "proxyuser" );
+
+ if ( ! _proxyuserpwd.empty() ) {
+ string proxypassword( _url.getQueryParam( "proxypassword" ) );
+ if ( ! proxypassword.empty() ) {
+ _proxyuserpwd += ":" + proxypassword;
+ }
+ } else {
+ if (curlconf.proxyuserpwd.empty())
+ DBG << "~/.curlrc does not contain the proxy-user option" << endl;
+ else
+ {
+ _proxyuserpwd = curlconf.proxyuserpwd;
+ DBG << "using proxy-user from ~/.curlrc" << endl;
+ }
+ }
+
+ _proxyuserpwd = unEscape( _proxyuserpwd );
+ ret = curl_easy_setopt( _curl, CURLOPT_PROXYUSERPWD, _proxyuserpwd.c_str() );
+ if ( ret != 0 ) {
+ disconnectFrom();
+ ZYPP_THROW(MediaAria2cSetOptException(_url, _curlError));
+ }
+ }
+
+ *---------------------------------------------------------------*
+ *---------------------------------------------------------------*
+
+ _currentCookieFile = _cookieFile.asString();
+
+ ret = curl_easy_setopt( _curl, CURLOPT_COOKIEFILE,
+ _currentCookieFile.c_str() );
+ if ( ret != 0 ) {
+ disconnectFrom();
+ ZYPP_THROW(MediaAria2cSetOptException(_url, _curlError));
+ }
+
+ ret = curl_easy_setopt( _curl, CURLOPT_COOKIEJAR,
+ _currentCookieFile.c_str() );
+ if ( ret != 0 ) {
+ disconnectFrom();
+ ZYPP_THROW(MediaAria2cSetOptException(_url, _curlError));
+ }
+
+ ret = curl_easy_setopt( _curl, CURLOPT_PROGRESSFUNCTION,
+ &progressCallback );
+ if ( ret != 0 ) {
+ disconnectFrom();
+ ZYPP_THROW(MediaAria2cSetOptException(_url, _curlError));
+ }
+
+ ret = curl_easy_setopt( _curl, CURLOPT_NOPROGRESS, false );
+ if ( ret != 0 ) {
+ disconnectFrom();
+ ZYPP_THROW(MediaAria2cSetOptException(_url, _curlError));
+ }
+*/
+ // FIXME: need a derived class to propelly compare url's
+ MediaSourceRef media( new MediaSource(_url.getScheme(), _url.asString()));
+ setMediaSource(media);
+
+}
+
+bool
+MediaAria2c::checkAttachPoint(const Pathname &apoint) const
+{
+ return MediaHandler::checkAttachPoint( apoint, true, true);
+}
+
+///////////////////////////////////////////////////////////////////
+//
+//
+// METHOD NAME : MediaAria2c::disconnectFrom
+// METHOD TYPE : PMError
+//
+void MediaAria2c::disconnectFrom()
+{
+ /*
+ if ( _curl )
+ {
+ curl_easy_cleanup( _curl );
+ _curl = NULL;
+ }*/
+}
+
+
+///////////////////////////////////////////////////////////////////
+//
+//
+// METHOD NAME : MediaAria2c::releaseFrom
+// METHOD TYPE : void
+//
+// DESCRIPTION : Asserted that media is attached.
+//
+void MediaAria2c::releaseFrom( const std::string & ejectDev )
+{
+ disconnect();
+}
+
+static Url getFileUrl(const Url & url, const Pathname & filename)
+{
+ Url newurl(url);
+ string path = url.getPathName();
+ if ( !path.empty() && path != "/" && *path.rbegin() == '/' &&
+ filename.absolute() )
+ {
+ // If url has a path with trailing slash, remove the leading slash from
+ // the absolute file name
+ path += filename.asString().substr( 1, filename.asString().size() - 1 );
+ }
+ else if ( filename.relative() )
+ {
+ // Add trailing slash to path, if not already there
+ if (path.empty()) path = "/";
+ else if (*path.rbegin() != '/' ) path += "/";
+ // Remove "./" from begin of relative file name
+ path += filename.asString().substr( 2, filename.asString().size() - 2 );
+ }
+ else
+ {
+ path += filename.asString();
+ }
+
+ newurl.setPathName(path);
+ return newurl;
+}
+
+
+///////////////////////////////////////////////////////////////////
+//
+// METHOD NAME : MediaAria2c::getFile
+// METHOD TYPE : void
+//
+void MediaAria2c::getFile( const Pathname & filename ) const
+{
+ // Use absolute file name to prevent access of files outside of the
+ // hierarchy below the attach point.
+ getFileCopy(filename, localPath(filename).absolutename());
+}
+
+///////////////////////////////////////////////////////////////////
+//
+// METHOD NAME : MediaAria2c::getFileCopy
+// METHOD TYPE : void
+//
+void MediaAria2c::getFileCopy( const Pathname & filename , const Pathname & target) const
+{
+ callback::SendReport<DownloadProgressReport> report;
+
+ Url fileurl(getFileUrl(_url, filename));
+
+ bool retry = false;
+ CurlAuthData auth_data;
+
+ do
+ {
+ try
+ {
+ report->start(_url, target.asString() );
+
+ const char* argv[] =
+ {
+ _aria2cPath.c_str(),
+ str::form("--user-agent=\"%s\""
+ , agentString()).c_str(),
+ "--summary-interval=1",
+ "--follow-metalink=mem",
+ "--check-integrity=true",
+ str::form("--dir=\"%s\"", target.dirname().c_str()).c_str(),
+ fileurl.asString().c_str(),
+ NULL
+ };
+
+ ExternalProgram aria(argv, ExternalProgram::Stderr_To_Stdout);
+ int nLine = 0;
+
+ //Process response
+ for(std::string ariaResponse( aria.receiveLine());
+ ariaResponse.length();
+ ariaResponse = aria.receiveLine())
+ {
+ //cout << ariaResponse;
+ if (!ariaResponse.substr(0,9).compare("[#2 SIZE:")) {
+
+ if (!nLine)
+ {
+ size_t left_bound = ariaResponse.find('(',0) + 1;
+ size_t count = ariaResponse.find('%',left_bound) - left_bound;
+ //cout << ariaResponse.substr(left_bound, count) << endl;
+ //progressData.toMax();
+ report->progress ( std::atoi(ariaResponse.substr(left_bound, count).c_str()), _url, -1, -1 );
+ nLine = 1;
+ }
+ else
+ {
+ nLine = 0;
+ }
+
+
+ }
+ }
+ aria.close();
+
+ report->finish( _url , zypp::media::DownloadProgressReport::NO_ERROR, "");
+ retry = false;
+ }
+
+
+ // retry with proper authentication data
+ catch (MediaUnauthorizedException & ex_r)
+ {
+ callback::SendReport<AuthenticationReport> auth_report;
+
+ /*
+
+ Here, we can try using this aria2c options - TODO
+
+ --http-user=USER
+ Set HTTP user. This affects all URLs.
+
+ --http-passwd=PASSWD
+ Set HTTP password. This affects all URLs.
+ */
+
+ //if (!_url.getUsername().empty() && !retry)
+ // auth_data.setUserName(_url.getUsername());
+
+ //string prompt_msg;
+ //if (retry || !_url.getUsername().empty())
+ // prompt_msg = _("Invalid user name or password.");
+ //else // first prompt
+ // prompt_msg = boost::str(boost::format(
+ // _("Authentication required for '%s'")) % _url.asString());
+
+ // set available authentication types from the exception
+ //auth_data.setAuthType(ex_r.hint());
+
+ //if (auth_report->prompt(_url, prompt_msg, auth_data))
+ //{
+ //DBG << "callback answer: retry" << endl
+ // << "CurlAuthData: " << auth_data << endl;
+
+ //if (auth_data.valid()) {
+ //_userpwd = auth_data.getUserPwd();
+
+ // set username and password
+ //CURLcode ret = curl_easy_setopt(_curl, CURLOPT_USERPWD, _userpwd.c_str());
+ //if ( ret != 0 ) ZYPP_THROW(MediaAria2cSetOptException(_url, _curlError));
+
+ // set auth type
+ //ret = curl_easy_setopt(_curl, CURLOPT_HTTPAUTH, auth_data.authType());
+ //if ( ret != 0 ) ZYPP_THROW(MediaAria2cSetOptException(_url, _curlError));
+ //}
+
+ //retry = true;
+ //}
+ //else
+ //{
+ // DBG << "callback answer: cancel" << endl;
+ // report->finish(fileurl, zypp::media::DownloadProgressReport::ACCESS_DENIED, ex_r.asUserString());
+ // ZYPP_RETHROW(ex_r);
+ //}
+ }
+ // unexpected exception
+ catch (MediaException & excpt_r)
+ {
+ // FIXME: error number fix
+ report->finish(fileurl, zypp::media::DownloadProgressReport::ERROR, excpt_r.asUserString());
+ ZYPP_RETHROW(excpt_r);
+ }
+ }
+ while (retry);
+
+ report->finish(fileurl, zypp::media::DownloadProgressReport::NO_ERROR, "");
+}
+
+bool MediaAria2c::getDoesFileExist( const Pathname & filename ) const
+{
+ return true;
+ /*
+ bool retry = false;
+ CurlAuthData auth_data;
+
+ do
+ {
+ try
+ {
+ return doGetDoesFileExist( filename );
+ }
+ // authentication problem, retry with proper authentication data
+ catch (MediaUnauthorizedException & ex_r)
+ {
+ callback::SendReport<AuthenticationReport> auth_report;
+
+ if (!_url.getUsername().empty() && !retry)
+ auth_data.setUserName(_url.getUsername());
+
+ string prompt_msg;
+ if (retry || !_url.getUsername().empty())
+ prompt_msg = _("Invalid user name or password.");
+ else // first prompt
+ prompt_msg = boost::str(boost::format(
+ _("Authentication required for '%s'")) % _url.asString());
+
+ // set available authentication types from the exception
+ auth_data.setAuthType(ex_r.hint());
+
+ if (auth_report->prompt(_url, prompt_msg, auth_data))
+ {
+ DBG << "callback answer: retry" << endl
+ << "CurlAuthData: " << auth_data << endl;
+
+ if (auth_data.valid()) {
+ _userpwd = auth_data.getUserPwd();
+
+ // set username and password
+ //CURLcode ret = curl_easy_setopt(_curl, CURLOPT_USERPWD, _userpwd.c_str());
+ //if ( ret != 0 ) ZYPP_THROW(MediaAria2cSetOptException(_url, _curlError));
+
+ // set auth type
+ //ret = curl_easy_setopt(_curl, CURLOPT_HTTPAUTH, auth_data.authType());
+ //if ( ret != 0 ) ZYPP_THROW(MediaAria2cSetOptException(_url, _curlError));
+ }
+
+ retry = true;
+ }
+ else
+ {
+ DBG << "callback answer: cancel" << endl;
+ ZYPP_RETHROW(ex_r);
+ }
+ }
+ // unexpected exception
+ catch (MediaException & excpt_r)
+ {
+ ZYPP_RETHROW(excpt_r);
+ }
+ }
+ while (retry);
+
+ return false;
+*/
+}
+
+/*
+bool MediaAria2c::doGetDoesFileExist( const Pathname & filename ) const
+{
+
+ DBG << filename.asString() << endl;
+
+ if(!_url.isValid())
+ ZYPP_THROW(MediaBadUrlException(_url));
+
+ if(_url.getHost().empty())
+ ZYPP_THROW(MediaBadUrlEmptyHostException(_url));
+
+ string path = _url.getPathName();
+ if ( !path.empty() && path != "/" && *path.rbegin() == '/' &&
+ filename.absolute() ) {
+ // If url has a path with trailing slash, remove the leading slash from
+ // the absolute file name
+ path += filename.asString().substr( 1, filename.asString().size() - 1 );
+ } else if ( filename.relative() ) {
+ // Add trailing slash to path, if not already there
+ if ( !path.empty() && *path.rbegin() != '/' ) path += "/";
+ // Remove "./" from begin of relative file name
+ path += filename.asString().substr( 2, filename.asString().size() - 2 );
+ } else {
+ path += filename.asString();
+ }
+
+ Url url( _url );
+ url.setPathName( path );
+
+ DBG << "URL: " << url.asString() << endl;
+ // Use URL without options and without username and passwd
+ // (some proxies dislike them in the URL).
+ // Curl seems to need the just scheme, hostname and a path;
+ // the rest was already passed as curl options (in attachTo).
+ Url curlUrl( url );
+
+ // Use asString + url::ViewOptions instead?
+ curlUrl.setUsername( "" );
+ curlUrl.setPassword( "" );
+ curlUrl.setPathParams( "" );
+ curlUrl.setQueryString( "" );
+ curlUrl.setFragment( "" );
+
+ //
+ // See also Bug #154197 and ftp url definition in RFC 1738:
+ // The url "ftp://user@host/foo/bar/file" contains a path,
+ // that is relative to the user's home.
+ // The url "ftp://user@host//foo/bar/file" (or also with
+ // encoded slash as %2f) "ftp://user@host/%2ffoo/bar/file"
+ // contains an absolute path.
+ //
+ string urlBuffer( curlUrl.asString());
+ CURLcode ret = curl_easy_setopt( _curl, CURLOPT_URL,
+ urlBuffer.c_str() );
+ if ( ret != 0 ) {
+ ZYPP_THROW(MediaAria2cSetOptException(url, _curlError));
+ }
+
+ // instead of returning no data with NOBODY, we return
+ // little data, that works with broken servers, and
+ // works for ftp as well, because retrieving only headers
+ // ftp will return always OK code ?
+ if ( _url.getScheme() == "http" || _url.getScheme() == "https" )
+ ret = curl_easy_setopt( _curl, CURLOPT_NOBODY, 1 );
+ else
+ ret = curl_easy_setopt( _curl, CURLOPT_RANGE, "0-1" );
+
+ if ( ret != 0 ) {
+ curl_easy_setopt( _curl, CURLOPT_NOBODY, NULL );
+ curl_easy_setopt( _curl, CURLOPT_RANGE, NULL );
+ yes, this is why we never got to get NOBODY working before,
+ because setting it changes this option too, and we also
+ need to reset it
+ See: http://curl.haxx.se/mail/archive-2005-07/0073.html
+
+ curl_easy_setopt( _curl, CURLOPT_HTTPGET, 1 );
+ ZYPP_THROW(MediaAria2cSetOptException(url, _curlError));
+ }
+
+
+ FILE *file = ::fopen( "/dev/null", "w" );
+ if ( !file ) {
+ ::fclose(file);
+ ERR << "fopen failed for /dev/null" << endl;
+ curl_easy_setopt( _curl, CURLOPT_NOBODY, NULL );
+ curl_easy_setopt( _curl, CURLOPT_RANGE, NULL );
+ yes, this is why we never got to get NOBODY working before,
+ because setting it changes this option too, and we also
+ need to reset it
+ See: http://curl.haxx.se/mail/archive-2005-07/0073.html
+
+ curl_easy_setopt( _curl, CURLOPT_HTTPGET, 1 );
+ if ( ret != 0 ) {
+ ZYPP_THROW(MediaAria2cSetOptException(url, _curlError));
+ }
+ ZYPP_THROW(MediaWriteException("/dev/null"));
+ }
+
+ ret = curl_easy_setopt( _curl, CURLOPT_WRITEDATA, file );
+ if ( ret != 0 ) {
+ ::fclose(file);
+ std::string err( _curlError);
+ curl_easy_setopt( _curl, CURLOPT_RANGE, NULL );
+ curl_easy_setopt( _curl, CURLOPT_NOBODY, NULL );
+ yes, this is why we never got to get NOBODY working before,
+ because setting it changes this option too, and we also
+ need to reset it
+ See: http://curl.haxx.se/mail/archive-2005-07/0073.html
+
+ curl_easy_setopt( _curl, CURLOPT_HTTPGET, 1 );
+ if ( ret != 0 ) {
+ ZYPP_THROW(MediaAria2cSetOptException(url, _curlError));
+ }
+ ZYPP_THROW(MediaAria2cSetOptException(url, err));
+ }
+ // Set callback and perform.
+ //ProgressData progressData(_xfer_timeout, url, &report);
+ //report->start(url, dest);
+ //if ( curl_easy_setopt( _curl, CURLOPT_PROGRESSDATA, &progressData ) != 0 ) {
+ // WAR << "Can't set CURLOPT_PROGRESSDATA: " << _curlError << endl;;
+ //}
+
+ CURLcode ok = curl_easy_perform( _curl );
+ MIL << "perform code: " << ok << " [ " << curl_easy_strerror(ok) << " ]" << endl;
+
+ // reset curl settings
+ if ( _url.getScheme() == "http" || _url.getScheme() == "https" )
+ {
+ ret = curl_easy_setopt( _curl, CURLOPT_NOBODY, NULL );
+ yes, this is why we never got to get NOBODY working before,
+ because setting it changes this option too, and we also
+ need to reset it
+ See: http://curl.haxx.se/mail/archive-2005-07/0073.html
+
+ ret = curl_easy_setopt( _curl, CURLOPT_HTTPGET, 1 );
+ }
+ else
+ ret = curl_easy_setopt( _curl, CURLOPT_RANGE, NULL );
+
+ if ( ret != 0 )
+ {
+ ZYPP_THROW(MediaAria2cSetOptException(url, _curlError));
+ }
+
+ if ( ok != 0 )
+ {
+ ::fclose( file );
+
+ std::string err;
+ try
+ {
+ bool err_file_not_found = false;
+ switch ( ok )
+ {
+ case CURLE_FTP_COULDNT_RETR_FILE:
+ case CURLE_FTP_ACCESS_DENIED:
+ err_file_not_found = true;
+ break;
+ case CURLE_HTTP_RETURNED_ERROR:
+ {
+ long httpReturnCode = 0;
+ CURLcode infoRet = curl_easy_getinfo( _curl,
+ CURLINFO_RESPONSE_CODE,
+ &httpReturnCode );
+ if ( infoRet == CURLE_OK )
+ {
+ string msg = "HTTP response: " +
+ str::numstring( httpReturnCode );
+ if ( httpReturnCode == 401 )
+ {
+ std::string auth_hint = getAuthHint();
+
+ DBG << msg << " Login failed (URL: " << url.asString() << ")" << std::endl;
+ DBG << "MediaUnauthorizedException auth hint: '" << auth_hint << "'" << std::endl;
+
+ ZYPP_THROW(MediaUnauthorizedException(
+ url, "Login failed.", _curlError, auth_hint
+ ));
+ }
+ else
+ if ( httpReturnCode == 403)
+ {
+ ZYPP_THROW(MediaForbiddenException(url));
+ }
+ else
+ if ( httpReturnCode == 404)
+ {
+ err_file_not_found = true;
+ break;
+ }
+
+ msg += err;
+ DBG << msg << " (URL: " << url.asString() << ")" << std::endl;
+ ZYPP_THROW(MediaAria2cException(url, msg, _curlError));
+ }
+ else
+ {
+ string msg = "Unable to retrieve HTTP response:";
+ msg += err;
+ DBG << msg << " (URL: " << url.asString() << ")" << std::endl;
+ ZYPP_THROW(MediaAria2cException(url, msg, _curlError));
+ }
+ }
+ break;
+ case CURLE_UNSUPPORTED_PROTOCOL:
+ case CURLE_URL_MALFORMAT:
+ case CURLE_URL_MALFORMAT_USER:
+ case CURLE_BAD_PASSWORD_ENTERED:
+ case CURLE_FTP_USER_PASSWORD_INCORRECT:
+ err = "Login failed";
+ break;
+ case CURLE_COULDNT_RESOLVE_PROXY:
+ case CURLE_COULDNT_RESOLVE_HOST:
+ case CURLE_COULDNT_CONNECT:
+ case CURLE_FTP_CANT_GET_HOST:
+ err = "Connection failed";
+ break;
+ case CURLE_WRITE_ERROR:
+ err = "Write error";
+ break;
+ case CURLE_ABORTED_BY_CALLBACK:
+ case CURLE_OPERATION_TIMEOUTED:
+ err = "Timeout reached";
+ ZYPP_THROW(MediaTimeoutException(url));
+ break;
+ case CURLE_SSL_CACERT:
+ ZYPP_THROW(MediaBadCAException(url,_curlError));
+ case CURLE_SSL_PEER_CERTIFICATE:
+ default:
+ err = curl_easy_strerror(ok);
+ if (err.empty())
+ err = "Unrecognized error";
+ break;
+ }
+
+ if( err_file_not_found)
+ {
+ // file does not exists
+ return false;
+ }
+ else
+ {
+ // there was an error
+ ZYPP_THROW(MediaAria2cException(url, string(), _curlError));
+ }
+ }
+ catch (const MediaException & excpt_r)
+ {
+ ZYPP_RETHROW(excpt_r);
+ }
+ }
+
+ // exists
+ return ( ok == CURLE_OK );
+ //if ( curl_easy_setopt( _curl, CURLOPT_PROGRESSDATA, NULL ) != 0 ) {
+ // WAR << "Can't unset CURLOPT_PROGRESSDATA: " << _curlError << endl;;
+ //}
+
+}
+*/
+
+/*
+void MediaAria2c::doGetFileCopy( const Pathname & filename , const Pathname & target, callback::SendReport<DownloadProgressReport> & report) const
+{
+ DBG << filename.asString() << endl;
+
+ if(!_url.isValid())
+ ZYPP_THROW(MediaBadUrlException(_url));
+
+ if(_url.getHost().empty())
+ ZYPP_THROW(MediaBadUrlEmptyHostException(_url));
+
+ Url url(getFileUrl(_url, filename));
+
+ Pathname dest = target.absolutename();
+ if( assert_dir( dest.dirname() ) )
+ {
+ DBG << "assert_dir " << dest.dirname() << " failed" << endl;
+ ZYPP_THROW( MediaSystemException(url, "System error on " + dest.dirname().asString()) );
+ }
+
+ DBG << "URL: " << url.asString() << endl;
+ // Use URL without options and without username and passwd
+ // (some proxies dislike them in the URL).
+ // Curl seems to need the just scheme, hostname and a path;
+ // the rest was already passed as curl options (in attachTo).
+ Url curlUrl( url );
+
+ // Use asString + url::ViewOptions instead?
+ curlUrl.setUsername( "" );
+ curlUrl.setPassword( "" );
+ curlUrl.setPathParams( "" );
+ curlUrl.setQueryString( "" );
+ curlUrl.setFragment( "" );
+
+ //
+ // See also Bug #154197 and ftp url definition in RFC 1738:
+ // The url "ftp://user@host/foo/bar/file" contains a path,
+ // that is relative to the user's home.
+ // The url "ftp://user@host//foo/bar/file" (or also with
+ // encoded slash as %2f) "ftp://user@host/%2ffoo/bar/file"
+ // contains an absolute path.
+ //
+ string urlBuffer( curlUrl.asString());
+ CURLcode ret = curl_easy_setopt( _curl, CURLOPT_URL,
+ urlBuffer.c_str() );
+ if ( ret != 0 ) {
+ ZYPP_THROW(MediaAria2cSetOptException(url, _curlError));
+ }
+
+ // set IFMODSINCE time condition (no download if not modified)
+ curl_easy_setopt(_curl, CURLOPT_TIMECONDITION, CURL_TIMECOND_IFMODSINCE);
+ curl_easy_setopt(_curl, CURLOPT_TIMEVALUE, PathInfo(target).mtime());
+
+ string destNew = target.asString() + ".new.zypp.XXXXXX";
+ char *buf = ::strdup( destNew.c_str());
+ if( !buf)
+ {
+ ERR << "out of memory for temp file name" << endl;
+ ZYPP_THROW(MediaSystemException(
+ url, "out of memory for temp file name"
+ ));
+ }
+
+ int tmp_fd = ::mkstemp( buf );
+ if( tmp_fd == -1)
+ {
+ free( buf);
+ ERR << "mkstemp failed for file '" << destNew << "'" << endl;
+ ZYPP_THROW(MediaWriteException(destNew));
+ }
+ destNew = buf;
+ free( buf);
+
+ FILE *file = ::fdopen( tmp_fd, "w" );
+ if ( !file ) {
+ ::close( tmp_fd);
+ filesystem::unlink( destNew );
+ ERR << "fopen failed for file '" << destNew << "'" << endl;
+ ZYPP_THROW(MediaWriteException(destNew));
+ }
+
+ DBG << "dest: " << dest << endl;
+ DBG << "temp: " << destNew << endl;
+
+ ret = curl_easy_setopt( _curl, CURLOPT_WRITEDATA, file );
+ if ( ret != 0 ) {
+ ::fclose( file );
+ filesystem::unlink( destNew );
+ ZYPP_THROW(MediaAria2cSetOptException(url, _curlError));
+ }
+
+ // Set callback and perform.
+ ProgressData progressData(_xfer_timeout, url, &report);
+ report->start(url, dest);
+ if ( curl_easy_setopt( _curl, CURLOPT_PROGRESSDATA, &progressData ) != 0 ) {
+ WAR << "Can't set CURLOPT_PROGRESSDATA: " << _curlError << endl;;
+ }
+
+ ret = curl_easy_perform( _curl );
+
+ if ( curl_easy_setopt( _curl, CURLOPT_PROGRESSDATA, NULL ) != 0 ) {
+ WAR << "Can't unset CURLOPT_PROGRESSDATA: " << _curlError << endl;;
+ }
+
+ if ( ret != 0 ) {
+ ERR << "curl error: " << ret << ": " << _curlError
+ << ", temp file size " << PathInfo(destNew).size()
+ << " byte." << endl;
+
+ ::fclose( file );
+ filesystem::unlink( destNew );
+
+ std::string err;
+ try {
+ bool err_file_not_found = false;
+ switch ( ret ) {
+ case CURLE_UNSUPPORTED_PROTOCOL:
+ case CURLE_URL_MALFORMAT:
+ case CURLE_URL_MALFORMAT_USER:
+ err = " Bad URL";
+ case CURLE_HTTP_RETURNED_ERROR:
+ {
+ long httpReturnCode = 0;
+ CURLcode infoRet = curl_easy_getinfo( _curl,
+ CURLINFO_RESPONSE_CODE,
+ &httpReturnCode );
+ if ( infoRet == CURLE_OK ) {
+ string msg = "HTTP response: " +
+ str::numstring( httpReturnCode );
+ if ( httpReturnCode == 401 )
+ {
+ std::string auth_hint = getAuthHint();
+
+ DBG << msg << " Login failed (URL: " << url.asString() << ")" << std::endl;
+ DBG << "MediaUnauthorizedException auth hint: '" << auth_hint << "'" << std::endl;
+
+ ZYPP_THROW(MediaUnauthorizedException(
+ url, "Login failed.", _curlError, auth_hint
+ ));
+ }
+ else
+ if ( httpReturnCode == 403)
+ {
+ ZYPP_THROW(MediaForbiddenException(url));
+ }
+ else
+ if ( httpReturnCode == 404)
+ {
+ ZYPP_THROW(MediaFileNotFoundException(_url, filename));
+ }
+
+ msg += err;
+ DBG << msg << " (URL: " << url.asString() << ")" << std::endl;
+ ZYPP_THROW(MediaAria2cException(url, msg, _curlError));
+ }
+ else
+ {
+ string msg = "Unable to retrieve HTTP response:";
+ msg += err;
+ DBG << msg << " (URL: " << url.asString() << ")" << std::endl;
+ ZYPP_THROW(MediaAria2cException(url, msg, _curlError));
+ }
+ }
+ break;
+ case CURLE_FTP_COULDNT_RETR_FILE:
+ case CURLE_FTP_ACCESS_DENIED:
+ err = "File not found";
+ err_file_not_found = true;
+ break;
+ case CURLE_BAD_PASSWORD_ENTERED:
+ case CURLE_FTP_USER_PASSWORD_INCORRECT:
+ err = "Login failed";
+ break;
+ case CURLE_COULDNT_RESOLVE_PROXY:
+ case CURLE_COULDNT_RESOLVE_HOST:
+ case CURLE_COULDNT_CONNECT:
+ case CURLE_FTP_CANT_GET_HOST:
+ err = "Connection failed";
+ break;
+ case CURLE_WRITE_ERROR:
+ err = "Write error";
+ break;
+ case CURLE_ABORTED_BY_CALLBACK:
+ case CURLE_OPERATION_TIMEDOUT:
+ if( progressData.reached)
+ {
+ err = "Timeout reached";
+ ZYPP_THROW(MediaTimeoutException(url));
+ }
+ else
+ {
+ err = "User abort";
+ }
+ break;
+ case CURLE_SSL_PEER_CERTIFICATE:
+ default:
+ err = "Unrecognized error";
+ break;
+ }
+ if( err_file_not_found)
+ {
+ ZYPP_THROW(MediaFileNotFoundException(_url, filename));
+ }
+ else
+ {
+ ZYPP_THROW(MediaAria2cException(url, err, _curlError));
+ }
+ }
+ catch (const MediaException & excpt_r)
+ {
+ ZYPP_RETHROW(excpt_r);
+ }
+ }
+#if DETECT_DIR_INDEX
+ else
+ if(curlUrl.getScheme() == "http" ||
+ curlUrl.getScheme() == "https")
+ {
+ //
+ // try to check the effective url and set the not_a_file flag
+ // if the url path ends with a "/", what usually means, that
+ // we've received a directory index (index.html content).
+ //
+ // Note: This may be dangerous and break file retrieving in
+ // case of some server redirections ... ?
+ //
+ bool not_a_file = false;
+ char *ptr = NULL;
+ CURLcode ret = curl_easy_getinfo( _curl,
+ CURLINFO_EFFECTIVE_URL,
+ &ptr);
+ if ( ret == CURLE_OK && ptr != NULL)
+ {
+ try
+ {
+ Url eurl( ptr);
+ std::string path( eurl.getPathName());
+ if( !path.empty() && path != "/" && *path.rbegin() == '/')
+ {
+ DBG << "Effective url ("
+ << eurl
+ << ") seems to provide the index of a directory"
+ << endl;
+ not_a_file = true;
+ }
+ }
+ catch( ... )
+ {}
+ }
+
+ if( not_a_file)
+ {
+ ::fclose( file );
+ filesystem::unlink( destNew );
+ ZYPP_THROW(MediaNotAFileException(_url, filename));
+ }
+ }
+#endif // DETECT_DIR_INDEX
+
+ long httpReturnCode = 0;
+ CURLcode infoRet = curl_easy_getinfo(_curl,
+ CURLINFO_RESPONSE_CODE,
+ &httpReturnCode);
+ bool modified = true;
+ if (infoRet == CURLE_OK)
+ {
+ DBG << "HTTP response: " + str::numstring(httpReturnCode);
+ cout << "HTTP response: " + str::numstring(httpReturnCode);
+ if ( httpReturnCode == 304 ) // not modified
+ {
+ DBG << " Not modified.";
+ modified = false;
+ }
+ DBG << endl;
+ }
+ else
+ {
+ WAR << "Could not get the reponse code." << endl;
+ }
+
+ if (modified || infoRet != CURLE_OK)
+ {
+ // apply umask
+ if ( ::fchmod( ::fileno(file), filesystem::applyUmaskTo( 0644 ) ) )
+ {
+ ERR << "Failed to chmod file " << destNew << endl;
+ }
+ ::fclose( file );
+
+ // move the temp file into dest
+ if ( rename( destNew, dest ) != 0 ) {
+ ERR << "Rename failed" << endl;
+ ZYPP_THROW(MediaWriteException(dest));
+ }
+ }
+ else
+ {
+ // close and remove the temp file
+ ::fclose( file );
+ filesystem::unlink( destNew );
+ }
+
+ DBG << "done: " << PathInfo(dest) << endl;
+}
+*/
+
+
+///////////////////////////////////////////////////////////////////
+//
+//
+// METHOD NAME : MediaAria2c::getDir
+// METHOD TYPE : PMError
+//
+// DESCRIPTION : Asserted that media is attached
+//
+void MediaAria2c::getDir( const Pathname & dirname, bool recurse_r ) const
+{
+ filesystem::DirContent content;
+ getDirInfo( content, dirname, /*dots*/false );
+
+ for ( filesystem::DirContent::const_iterator it = content.begin(); it != content.end(); ++it ) {
+ Pathname filename = dirname + it->name;
+ int res = 0;
+
+ switch ( it->type ) {
+ case filesystem::FT_NOT_AVAIL: // old directory.yast contains no typeinfo at all
+ case filesystem::FT_FILE:
+ getFile( filename );
+ break;
+ case filesystem::FT_DIR: // newer directory.yast contain at least directory info
+ if ( recurse_r ) {
+ getDir( filename, recurse_r );
+ } else {
+ res = assert_dir( localPath( filename ) );
+ if ( res ) {
+ WAR << "Ignore error (" << res << ") on creating local directory '" << localPath( filename ) << "'" << endl;
+ }
+ }
+ break;
+ default:
+ // don't provide devices, sockets, etc.
+ break;
+ }
+ }
+}
+
+///////////////////////////////////////////////////////////////////
+//
+//
+// METHOD NAME : MediaAria2c::getDirInfo
+// METHOD TYPE : PMError
+//
+// DESCRIPTION : Asserted that media is attached and retlist is empty.
+//
+void MediaAria2c::getDirInfo( std::list<std::string> & retlist,
+ const Pathname & dirname, bool dots ) const
+{
+ getDirectoryYast( retlist, dirname, dots );
+}
+
+///////////////////////////////////////////////////////////////////
+//
+//
+// METHOD NAME : MediaAria2c::getDirInfo
+// METHOD TYPE : PMError
+//
+// DESCRIPTION : Asserted that media is attached and retlist is empty.
+//
+void MediaAria2c::getDirInfo( filesystem::DirContent & retlist,
+ const Pathname & dirname, bool dots ) const
+{
+ getDirectoryYast( retlist, dirname, dots );
+}
+
+///////////////////////////////////////////////////////////////////
+//
+//
+// METHOD NAME : MediaAria2c::getAria2cVersion
+//
+// DESCRIPTION : We get Aria2c version
+//
+std::string MediaAria2c::getAria2cVersion()
+{
+ const char* argv[] =
+ {
+ _aria2cPath.c_str(),
+ "--version",
+ NULL
+ };
+
+ ExternalProgram aria(argv, ExternalProgram::Stderr_To_Stdout);
+
+ std::string vResponse = aria.receiveLine();
+ aria.close();
+ return vResponse;
+}
+
+///////////////////////////////////////////////////////////////////
+//
+//
+// METHOD NAME : MediaAria2c::whereisAria2c
+//
+// DESCRIPTION : Get aria2c path
+//
+#define ARIA_DEFAULT_BINARY "/usr/bin/aria2c"
+
+Pathname MediaAria2c::whereisAria2c()
+{
+ Pathname aria2cPathr(ARIA_DEFAULT_BINARY);
+
+ const char* argv[] =
+ {
+ "whereis",
+ "-b",
+ "aria2c",
+ NULL
+ };
+
+ ExternalProgram aria(argv, ExternalProgram::Stderr_To_Stdout);
+
+ std::string ariaResponse( aria.receiveLine());
+ aria.close();
+
+ string::size_type pos = ariaResponse.find('/', 0 );
+ if( pos != string::npos )
+ {
+ aria2cPathr = ariaResponse;
+ string::size_type pose = ariaResponse.find(' ', pos + 1 );
+ aria2cPathr = ariaResponse.substr( pos , pose - pos );
+ MIL << "We will use aria2c located here: " << ariaResponse.substr( pos , pose - pos) << endl;
+ }
+ else
+ {
+ MIL << "We don't know were is ari2ac binary. We will use aria2c located here: " << aria2cPathr << endl;
+ }
+
+ return aria2cPathr;
+}
+
+///////////////////////////////////////////////////////////////////
+//
+//
+// METHOD NAME : MediaAria2c::progressCallback
+// METHOD TYPE : int
+//
+// DESCRIPTION : Progress callback triggered from MediaAria2c::getFile
+//
+/*
+int MediaAria2c::progressCallback( void *clientp,
+ double dltotal, double dlnow,
+ double ultotal, double ulnow)
+{
+ ProgressData *pdata = reinterpret_cast<ProgressData *>(clientp);
+ if( pdata)
+ {
+ time_t now = time(NULL);
+ if( now > 0)
+ {
+ // reset time of last change in case initial time()
+ // failed or the time was adjusted (goes backward)
+ if( pdata->ltime <= 0 || pdata->ltime > now)
+ {
+ pdata->ltime = now;
+ }
+
+ // start time counting as soon as first data arrives
+ // (skip the connection / redirection time at begin)
+ time_t dif = 0;
+ if (dlnow > 0 || ulnow > 0)
+ {
+ dif = (now - pdata->ltime);
+ dif = dif > 0 ? dif : 0;
+
+ pdata->secs += dif;
+ }
+
+ // update the drate_avg and drate_period only after a second has passed
+ // (this callback is called much more often than a second)
+ // otherwise the values would be far from accurate when measuring
+ // the time in seconds
+ //! \todo more accurate download rate computationn, e.g. compute average value from last 5 seconds, or work with milliseconds instead of seconds
+
+ if ( pdata->secs > 1 && (dif > 0 || dlnow == dltotal ))
+ pdata->drate_avg = (dlnow / pdata->secs);
+
+ if ( dif > 0 )
+ {
+ pdata->drate_period = ((dlnow - pdata->dload_period) / dif);
+ pdata->dload_period = dlnow;
+ }
+ }
+
+ // send progress report first, abort transfer if requested
+ if( pdata->report)
+ {
+ if (!(*(pdata->report))->progress(int( dlnow * 100 / dltotal ),
+ pdata->url,
+ pdata->drate_avg,
+ pdata->drate_period))
+ {
+ return 1; // abort transfer
+ }
+ }
+
+ // check if we there is a timeout set
+ if( pdata->timeout > 0)
+ {
+ if( now > 0)
+ {
+ bool progress = false;
+
+ // update download data if changed, mark progress
+ if( dlnow != pdata->dload)
+ {
+ progress = true;
+ pdata->dload = dlnow;
+ pdata->ltime = now;
+ }
+ // update upload data if changed, mark progress
+ if( ulnow != pdata->uload)
+ {
+ progress = true;
+ pdata->uload = ulnow;
+ pdata->ltime = now;
+ }
+
+ if( !progress && (now >= (pdata->ltime + pdata->timeout)))
+ {
+ pdata->reached = true;
+ return 1; // aborts transfer
+ }
+ }
+ }
+ }
+ return 0;
+}
+*/
+/*
+string MediaAria2c::getAuthHint() const
+{
+ long auth_info = CURLAUTH_NONE;
+
+ CURLcode infoRet =
+ curl_easy_getinfo(_curl, CURLINFO_HTTPAUTH_AVAIL, &auth_info);
+
+ if(infoRet == CURLE_OK)
+ {
+ return CurlAuthData::auth_type_long2str(auth_info);
+ }
+
+ return "";
+}*/
+
+ } // namespace media
+} // namespace zypp
+//
Added: trunk/libzypp/zypp/media/MediaAria2c.h
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/media/MediaAria2c.h…
==============================================================================
--- trunk/libzypp/zypp/media/MediaAria2c.h (added)
+++ trunk/libzypp/zypp/media/MediaAria2c.h Tue Sep 30 08:56:02 2008
@@ -0,0 +1,144 @@
+/*---------------------------------------------------------------------\
+| ____ _ __ __ ___ |
+| |__ / \ / / . \ . \ |
+| / / \ V /| _/ _/ |
+| / /__ | | | | | | |
+| /_____||_| |_| |_| |
+| |
+\---------------------------------------------------------------------*/
+/** \file zypp/media/MediaAria2c.h
+ *
+*/
+#ifndef ZYPP_MEDIA_MEDIAARIA2C_H
+#define ZYPP_MEDIA_MEDIAARIA2C_H
+
+#include "zypp/media/MediaHandler.h"
+#include "zypp/ZYppCallbacks.h"
+
+namespace zypp {
+ namespace media {
+
+///////////////////////////////////////////////////////////////////
+//
+// CLASS NAME : MediaAria2c
+/**
+ * @short Implementation class for FTP, HTTP and HTTPS MediaHandler using an external program (aria2c) to retrive files
+ * @author gfarrasb (gfarrasb(a)gmail.com)
+ * @see MediaHandler
+ **/
+class MediaAria2c : public MediaHandler {
+
+ public:
+ /**
+ * check if aria2c command line is present in the system
+ **/
+ static bool existsAria2cmd();
+
+ protected:
+ virtual void attachTo (bool next = false);
+ virtual void releaseFrom( const std::string & ejectDev );
+ virtual void getFile( const Pathname & filename ) const;
+ virtual void getDir( const Pathname & dirname, bool recurse_r ) const;
+ virtual void getDirInfo( std::list<std::string> & retlist,
+ const Pathname & dirname, bool dots = true ) const;
+ virtual void getDirInfo( filesystem::DirContent & retlist,
+ const Pathname & dirname, bool dots = true ) const;
+ /**
+ * Repeatedly calls doGetDoesFileExist() until it successfully returns,
+ * fails unexpectedly, or user cancels the operation. This is used to
+ * handle authentication or similar retry scenarios on media level.
+ */
+ virtual bool getDoesFileExist( const Pathname & filename ) const;
+
+ /**
+ * \see MediaHandler::getDoesFileExist
+ */
+ //virtual bool doGetDoesFileExist( const Pathname & filename ) const;
+
+ /**
+ *
+ * \throws MediaException
+ *
+ */
+ virtual void disconnectFrom();
+ /**
+ *
+ * \throws MediaException
+ *
+ */
+ virtual void getFileCopy( const Pathname & srcFilename, const Pathname & targetFilename) const;
+
+ /**
+ *
+ * \throws MediaException
+ *
+ */
+ //virtual void doGetFileCopy( const Pathname & srcFilename, const Pathname & targetFilename, callback::SendReport<DownloadProgressReport> & _report) const;
+
+
+ virtual bool checkAttachPoint(const Pathname &apoint) const;
+
+ public:
+
+ MediaAria2c( const Url & url_r,
+ const Pathname & attach_point_hint_r );
+
+ virtual ~MediaAria2c() { try { release(); } catch(...) {} }
+
+ //static void setCookieFile( const Pathname & );
+
+ class Callbacks
+ {
+ public:
+ virtual ~Callbacks() {}
+ virtual bool progress( int percent ) = 0;
+ };
+
+ protected:
+
+ //static int progressCallback( void *clientp, double dltotal, double dlnow,
+ // double ultotal, double ulnow );
+
+ /** The user agent string */
+ static const char *const agentString();
+
+
+ private:
+ /**
+ * Return a comma separated list of available authentication methods
+ * supported by server.
+ */
+ //std::string getAuthHint() const;
+
+
+ private:
+
+ //We don't use curl here
+ //CURL *_curl;
+ //char _curlError[ CURL_ERROR_SIZE ];
+ //long _curlDebug;
+
+ mutable std::string _userpwd;
+ std::string _proxy;
+ std::string _proxyuserpwd;
+ std::string _currentCookieFile;
+ std::string _ca_path;
+ long _xfer_timeout;
+
+ static Pathname _cookieFile;
+
+ /** Aria2c path */
+ Pathname whereisAria2c();
+ static Pathname _aria2cPath;
+
+ /** External process to get aria2c version */
+ std::string getAria2cVersion();
+ static std::string _aria2cVersion;
+};
+
+///////////////////////////////////////////////////////////////////
+
+ } // namespace media
+} // namespace zypp
+
+#endif // ZYPP_MEDIA_MEDIAARIA2C_H
--
To unsubscribe, e-mail: zypp-commit+unsubscribe(a)opensuse.org
For additional commands, e-mail: zypp-commit+help(a)opensuse.org
1
0
[zypp-commit] r11212 - in /trunk/libzypp: package/libzypp.changes zypp/CMakeLists.txt zypp/media/MediaAccess.cc zypp/media/MediaAccess.h zypp/media/MediaException.cc zypp/media/MediaException.h
by dmacvicar@svn.opensuse.org 29 Sep '08
by dmacvicar@svn.opensuse.org 29 Sep '08
29 Sep '08
Author: dmacvicar
Date: Tue Sep 30 00:04:58 2008
New Revision: 11212
URL: http://svn.opensuse.org/viewcvs/zypp?rev=11212&view=rev
Log:
- Merge aria2c Media handler code from Google SOC 2008
(Gerard Farras)
- Only activated by making env var ZYPP_ARIA=1
- various changes on merge:
- moved exist function to the Aria specific class
- close programs
- use arrays of commands instead of building strings
- some reformatting
- cleanup will come later
TODO: Move the exceptions also in the aria class.
NOTE: the default handler is still the curl one. We merge the code
so people can enable it and test it. But it can't be enabled without
setting the env variable.
Modified:
trunk/libzypp/package/libzypp.changes
trunk/libzypp/zypp/CMakeLists.txt
trunk/libzypp/zypp/media/MediaAccess.cc
trunk/libzypp/zypp/media/MediaAccess.h
trunk/libzypp/zypp/media/MediaException.cc
trunk/libzypp/zypp/media/MediaException.h
Modified: trunk/libzypp/package/libzypp.changes
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/package/libzypp.changes?…
==============================================================================
--- trunk/libzypp/package/libzypp.changes (original)
+++ trunk/libzypp/package/libzypp.changes Tue Sep 30 00:04:58 2008
@@ -1,4 +1,11 @@
-------------------------------------------------------------------
+Mon Sep 29 23:59:10 CEST 2008 - dmacvicar(a)suse.de
+
+- Merge aria2c Media handler code from Google SOC 2008
+ (Gerard Farras)
+- Only activated by making env var ZYPP_ARIA=1
+
+-------------------------------------------------------------------
Mon Sep 29 15:56:17 CEST 2008 - jkupec(a)suse.cz
- history: tell which package failed before logging rpm output or
Modified: trunk/libzypp/zypp/CMakeLists.txt
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/CMakeLists.txt?rev=…
==============================================================================
--- trunk/libzypp/zypp/CMakeLists.txt (original)
+++ trunk/libzypp/zypp/CMakeLists.txt Tue Sep 30 00:04:58 2008
@@ -258,6 +258,7 @@
media/MediaCIFS.cc
media/ProxyInfo.cc
media/MediaCurl.cc
+ media/MediaAria2c.cc
media/MediaISO.cc
media/MediaManager.cc
media/MediaUserAuth.cc
@@ -271,6 +272,7 @@
media/MediaCD.h
media/MediaCIFS.h
media/MediaCurl.h
+ media/MediaAria2c.h
media/MediaDIR.h
media/MediaDISK.h
media/MediaException.h
Modified: trunk/libzypp/zypp/media/MediaAccess.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/media/MediaAccess.c…
==============================================================================
--- trunk/libzypp/zypp/media/MediaAccess.cc (original)
+++ trunk/libzypp/zypp/media/MediaAccess.cc Tue Sep 30 00:04:58 2008
@@ -15,6 +15,7 @@
#include <iostream>
#include "zypp/base/Logger.h"
+#include "zypp/ExternalProgram.h"
#include "zypp/media/MediaException.h"
#include "zypp/media/MediaAccess.h"
@@ -27,6 +28,7 @@
#include "zypp/media/MediaSMB.h"
#include "zypp/media/MediaCIFS.h"
#include "zypp/media/MediaCurl.h"
+#include "zypp/media/MediaAria2c.h"
#include "zypp/media/MediaISO.h"
using namespace std;
@@ -126,7 +128,14 @@
else if (scheme == "cifs")
_handler = new MediaCIFS (url,preferred_attach_point);
else if (scheme == "ftp" || scheme == "http" || scheme == "https")
- _handler = new MediaCurl (url,preferred_attach_point);
+ {
+ // Another good idea would be activate MediaAria2c handler via external var
+ if ( getenv( "ZYPP_ARIA2C" ) &&
+ MediaAria2c::existsAria2cmd() )
+ _handler = new MediaAria2c (url,preferred_attach_point);
+ else
+ _handler = new MediaCurl (url,preferred_attach_point);
+ }
else
{
ZYPP_THROW(MediaUnsupportedUrlSchemeException(url));
Modified: trunk/libzypp/zypp/media/MediaAccess.h
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/media/MediaAccess.h…
==============================================================================
--- trunk/libzypp/zypp/media/MediaAccess.h (original)
+++ trunk/libzypp/zypp/media/MediaAccess.h Tue Sep 30 00:04:58 2008
@@ -72,9 +72,9 @@
void resetParentId();
bool dependsOnParent() const;
+
bool dependsOnParent(MediaAccessId parentId,
bool exactIdMatch) const;
-
public:
/**
Modified: trunk/libzypp/zypp/media/MediaException.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/media/MediaExceptio…
==============================================================================
--- trunk/libzypp/zypp/media/MediaException.cc (original)
+++ trunk/libzypp/zypp/media/MediaException.cc Tue Sep 30 00:04:58 2008
@@ -85,6 +85,22 @@
<< endl;
}
+ std::ostream & MediaMetalinkInitException::dumpOn( std::ostream & str) const
+ {
+ return str << form(
+ // TranslatorExplanation: curl is the name of a library, don't translate
+ _("Download (Metalink curl) initialization failed for '%s'"), _url.c_str())
+ << endl;
+ }
+
+ std::ostream & MediaAria2cInitException::dumpOn( std::ostream & str) const
+ {
+ return str << form(
+ // TranslatorExplanation: curl is the name of a library, don't translate
+ _("Download (Metalink curl) initialization failed for '%s'"), _url.c_str())
+ << endl;
+ }
+
std::ostream & MediaSystemException::dumpOn( std::ostream & str) const
{
return str << form(
@@ -163,6 +179,42 @@
<< endl << _msg << endl;
}
+ std::ostream & MediaMetalinkException::dumpOn( std::ostream & str) const
+ {
+ // TranslatorExplanation: curl is the name of a library, don't translate
+ return str << form(_(
+ "Download (metalink curl) error for '%s':\n"
+ "Error code: %s\n"
+ "Error message: %s\n"), _url.c_str(), _err.c_str(), _msg.c_str());
+ }
+
+ std::ostream & MediaMetalinkSetOptException::dumpOn( std::ostream & str) const
+ {
+ return str << form(
+ // TranslatorExplanation: curl is the name of a library, don't translate
+ _("Error occurred while setting download (metalink curl) options for '%s':"),
+ _url.c_str())
+ << endl << _msg << endl;
+ }
+
+ std::ostream & MediaAria2cException::dumpOn( std::ostream & str) const
+ {
+ // TranslatorExplanation: curl is the name of a library, don't translate
+ return str << form(_(
+ "Download (metalink curl) error for '%s':\n"
+ "Error code: %s\n"
+ "Error message: %s\n"), _url.c_str(), _err.c_str(), _msg.c_str());
+ }
+
+ std::ostream & MediaAria2cSetOptException::dumpOn( std::ostream & str) const
+ {
+ return str << form(
+ // TranslatorExplanation: curl is the name of a library, don't translate
+ _("Error occurred while setting download (metalink curl) options for '%s':"),
+ _url.c_str())
+ << endl << _msg << endl;
+ }
+
std::ostream & MediaNotDesiredException::dumpOn( std::ostream & str ) const
{
return str << form(
Modified: trunk/libzypp/zypp/media/MediaException.h
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/media/MediaExceptio…
==============================================================================
--- trunk/libzypp/zypp/media/MediaException.h (original)
+++ trunk/libzypp/zypp/media/MediaException.h Tue Sep 30 00:04:58 2008
@@ -214,6 +214,34 @@
std::string _url;
};
+class MediaMetalinkInitException : public MediaException
+ {
+ public:
+ MediaMetalinkInitException(const Url & url_r)
+ : MediaException()
+ , _url(url_r.asString())
+ {}
+ virtual ~MediaMetalinkInitException() throw() {};
+ protected:
+ virtual std::ostream & dumpOn( std::ostream & str ) const;
+ private:
+ std::string _url;
+ };
+
+class MediaAria2cInitException : public MediaException
+ {
+ public:
+ MediaAria2cInitException(const Url & url_r)
+ : MediaException()
+ , _url(url_r.asString())
+ {}
+ virtual ~MediaAria2cInitException() throw() {};
+ protected:
+ virtual std::ostream & dumpOn( std::ostream & str ) const;
+ private:
+ std::string _url;
+ };
+
class MediaSystemException : public MediaException
{
public:
@@ -372,6 +400,74 @@
std::string _msg;
};
+ class MediaMetalinkException : public MediaException
+ {
+ public:
+ MediaMetalinkException(const Url & url_r,
+ const std::string & err_r,
+ const std::string & msg_r)
+ : MediaException()
+ , _url(url_r.asString())
+ , _err(err_r)
+ , _msg(msg_r)
+ {}
+ virtual ~MediaMetalinkException() throw() {};
+ protected:
+ virtual std::ostream & dumpOn( std::ostream & str ) const;
+ std::string _url;
+ std::string _err;
+ std::string _msg;
+ };
+
+ class MediaMetalinkSetOptException : public MediaException
+ {
+ public:
+ MediaMetalinkSetOptException(const Url & url_r, const std::string & msg_r)
+ : MediaException()
+ , _url(url_r.asString())
+ , _msg(msg_r)
+ {}
+ virtual ~MediaMetalinkSetOptException() throw() {};
+ protected:
+ virtual std::ostream & dumpOn( std::ostream & str ) const;
+ std::string _url;
+ std::string _msg;
+ };
+
+ class MediaAria2cException : public MediaException
+ {
+ public:
+ MediaAria2cException(const Url & url_r,
+ const std::string & err_r,
+ const std::string & msg_r)
+ : MediaException()
+ , _url(url_r.asString())
+ , _err(err_r)
+ , _msg(msg_r)
+ {}
+ virtual ~MediaAria2cException() throw() {};
+ protected:
+ virtual std::ostream & dumpOn( std::ostream & str ) const;
+ std::string _url;
+ std::string _err;
+ std::string _msg;
+ };
+
+ class MediaAria2cSetOptException : public MediaException
+ {
+ public:
+ MediaAria2cSetOptException(const Url & url_r, const std::string & msg_r)
+ : MediaException()
+ , _url(url_r.asString())
+ , _msg(msg_r)
+ {}
+ virtual ~MediaAria2cSetOptException() throw() {};
+ protected:
+ virtual std::ostream & dumpOn( std::ostream & str ) const;
+ std::string _url;
+ std::string _msg;
+ };
+
class MediaNotDesiredException : public MediaException
{
public:
--
To unsubscribe, e-mail: zypp-commit+unsubscribe(a)opensuse.org
For additional commands, e-mail: zypp-commit+help(a)opensuse.org
1
0
29 Sep '08
Author: jkupec
Date: Mon Sep 29 22:50:11 2008
New Revision: 11211
URL: http://svn.opensuse.org/viewcvs/zypp?rev=11211&view=rev
Log:
- changes
Modified:
trunk/libzypp/package/libzypp.changes
Modified: trunk/libzypp/package/libzypp.changes
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/package/libzypp.changes?…
==============================================================================
--- trunk/libzypp/package/libzypp.changes (original)
+++ trunk/libzypp/package/libzypp.changes Mon Sep 29 22:50:11 2008
@@ -3,6 +3,7 @@
- history: tell which package failed before logging rpm output or
error message (bnc #430585)
+- no localization for history log comments
- revision 11202
-------------------------------------------------------------------
--
To unsubscribe, e-mail: zypp-commit+unsubscribe(a)opensuse.org
For additional commands, e-mail: zypp-commit+help(a)opensuse.org
1
0
[zypp-commit] r11210 - /trunk/libzypp/zypp/target/rpm/RpmDb.cc
by jkupec@svn.opensuse.org 29 Sep '08
by jkupec@svn.opensuse.org 29 Sep '08
29 Sep '08
Author: jkupec
Date: Mon Sep 29 22:48:05 2008
New Revision: 11210
URL: http://svn.opensuse.org/viewcvs/zypp?rev=11210&view=rev
Log:
- no localization for history log comments
Modified:
trunk/libzypp/zypp/target/rpm/RpmDb.cc
Modified: trunk/libzypp/zypp/target/rpm/RpmDb.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/target/rpm/RpmDb.cc…
==============================================================================
--- trunk/libzypp/zypp/target/rpm/RpmDb.cc (original)
+++ trunk/libzypp/zypp/target/rpm/RpmDb.cc Mon Sep 29 22:48:05 2008
@@ -2072,11 +2072,10 @@
if ( rpm_status != 0 )
{
historylog.comment(
- // %s = filename of rpm package
- str::form(_("%s install failed"), Pathname::basename(filename).c_str()),
+ str::form("%s install failed", Pathname::basename(filename).c_str()),
true /*timestamp*/);
ostringstream sstr;
- sstr << _("rpm output:") << endl << rpmmsg << endl;
+ sstr << "rpm output:" << endl << rpmmsg << endl;
historylog.comment(sstr.str());
// TranslatorExplanation the colon is followed by an error message
ZYPP_THROW(RpmSubprocessException(string(_("RPM failed: ")) +
@@ -2085,11 +2084,10 @@
else if ( ! rpmmsg.empty() )
{
historylog.comment(
- // %s = filename of rpm package
- str::form(_("%s installed ok"), Pathname::basename(filename).c_str()),
+ str::form("%s installed ok", Pathname::basename(filename).c_str()),
true /*timestamp*/);
ostringstream sstr;
- sstr << _("Additional rpm output:") << endl << rpmmsg << endl;
+ sstr << "Additional rpm output:" << endl << rpmmsg << endl;
historylog.comment(sstr.str());
}
}
@@ -2211,10 +2209,9 @@
if ( rpm_status != 0 )
{
historylog.comment(
- // %s = name of rpm package
- str::form(_("%s remove failed"), name_r.c_str()), true /*timestamp*/);
+ str::form("%s remove failed", name_r.c_str()), true /*timestamp*/);
ostringstream sstr;
- sstr << _("rpm output:") << endl << rpmmsg << endl;
+ sstr << "rpm output:" << endl << rpmmsg << endl;
historylog.comment(sstr.str());
// TranslatorExplanation the colon is followed by an error message
ZYPP_THROW(RpmSubprocessException(string(_("RPM failed: ")) +
@@ -2223,11 +2220,10 @@
else if ( ! rpmmsg.empty() )
{
historylog.comment(
- // %s = name of rpm package
- str::form(_("%s removed ok"), name_r.c_str()), true /*timestamp*/);
+ str::form("%s removed ok", name_r.c_str()), true /*timestamp*/);
ostringstream sstr;
- sstr << _("Additional rpm output:") << endl << rpmmsg << endl;
+ sstr << "Additional rpm output:" << endl << rpmmsg << endl;
historylog.comment(sstr.str());
}
}
--
To unsubscribe, e-mail: zypp-commit+unsubscribe(a)opensuse.org
For additional commands, e-mail: zypp-commit+help(a)opensuse.org
1
0
[zypp-commit] r11209 - in /trunk/zypper/po: cs.po da.po en_US.po fi.po fr.po gl.po hu.po it.po km.po ko.po nl.po ru.po sk.po zh_CN.po zh_TW.po
by jkupec@svn.opensuse.org 29 Sep '08
by jkupec@svn.opensuse.org 29 Sep '08
29 Sep '08
Author: jkupec
Date: Mon Sep 29 19:11:12 2008
New Revision: 11209
URL: http://svn.opensuse.org/viewcvs/zypp?rev=11209&view=rev
Log:
- old translations
Removed:
trunk/zypper/po/cs.po
trunk/zypper/po/da.po
trunk/zypper/po/en_US.po
trunk/zypper/po/fi.po
trunk/zypper/po/fr.po
trunk/zypper/po/gl.po
trunk/zypper/po/hu.po
trunk/zypper/po/it.po
trunk/zypper/po/km.po
trunk/zypper/po/ko.po
trunk/zypper/po/nl.po
trunk/zypper/po/ru.po
trunk/zypper/po/sk.po
trunk/zypper/po/zh_CN.po
trunk/zypper/po/zh_TW.po
--
To unsubscribe, e-mail: zypp-commit+unsubscribe(a)opensuse.org
For additional commands, e-mail: zypp-commit+help(a)opensuse.org
1
0