00001 /*---------------------------------------------------------------------\ 00002 | | 00003 | __ __ ____ _____ ____ | 00004 | \ \ / /_ _/ ___|_ _|___ \ | 00005 | \ V / _` \___ \ | | __) | | 00006 | | | (_| |___) || | / __/ | 00007 | |_|\__,_|____/ |_| |_____| | 00008 | | 00009 | core system | 00010 | (C) SuSE GmbH | 00011 \----------------------------------------------------------------------/ 00012 00013 File: Y2PM.h 00014 00015 Author: Michael Andres <ma@suse.de> 00016 Maintainer: Michael Andres <ma@suse.de> 00017 00018 Purpose: Core class providing access to all components of the 00019 Package Management creating them on demand. 00020 00021 /-*/ 00022 #ifndef Y2PM_h 00023 #define Y2PM_h 00024 00025 #include <iosfwd> 00026 #include <string> 00027 00028 #include <y2util/Pathname.h> 00029 00030 #include <y2pm/PMTypes.h> 00031 00033 // 00034 // CLASS NAME : Y2PM 00039 class Y2PM { 00040 00041 private: 00042 00044 // global settings 00046 00047 static Pathname _system_rootdir; 00048 00049 static bool _cache_to_ramdisk; 00050 00051 // the current base architecture of the target 00052 static PkgArch _base_arch; 00053 // the current list of allowed architectures 00054 static PM::ArchSet _allowed_archs; 00055 00056 private: 00057 00059 // components provided 00061 00062 static InstTarget * _instTarget; 00063 00064 static InstSrcManager * _instSrcManager; 00065 00066 static PMPackageManager * _packageManager; 00067 00068 static PMSelectionManager * _selectionManager; 00069 00070 static PMYouPatchManager * _youPatchManager; 00071 00072 static void cleanupAtExit(); 00073 00075 // 00076 // Rcfile 00077 // 00079 public: 00080 00081 static PMError rcInit(); 00082 static PMError rcSave(); 00083 static PMError rcCopyTo(); 00084 00086 // 00087 // package/selection candidate selection 00088 // 00090 public: 00091 00092 static PMError setCandidateOrder( PM::CandidateOrder neworder_r ); 00093 00095 // 00096 // Locale settings 00097 // 00099 public: 00100 00101 typedef PM::LocaleSet LocaleSet; 00102 typedef PM::LocaleOrder LocaleOrder; 00103 00108 static LocaleOrder getLocaleFallback( const LangCode & locale_r ); 00109 00113 static LocaleOrder getLocaleFallback() { 00114 return getLocaleFallback( getPreferredLocale() ); 00115 } 00116 00121 static const LangCode & getPreferredLocale(); 00122 00126 static PMError setPreferredLocale( const LangCode & preferred_locale_r ); 00127 00132 static const LocaleSet & getRequestedLocales(); 00133 00137 static PMError setRequestedLocales( const LocaleSet & requested_locales_r ); 00138 static PMError setRequestedLocales( const LangCode & requested_locale_r ) { 00139 LocaleSet tmpset; 00140 tmpset.insert( requested_locale_r ); 00141 return setRequestedLocales( tmpset ); 00142 } 00143 00147 static PMError addRequestedLocales( const LocaleSet & requested_locales_r ); 00148 static PMError addRequestedLocales( const LangCode & requested_locale_r ) { 00149 LocaleSet tmpset; 00150 tmpset.insert( requested_locale_r ); 00151 return addRequestedLocales( tmpset ); 00152 } 00153 00157 static PMError delRequestedLocales( const LocaleSet & requested_locales_r ); 00158 static PMError delRequestedLocales( const LangCode & requested_locale_r ) { 00159 LocaleSet tmpset; 00160 tmpset.insert( requested_locale_r ); 00161 return delRequestedLocales( tmpset ); 00162 } 00163 00164 private: 00165 00166 class LocaleSettings; 00167 static LocaleSettings & localeSettings(); 00168 00172 static PMError Y2PM::preferredLocaleChanged(); 00176 static PMError Y2PM::requestedLocalesChanged( const LocaleSet & addLocales_r, 00177 const LocaleSet & delLocales_r ); 00178 00179 public: 00180 00184 static PkgArch baseArch(void); 00185 00189 static const PM::ArchSet & allowedArchs(void) { return _allowed_archs; } 00190 static void setAllowedArchs(const PM::ArchSet & allowed_archs) { _allowed_archs = allowed_archs; } 00191 00198 static bool runningFromSystem() { return( _system_rootdir == "/" ); } 00199 static void setNotRunningFromSystem() {_system_rootdir = Pathname(); } 00200 00205 static bool cacheToRamdisk() { return _cache_to_ramdisk; } 00206 static void setCacheToRamdisk( const bool val_r ) { _cache_to_ramdisk = val_r; } 00207 00208 public: 00209 00214 static InstTarget & instTarget(); 00215 00232 static PMError instTargetInit( Pathname root_r = "" ); 00233 00244 static PMError instTargetUpdate(); 00245 00250 static PMError instTargetClose(); 00251 00252 00262 static bool noAutoInstSrcManager(); 00263 00267 static bool hasInstSrcManager() { return _instSrcManager; } 00268 00272 static InstSrcManager & instSrcManager(); 00273 00279 static void ISM_RanksCanged(); 00280 00284 static PMPackageManager & packageManager(); 00285 00289 static PMSelectionManager & selectionManager(); 00290 00294 static PMYouPatchManager & youPatchManager(); 00295 00299 static void packageSelectionSaveState(); 00303 static bool packageSelectionRestoreState(); 00307 static bool packageSelectionDiffState(); 00311 static void packageSelectionClearSaveState(); 00312 00313 public: 00314 00325 static int commitPackages( unsigned int media_nr, 00326 std::list<std::string>& errors_r, 00327 std::list<std::string>& remaining_r, 00328 std::list<std::string>& srcremaining_r ); 00330 static int commitPackages( unsigned int media_nr, 00331 std::list<std::string>& errors_r, 00332 std::list<std::string>& remaining_r, 00333 std::list<std::string>& srcremaining_r, 00334 PM::ISrcIdList installrank ); 00335 00339 static PMError installFile( const Pathname & path_r ); 00340 00344 static PMError removePackage( const std::string & pkgname_r ); 00345 }; 00346 00348 00349 #endif // Y2PM_h