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 private: 00052 00054 // components provided 00056 00057 static InstTarget * _instTarget; 00058 00059 static InstSrcManager * _instSrcManager; 00060 00061 static PMPackageManager * _packageManager; 00062 00063 static PMSelectionManager * _selectionManager; 00064 00065 static PMYouPatchManager * _youPatchManager; 00066 00067 static PMLanguageManager * _languageManager; 00068 00069 static bool _languageManagerDirty; 00070 00071 static void cleanupAtExit(); 00072 00074 // 00075 // Rcfile 00076 // 00078 public: 00079 00080 static PMError rcInit(); 00081 static PMError rcSave(); 00082 static PMError rcCopyTo(); 00083 00085 // 00086 // package/selection candidate selection 00087 // 00089 public: 00090 00091 static PMError setCandidateOrder( PM::CandidateOrder neworder_r ); 00092 00094 // 00095 // target architecture 00096 // 00098 private: 00099 00103 static PkgArch _base_arch; 00107 static PM::ArchSet _allowed_archs; 00108 00109 public: 00110 00114 static PkgArch baseArch(); 00115 00119 static const PM::ArchSet & allowedArchs(void); 00120 static void setAllowedArchs(const PM::ArchSet & allowed_archs) { _allowed_archs = allowed_archs; } 00121 00123 // 00124 // Locale settings 00125 // 00127 public: 00128 00129 typedef PM::LocaleSet LocaleSet; 00130 typedef PM::LocaleOrder LocaleOrder; 00131 00136 static LocaleOrder getLocaleFallback( const LangCode & locale_r ); 00137 00141 static LocaleOrder getLocaleFallback() { 00142 return getLocaleFallback( getPreferredLocale() ); 00143 } 00144 00149 static const LangCode & getPreferredLocale(); 00150 00154 static PMError setPreferredLocale( const LangCode & preferred_locale_r ); 00155 00160 static const LocaleSet & getRequestedLocales(); 00161 00165 static PMError setRequestedLocales( const LocaleSet & requested_locales_r ); 00166 static PMError setRequestedLocales( const LangCode & requested_locale_r ) { 00167 LocaleSet tmpset; 00168 tmpset.insert( requested_locale_r ); 00169 return setRequestedLocales( tmpset ); 00170 } 00171 00172 private: 00173 friend class PMLanguageManager; 00177 static PMError addRequestedLocales( const LocaleSet & requested_locales_r ); 00178 static PMError addRequestedLocales( const LangCode & requested_locale_r ) { 00179 LocaleSet tmpset; 00180 tmpset.insert( requested_locale_r ); 00181 return addRequestedLocales( tmpset ); 00182 } 00183 00187 static PMError delRequestedLocales( const LocaleSet & requested_locales_r ); 00188 static PMError delRequestedLocales( const LangCode & requested_locale_r ) { 00189 LocaleSet tmpset; 00190 tmpset.insert( requested_locale_r ); 00191 return delRequestedLocales( tmpset ); 00192 } 00193 00194 private: 00195 00196 class LocaleSettings; 00197 static LocaleSettings & localeSettings(); 00198 00202 static PMError Y2PM::preferredLocaleChanged(); 00206 static PMError Y2PM::requestedLocalesChanged( const LocaleSet & addLocales_r, 00207 const LocaleSet & delLocales_r ); 00208 00209 public: 00210 00217 static bool runningFromSystem() { return( _system_rootdir == "/" ); } 00218 static void setNotRunningFromSystem() {_system_rootdir = Pathname(); } 00219 00224 static bool cacheToRamdisk() { return _cache_to_ramdisk; } 00225 static void setCacheToRamdisk( const bool val_r ) { _cache_to_ramdisk = val_r; } 00226 00227 public: 00228 00233 static InstTarget & instTarget(); 00234 00251 static PMError instTargetInit( Pathname root_r = "" ); 00252 00263 static PMError instTargetUpdate(); 00264 00269 static PMError instTargetClose(); 00270 00271 00281 static bool noAutoInstSrcManager(); 00282 00286 static bool hasInstSrcManager() { return _instSrcManager; } 00287 00291 static InstSrcManager & instSrcManager(); 00292 00298 static void ISM_RanksCanged(); 00299 00303 static PMPackageManager & packageManager(); 00304 00308 static PMSelectionManager & selectionManager(); 00309 00313 static PMLanguageManager & languageManager(); 00314 00318 static void languageManagerTagDirty() { _languageManagerDirty = true; } 00319 00323 static PMYouPatchManager & youPatchManager(); 00324 00328 static void packageSelectionSaveState(); 00332 static bool packageSelectionRestoreState(); 00336 static bool packageSelectionDiffState(); 00340 static void packageSelectionClearSaveState(); 00341 00342 public: 00343 00354 static int commitPackages( unsigned int media_nr, 00355 std::list<std::string>& errors_r, 00356 std::list<std::string>& remaining_r, 00357 std::list<std::string>& srcremaining_r ); 00359 static int commitPackages( unsigned int media_nr, 00360 std::list<std::string>& errors_r, 00361 std::list<std::string>& remaining_r, 00362 std::list<std::string>& srcremaining_r, 00363 PM::ISrcIdList installrank ) __attribute__ ((deprecated)); 00364 00368 static PMError installFile( const Pathname & path_r ); 00369 00373 static PMError removePackage( const std::string & pkgname_r ); 00374 }; 00375 00377 00378 #endif // Y2PM_h
1.4.4