* more work on the package kit, repositories can now be added and

refreshed


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@40280 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Oliver Tappe
2011-01-24 20:48:03 +00:00
parent 77a8a5cce3
commit 35edda8f0b
40 changed files with 1507 additions and 263 deletions
+19 -3
View File
@@ -17,20 +17,36 @@ namespace Haiku {
namespace Package {
namespace Private {
class ActivateRepositoryConfigJob;
}
using Private::ActivateRepositoryConfigJob;
class AddRepositoryRequest : public Request {
typedef Request inherited;
public:
AddRepositoryRequest(const Context& context,
const BString& repositoryURL,
const BString& repositoryBaseURL,
bool asUserRepository);
virtual ~AddRepositoryRequest();
virtual status_t CreateJobsToRun(JobQueue& jobQueue);
virtual status_t CreateInitialJobs();
const BString& RepositoryName() const;
protected:
// JobStateListener
virtual void JobSucceeded(Job* job);
private:
BString fRepositoryURL;
BString fRepositoryBaseURL;
bool fAsUserRepository;
ActivateRepositoryConfigJob* fActivateJob;
BString fRepositoryName;
};
+31
View File
@@ -0,0 +1,31 @@
/*
* Copyright 2011, Haiku, Inc.
* Distributed under the terms of the MIT License.
*/
#ifndef _HAIKU__PACKAGE__ATTRIBUTES_H_
#define _HAIKU__PACKAGE__ATTRIBUTES_H_
namespace Haiku {
namespace Package {
// attributes used in package and as file attribute, too
extern const char* kNameAttribute;
extern const char* kVendorAttribute;
extern const char* kVersionAttribute;
// attributes kept local to packages
extern const char* kCopyrightAttribute;
extern const char* kLicenseAttribute;
extern const char* kProvidesAttribute;
extern const char* kRequiresAttribute;
} // namespace Package
} // namespace Haiku
#endif // _HAIKU__PACKAGE__ATTRIBUTES_H_
+4 -3
View File
@@ -6,7 +6,7 @@
#define _HAIKU__PACKAGE__CONTEXT_H_
#include <package/TempEntryManager.h>
#include <package/TempfileManager.h>
namespace Haiku {
@@ -15,6 +15,7 @@ namespace Package {
class JobStateListener;
using Private::TempfileManager;
struct DecisionProvider {
@@ -37,7 +38,7 @@ public:
Context(DecisionProvider& decisionProvider);
~Context();
TempEntryManager& GetTempEntryManager() const;
TempfileManager& GetTempfileManager() const;
JobStateListener* GetJobStateListener() const;
void SetJobStateListener(JobStateListener* listener);
@@ -45,7 +46,7 @@ public:
DecisionProvider& GetDecisionProvider() const;
private:
mutable TempEntryManager fTempEntryManager;
mutable TempfileManager fTempfileManager;
DecisionProvider& fDecisionProvider;
JobStateListener* fJobStateListener;
};
+5
View File
@@ -18,6 +18,7 @@ namespace Package {
class Context;
class Job;
struct JobStateListener {
virtual ~JobStateListener();
@@ -51,6 +52,7 @@ public:
const BString& Title() const;
JobState State() const;
status_t Result() const;
const BString& ErrorString() const;
status_t AddStateListener(JobStateListener* listener);
status_t RemoveStateListener(
@@ -65,6 +67,8 @@ protected:
virtual status_t Execute() = 0;
virtual void Cleanup(status_t jobResult);
void SetErrorString(const BString&);
void NotifyStateListeners();
const Context& fContext;
@@ -74,6 +78,7 @@ private:
JobState fState;
status_t fResult;
BString fErrorString;
typedef BObjectList<Job> JobList;
JobList fDependencies;
@@ -0,0 +1,56 @@
/*
* Copyright 2011, Haiku, Inc.
* Distributed under the terms of the MIT License.
*/
#ifndef _HAIKU__PACKAGE__REFRESH_REPOSITORY_REQUEST_H_
#define _HAIKU__PACKAGE__REFRESH_REPOSITORY_REQUEST_H_
#include <Entry.h>
#include <String.h>
#include <package/Context.h>
#include <package/RepositoryConfig.h>
#include <package/Request.h>
namespace Haiku {
namespace Package {
namespace Private {
class ValidateChecksumJob;
}
using Private::ValidateChecksumJob;
class RefreshRepositoryRequest : public Request {
typedef Request inherited;
public:
RefreshRepositoryRequest(const Context& context,
const RepositoryConfig& repoConfig);
virtual ~RefreshRepositoryRequest();
virtual status_t CreateInitialJobs();
protected:
// JobStateListener
virtual void JobSucceeded(Job* job);
private:
status_t _FetchRepositoryCache();
BEntry fFetchedChecksumFile;
RepositoryConfig fRepoConfig;
ValidateChecksumJob* fValidateChecksumJob;
};
} // namespace Package
} // namespace Haiku
#endif // _HAIKU__PACKAGE__REFRESH_REPOSITORY_REQUEST_H_
+38 -9
View File
@@ -2,23 +2,52 @@
* Copyright 2011, Haiku, Inc.
* Distributed under the terms of the MIT License.
*/
#ifndef _REPOSITORY_H_
#define _REPOSITORY_H_
#ifndef _HAIKU__PACKAGE__REPOSITORY_CACHE_H_
#define _HAIKU__PACKAGE__REPOSITORY_CACHE_H_
#include <Archivable.h>
#include <Entry.h>
#include <String.h>
class BMessage;
class BEntry;
class BRepository {
namespace Haiku {
namespace Package {
//class RepositoryHeader;
class RepositoryCache {
public:
BRepository(const char* url);
RepositoryCache();
RepositoryCache(const BEntry& entry);
virtual ~RepositoryCache();
public:
static BArchivable* Instantiate(BMessage* archive);
status_t SetTo(const BEntry& entry);
status_t InitCheck() const;
// const RepositoryHeader* Header() const;
const BEntry& Entry() const;
bool IsUserSpecific() const;
void SetIsUserSpecific(bool isUserSpecific);
private:
status_t fInitStatus;
BEntry fEntry;
// RepositoryHeader* fHeader;
bool fIsUserSpecific;
};
#endif // _REPOSITORY_H_
} // namespace Package
} // namespace Haiku
#endif // _HAIKU__PACKAGE__REPOSITORY_CACHE_H_
+8 -4
View File
@@ -7,6 +7,7 @@
#include <Archivable.h>
#include <Entry.h>
#include <String.h>
@@ -34,6 +35,8 @@ public:
status_t StoreAsConfigFile(const BEntry& entry) const;
status_t SetTo(const BEntry& entry);
status_t SetTo(const BMessage* data);
status_t InitCheck() const;
const BString& Name() const;
@@ -41,6 +44,8 @@ public:
uint8 Priority() const;
bool IsUserSpecific() const;
const BEntry& Entry() const;
void SetName(const BString& name);
void SetURL(const BString& url);
void SetPriority(uint8 priority);
@@ -49,21 +54,20 @@ public:
public:
static RepositoryConfig* Instantiate(BMessage* data);
static const uint8 kDefaultPriority = 50;
static const uint8 kDefaultPriority;
static const char* kNameField;
static const char* kURLField;
static const char* kPriorityField;
private:
status_t _InitFrom(const BEntry& entry);
status_t _InitFrom(const BMessage* data);
status_t fInitStatus;
BString fName;
BString fURL;
uint8 fPriority;
bool fIsUserSpecific;
BEntry fEntry;
};
+11 -7
View File
@@ -8,6 +8,8 @@
#include <SupportDefs.h>
#include <package/JobQueue.h>
namespace Haiku {
@@ -15,23 +17,25 @@ namespace Package {
class Context;
class Job;
class JobQueue;
using Private::JobQueue;
class Request {
class Request : protected JobStateListener {
public:
Request(const Context& context);
virtual ~Request();
virtual status_t CreateJobsToRun(JobQueue& jobQueue) = 0;
virtual status_t CreateInitialJobs() = 0;
const Context& GetContext() const;
Job* PopRunnableJob();
protected:
status_t QueueJob(Job* job, JobQueue& jobQueue) const;
private:
status_t QueueJob(Job* job);
const Context& fContext;
private:
JobQueue fJobQueue;
};
+21
View File
@@ -7,10 +7,14 @@
#include <Entry.h>
#include <FindDirectory.h>
#include <Path.h>
#include <SupportDefs.h>
template <class T> class BObjectList;
namespace Haiku {
namespace Package {
@@ -25,22 +29,39 @@ struct RepositoryConfigVisitor {
};
class RepositoryCache;
class RepositoryConfig;
class Roster {
public:
Roster();
~Roster();
status_t GetCommonRepositoryCachePath(BPath* path,
bool create = false) const;
status_t GetUserRepositoryCachePath(BPath* path,
bool create = false) const;
status_t GetCommonRepositoryConfigPath(BPath* path,
bool create = false) const;
status_t GetUserRepositoryConfigPath(BPath* path,
bool create = false) const;
status_t GetRepositoryNames(BObjectList<BString>& names);
status_t VisitCommonRepositoryConfigs(
RepositoryConfigVisitor& visitor);
status_t VisitUserRepositoryConfigs(
RepositoryConfigVisitor& visitor);
status_t GetRepositoryCache(const BString& name,
RepositoryCache* repositoryCache);
status_t GetRepositoryConfig(const BString& name,
RepositoryConfig* repositoryConfig);
private:
status_t _GetRepositoryPath(BPath* path, bool create,
directory_which whichDir) const;
status_t _VisitRepositoryConfigs(const BPath& path,
RepositoryConfigVisitor& visitor);
@@ -0,0 +1,52 @@
/*
* Copyright 2011, Oliver Tappe <[email protected]>
* Distributed under the terms of the MIT License.
*/
#ifndef _HAIKU__PACKAGE__PRIVATE__ACTIVATE_REPOSITORY_CACHE_JOB_H_
#define _HAIKU__PACKAGE__PRIVATE__ACTIVATE_REPOSITORY_CACHE_JOB_H_
#include <Directory.h>
#include <Entry.h>
#include <String.h>
#include <package/Job.h>
namespace Haiku {
namespace Package {
namespace Private {
class ActivateRepositoryCacheJob : public Job {
typedef Job inherited;
public:
ActivateRepositoryCacheJob(
const Context& context,
const BString& title,
const BEntry& fetchedRepoCacheEntry,
const BString& repositoryName,
const BDirectory& targetDirectory);
virtual ~ActivateRepositoryCacheJob();
protected:
virtual status_t Execute();
private:
BEntry fFetchedRepoCacheEntry;
BString fRepositoryName;
BDirectory fTargetDirectory;
};
} // namespace Private
} // namespace Package
} // namespace Haiku
#endif // _HAIKU__PACKAGE__PRIVATE__ACTIVATE_REPOSITORY_CACHE_JOB_H_
@@ -1,9 +1,9 @@
/*
* Copyright 2011, Haiku, Inc.
* Copyright 2011, Oliver Tappe <[email protected]>
* Distributed under the terms of the MIT License.
*/
#ifndef _HAIKU__PACKAGE__ACTIVATE_REPOSITORY_CONFIG_JOB_H_
#define _HAIKU__PACKAGE__ACTIVATE_REPOSITORY_CONFIG_JOB_H_
#ifndef _HAIKU__PACKAGE__PRIVATE__ACTIVATE_REPOSITORY_CONFIG_JOB_H_
#define _HAIKU__PACKAGE__PRIVATE__ACTIVATE_REPOSITORY_CONFIG_JOB_H_
#include <Directory.h>
@@ -17,6 +17,8 @@ namespace Haiku {
namespace Package {
namespace Private {
class ActivateRepositoryConfigJob : public Job {
typedef Job inherited;
@@ -26,23 +28,31 @@ public:
const Context& context,
const BString& title,
const BEntry& archivedRepoConfigEntry,
const BString& repositoryBaseURL,
const BDirectory& targetDirectory);
virtual ~ActivateRepositoryConfigJob();
const BString& RepositoryName() const;
protected:
virtual status_t Execute();
virtual void Cleanup(status_t jobResult);
private:
BEntry fArchivedRepoConfigEntry;
BString fRepositoryBaseURL;
BDirectory fTargetDirectory;
BEntry fTargetEntry;
BString fRepositoryName;
};
} // namespace Private
} // namespace Package
} // namespace Haiku
#endif // _HAIKU__PACKAGE__ACTIVATE_REPOSITORY_CONFIG_JOB_H_
#endif // _HAIKU__PACKAGE__PRIVATE__ACTIVATE_REPOSITORY_CONFIG_JOB_H_
@@ -0,0 +1,61 @@
/*
* Copyright 2011, Oliver Tappe <zooey@hirschkaefer.de>
* Distributed under the terms of the MIT License.
*/
#ifndef _HAIKU__PACKAGE__PRIVATE__CHECKSUM_ACCESSORS_H_
#define _HAIKU__PACKAGE__PRIVATE__CHECKSUM_ACCESSORS_H_
#include <Entry.h>
#include <String.h>
namespace Haiku {
namespace Package {
namespace Private {
class ChecksumAccessor {
public:
virtual ~ChecksumAccessor();
virtual status_t GetChecksum(BString& checksum) const = 0;
};
class ChecksumFileChecksumAccessor : public ChecksumAccessor {
public:
ChecksumFileChecksumAccessor(
const BEntry& checksumFileEntry);
virtual status_t GetChecksum(BString& checksum) const;
private:
BEntry fChecksumFileEntry;
};
class GeneralFileChecksumAccessor : public ChecksumAccessor {
public:
GeneralFileChecksumAccessor(
const BEntry& fileEntry,
bool skipMissingFile = false);
virtual status_t GetChecksum(BString& checksum) const;
private:
BEntry fFileEntry;
bool fSkipMissingFile;
};
} // namespace Private
} // namespace Package
} // namespace Haiku
#endif // _HAIKU__PACKAGE__PRIVATE__CHECKSUM_ACCESSORS_H_
+8 -4
View File
@@ -1,9 +1,9 @@
/*
* Copyright 2011, Haiku, Inc.
* Copyright 2011, Oliver Tappe <zooey@hirschkaefer.de>
* Distributed under the terms of the MIT License.
*/
#ifndef _HAIKU__PACKAGE__FETCH_FILE_JOB_H_
#define _HAIKU__PACKAGE__FETCH_FILE_JOB_H_
#ifndef _HAIKU__PACKAGE__PRIVATE__FETCH_FILE_JOB_H_
#define _HAIKU__PACKAGE__PRIVATE__FETCH_FILE_JOB_H_
#include <Entry.h>
@@ -16,6 +16,8 @@ namespace Haiku {
namespace Package {
namespace Private {
class FetchFileJob : public Job {
typedef Job inherited;
@@ -37,9 +39,11 @@ private:
};
} // namespace Private
} // namespace Package
} // namespace Haiku
#endif // _HAIKU__PACKAGE__FETCH_FILE_JOB_H_
#endif // _HAIKU__PACKAGE__PRIVATE__FETCH_FILE_JOB_H_
@@ -16,6 +16,8 @@ namespace Haiku {
namespace Package {
namespace Private {
class JobQueue : public JobStateListener {
public:
@@ -43,6 +45,8 @@ private:
};
} // namespace Private
} // namespace Package
} // namespace Haiku
@@ -1,9 +1,9 @@
/*
* Copyright 2011, Haiku, Inc.
* Copyright 2011, Oliver Tappe <zooey@hirschkaefer.de>
* Distributed under the terms of the MIT License.
*/
#ifndef _HAIKU__PACKAGE__TEMP_ENTRY_MANAGER_H_
#define _HAIKU__PACKAGE__TEMP_ENTRY_MANAGER_H_
#ifndef _HAIKU__PACKAGE__PRIVATE__TEMPFILE_MANAGER_H_
#define _HAIKU__PACKAGE__PRIVATE__TEMPFILE_MANAGER_H_
#include <Directory.h>
@@ -16,11 +16,13 @@ namespace Haiku {
namespace Package {
namespace Private {
class TempEntryManager {
class TempfileManager {
public:
TempEntryManager();
~TempEntryManager();
TempfileManager();
~TempfileManager();
void SetBaseDirectory(const BDirectory& baseDir);
@@ -35,9 +37,11 @@ private:
};
} // namespace Private
} // namespace Package
} // namespace Haiku
#endif // _HAIKU__PACKAGE__TEMP_ENTRY_MANAGER_H_
#endif // _HAIKU__PACKAGE__PRIVATE__TEMPFILE_MANAGER_H_
@@ -0,0 +1,57 @@
/*
* Copyright 2011, Oliver Tappe <zooey@hirschkaefer.de>
* Distributed under the terms of the MIT License.
*/
#ifndef _HAIKU__PACKAGE__PRIVATE__VALIDATE_CHECKSUM_JOB_H_
#define _HAIKU__PACKAGE__PRIVATE__VALIDATE_CHECKSUM_JOB_H_
#include <Directory.h>
#include <Entry.h>
#include <String.h>
#include <package/ChecksumAccessors.h>
#include <package/Job.h>
namespace Haiku {
namespace Package {
namespace Private {
class ValidateChecksumJob : public Job {
typedef Job inherited;
public:
ValidateChecksumJob(
const Context& context,
const BString& title,
ChecksumAccessor* expectedChecksumAccessor,
ChecksumAccessor* realChecksumAccessor,
bool failIfChecksumsDontMatch = true);
virtual ~ValidateChecksumJob();
bool ChecksumsMatch() const;
protected:
virtual status_t Execute();
private:
ChecksumAccessor* fExpectedChecksumAccessor;
ChecksumAccessor* fRealChecksumAccessor;
bool fFailIfChecksumsDontMatch;
bool fChecksumsMatch;
};
} // namespace Private
} // namespace Package
} // namespace Haiku
#endif // _HAIKU__PACKAGE__PRIVATE__VALIDATE_CHECKSUM_JOB_H_