Main Page | Class Hierarchy | Class List | Directories | File List | Class Members | File Members

packagemanager.h

Go to the documentation of this file.
00001 /*!\file packagemanager.h
00002         \brief Declerations for PackageManager and Virtual.
00003         Should be included in every interface that uses the PackageManager.*/
00004 
00005 #ifndef __PACKAGEMANAGER_H__
00006 #define __PACKAGEMANAGER_H__
00007 
00008 #include "packageversiondatabase.h"
00009 #include "packagedatabase.h"
00010 #include "package.h"
00011 #include "packageversion.h"
00012 #include "installeddatabase.h"
00013 #include "installedpackage.h"
00014 #include <vector>
00015 #include "pmstring.h"
00016 #include "pstream.h"
00017 
00018 /*NF means Not Fixing.
00019   NF - known issue with purge dist and not up to date, portage deletes ebuild
00020   NF - output is in wrong order - problem with popen or something
00021   NF - issue with having virtuals already provided in the list, ie someone does semerge xfree gnome will install xorg and xfree
00022   NF - dont check dependencies when we upgrade
00023   NF - cant work out dependencies of a vector of packageversions. This could prove to be a problem*/
00024 
00025 //!Small struct to contain info about virtuals.
00026 /*!Virtual is a struct that encapsulates all the info about a virtual. i.e. its
00027   text based form and its category/name version.*/
00028 struct Virtual
00029 {
00030         PMString virtualString; //!<The virtual string form of the virtual, i.e. virtual/x11.
00031         PMString category;              //!<The category of the corresponding package.
00032         PMString name;                  //!<The name of the corresponding package.
00033         PMString version;               //!<The version of the package that is required.
00034 };
00035 
00036 //!The main class that interfaces with the database backend.
00037 /*!The Package Management system. This is the daddy that glues all the classes together
00038   and is the main interface for users. This should be the only class needed to interface
00039   with all the DB's. If there is any functionality missing, let me know ASAP.*/
00040 class PackageManager
00041 {
00042         public:
00043                 PackageManager();                                                                                                                                                                               //!<Constructor.
00044                 PackageManager(Keyword acceptKeyword, PMString useFlags, std::vector<Virtual> virtuals);                                //!<Constructor.
00045                 ~PackageManager();                                                                                                                                                                              //!<Destructor.
00046         
00047                 std::vector<Package> SearchPackageName(PMString name);                          //!<Search for name. Can be category/name or just name.
00048                 std::vector<Package> SearchRegExpName(PMString expression);                     //!<Search for category/name using regexp.
00049                 std::vector<Package> SearchNameContains(PMString lookup);                       //!<Search for category/name that contains lookup.
00050                 std::vector<Package> SearchRegExpDescription(PMString expression);      //!<Search description for expression using regexp.
00051                 std::vector<Package> SearchDescriptionContains(PMString lookup);        //!<Search for description containing lookup.
00052                 
00053                 PackageVersion SearchSpecificVersion(Package searchPackage,PMString version);                                                   //!<Search for version of searchPackage.
00054                 PackageVersion GetLatestVersion(Package searchPackage, bool hardMasked = false, PMString slot = "");    //!<Get latest version of searchPackage.
00055                 PackageVersion GetLatestAvailableVersion(Package searchPackage, PMString slot = "");                                    //!<Get latest available version of searchPackage.
00056                 PackageVersion GetLatestVersionInstalled(Package passedPackage);                                                                                //!<Get latest version installed of passedPackage.
00057                 PackageVersion GetVirtual(PMString virtualString);                                                                                                              //!<Get PackageVersion that should be installed for virtualString.
00058                 
00059                 std::vector<PackageVersion> FullSearchPackage(PMString searchString);                                                                                   //!<Search for PackageVersion using searchString ( cat/name-ver or name-ver ).
00060                 std::vector<PackageVersion> GetVersions(Package searchPackage, bool hardMasked = false, PMString slot = "");    //!<Get all versions of searchPackage.
00061                 std::vector<PackageVersion> GetAvailableVersions(Package searchPackage, PMString slot = "");                                    //!<Get available versions of searchPackage.
00062                 std::vector<PackageVersion> GetVersionsInstalled(Package passedPackage);                                                                                //!<Get versions installed of passedPackage.
00063                 std::vector<PackageVersion> CalculateNotInstalledDependencies(PackageVersion version);                                                  //!<Calculate all dependencies not installed for version.
00064                 std::vector<PackageVersion> CalculateAllDependencies(PackageVersion version);                                                                   //!<Calculate all dependencies for version.
00065                 
00066                 bool SearchVersionExists(Package searchPackage,PMString version);       //!<Returns true if version of searchPackage exists.
00067                 bool IsVersionInstalled(PackageVersion passedVersion);                          //!<Returns true if passedVersion is installed.
00068                 bool IsPackageInstalled(Package passedPackage);                                         //!<Returns true if passedPackage is installed.
00069                 bool IsPackageInWorld(Package passedPackage);                                           //!<Returns true if passedPackage is in world.
00070                 bool IsSlotInstalled(Package passedPackage, PMString slot);             //!<Returns true if slot of package is installed.
00071                 
00072                 void CreateAllDatabases(bool clearCache = true,bool cacheFileSizes=false);                                      //!<Create the DB, also refill.
00073                 void CreatePackageDatabases(bool clearCache = true, bool cacheFileSizes=false);                         //!<Create the DB's for packages - should be done after each sync.
00074                 void CreateInstalledDatabase();                                                                                                                         //!<Create the installed DB - should be done whenever emerge is used.
00075                 void SetPackageInstalled(PackageVersion version,bool upgrade = false,bool inWorld = true);      //!<Set version to be installed.
00076                 void SetPackageRemoved(PackageVersion version,bool upgrade = false);                                            //!<Set version to be removed.
00077                 void RegenWorldFile();                                                                                                                                          //!<Regenerate the world file from the InstalledDb.
00078                 void AddToWorld(Package toAdd);                                                                                                                         //!<Add package to the world file.
00079                 void RemoveFromWorld(Package toRemove);                                                                                                         //!<Remove package from the world file.
00080                 
00081                 void SetKeyword(PMString keyword);                              //!<Set keyword to keyword.
00082                 void SetKeyword(Keyword keyword);                               //!<Set keyword to keyword.
00083                 void AddUseFlag(PMString flag);                                 //!<Add a use flag.
00084                 void SetUseFlags(PMString flags);                               //!<Set the use flags.
00085                 void SetVirtuals(std::vector<Virtual> virtuals);//!<Set the virtuals.
00086                 void AddVirtual(Virtual passedVirtual);                 //!<Add a virtual.
00087                 
00088                 void SetHardMaskedPackages(std::vector<PMString> hardMasked);   //!<Set the hardMasked package regexp.
00089                 void SetUnstablePackages(std::vector<PMString> unStable);               //!<Set the unstable package regexp.
00090                 void SetStablePackages(std::vector<PMString> stable);                   //!<Set the stable package regexp.
00091                 
00092                 void FetchPackages(PackageVersion version, redi::ipstream& streamToOutput);                                                                                                     //!<Fetch version.
00093                 void InstallPackage(PackageVersion version, redi::ipstream& streamToOutput, bool threaded = false, bool inWorld = true);        //!<Install version.
00094                 void RemovePackage(PackageVersion version, redi::ipstream& streamToOutput, bool threaded = false);                                                      //!<Remove version.
00095                 
00096                 Virtual GetVirtual(PackageVersion passedVersion);       //!<Returns the virtual that passedVersion provides.
00097                 
00098                 std::vector<InstalledPackage> GetWorldPackages();                                                               //!<Fetch all world packages.
00099                 std::vector<InstalledPackage> GetAllInstalledPackages();                                                //!<Fetch all installed packages.
00100                 std::vector<InstalledPackage> FindRedundantPackages();                                                  //!<Returns all the redundant packages.
00101                 std::vector<InstalledPackage> ReverseDependencies(PackageVersion passedVersion);//!<Returns the reverse dependencies of passedVersion.
00102 
00103                 std::vector<PackageUpgrade> GetWorldUpdates();  //!<Fetch all world updates.
00104                 std::vector<PackageUpgrade> GetAllUpdates();    //!<Fetch all the updates on the system.
00105                 
00106                 std::vector<PMString> GetVirtualsProvided();            //!<Get all virtuals provided by installed packages.
00107                 std::vector<PMString> FindRedundantSourceFiles();       //!<Finds source files not needed by anything installed.
00108                 
00109         protected:
00110                 void _FillDatabase(bool cacheFileSizes);        //!<Fill the PackageVersion and PackageName DB's.
00111                 void _FillInstalledDatabase();                          //!<Fill the installed DB.
00112                 
00113                 bool _DependenciesArrange(std::vector<PackageVersion>& hayStack, PackageVersion dependency, PackageVersion mainPackage,DependencyStage stage);  //!<Adds dependency to hayStack based on the location of the dependent package, mainPackage.
00114                 bool _FindRegExpMatch(std::vector<PMString> hayStack, PMString needle);                                                                                                                                                 //!<See if the needle matches any of the regular expressions in haystack.
00115                 PMString PackageManager::_GetSlotFromPortageDB(PackageVersion version);                                                                                                                                                 //!<Return the slot from /var/db/pkg.
00116                 PackageVersion _VirtualInList(std::vector<PackageVersion> list,PMString virtualString);                                                                                                                 //!<Returns the version that provides a virtual in the list.
00117                 PackageVersion _FulfillDependency(Dependency dependency);                                                                                                                                                                               //!<Returns a PackageVersion to fulfill dependency
00118                 
00119                 PackageDatabase _packageNameDatabase;                   //!<Package Name DB.
00120                 PackageVersionDatabase _packageVersionDatabase; //!<Package Version DB.
00121                 InstalledDatabase _installedPackagesDatabase;   //!<Installed Packages DB.
00122                 Keyword _acceptKeyword;                                                 //!<The Arch Keyword.
00123                 PMString _useFlags;                                                             //!<Use flags.
00124                 std::vector<Virtual> _virtuals;                                 //!<Virtuals.
00125                 std::vector<PMString> _hardMaskedPackages;              //!<Hard masked packages regexps.
00126                 std::vector<PMString> _unStablePackages;                //!<Unstable packages regexps.
00127                 std::vector<PMString> _stablePackages;                  //!<Stable packages regexps.
00128 };
00129 
00130 #endif

Generated on Wed May 25 15:29:54 2005 for Package Management System for Gentoo Linux by  doxygen 1.4.1