PackageKit: HPKR BMessage Format Fix
Some older repositories are having problems because they are configured with a `url` (identifier) form that is not actually a well-formed URL. This caused problems when it was then interpreted as the base-url because it did not start with "http". I have changed this so that the base-url is not derived from the url and can be missing. Resolves #16149 Change-Id: I10acd8db65082ff6c72fcff1550eb63475e86133 Reviewed-on: https://review.haiku-os.org/c/haiku/+/2931 Reviewed-by: waddlesplash <[email protected]>
This commit is contained in:
committed by
waddlesplash
parent
2778057ccd
commit
991d1a2097
@@ -3,5 +3,5 @@ vendor "Haiku Project"
|
||||
summary "The Haiku repository (for Haiku %HAIKU_VERSION_NO_REVISION%)"
|
||||
priority 1
|
||||
baseurl https://eu.hpkg.haiku-os.org/haiku/master/%HAIKU_PACKAGING_ARCH%/current
|
||||
url https://hpkg.haiku-os.org/haiku/master/%HAIKU_PACKAGING_ARCH%/current
|
||||
identifier https://hpkg.haiku-os.org/haiku/master/%HAIKU_PACKAGING_ARCH%/current
|
||||
architecture %HAIKU_PACKAGING_ARCH%
|
||||
|
||||
@@ -3,5 +3,5 @@ vendor "Haiku Project"
|
||||
summary "The HaikuPorts repository (for Haiku %HAIKU_VERSION_NO_REVISION%)"
|
||||
priority 1
|
||||
baseurl https://eu.hpkg.haiku-os.org/haikuports/master/%HAIKU_PACKAGING_ARCH%/current
|
||||
url https://hpkg.haiku-os.org/haikuports/master/%HAIKU_PACKAGING_ARCH%/current
|
||||
identifier https://hpkg.haiku-os.org/haikuports/master/%HAIKU_PACKAGING_ARCH%/current
|
||||
architecture %HAIKU_PACKAGING_ARCH%
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2011-2018, Haiku, Inc. All Rights Reserved.
|
||||
* Copyright 2011-2020, Haiku, Inc. All Rights Reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
@@ -92,15 +92,14 @@ BRepositoryInfo::Archive(BMessage* data, bool deep) const
|
||||
|
||||
if ((result = data->AddString(kNameField, fName)) != B_OK)
|
||||
return result;
|
||||
// Field in the archive is named "url" for backward compatility reasons.
|
||||
// We can change this when everyone has updated to a version of Haiku
|
||||
// with support for reading the "identifier" field.
|
||||
if ((result = data->AddString(kIdentifierField, fIdentifier)) != B_OK)
|
||||
return result;
|
||||
// "url" is an older, deprecated key for "identifier"
|
||||
if ((result = data->AddString(kURLField, fIdentifier)) != B_OK)
|
||||
return result;
|
||||
if ((result = data->AddString(kVendorField, fVendor)) != B_OK)
|
||||
return result;
|
||||
result = data->AddString(kSummaryField, fSummary);
|
||||
if (result != B_OK)
|
||||
if ((result = data->AddString(kSummaryField, fSummary)) != B_OK)
|
||||
return result;
|
||||
if ((result = data->AddUInt8(kPriorityField, fPriority)) != B_OK)
|
||||
return result;
|
||||
@@ -282,34 +281,41 @@ BRepositoryInfo::_SetTo(const BMessage* data)
|
||||
status_t result;
|
||||
if ((result = data->FindString(kNameField, &fName)) != B_OK)
|
||||
return result;
|
||||
if ((result = data->FindString(kIdentifierField, &fIdentifier)) != B_OK) {
|
||||
// Handle the "url" field as well (it is still the one we generate).
|
||||
// Later on when everyone is using this code we can switch the writing
|
||||
// side to use the "identifier" field with its correct name.
|
||||
if ((result = data->FindString(kURLField, &fIdentifier)) != B_OK)
|
||||
return result;
|
||||
result = data->FindString(kIdentifierField, &fIdentifier);
|
||||
if (result == B_NAME_NOT_FOUND) {
|
||||
result = data->FindString(kURLField, &fIdentifier);
|
||||
// this is a legacy key for the identifier.
|
||||
}
|
||||
if (result != B_OK)
|
||||
return result;
|
||||
if ((result = data->FindString(kVendorField, &fVendor)) != B_OK)
|
||||
return result;
|
||||
if ((result = data->FindString(kSummaryField, &fSummary)) != B_OK)
|
||||
return result;
|
||||
if ((result = data->FindUInt8(kPriorityField, &fPriority)) != B_OK)
|
||||
return result;
|
||||
result = data->FindUInt8(kArchitectureField, (uint8*)&fArchitecture);
|
||||
if (result != B_OK)
|
||||
if ((result = data->FindUInt8(
|
||||
kArchitectureField, (uint8*)&fArchitecture)) != B_OK) {
|
||||
return result;
|
||||
}
|
||||
if (fArchitecture == B_PACKAGE_ARCHITECTURE_ANY)
|
||||
return B_BAD_DATA;
|
||||
|
||||
// Old packages had no base-url field, the "url" field acted both as an
|
||||
// identifier and locator for the repository.
|
||||
data->FindString(kBaseURLField, &fBaseURL);
|
||||
if (fBaseURL.Length() == 0) {
|
||||
fBaseURL = fIdentifier;
|
||||
// In that case make sure the identifier is indeed an http URL
|
||||
// (in the new format, the protocol is not required to be http anymore)
|
||||
if (!fBaseURL.StartsWith("http"))
|
||||
return B_BAD_DATA;
|
||||
// this field is optional because earlier versions did not support this
|
||||
// field.
|
||||
status_t baseUrlResult = data->FindString(kBaseURLField, &fBaseURL);
|
||||
switch (baseUrlResult) {
|
||||
case B_NAME_NOT_FOUND:
|
||||
// This is a temporary measure because older versions of the file
|
||||
// format would take the "url" (identifier) field for the "base-url"
|
||||
// Once this transitional period is over this can be removed.
|
||||
if (fIdentifier.StartsWith("http"))
|
||||
fBaseURL = fIdentifier;
|
||||
break;
|
||||
case B_OK:
|
||||
break;
|
||||
default:
|
||||
return baseUrlResult;
|
||||
}
|
||||
|
||||
const char* licenseName;
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
/*
|
||||
* Copyright 2013, Haiku, Inc. All Rights Reserved.
|
||||
* Copyright 2013-2020, Haiku, Inc. All Rights Reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
* Ingo Weinhold <[email protected]>
|
||||
* Andrew Lindesay <[email protected]>
|
||||
*/
|
||||
|
||||
|
||||
@@ -141,18 +142,37 @@ BRepositoryBuilder::AddPackage(const char* path, BSolverPackage** _package)
|
||||
size_t pathLength = strlen(path);
|
||||
status_t error;
|
||||
PackageInfoErrorListener errorListener(path);
|
||||
BEntry entry(path, true);
|
||||
|
||||
if (!entry.Exists()) {
|
||||
DIE_DETAILS(errorListener.Errors(), B_FILE_NOT_FOUND,
|
||||
"the package data file does not exist at \"%s\"", path);
|
||||
}
|
||||
|
||||
struct stat entryStat;
|
||||
error = entry.GetStat(&entryStat);
|
||||
|
||||
if (error != B_OK) {
|
||||
DIE_DETAILS(errorListener.Errors(), error,
|
||||
"failed to access the package data file at \"%s\"", path);
|
||||
}
|
||||
|
||||
if (entryStat.st_size == 0) {
|
||||
DIE_DETAILS(errorListener.Errors(), B_BAD_DATA,
|
||||
"empty package data file at \"%s\"", path);
|
||||
}
|
||||
|
||||
if (pathLength > 5 && strcmp(path + pathLength - 5, ".hpkg") == 0) {
|
||||
// a package file
|
||||
error = packageInfo.ReadFromPackageFile(path);
|
||||
} else {
|
||||
// a package info file (supposedly)
|
||||
error = packageInfo.ReadFromConfigFile(BEntry(path, true),
|
||||
&errorListener);
|
||||
error = packageInfo.ReadFromConfigFile(entry, &errorListener);
|
||||
}
|
||||
|
||||
if (error != B_OK) {
|
||||
DIE_DETAILS(errorListener.Errors(), error,
|
||||
"failed to read package info from \"%s\"", path);
|
||||
"failed to read package data file at \"%s\"", path);
|
||||
}
|
||||
|
||||
// add the package
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2018, Haiku, Inc. All Rights Reserved.
|
||||
* Copyright 2013-2020, Haiku, Inc. All Rights Reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
@@ -104,6 +104,10 @@ main(int argc, const char* const* argv)
|
||||
DIE(error, "failed to read repository file '%s'", repositories[i]);
|
||||
BRepositoryBuilder(*repository, cache)
|
||||
.AddToSolver(solver, false);
|
||||
if (cache.Info().BaseURL().IsEmpty()) {
|
||||
DIE(B_ERROR, "missing base url in repository file '%s'",
|
||||
repositories[i]);
|
||||
}
|
||||
repositoryInfos[repository] = cache.Info();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user