Add a package info "install-path" attribute
The attribute is intended for simplifying package building. The package's install path will be used for the package's .self package symlink, allowing installation to a temporary directory when building the package.
This commit is contained in:
parent
7efa133cb4
commit
6ae0ecd49a
@ -60,6 +60,7 @@ public:
|
|||||||
const BString& Vendor() const;
|
const BString& Vendor() const;
|
||||||
const BString& Packager() const;
|
const BString& Packager() const;
|
||||||
const BString& Checksum() const;
|
const BString& Checksum() const;
|
||||||
|
const BString& InstallPath() const;
|
||||||
|
|
||||||
uint32 Flags() const;
|
uint32 Flags() const;
|
||||||
|
|
||||||
@ -89,6 +90,7 @@ public:
|
|||||||
void SetVendor(const BString& vendor);
|
void SetVendor(const BString& vendor);
|
||||||
void SetPackager(const BString& packager);
|
void SetPackager(const BString& packager);
|
||||||
void SetChecksum(const BString& checksum);
|
void SetChecksum(const BString& checksum);
|
||||||
|
void SetInstallPath(const BString& installPath);
|
||||||
|
|
||||||
void SetFlags(uint32 flags);
|
void SetFlags(uint32 flags);
|
||||||
|
|
||||||
@ -174,6 +176,7 @@ private:
|
|||||||
BObjectList<BString> fReplacesList;
|
BObjectList<BString> fReplacesList;
|
||||||
|
|
||||||
BString fChecksum;
|
BString fChecksum;
|
||||||
|
BString fInstallPath;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -37,6 +37,8 @@ enum BPackageInfoAttributeID {
|
|||||||
B_PACKAGE_INFO_URLS, // list
|
B_PACKAGE_INFO_URLS, // list
|
||||||
B_PACKAGE_INFO_SOURCE_URLS, // list
|
B_PACKAGE_INFO_SOURCE_URLS, // list
|
||||||
B_PACKAGE_INFO_CHECKSUM, // sha256-checksum
|
B_PACKAGE_INFO_CHECKSUM, // sha256-checksum
|
||||||
|
B_PACKAGE_INFO_INSTALL_PATH, // package install path; only for package
|
||||||
|
// building
|
||||||
//
|
//
|
||||||
B_PACKAGE_INFO_ENUM_COUNT,
|
B_PACKAGE_INFO_ENUM_COUNT,
|
||||||
};
|
};
|
||||||
|
@ -126,6 +126,7 @@ enum BHPKGAttributeID {
|
|||||||
B_HPKG_ATTRIBUTE_ID_PACKAGE_PROVIDES_COMPATIBLE = 41,
|
B_HPKG_ATTRIBUTE_ID_PACKAGE_PROVIDES_COMPATIBLE = 41,
|
||||||
B_HPKG_ATTRIBUTE_ID_PACKAGE_URL = 42,
|
B_HPKG_ATTRIBUTE_ID_PACKAGE_URL = 42,
|
||||||
B_HPKG_ATTRIBUTE_ID_PACKAGE_SOURCE_URL = 43,
|
B_HPKG_ATTRIBUTE_ID_PACKAGE_SOURCE_URL = 43,
|
||||||
|
B_HPKG_ATTRIBUTE_ID_PACKAGE_INSTALL_PATH = 44,
|
||||||
//
|
//
|
||||||
B_HPKG_ATTRIBUTE_ID_ENUM_COUNT,
|
B_HPKG_ATTRIBUTE_ID_ENUM_COUNT,
|
||||||
};
|
};
|
||||||
|
@ -48,6 +48,7 @@ public:
|
|||||||
~BPackageWriter();
|
~BPackageWriter();
|
||||||
|
|
||||||
status_t Init(const char* fileName, uint32 flags = 0);
|
status_t Init(const char* fileName, uint32 flags = 0);
|
||||||
|
status_t SetInstallPath(const char* installPath);
|
||||||
void SetCheckLicenses(bool checkLicenses);
|
void SetCheckLicenses(bool checkLicenses);
|
||||||
status_t AddEntry(const char* fileName, int fd = -1);
|
status_t AddEntry(const char* fileName, int fd = -1);
|
||||||
status_t Finish();
|
status_t Finish();
|
||||||
|
@ -10,6 +10,8 @@
|
|||||||
#include <util/DoublyLinkedList.h>
|
#include <util/DoublyLinkedList.h>
|
||||||
#include <util/OpenHashTable.h>
|
#include <util/OpenHashTable.h>
|
||||||
|
|
||||||
|
#include <String.h>
|
||||||
|
|
||||||
#include <package/hpkg/PackageWriter.h>
|
#include <package/hpkg/PackageWriter.h>
|
||||||
#include <package/hpkg/Strings.h>
|
#include <package/hpkg/Strings.h>
|
||||||
#include <package/hpkg/WriterImplBase.h>
|
#include <package/hpkg/WriterImplBase.h>
|
||||||
@ -43,6 +45,7 @@ public:
|
|||||||
~PackageWriterImpl();
|
~PackageWriterImpl();
|
||||||
|
|
||||||
status_t Init(const char* fileName, uint32 flags);
|
status_t Init(const char* fileName, uint32 flags);
|
||||||
|
status_t SetInstallPath(const char* installPath);
|
||||||
void SetCheckLicenses(bool checkLicenses);
|
void SetCheckLicenses(bool checkLicenses);
|
||||||
status_t AddEntry(const char* fileName, int fd = -1);
|
status_t AddEntry(const char* fileName, int fd = -1);
|
||||||
status_t Finish();
|
status_t Finish();
|
||||||
@ -148,6 +151,7 @@ private:
|
|||||||
StringCache fStringCache;
|
StringCache fStringCache;
|
||||||
|
|
||||||
BPackageInfo fPackageInfo;
|
BPackageInfo fPackageInfo;
|
||||||
|
BString fInstallPath;
|
||||||
bool fCheckLicenses;
|
bool fCheckLicenses;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -230,6 +230,10 @@ struct PackageContentListHandler : BPackageContentHandler {
|
|||||||
printf("\treplaces: %s\n", value.string);
|
printf("\treplaces: %s\n", value.string);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case B_PACKAGE_INFO_INSTALL_PATH:
|
||||||
|
printf("\tinstall path: %s\n", value.string);
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
printf(
|
printf(
|
||||||
"*** Invalid package attribute section: unexpected "
|
"*** Invalid package attribute section: unexpected "
|
||||||
|
@ -670,7 +670,7 @@ BPackageInfo::Parser::_Parse(BPackageInfo* packageInfo)
|
|||||||
|
|
||||||
BPackageInfoAttributeID attribute = B_PACKAGE_INFO_ENUM_COUNT;
|
BPackageInfoAttributeID attribute = B_PACKAGE_INFO_ENUM_COUNT;
|
||||||
for (int i = 0; i < B_PACKAGE_INFO_ENUM_COUNT; i++) {
|
for (int i = 0; i < B_PACKAGE_INFO_ENUM_COUNT; i++) {
|
||||||
if (t.text.ICompare(names[i]) == 0) {
|
if (names[i] != NULL && t.text.ICompare(names[i]) == 0) {
|
||||||
attribute = (BPackageInfoAttributeID)i;
|
attribute = (BPackageInfoAttributeID)i;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -803,6 +803,7 @@ const char* BPackageInfo::kElementNames[B_PACKAGE_INFO_ENUM_COUNT] = {
|
|||||||
"urls",
|
"urls",
|
||||||
"source-urls",
|
"source-urls",
|
||||||
"checksum", // not being parsed, computed externally
|
"checksum", // not being parsed, computed externally
|
||||||
|
NULL, // install-path -- not settable via .PackageInfo
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -948,6 +949,13 @@ BPackageInfo::Checksum() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const BString&
|
||||||
|
BPackageInfo::InstallPath() const
|
||||||
|
{
|
||||||
|
return fInstallPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
uint32
|
uint32
|
||||||
BPackageInfo::Flags() const
|
BPackageInfo::Flags() const
|
||||||
{
|
{
|
||||||
@ -1081,6 +1089,13 @@ BPackageInfo::SetChecksum(const BString& checksum)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
BPackageInfo::SetInstallPath(const BString& installPath)
|
||||||
|
{
|
||||||
|
fInstallPath = installPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
BPackageInfo::SetVersion(const BPackageVersion& version)
|
BPackageInfo::SetVersion(const BPackageVersion& version)
|
||||||
{
|
{
|
||||||
@ -1296,6 +1311,7 @@ BPackageInfo::Clear()
|
|||||||
fVendor.Truncate(0);
|
fVendor.Truncate(0);
|
||||||
fPackager.Truncate(0);
|
fPackager.Truncate(0);
|
||||||
fChecksum.Truncate(0);
|
fChecksum.Truncate(0);
|
||||||
|
fInstallPath.Truncate(0);
|
||||||
fFlags = 0;
|
fFlags = 0;
|
||||||
fArchitecture = B_PACKAGE_ARCHITECTURE_ENUM_COUNT;
|
fArchitecture = B_PACKAGE_ARCHITECTURE_ENUM_COUNT;
|
||||||
fVersion.Clear();
|
fVersion.Clear();
|
||||||
|
@ -60,6 +60,7 @@ static const char* kAttributeNames[B_HPKG_ATTRIBUTE_ID_ENUM_COUNT + 1] = {
|
|||||||
"package:provides.compatible",
|
"package:provides.compatible",
|
||||||
"package:url",
|
"package:url",
|
||||||
"package:source-url",
|
"package:source-url",
|
||||||
|
"package:install-path",
|
||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -39,6 +39,16 @@ BPackageWriter::Init(const char* fileName, uint32 flags)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
status_t
|
||||||
|
BPackageWriter::SetInstallPath(const char* installPath)
|
||||||
|
{
|
||||||
|
if (fImpl == NULL)
|
||||||
|
return B_NO_INIT;
|
||||||
|
|
||||||
|
return fImpl->SetInstallPath(installPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
BPackageWriter::SetCheckLicenses(bool checkLicenses)
|
BPackageWriter::SetCheckLicenses(bool checkLicenses)
|
||||||
{
|
{
|
||||||
|
@ -485,6 +485,16 @@ PackageWriterImpl::Init(const char* fileName, uint32 flags)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
status_t
|
||||||
|
PackageWriterImpl::SetInstallPath(const char* installPath)
|
||||||
|
{
|
||||||
|
fInstallPath = installPath;
|
||||||
|
return installPath == NULL
|
||||||
|
|| (size_t)fInstallPath.Length() == strlen(installPath)
|
||||||
|
? B_OK : B_NO_MEMORY;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
PackageWriterImpl::SetCheckLicenses(bool checkLicenses)
|
PackageWriterImpl::SetCheckLicenses(bool checkLicenses)
|
||||||
{
|
{
|
||||||
@ -575,6 +585,8 @@ PackageWriterImpl::Finish()
|
|||||||
return B_BAD_DATA;
|
return B_BAD_DATA;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fPackageInfo.SetInstallPath(fInstallPath);
|
||||||
|
|
||||||
RegisterPackageInfo(PackageAttributes(), fPackageInfo);
|
RegisterPackageInfo(PackageAttributes(), fPackageInfo);
|
||||||
|
|
||||||
if (fCheckLicenses) {
|
if (fCheckLicenses) {
|
||||||
|
@ -441,6 +441,10 @@ ReaderImplBase::PackageAttributeHandler::HandleAttribute(
|
|||||||
fPackageInfoValue.SetTo(B_PACKAGE_INFO_CHECKSUM, value.string);
|
fPackageInfoValue.SetTo(B_PACKAGE_INFO_CHECKSUM, value.string);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case B_HPKG_ATTRIBUTE_ID_PACKAGE_INSTALL_PATH:
|
||||||
|
fPackageInfoValue.SetTo(B_PACKAGE_INFO_INSTALL_PATH, value.string);
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
context->errorOutput->PrintError(
|
context->errorOutput->PrintError(
|
||||||
"Error: Invalid package attribute section: unexpected "
|
"Error: Invalid package attribute section: unexpected "
|
||||||
|
@ -527,6 +527,17 @@ WriterImplBase::RegisterPackageInfo(PackageAttributeList& attributeList,
|
|||||||
= fPackageStringCache.Get(packageInfo.Checksum().String());
|
= fPackageStringCache.Get(packageInfo.Checksum().String());
|
||||||
attributeList.Add(checksum);
|
attributeList.Add(checksum);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// install path (optional)
|
||||||
|
if (!packageInfo.InstallPath().IsEmpty()) {
|
||||||
|
PackageAttribute* installPath = new PackageAttribute(
|
||||||
|
B_HPKG_ATTRIBUTE_ID_PACKAGE_INSTALL_PATH,
|
||||||
|
B_HPKG_ATTRIBUTE_TYPE_STRING,
|
||||||
|
B_HPKG_ATTRIBUTE_ENCODING_STRING_TABLE);
|
||||||
|
installPath->string = fPackageStringCache.Get(
|
||||||
|
packageInfo.InstallPath().String());
|
||||||
|
attributeList.Add(installPath);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user