2011-01-28 02:17:03 +03:00
|
|
|
/*
|
2011-01-29 20:59:58 +03:00
|
|
|
* Copyright 2011, Haiku, Inc.
|
2011-01-28 02:17:03 +03:00
|
|
|
* Distributed under the terms of the MIT License.
|
|
|
|
*/
|
|
|
|
#ifndef _PACKAGE__PACKAGE_INFO_H_
|
|
|
|
#define _PACKAGE__PACKAGE_INFO_H_
|
|
|
|
|
|
|
|
|
2013-04-14 16:09:11 +04:00
|
|
|
#include <Archivable.h>
|
2011-01-28 02:17:03 +03:00
|
|
|
#include <ObjectList.h>
|
|
|
|
#include <String.h>
|
2011-07-16 18:36:36 +04:00
|
|
|
#include <StringList.h>
|
2011-01-28 02:17:03 +03:00
|
|
|
|
2013-05-23 23:29:18 +04:00
|
|
|
#include <package/GlobalSettingsFileInfo.h>
|
2011-02-04 20:43:07 +03:00
|
|
|
#include <package/PackageArchitecture.h>
|
2011-02-08 22:50:36 +03:00
|
|
|
#include <package/PackageFlags.h>
|
2011-02-04 20:43:07 +03:00
|
|
|
#include <package/PackageInfoAttributes.h>
|
2011-01-29 20:59:58 +03:00
|
|
|
#include <package/PackageResolvable.h>
|
|
|
|
#include <package/PackageResolvableExpression.h>
|
|
|
|
#include <package/PackageVersion.h>
|
2013-05-24 05:11:18 +04:00
|
|
|
#include <package/User.h>
|
2013-05-23 23:29:18 +04:00
|
|
|
#include <package/UserSettingsFileInfo.h>
|
2011-01-29 20:59:58 +03:00
|
|
|
|
2011-01-28 02:17:03 +03:00
|
|
|
|
|
|
|
class BEntry;
|
2011-07-01 03:37:48 +04:00
|
|
|
class BFile;
|
2011-01-28 02:17:03 +03:00
|
|
|
|
|
|
|
|
|
|
|
namespace BPackageKit {
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Keeps a list of package info elements (e.g. name, version, vendor, ...) which
|
|
|
|
* will be converted to package attributes when creating a package. Usually,
|
2013-04-02 03:18:16 +04:00
|
|
|
* these elements have been parsed from a ".PackageInfo" file.
|
|
|
|
* Alternatively, they can be read from an existing package file.
|
2011-01-28 02:17:03 +03:00
|
|
|
*/
|
2013-04-14 16:09:11 +04:00
|
|
|
class BPackageInfo : public BArchivable {
|
2011-01-28 02:17:03 +03:00
|
|
|
public:
|
|
|
|
struct ParseErrorListener {
|
|
|
|
virtual ~ParseErrorListener();
|
|
|
|
virtual void OnError(const BString& msg, int line, int col) = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
public:
|
|
|
|
BPackageInfo();
|
2013-04-14 16:09:11 +04:00
|
|
|
BPackageInfo(BMessage* archive,
|
|
|
|
status_t* _error = NULL);
|
|
|
|
virtual ~BPackageInfo();
|
2011-01-28 02:17:03 +03:00
|
|
|
|
|
|
|
status_t ReadFromConfigFile(
|
|
|
|
const BEntry& packageInfoEntry,
|
|
|
|
ParseErrorListener* listener = NULL);
|
2011-07-01 03:37:48 +04:00
|
|
|
status_t ReadFromConfigFile(
|
|
|
|
BFile& packageInfoFile,
|
|
|
|
ParseErrorListener* listener = NULL);
|
2011-01-28 02:17:03 +03:00
|
|
|
status_t ReadFromConfigString(
|
|
|
|
const BString& packageInfoString,
|
|
|
|
ParseErrorListener* listener = NULL);
|
2013-04-02 03:18:16 +04:00
|
|
|
status_t ReadFromPackageFile(const char* path);
|
|
|
|
status_t ReadFromPackageFile(int fd);
|
2011-01-28 02:17:03 +03:00
|
|
|
|
|
|
|
status_t InitCheck() const;
|
|
|
|
|
|
|
|
const BString& Name() const;
|
|
|
|
const BString& Summary() const;
|
|
|
|
const BString& Description() const;
|
|
|
|
const BString& Vendor() const;
|
|
|
|
const BString& Packager() const;
|
2013-05-13 23:02:30 +04:00
|
|
|
const BString& BasePackage() const;
|
2011-02-09 22:11:23 +03:00
|
|
|
const BString& Checksum() const;
|
2011-07-11 16:00:55 +04:00
|
|
|
const BString& InstallPath() const;
|
2011-01-28 02:17:03 +03:00
|
|
|
|
2011-02-08 22:50:36 +03:00
|
|
|
uint32 Flags() const;
|
|
|
|
|
2011-01-28 02:17:03 +03:00
|
|
|
BPackageArchitecture Architecture() const;
|
|
|
|
|
|
|
|
const BPackageVersion& Version() const;
|
|
|
|
|
2011-07-16 18:36:36 +04:00
|
|
|
const BStringList& CopyrightList() const;
|
|
|
|
const BStringList& LicenseList() const;
|
|
|
|
const BStringList& URLList() const;
|
|
|
|
const BStringList& SourceURLList() const;
|
2011-01-28 02:17:03 +03:00
|
|
|
|
2013-05-23 23:29:18 +04:00
|
|
|
const BObjectList<BGlobalSettingsFileInfo>&
|
|
|
|
GlobalSettingsFileInfos() const;
|
|
|
|
const BObjectList<BUserSettingsFileInfo>&
|
|
|
|
UserSettingsFileInfos() const;
|
|
|
|
|
2013-05-24 05:11:18 +04:00
|
|
|
const BObjectList<BUser>& Users() const;
|
|
|
|
const BStringList& Groups() const;
|
|
|
|
|
2013-05-25 01:46:22 +04:00
|
|
|
const BStringList& PostInstallScripts() const;
|
|
|
|
|
2011-01-29 20:59:58 +03:00
|
|
|
const BObjectList<BPackageResolvable>& ProvidesList() const;
|
|
|
|
const BObjectList<BPackageResolvableExpression>&
|
|
|
|
RequiresList() const;
|
|
|
|
const BObjectList<BPackageResolvableExpression>&
|
|
|
|
SupplementsList() const;
|
|
|
|
const BObjectList<BPackageResolvableExpression>&
|
|
|
|
ConflictsList() const;
|
|
|
|
const BObjectList<BPackageResolvableExpression>&
|
|
|
|
FreshensList() const;
|
2011-07-16 18:36:36 +04:00
|
|
|
const BStringList& ReplacesList() const;
|
2011-01-28 02:17:03 +03:00
|
|
|
|
2013-04-20 23:10:21 +04:00
|
|
|
BString CanonicalFileName() const;
|
|
|
|
|
2011-01-28 02:17:03 +03:00
|
|
|
void SetName(const BString& name);
|
|
|
|
void SetSummary(const BString& summary);
|
|
|
|
void SetDescription(const BString& description);
|
|
|
|
void SetVendor(const BString& vendor);
|
|
|
|
void SetPackager(const BString& packager);
|
2013-05-13 23:02:30 +04:00
|
|
|
void SetBasePackage(const BString& basePackage);
|
2011-02-09 22:11:23 +03:00
|
|
|
void SetChecksum(const BString& checksum);
|
2011-07-11 16:00:55 +04:00
|
|
|
void SetInstallPath(const BString& installPath);
|
2011-01-28 02:17:03 +03:00
|
|
|
|
2011-02-08 22:50:36 +03:00
|
|
|
void SetFlags(uint32 flags);
|
|
|
|
|
2011-01-28 02:17:03 +03:00
|
|
|
void SetArchitecture(
|
|
|
|
BPackageArchitecture architecture);
|
|
|
|
|
|
|
|
void SetVersion(const BPackageVersion& version);
|
|
|
|
|
2011-01-29 20:59:58 +03:00
|
|
|
void ClearCopyrightList();
|
2011-01-28 02:17:03 +03:00
|
|
|
status_t AddCopyright(const BString& copyright);
|
|
|
|
|
2011-01-29 20:59:58 +03:00
|
|
|
void ClearLicenseList();
|
2011-01-28 02:17:03 +03:00
|
|
|
status_t AddLicense(const BString& license);
|
|
|
|
|
2011-06-28 19:24:34 +04:00
|
|
|
void ClearURLList();
|
|
|
|
status_t AddURL(const BString& url);
|
|
|
|
|
|
|
|
void ClearSourceURLList();
|
|
|
|
status_t AddSourceURL(const BString& url);
|
|
|
|
|
2013-05-23 23:29:18 +04:00
|
|
|
void ClearGlobalSettingsFileInfos();
|
|
|
|
status_t AddGlobalSettingsFileInfo(
|
|
|
|
const BGlobalSettingsFileInfo& info);
|
|
|
|
|
|
|
|
void ClearUserSettingsFileInfos();
|
|
|
|
status_t AddUserSettingsFileInfo(
|
|
|
|
const BUserSettingsFileInfo& info);
|
|
|
|
|
2013-05-24 05:11:18 +04:00
|
|
|
void ClearUsers();
|
|
|
|
status_t AddUser(const BUser& user);
|
|
|
|
|
|
|
|
void ClearGroups();
|
|
|
|
status_t AddGroup(const BString& group);
|
|
|
|
|
2013-05-25 01:46:22 +04:00
|
|
|
void ClearPostInstallScripts();
|
|
|
|
status_t AddPostInstallScript(const BString& path);
|
|
|
|
|
2011-01-29 20:59:58 +03:00
|
|
|
void ClearProvidesList();
|
|
|
|
status_t AddProvides(const BPackageResolvable& provides);
|
2011-01-28 02:17:03 +03:00
|
|
|
|
2011-01-29 20:59:58 +03:00
|
|
|
void ClearRequiresList();
|
|
|
|
status_t AddRequires(
|
|
|
|
const BPackageResolvableExpression& expr);
|
2011-01-28 02:17:03 +03:00
|
|
|
|
2011-01-29 20:59:58 +03:00
|
|
|
void ClearSupplementsList();
|
|
|
|
status_t AddSupplements(
|
|
|
|
const BPackageResolvableExpression& expr);
|
2011-01-28 02:17:03 +03:00
|
|
|
|
2011-01-29 20:59:58 +03:00
|
|
|
void ClearConflictsList();
|
|
|
|
status_t AddConflicts(
|
|
|
|
const BPackageResolvableExpression& expr);
|
2011-01-28 02:17:03 +03:00
|
|
|
|
2011-01-29 20:59:58 +03:00
|
|
|
void ClearFreshensList();
|
|
|
|
status_t AddFreshens(
|
|
|
|
const BPackageResolvableExpression& expr);
|
2011-01-29 02:36:08 +03:00
|
|
|
|
2011-01-29 20:59:58 +03:00
|
|
|
void ClearReplacesList();
|
|
|
|
status_t AddReplaces(const BString& replaces);
|
2011-01-28 02:17:03 +03:00
|
|
|
|
2011-01-29 20:59:58 +03:00
|
|
|
void Clear();
|
|
|
|
|
2013-04-14 16:09:11 +04:00
|
|
|
virtual status_t Archive(BMessage* archive,
|
|
|
|
bool deep = true) const;
|
|
|
|
static BArchivable* Instantiate(BMessage* archive);
|
|
|
|
|
2013-04-11 02:37:25 +04:00
|
|
|
status_t GetConfigString(BString& _string) const;
|
|
|
|
BString ToString() const;
|
|
|
|
|
2011-01-29 20:59:58 +03:00
|
|
|
public:
|
2011-02-09 22:11:23 +03:00
|
|
|
static status_t GetArchitectureByName(const BString& name,
|
|
|
|
BPackageArchitecture& _architecture);
|
|
|
|
|
2013-04-03 06:06:26 +04:00
|
|
|
static status_t ParseVersionString(const BString& string,
|
2013-04-16 02:05:19 +04:00
|
|
|
bool revisionIsOptional,
|
2013-04-03 06:06:26 +04:00
|
|
|
BPackageVersion& _version,
|
|
|
|
ParseErrorListener* listener = NULL);
|
|
|
|
|
|
|
|
public:
|
2013-05-22 01:20:51 +04:00
|
|
|
static const char* const kElementNames[];
|
|
|
|
static const char* const kArchitectureNames[];
|
2013-05-23 23:29:18 +04:00
|
|
|
static const char* const kSettingsFileUpdateTypes[];
|
2011-01-28 02:17:03 +03:00
|
|
|
|
2011-01-29 20:59:58 +03:00
|
|
|
private:
|
|
|
|
class Parser;
|
2011-06-30 02:05:19 +04:00
|
|
|
friend class Parser;
|
2013-04-11 02:37:25 +04:00
|
|
|
struct StringBuilder;
|
2013-04-14 16:09:11 +04:00
|
|
|
struct FieldName;
|
2013-05-13 04:40:24 +04:00
|
|
|
struct PackageFileLocation;
|
2013-04-14 16:09:11 +04:00
|
|
|
|
|
|
|
typedef BObjectList<BPackageResolvable> ResolvableList;
|
|
|
|
typedef BObjectList<BPackageResolvableExpression>
|
|
|
|
ResolvableExpressionList;
|
|
|
|
|
2013-05-23 23:29:18 +04:00
|
|
|
typedef BObjectList<BGlobalSettingsFileInfo>
|
|
|
|
GlobalSettingsFileInfoList;
|
|
|
|
typedef BObjectList<BUserSettingsFileInfo>
|
|
|
|
UserSettingsFileInfoList;
|
|
|
|
|
2013-05-24 05:11:18 +04:00
|
|
|
typedef BObjectList<BUser> UserList;
|
|
|
|
|
2013-04-14 16:09:11 +04:00
|
|
|
private:
|
2013-05-13 04:40:24 +04:00
|
|
|
status_t _ReadFromPackageFile(
|
|
|
|
const PackageFileLocation& fileLocation);
|
|
|
|
|
2013-04-14 16:09:11 +04:00
|
|
|
static status_t _AddVersion(BMessage* archive,
|
|
|
|
const char* field,
|
|
|
|
const BPackageVersion& version);
|
|
|
|
static status_t _AddResolvables(BMessage* archive,
|
|
|
|
const char* field,
|
|
|
|
const ResolvableList& resolvables);
|
|
|
|
static status_t _AddResolvableExpressions(BMessage* archive,
|
|
|
|
const char* field,
|
|
|
|
const ResolvableExpressionList&
|
|
|
|
expressions);
|
2013-05-23 23:29:18 +04:00
|
|
|
static status_t _AddGlobalSettingsFileInfos(BMessage* archive,
|
|
|
|
const char* field,
|
|
|
|
const GlobalSettingsFileInfoList&
|
|
|
|
infos);
|
|
|
|
static status_t _AddUserSettingsFileInfos(BMessage* archive,
|
|
|
|
const char* field,
|
|
|
|
const UserSettingsFileInfoList&
|
|
|
|
infos);
|
2013-05-24 05:11:18 +04:00
|
|
|
static status_t _AddUsers(BMessage* archive, const char* field,
|
|
|
|
const UserList& users);
|
2013-05-23 23:29:18 +04:00
|
|
|
|
2013-04-14 16:09:11 +04:00
|
|
|
static status_t _ExtractVersion(BMessage* archive,
|
|
|
|
const char* field, int32 index,
|
|
|
|
BPackageVersion& _version);
|
|
|
|
static status_t _ExtractStringList(BMessage* archive,
|
|
|
|
const char* field, BStringList& _list);
|
|
|
|
static status_t _ExtractResolvables(BMessage* archive,
|
|
|
|
const char* field,
|
|
|
|
ResolvableList& _resolvables);
|
|
|
|
static status_t _ExtractResolvableExpressions(BMessage* archive,
|
|
|
|
const char* field,
|
|
|
|
ResolvableExpressionList& _expressions);
|
2013-05-23 23:29:18 +04:00
|
|
|
static status_t _ExtractGlobalSettingsFileInfos(
|
|
|
|
BMessage* archive, const char* field,
|
|
|
|
GlobalSettingsFileInfoList& _infos);
|
|
|
|
static status_t _ExtractUserSettingsFileInfos(
|
|
|
|
BMessage* archive, const char* field,
|
|
|
|
UserSettingsFileInfoList& _infos);
|
2013-05-24 05:11:18 +04:00
|
|
|
static status_t _ExtractUsers(BMessage* archive,
|
|
|
|
const char* field, UserList& _users);
|
2011-01-29 20:59:58 +03:00
|
|
|
|
2011-01-28 02:17:03 +03:00
|
|
|
private:
|
|
|
|
BString fName;
|
|
|
|
BString fSummary;
|
|
|
|
BString fDescription;
|
|
|
|
BString fVendor;
|
|
|
|
BString fPackager;
|
2013-05-13 23:02:30 +04:00
|
|
|
BString fBasePackage;
|
2011-01-28 02:17:03 +03:00
|
|
|
|
2011-02-08 22:50:36 +03:00
|
|
|
uint32 fFlags;
|
|
|
|
|
2013-04-14 16:09:11 +04:00
|
|
|
BPackageArchitecture fArchitecture;
|
2011-01-28 02:17:03 +03:00
|
|
|
|
|
|
|
BPackageVersion fVersion;
|
|
|
|
|
2011-07-16 18:36:36 +04:00
|
|
|
BStringList fCopyrightList;
|
|
|
|
BStringList fLicenseList;
|
|
|
|
BStringList fURLList;
|
|
|
|
BStringList fSourceURLList;
|
2011-01-29 20:59:58 +03:00
|
|
|
|
2013-05-23 23:29:18 +04:00
|
|
|
BObjectList<BGlobalSettingsFileInfo> fGlobalSettingsFileInfos;
|
|
|
|
BObjectList<BUserSettingsFileInfo> fUserSettingsFileInfos;
|
|
|
|
|
2013-05-24 05:11:18 +04:00
|
|
|
UserList fUsers;
|
|
|
|
BStringList fGroups;
|
|
|
|
|
2013-05-25 01:46:22 +04:00
|
|
|
BStringList fPostInstallScripts;
|
|
|
|
|
2013-04-14 16:09:11 +04:00
|
|
|
ResolvableList fProvidesList;
|
2011-01-29 20:59:58 +03:00
|
|
|
|
2013-04-14 16:09:11 +04:00
|
|
|
ResolvableExpressionList fRequiresList;
|
|
|
|
ResolvableExpressionList fSupplementsList;
|
|
|
|
ResolvableExpressionList fConflictsList;
|
|
|
|
ResolvableExpressionList fFreshensList;
|
2011-01-28 02:17:03 +03:00
|
|
|
|
2011-07-16 18:36:36 +04:00
|
|
|
BStringList fReplacesList;
|
2011-02-09 22:11:23 +03:00
|
|
|
|
|
|
|
BString fChecksum;
|
2011-07-11 16:00:55 +04:00
|
|
|
BString fInstallPath;
|
2011-01-28 02:17:03 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
} // namespace BPackageKit
|
|
|
|
|
|
|
|
|
|
|
|
#endif // _PACKAGE__PACKAGE_INFO_H_
|