BPackageManager: Support installing/updating local package files

* The Install() and Update() versions that take a const char* array
  now check whether a string looks like a path to a local package file.
  If so, they use that file instead of interpreting the string as a
  search string.
* Extend the repository hierarchy. There's now a LocalRepository base
  class from which InstalledRepository and the new MiscLocalRepository
  derive. The latter is instantiated once and collects all package files
  specified by path.
This commit is contained in:
Ingo Weinhold
2014-06-15 17:21:01 +02:00
parent ea761a10d4
commit f2f19f110d
2 changed files with 192 additions and 34 deletions
@@ -10,6 +10,9 @@
#define _PACKAGE__MANAGER__PRIVATE__PACKAGE_MANAGER_H_
#include <map>
#include <string>
#include <Directory.h>
#include <ObjectList.h>
#include <package/Context.h>
@@ -42,6 +45,8 @@ using BPackageKit::BPrivate::BDaemonClient;
class BPackageManager : protected BJobStateListener {
public:
class RemoteRepository;
class LocalRepository;
class MiscLocalRepository;
class InstalledRepository;
class Transaction;
class InstallationInterface;
@@ -126,8 +131,8 @@ private:
void _CommitPackageChanges(Transaction& transaction);
void _ClonePackageFile(
InstalledRepository* repository,
const BString& fileName,
LocalRepository* repository,
BSolverPackage* package,
const BEntry& entry);
int32 _FindBasePackage(const PackageList& packages,
const BPackageInfo& info);
@@ -140,6 +145,13 @@ private:
const BRepositoryConfig& config,
bool refresh, BRepositoryCache& _cache);
void _AddPackageSpecifiers(
const char* const* searchStrings,
int searchStringCount,
BSolverPackageSpecifierList& specifierList);
bool _IsLocalPackage(const char* fileName);
BSolverPackage* _AddLocalPackage(const char* fileName);
bool _NextSpecificInstallationLocation();
protected:
@@ -149,6 +161,7 @@ protected:
InstalledRepository* fHomeRepository;
InstalledRepositoryList fInstalledRepositories;
RemoteRepositoryList fOtherRepositories;
MiscLocalRepository* fLocalRepository;
TransactionList fTransactions;
// must be set by the derived class
@@ -169,7 +182,33 @@ private:
};
class BPackageManager::InstalledRepository : public BSolverRepository {
class BPackageManager::LocalRepository : public BSolverRepository {
public:
LocalRepository();
LocalRepository(const BString& name);
virtual void GetPackagePath(BSolverPackage* package,
BPath& _path) = 0;
};
class BPackageManager::MiscLocalRepository : public LocalRepository {
public:
MiscLocalRepository();
BSolverPackage* AddLocalPackage(const char* fileName);
virtual void GetPackagePath(BSolverPackage* package,
BPath& _path);
private:
typedef std::map<BSolverPackage*, std::string> PackagePathMap;
private:
PackagePathMap fPackagePaths;
};
class BPackageManager::InstalledRepository : public LocalRepository {
public:
typedef BObjectList<BSolverPackage> PackageList;
@@ -185,6 +224,9 @@ public:
int32 InitialPriority() const
{ return fInitialPriority; }
virtual void GetPackagePath(BSolverPackage* package,
BPath& _path);
void DisablePackage(BSolverPackage* package);
// throws, if already disabled
bool EnablePackage(BSolverPackage* package);