You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

105 lines
3.5 KiB

  1. // -*- mode: cpp; mode: fold -*-
  2. // Description /*{{{*/
  3. /* ######################################################################
  4. System - Abstraction for running on different systems.
  5. Instances of this class can be thought of as factories or meta-classes
  6. for a variety of more specialized classes. Together this class and
  7. it's specialized offspring completely define the environment and how
  8. to access resources for a specific system. There are several sub
  9. areas that are all orthogonal - each system has a unique combination of
  10. these sub areas:
  11. - Versioning. Different systems have different ideas on versions.
  12. Within a system all sub classes must follow the same versioning
  13. rules.
  14. - Local tool locking to prevent multiple tools from accessing the
  15. same database.
  16. - Candidate Version selection policy - this is probably almost always
  17. managed using a standard APT class
  18. - Actual Package installation
  19. * Indication of what kind of binary formats are supported
  20. - Selection of local 'status' indexes that make up the pkgCache.
  21. It is important to note that the handling of index files is not a
  22. function of the system. Index files are handled through a separate
  23. abstraction - the only requirement is that the index files have the
  24. same idea of versioning as the target system.
  25. Upon startup each supported system instantiates an instance of the
  26. pkgSystem class (using a global constructor) which will make itself
  27. available to the main APT init routine. That routine will select the
  28. proper system and make it the global default.
  29. ##################################################################### */
  30. /*}}}*/
  31. #ifndef PKGLIB_PKGSYSTEM_H
  32. #define PKGLIB_PKGSYSTEM_H
  33. #include <apt-pkg/pkgcache.h>
  34. #include <apt-pkg/cacheiterators.h>
  35. #include <vector>
  36. #ifndef APT_8_CLEANER_HEADERS
  37. #include <apt-pkg/depcache.h>
  38. #endif
  39. class pkgDepCache;
  40. class pkgPackageManager;
  41. class pkgVersioningSystem;
  42. class Configuration;
  43. class pkgIndexFile;
  44. class pkgSystem
  45. {
  46. public:
  47. // Global list of supported systems
  48. static pkgSystem **GlobalList;
  49. static unsigned long GlobalListLen;
  50. static pkgSystem *GetSystem(const char *Label);
  51. const char * const Label;
  52. pkgVersioningSystem * const VS;
  53. /* Prevent other programs from touching shared data not covered by
  54. other locks (cache or state locks) */
  55. virtual bool Lock() = 0;
  56. virtual bool UnLock(bool NoErrors = false) = 0;
  57. /* Various helper classes to interface with specific bits of this
  58. environment */
  59. virtual pkgPackageManager *CreatePM(pkgDepCache *Cache) const = 0;
  60. /* Load environment specific configuration and perform any other setup
  61. necessary */
  62. virtual bool Initialize(Configuration &/*Cnf*/) {return true;};
  63. /* Type is some kind of Globally Unique way of differentiating
  64. archive file types.. */
  65. virtual bool ArchiveSupported(const char *Type) = 0;
  66. // Return a list of system index files..
  67. virtual bool AddStatusFiles(std::vector<pkgIndexFile *> &List) = 0;
  68. virtual bool FindIndex(pkgCache::PkgFileIterator File,
  69. pkgIndexFile *&Found) const = 0;
  70. /* Evauluate how 'right' we are for this system based on the filesystem
  71. etc.. */
  72. virtual signed Score(Configuration const &/*Cnf*/) {
  73. return 0;
  74. };
  75. pkgSystem(char const * const Label, pkgVersioningSystem * const VS);
  76. virtual ~pkgSystem();
  77. private:
  78. void * const d;
  79. };
  80. // The environment we are operating in.
  81. extern pkgSystem *_system;
  82. #endif