ref: refs/heads/ma-misc
commit d7ecdc1232a8b6381b9266a06053970e6aab1eb7
Author: Michael Andres
Date: Tue Aug 4 16:18:36 2009 +0200
Create misc subdirectory
---
zypp/CMakeLists.txt | 16 +++++-
zypp/Misc.cc | 111 ----------------------------------------
zypp/Misc.h | 63 ----------------------
zypp/misc/DefaultLoadSystem.cc | 111 ++++++++++++++++++++++++++++++++++++++++
zypp/misc/DefaultLoadSystem.h | 63 ++++++++++++++++++++++
5 files changed, 188 insertions(+), 176 deletions(-)
diff --git a/zypp/CMakeLists.txt b/zypp/CMakeLists.txt
index 846e3cb..dae0fd9 100644
--- a/zypp/CMakeLists.txt
+++ b/zypp/CMakeLists.txt
@@ -32,7 +32,6 @@ SET( zypp_SRCS
Locks.cc
MediaProducts.cc
MediaSetAccess.cc
- Misc.cc
NameKindProxy.cc
OnMediaLocation.cc
Package.cc
@@ -120,7 +119,6 @@ SET( zypp_HEADERS
ManagedFile.h
MediaProducts.h
MediaSetAccess.h
- Misc.h
NameKindProxy.h
Vendor.h
OnMediaLocation.h
@@ -761,8 +759,21 @@ SET( zypp_ws_HEADERS
ws/WebpinResult.h
)
+####################################################################
+
+SET( zypp_misc_HEADERS
+ Misc.h
+ misc/DefaultLoadSystem.h
+)
+
+SET( zypp_misc_SRCS
+ misc/DefaultLoadSystem.cc
+)
+
+####################################################################
SET( zypp_lib_SRCS
+${zypp_misc_SRCS}
${zypp_pool_SRCS}
${zypp_parser_susetags_SRCS}
${zypp_parser_xml_SRCS}
@@ -820,6 +831,7 @@ ${zypp_source_susetags_HEADERS}
${zypp_target_modalias_HEADERS}
${zypp_target_HEADERS}
${zypp_pool_HEADERS}
+${zypp_misc_HEADERS}
)
#
diff --git a/zypp/Misc.cc b/zypp/Misc.cc
deleted file mode 100644
index 8683f6c..0000000
--- a/zypp/Misc.cc
+++ /dev/null
@@ -1,111 +0,0 @@
-/*---------------------------------------------------------------------\
-| ____ _ __ __ ___ |
-| |__ / \ / / . \ . \ |
-| / / \ V /| _/ _/ |
-| / /__ | | | | | | |
-| /_____||_| |_| |_| |
-| |
-\---------------------------------------------------------------------*/
-/** \file zypp/Misc.cc
- *
-*/
-#include <iostream>
-
-#include "zypp/base/LogTools.h"
-#include "zypp/PathInfo.h"
-
-#include "zypp/Misc.h"
-
-#include "zypp/ZYppFactory.h"
-#include "zypp/zypp_detail/ZYppReadOnlyHack.h"
-#include "zypp/Target.h"
-#include "zypp/RepoManager.h"
-#include "zypp/sat/Pool.h"
-
-using std::endl;
-
-#undef ZYPP_BASE_LOGGER_LOGGROUP
-#define ZYPP_BASE_LOGGER_LOGGROUP "zypp::misc"
-
-///////////////////////////////////////////////////////////////////
-namespace zypp
-{ /////////////////////////////////////////////////////////////////
- ///////////////////////////////////////////////////////////////////
- namespace misc
- { /////////////////////////////////////////////////////////////////
-
- void defaultLoadSystem( const Pathname & sysRoot_r, LoadSystemFlags flags_r )
- {
- MIL << str::form( "*** Load system at '%s' (%lx)", sysRoot_r.c_str(), (unsigned long)flags_r ) << endl;
-
- if ( ! PathInfo( sysRoot_r ).isDir() )
- ZYPP_THROW( Exception(str::form("sysRoot_r argument needs to be a directory. (%s)", sysRoot_r.c_str())) );
-
- if ( ZYppFactory::instance().haveZYpp() )
- ZYPP_THROW( Exception("ZYpp instance is already created. (Call this method earlier.)") );
-
- if ( flags_r.testFlag( LS_READONLY ) )
- zypp_readonly_hack::IWantIt ();
-
- sat::Pool satpool( sat::Pool::instance() );
-
- if ( 1 )
- {
- MIL << "*** load target '" << Repository::systemRepoAlias() << "'\t" << endl;
- getZYpp()->initializeTarget( sysRoot_r );
- getZYpp()->target()->load();
- MIL << satpool.systemRepo() << endl;
- }
-
- if ( 1 )
- {
- RepoManager repoManager( sysRoot_r );
- RepoInfoList repos = repoManager.knownRepositories();
- for_( it, repos.begin(), repos.end() )
- {
- RepoInfo & nrepo( *it );
-
- if ( ! nrepo.enabled() )
- continue;
-
- if ( ! flags_r.testFlag( LS_NOREFRESH ) )
- {
- if ( repoManager.isCached( nrepo )
- && ( nrepo.type() == repo::RepoType::RPMPLAINDIR // refreshes always
- || repoManager.checkIfToRefreshMetadata( nrepo, nrepo.url() ) == RepoManager::REFRESH_NEEDED ) )
- {
- MIL << str::form( "*** clean cache for repo '%s'\t", nrepo.name().c_str() ) << endl;
- repoManager.cleanCache( nrepo );
- MIL << str::form( "*** refresh repo '%s'\t", nrepo.name().c_str() ) << endl;
- repoManager.refreshMetadata( nrepo );
- }
- }
-
- if ( ! repoManager.isCached( nrepo ) )
- {
- MIL << str::form( "*** build cache for repo '%s'\t", nrepo.name().c_str() ) << endl;
- repoManager.buildCache( nrepo );
- }
-
- MIL << str::form( "*** load repo '%s'\t", nrepo.name().c_str() ) << std::flush;
- try
- {
- repoManager.loadFromCache( nrepo );
- MIL << satpool.reposFind( nrepo.alias() ) << endl;
- }
- catch ( const Exception & exp )
- {
- ERR << "*** load repo failed: " << exp.asString() + "\n" + exp.historyAsString() << endl;
- ZYPP_RETHROW ( exp );
- }
- }
- }
- MIL << str::form( "*** Read system at '%s'", sysRoot_r.c_str() ) << endl;
- }
-
- /////////////////////////////////////////////////////////////////
- } // namespace misc
- ///////////////////////////////////////////////////////////////////
- /////////////////////////////////////////////////////////////////
-} // namespace zypp
-///////////////////////////////////////////////////////////////////
diff --git a/zypp/Misc.h b/zypp/Misc.h
deleted file mode 100644
index d8c4c1a..0000000
--- a/zypp/Misc.h
+++ /dev/null
@@ -1,63 +0,0 @@
-/*---------------------------------------------------------------------\
-| ____ _ __ __ ___ |
-| |__ / \ / / . \ . \ |
-| / / \ V /| _/ _/ |
-| / /__ | | | | | | |
-| /_____||_| |_| |_| |
-| |
-\---------------------------------------------------------------------*/
-/** \file zypp/Misc.h
- *
-*/
-#ifndef ZYPP_MISC_H
-#define ZYPP_MISC_H
-
-#include <iosfwd>
-
-#include "zypp/Pathname.h"
-#include "zypp/base/Flags.h"
-
-///////////////////////////////////////////////////////////////////
-namespace zypp
-{ /////////////////////////////////////////////////////////////////
- ///////////////////////////////////////////////////////////////////
- namespace misc
- { /////////////////////////////////////////////////////////////////
-
- /**
- * Bits for tuning \ref defaultLoadSystem.
- *
- * Use \ref LoadSystemFlags as a type-safe way of
- * storing OR-combinations.
- */
- enum LoadSystemFlag
- {
- LS_READONLY = (1 << 0), //!< // Create readonly ZYpp instance.
- LS_NOREFRESH = (1 << 1) //!< // Don't refresh existing repos.
- };
-
- /** \relates LoadSystemFlag Type-safe way of storing OR-combinations. */
- ZYPP_DECLARE_FLAGS_AND_OPERATORS( LoadSystemFlags, LoadSystemFlag );
-
- /**
- * Create the ZYpp instance and load target and enabled repositories.
- *
- * \see LoadSystemFlag for options.
- *
- * \throws Exception on error
- *
- * \todo properly handle service refreshs
- */
- void defaultLoadSystem( const Pathname & sysRoot_r = "/", LoadSystemFlags flags_r = LoadSystemFlags() );
-
- /** \overload */
- inline void defaultLoadSystem( LoadSystemFlags flags_r )
- { defaultLoadSystem( "/", flags_r ); }
-
- /////////////////////////////////////////////////////////////////
- } // namespace misc
- ///////////////////////////////////////////////////////////////////
- /////////////////////////////////////////////////////////////////
-} // namespace zypp
-///////////////////////////////////////////////////////////////////
-#endif // ZYPP_MISC_H
diff --git a/zypp/misc/DefaultLoadSystem.cc b/zypp/misc/DefaultLoadSystem.cc
new file mode 100644
index 0000000..abb24fb
--- /dev/null
+++ b/zypp/misc/DefaultLoadSystem.cc
@@ -0,0 +1,111 @@
+/*---------------------------------------------------------------------\
+| ____ _ __ __ ___ |
+| |__ / \ / / . \ . \ |
+| / / \ V /| _/ _/ |
+| / /__ | | | | | | |
+| /_____||_| |_| |_| |
+| |
+\---------------------------------------------------------------------*/
+/** \file zypp/misc/DefaultLoadSystem.cc
+ *
+*/
+#include <iostream>
+
+#include "zypp/base/LogTools.h"
+#include "zypp/PathInfo.h"
+
+#include "zypp/misc/DefaultLoadSystem.h"
+
+#include "zypp/ZYppFactory.h"
+#include "zypp/zypp_detail/ZYppReadOnlyHack.h"
+#include "zypp/Target.h"
+#include "zypp/RepoManager.h"
+#include "zypp/sat/Pool.h"
+
+using std::endl;
+
+#undef ZYPP_BASE_LOGGER_LOGGROUP
+#define ZYPP_BASE_LOGGER_LOGGROUP "zypp::misc"
+
+///////////////////////////////////////////////////////////////////
+namespace zypp
+{ /////////////////////////////////////////////////////////////////
+ ///////////////////////////////////////////////////////////////////
+ namespace misc
+ { /////////////////////////////////////////////////////////////////
+
+ void defaultLoadSystem( const Pathname & sysRoot_r, LoadSystemFlags flags_r )
+ {
+ MIL << str::form( "*** Load system at '%s' (%lx)", sysRoot_r.c_str(), (unsigned long)flags_r ) << endl;
+
+ if ( ! PathInfo( sysRoot_r ).isDir() )
+ ZYPP_THROW( Exception(str::form("sysRoot_r argument needs to be a directory. (%s)", sysRoot_r.c_str())) );
+
+ if ( ZYppFactory::instance().haveZYpp() )
+ ZYPP_THROW( Exception("ZYpp instance is already created. (Call this method earlier.)") );
+
+ if ( flags_r.testFlag( LS_READONLY ) )
+ zypp_readonly_hack::IWantIt ();
+
+ sat::Pool satpool( sat::Pool::instance() );
+
+ if ( 1 )
+ {
+ MIL << "*** load target '" << Repository::systemRepoAlias() << "'\t" << endl;
+ getZYpp()->initializeTarget( sysRoot_r );
+ getZYpp()->target()->load();
+ MIL << satpool.systemRepo() << endl;
+ }
+
+ if ( 1 )
+ {
+ RepoManager repoManager( sysRoot_r );
+ RepoInfoList repos = repoManager.knownRepositories();
+ for_( it, repos.begin(), repos.end() )
+ {
+ RepoInfo & nrepo( *it );
+
+ if ( ! nrepo.enabled() )
+ continue;
+
+ if ( ! flags_r.testFlag( LS_NOREFRESH ) )
+ {
+ if ( repoManager.isCached( nrepo )
+ && ( nrepo.type() == repo::RepoType::RPMPLAINDIR // refreshes always
+ || repoManager.checkIfToRefreshMetadata( nrepo, nrepo.url() ) == RepoManager::REFRESH_NEEDED ) )
+ {
+ MIL << str::form( "*** clean cache for repo '%s'\t", nrepo.name().c_str() ) << endl;
+ repoManager.cleanCache( nrepo );
+ MIL << str::form( "*** refresh repo '%s'\t", nrepo.name().c_str() ) << endl;
+ repoManager.refreshMetadata( nrepo );
+ }
+ }
+
+ if ( ! repoManager.isCached( nrepo ) )
+ {
+ MIL << str::form( "*** build cache for repo '%s'\t", nrepo.name().c_str() ) << endl;
+ repoManager.buildCache( nrepo );
+ }
+
+ MIL << str::form( "*** load repo '%s'\t", nrepo.name().c_str() ) << std::flush;
+ try
+ {
+ repoManager.loadFromCache( nrepo );
+ MIL << satpool.reposFind( nrepo.alias() ) << endl;
+ }
+ catch ( const Exception & exp )
+ {
+ ERR << "*** load repo failed: " << exp.asString() + "\n" + exp.historyAsString() << endl;
+ ZYPP_RETHROW ( exp );
+ }
+ }
+ }
+ MIL << str::form( "*** Read system at '%s'", sysRoot_r.c_str() ) << endl;
+ }
+
+ /////////////////////////////////////////////////////////////////
+ } // namespace misc
+ ///////////////////////////////////////////////////////////////////
+ /////////////////////////////////////////////////////////////////
+} // namespace zypp
+///////////////////////////////////////////////////////////////////
diff --git a/zypp/misc/DefaultLoadSystem.h b/zypp/misc/DefaultLoadSystem.h
new file mode 100644
index 0000000..3b8b1aa
--- /dev/null
+++ b/zypp/misc/DefaultLoadSystem.h
@@ -0,0 +1,63 @@
+/*---------------------------------------------------------------------\
+| ____ _ __ __ ___ |
+| |__ / \ / / . \ . \ |
+| / / \ V /| _/ _/ |
+| / /__ | | | | | | |
+| /_____||_| |_| |_| |
+| |
+\---------------------------------------------------------------------*/
+/** \file zypp/misc/DefaultLoadSystem.h
+ *
+*/
+#ifndef ZYPP_MISC_DEFAULTLOADSYSTEM_H
+#define ZYPP_MISC_DEFAULTLOADSYSTEM_H
+
+#include <iosfwd>
+
+#include "zypp/Pathname.h"
+#include "zypp/base/Flags.h"
+
+///////////////////////////////////////////////////////////////////
+namespace zypp
+{ /////////////////////////////////////////////////////////////////
+ ///////////////////////////////////////////////////////////////////
+ namespace misc
+ { /////////////////////////////////////////////////////////////////
+
+ /**
+ * Bits for tuning \ref defaultLoadSystem.
+ *
+ * Use \ref LoadSystemFlags as a type-safe way of
+ * storing OR-combinations.
+ */
+ enum LoadSystemFlag
+ {
+ LS_READONLY = (1 << 0), //!< // Create readonly ZYpp instance.
+ LS_NOREFRESH = (1 << 1) //!< // Don't refresh existing repos.
+ };
+
+ /** \relates LoadSystemFlag Type-safe way of storing OR-combinations. */
+ ZYPP_DECLARE_FLAGS_AND_OPERATORS( LoadSystemFlags, LoadSystemFlag );
+
+ /**
+ * Create the ZYpp instance and load target and enabled repositories.
+ *
+ * \see LoadSystemFlag for options.
+ *
+ * \throws Exception on error
+ *
+ * \todo properly handle service refreshs
+ */
+ void defaultLoadSystem( const Pathname & sysRoot_r = "/", LoadSystemFlags flags_r = LoadSystemFlags() );
+
+ /** \overload */
+ inline void defaultLoadSystem( LoadSystemFlags flags_r )
+ { defaultLoadSystem( "/", flags_r ); }
+
+ /////////////////////////////////////////////////////////////////
+ } // namespace misc
+ ///////////////////////////////////////////////////////////////////
+ /////////////////////////////////////////////////////////////////
+} // namespace zypp
+///////////////////////////////////////////////////////////////////
+#endif // ZYPP_MISC_DEFAULTLOADSYSTEM_H
--
To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org
For additional commands, e-mail: zypp-commit+help@opensuse.org