Implemented repository writing:
* fleshed out RepositoryWriterImpl * renamed BRepositoryHeader to BRepositoryInfo (in accordance with BPackageInfo) * adjusted BRepositoryInfo to be able to parse itself from a driver_settings file * added package_repo binary (only 'create' works as of yet) git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@40405 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -55,6 +55,7 @@ public:
|
||||
const BString& Description() const;
|
||||
const BString& Vendor() const;
|
||||
const BString& Packager() const;
|
||||
const BString& Checksum() const;
|
||||
|
||||
uint32 Flags() const;
|
||||
|
||||
@@ -81,6 +82,7 @@ public:
|
||||
void SetDescription(const BString& description);
|
||||
void SetVendor(const BString& vendor);
|
||||
void SetPackager(const BString& packager);
|
||||
void SetChecksum(const BString& checksum);
|
||||
|
||||
void SetFlags(uint32 flags);
|
||||
|
||||
@@ -120,6 +122,9 @@ public:
|
||||
void Clear();
|
||||
|
||||
public:
|
||||
static status_t GetArchitectureByName(const BString& name,
|
||||
BPackageArchitecture& _architecture);
|
||||
|
||||
static const char* kElementNames[];
|
||||
static const char* kArchitectureNames[];
|
||||
|
||||
@@ -152,6 +157,8 @@ private:
|
||||
BObjectList<BPackageResolvableExpression> fFreshensList;
|
||||
|
||||
BObjectList<BString> fReplacesList;
|
||||
|
||||
BString fChecksum;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -34,6 +34,7 @@ enum BPackageInfoAttributeIndex {
|
||||
B_PACKAGE_INFO_REPLACES, // list of resolvables that this package
|
||||
// will replace (upon update)
|
||||
B_PACKAGE_INFO_FLAGS,
|
||||
B_PACKAGE_INFO_CHECKSUM, // sha256-checksum
|
||||
//
|
||||
B_PACKAGE_INFO_ENUM_COUNT,
|
||||
};
|
||||
|
||||
@@ -15,6 +15,12 @@
|
||||
namespace BPackageKit {
|
||||
|
||||
|
||||
namespace BHPKG {
|
||||
class BPackageResolvableData;
|
||||
}
|
||||
using BHPKG::BPackageResolvableData;
|
||||
|
||||
|
||||
/*
|
||||
* Defines a resolvable (something other packages can depend upon).
|
||||
* Each resolvable is defined as a name (with an optional type prefix)
|
||||
@@ -39,6 +45,8 @@ namespace BPackageKit {
|
||||
class BPackageResolvable {
|
||||
public:
|
||||
BPackageResolvable();
|
||||
BPackageResolvable(
|
||||
const BPackageResolvableData& data);
|
||||
BPackageResolvable(const BString& name,
|
||||
BPackageResolvableType type
|
||||
= B_PACKAGE_RESOLVABLE_TYPE_DEFAULT,
|
||||
|
||||
@@ -15,6 +15,12 @@
|
||||
namespace BPackageKit {
|
||||
|
||||
|
||||
namespace BHPKG {
|
||||
class BPackageResolvableExpressionData;
|
||||
}
|
||||
using BHPKG::BPackageResolvableExpressionData;
|
||||
|
||||
|
||||
/*
|
||||
* Expresses a constraint on a specific resolvable, either just a name
|
||||
* or a name plus a relational operator and a version.
|
||||
@@ -33,6 +39,9 @@ namespace BPackageKit {
|
||||
class BPackageResolvableExpression {
|
||||
public:
|
||||
BPackageResolvableExpression();
|
||||
BPackageResolvableExpression(
|
||||
const BPackageResolvableExpressionData& data
|
||||
);
|
||||
BPackageResolvableExpression(
|
||||
const BString& name,
|
||||
BPackageResolvableOperator _op
|
||||
|
||||
@@ -12,9 +12,17 @@
|
||||
namespace BPackageKit {
|
||||
|
||||
|
||||
namespace BHPKG {
|
||||
class BPackageVersionData;
|
||||
}
|
||||
using BHPKG::BPackageVersionData;
|
||||
|
||||
|
||||
class BPackageVersion {
|
||||
public:
|
||||
BPackageVersion();
|
||||
BPackageVersion(
|
||||
const BPackageVersionData& data);
|
||||
BPackageVersion(const BString& major,
|
||||
const BString& minor, const BString& micro,
|
||||
uint8 release);
|
||||
|
||||
@@ -9,15 +9,12 @@
|
||||
#include <Entry.h>
|
||||
#include <String.h>
|
||||
|
||||
#include <package/RepositoryHeader.h>
|
||||
#include <package/RepositoryInfo.h>
|
||||
|
||||
|
||||
namespace BPackageKit {
|
||||
|
||||
|
||||
//class RepositoryHeader;
|
||||
|
||||
|
||||
class BRepositoryCache {
|
||||
public:
|
||||
BRepositoryCache();
|
||||
@@ -27,7 +24,7 @@ public:
|
||||
status_t SetTo(const BEntry& entry);
|
||||
status_t InitCheck() const;
|
||||
|
||||
const BRepositoryHeader& Header() const;
|
||||
const BRepositoryInfo& Info() const;
|
||||
const BEntry& Entry() const;
|
||||
bool IsUserSpecific() const;
|
||||
|
||||
@@ -37,7 +34,7 @@ private:
|
||||
status_t fInitStatus;
|
||||
|
||||
BEntry fEntry;
|
||||
BRepositoryHeader fHeader;
|
||||
BRepositoryInfo fInfo;
|
||||
bool fIsUserSpecific;
|
||||
};
|
||||
|
||||
|
||||
@@ -2,55 +2,60 @@
|
||||
* Copyright 2011, Haiku, Inc.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef _PACKAGE__REPOSITORY_HEADER_H_
|
||||
#define _PACKAGE__REPOSITORY_HEADER_H_
|
||||
#ifndef _PACKAGE__REPOSITORY_INFO_H_
|
||||
#define _PACKAGE__REPOSITORY_INFO_H_
|
||||
|
||||
|
||||
#include <Archivable.h>
|
||||
#include <Entry.h>
|
||||
#include <String.h>
|
||||
|
||||
#include <package/PackageArchitecture.h>
|
||||
|
||||
|
||||
namespace BPackageKit {
|
||||
|
||||
|
||||
class BRepositoryHeader : public BArchivable {
|
||||
class BRepositoryInfo : public BArchivable {
|
||||
typedef BArchivable inherited;
|
||||
|
||||
public:
|
||||
BRepositoryHeader();
|
||||
BRepositoryHeader(BMessage* data);
|
||||
virtual ~BRepositoryHeader();
|
||||
BRepositoryInfo();
|
||||
BRepositoryInfo(BMessage* data);
|
||||
BRepositoryInfo(const BEntry& entry);
|
||||
virtual ~BRepositoryInfo();
|
||||
|
||||
virtual status_t Archive(BMessage* data, bool deep = true) const;
|
||||
|
||||
status_t SetTo(const BMessage* data);
|
||||
status_t SetTo(const BEntry& entry);
|
||||
status_t InitCheck() const;
|
||||
|
||||
const BString& Name() const;
|
||||
const BString& OriginalBaseURL() const;
|
||||
const BString& Vendor() const;
|
||||
const BString& ShortDescription() const;
|
||||
const BString& LongDescription() const;
|
||||
const BString& Summary() const;
|
||||
uint8 Priority() const;
|
||||
BPackageArchitecture Architecture() const;
|
||||
|
||||
void SetName(const BString& name);
|
||||
void SetOriginalBaseURL(const BString& url);
|
||||
void SetVendor(const BString& vendor);
|
||||
void SetShortDescription(const BString& description);
|
||||
void SetLongDescription(const BString& description);
|
||||
void SetSummary(const BString& summary);
|
||||
void SetPriority(uint8 priority);
|
||||
void SetArchitecture(BPackageArchitecture arch);
|
||||
|
||||
public:
|
||||
static BRepositoryHeader* Instantiate(BMessage* data);
|
||||
static BRepositoryInfo* Instantiate(BMessage* data);
|
||||
|
||||
static const uint8 kDefaultPriority;
|
||||
|
||||
static const char* kNameField;
|
||||
static const char* kURLField;
|
||||
static const char* kVendorField;
|
||||
static const char* kShortDescriptionField;
|
||||
static const char* kLongDescriptionField;
|
||||
static const char* kSummaryField;
|
||||
static const char* kPriorityField;
|
||||
static const char* kArchitectureField;
|
||||
|
||||
private:
|
||||
status_t fInitStatus;
|
||||
@@ -58,13 +63,13 @@ private:
|
||||
BString fName;
|
||||
BString fOriginalBaseURL;
|
||||
BString fVendor;
|
||||
BString fShortDescription;
|
||||
BString fLongDescription;
|
||||
BString fSummary;
|
||||
uint8 fPriority;
|
||||
BPackageArchitecture fArchitecture;
|
||||
};
|
||||
|
||||
|
||||
} // namespace BPackageKit
|
||||
|
||||
|
||||
#endif // _PACKAGE__REPOSITORY_HEADER_H_
|
||||
#endif // _PACKAGE__REPOSITORY_INFO_H_
|
||||
@@ -47,6 +47,7 @@ public:
|
||||
virtual status_t HandlePackageAttribute(
|
||||
const BPackageInfoAttributeValue& value
|
||||
) = 0;
|
||||
virtual status_t HandlePackageAttributesDone() = 0;
|
||||
|
||||
virtual void HandleErrorOccurred() = 0;
|
||||
};
|
||||
|
||||
@@ -16,6 +16,7 @@ namespace BPackageKit {
|
||||
|
||||
|
||||
class BPackageInfo;
|
||||
class BRepositoryInfo;
|
||||
|
||||
|
||||
namespace BHPKG {
|
||||
@@ -38,6 +39,8 @@ public:
|
||||
virtual void OnPackageAttributesSizeInfo(uint32 stringCount,
|
||||
uint32 uncompressedSize) = 0;
|
||||
virtual void OnRepositorySizeInfo(uint32 headerSize,
|
||||
uint32 repositoryInfoLength,
|
||||
uint32 packageCount,
|
||||
uint32 packageAttributesSize,
|
||||
uint64 totalSize) = 0;
|
||||
};
|
||||
@@ -47,7 +50,8 @@ class BRepositoryWriter {
|
||||
public:
|
||||
public:
|
||||
BRepositoryWriter(
|
||||
BRepositoryWriterListener* listener);
|
||||
BRepositoryWriterListener* listener,
|
||||
const BRepositoryInfo* repositoryInfo);
|
||||
~BRepositoryWriter();
|
||||
|
||||
status_t Init(const char* fileName);
|
||||
|
||||
@@ -25,7 +25,7 @@ public:
|
||||
ActivateRepositoryConfigJob(
|
||||
const BContext& context,
|
||||
const BString& title,
|
||||
const BEntry& archivedRepoHeaderEntry,
|
||||
const BEntry& archivedRepoInfoEntry,
|
||||
const BString& repositoryBaseURL,
|
||||
const BDirectory& targetDirectory);
|
||||
virtual ~ActivateRepositoryConfigJob();
|
||||
@@ -37,7 +37,7 @@ protected:
|
||||
virtual void Cleanup(status_t jobResult);
|
||||
|
||||
private:
|
||||
BEntry fArchivedRepoHeaderEntry;
|
||||
BEntry fArchivedRepoInfoEntry;
|
||||
BString fRepositoryBaseURL;
|
||||
BDirectory fTargetDirectory;
|
||||
BEntry fTargetEntry;
|
||||
|
||||
@@ -8,17 +8,21 @@
|
||||
|
||||
#include <Entry.h>
|
||||
|
||||
#include <package/hpkg/PackageContentHandler.h>
|
||||
#include <package/hpkg/RepositoryWriter.h>
|
||||
#include <package/hpkg/WriterImplBase.h>
|
||||
#include <package/PackageInfo.h>
|
||||
|
||||
|
||||
namespace BPackageKit {
|
||||
|
||||
|
||||
namespace BHPKG {
|
||||
|
||||
|
||||
class BDataReader;
|
||||
class BErrorOutput;
|
||||
class BPackageEntry;
|
||||
class BPackageEntryAttribute;
|
||||
class BPackageInfoAttributeValue;
|
||||
|
||||
|
||||
namespace BPrivate {
|
||||
@@ -26,26 +30,54 @@ namespace BPrivate {
|
||||
|
||||
struct hpkg_header;
|
||||
|
||||
class RepositoryWriterImpl : public WriterImplBase {
|
||||
class RepositoryWriterImpl
|
||||
: public WriterImplBase, private BPackageContentHandler {
|
||||
public:
|
||||
RepositoryWriterImpl(
|
||||
BRepositoryWriterListener* listener);
|
||||
BRepositoryWriterListener* listener,
|
||||
const BRepositoryInfo* repositoryInfo);
|
||||
~RepositoryWriterImpl();
|
||||
|
||||
status_t Init(const char* fileName);
|
||||
status_t AddPackage(const BEntry& packageEntry);
|
||||
status_t Finish();
|
||||
|
||||
private:
|
||||
// BPackageContentHandler
|
||||
virtual status_t HandleEntry(BPackageEntry* entry);
|
||||
virtual status_t HandleEntryAttribute(BPackageEntry* entry,
|
||||
BPackageEntryAttribute* attribute);
|
||||
virtual status_t HandleEntryDone(BPackageEntry* entry);
|
||||
|
||||
virtual status_t HandlePackageAttribute(
|
||||
const BPackageInfoAttributeValue& value
|
||||
);
|
||||
virtual status_t HandlePackageAttributesDone();
|
||||
|
||||
virtual void HandleErrorOccurred();
|
||||
|
||||
private:
|
||||
status_t _Init(const char* fileName);
|
||||
status_t _AddPackage(const BEntry& packageEntry);
|
||||
status_t _Finish();
|
||||
|
||||
status_t _RegisterCurrentPackageInfo();
|
||||
status_t _WriteRepositoryInfo(
|
||||
ssize_t& _repositoryInfoLength);
|
||||
off_t _WritePackageAttributes(
|
||||
hpkg_repo_header& header);
|
||||
hpkg_repo_header& header,
|
||||
off_t startOffset);
|
||||
|
||||
struct PackageNameSet;
|
||||
|
||||
private:
|
||||
BRepositoryWriterListener* fListener;
|
||||
|
||||
const BRepositoryInfo* fRepositoryInfo;
|
||||
|
||||
BPackageInfo fPackageInfo;
|
||||
uint32 fPackageCount;
|
||||
PackageNameSet* fPackageNames;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -51,6 +51,9 @@ struct hpkg_repo_header {
|
||||
uint16 version;
|
||||
uint64 total_size;
|
||||
|
||||
// repository header
|
||||
uint32 repository_header_length;
|
||||
|
||||
// package attributes section
|
||||
uint32 attributes_compression;
|
||||
uint32 attributes_length_compressed;
|
||||
|
||||
Reference in New Issue
Block a user