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: Ic972fde43f99466db9d5ea2325c0e77cf7d4aad5 Reviewed-on: https://review.haiku-os.org/c/haiku/+/2886 Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>
This commit is contained in:
parent
8301c4980b
commit
82f985c036
@ -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.
|
* Distributed under the terms of the MIT License.
|
||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
@ -92,15 +92,14 @@ BRepositoryInfo::Archive(BMessage* data, bool deep) const
|
|||||||
|
|
||||||
if ((result = data->AddString(kNameField, fName)) != B_OK)
|
if ((result = data->AddString(kNameField, fName)) != B_OK)
|
||||||
return result;
|
return result;
|
||||||
// Field in the archive is named "url" for backward compatility reasons.
|
if ((result = data->AddString(kIdentifierField, fIdentifier)) != B_OK)
|
||||||
// We can change this when everyone has updated to a version of Haiku
|
return result;
|
||||||
// with support for reading the "identifier" field.
|
// "url" is an older, deprecated key for "identifier"
|
||||||
if ((result = data->AddString(kURLField, fIdentifier)) != B_OK)
|
if ((result = data->AddString(kURLField, fIdentifier)) != B_OK)
|
||||||
return result;
|
return result;
|
||||||
if ((result = data->AddString(kVendorField, fVendor)) != B_OK)
|
if ((result = data->AddString(kVendorField, fVendor)) != B_OK)
|
||||||
return result;
|
return result;
|
||||||
result = data->AddString(kSummaryField, fSummary);
|
if ((result = data->AddString(kSummaryField, fSummary)) != B_OK)
|
||||||
if (result != B_OK)
|
|
||||||
return result;
|
return result;
|
||||||
if ((result = data->AddUInt8(kPriorityField, fPriority)) != B_OK)
|
if ((result = data->AddUInt8(kPriorityField, fPriority)) != B_OK)
|
||||||
return result;
|
return result;
|
||||||
@ -282,34 +281,35 @@ BRepositoryInfo::_SetTo(const BMessage* data)
|
|||||||
status_t result;
|
status_t result;
|
||||||
if ((result = data->FindString(kNameField, &fName)) != B_OK)
|
if ((result = data->FindString(kNameField, &fName)) != B_OK)
|
||||||
return result;
|
return result;
|
||||||
if ((result = data->FindString(kIdentifierField, &fIdentifier)) != B_OK) {
|
result = data->FindString(kIdentifierField, &fIdentifier);
|
||||||
// Handle the "url" field as well (it is still the one we generate).
|
if (result == B_NAME_NOT_FOUND) {
|
||||||
// Later on when everyone is using this code we can switch the writing
|
result = data->FindString(kURLField, &fIdentifier);
|
||||||
// side to use the "identifier" field with its correct name.
|
// this is a legacy key for the identifier.
|
||||||
if ((result = data->FindString(kURLField, &fIdentifier)) != B_OK)
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
if (result != B_OK)
|
||||||
|
return result;
|
||||||
if ((result = data->FindString(kVendorField, &fVendor)) != B_OK)
|
if ((result = data->FindString(kVendorField, &fVendor)) != B_OK)
|
||||||
return result;
|
return result;
|
||||||
if ((result = data->FindString(kSummaryField, &fSummary)) != B_OK)
|
if ((result = data->FindString(kSummaryField, &fSummary)) != B_OK)
|
||||||
return result;
|
return result;
|
||||||
if ((result = data->FindUInt8(kPriorityField, &fPriority)) != B_OK)
|
if ((result = data->FindUInt8(kPriorityField, &fPriority)) != B_OK)
|
||||||
return result;
|
return result;
|
||||||
result = data->FindUInt8(kArchitectureField, (uint8*)&fArchitecture);
|
if ((result = data->FindUInt8(
|
||||||
if (result != B_OK)
|
kArchitectureField, (uint8*)&fArchitecture)) != B_OK) {
|
||||||
return result;
|
return result;
|
||||||
|
}
|
||||||
if (fArchitecture == B_PACKAGE_ARCHITECTURE_ANY)
|
if (fArchitecture == B_PACKAGE_ARCHITECTURE_ANY)
|
||||||
return B_BAD_DATA;
|
return B_BAD_DATA;
|
||||||
|
|
||||||
// Old packages had no base-url field, the "url" field acted both as an
|
// this field is optional because earlier versions did not support this
|
||||||
// identifier and locator for the repository.
|
// field.
|
||||||
data->FindString(kBaseURLField, &fBaseURL);
|
status_t baseUrlResult = data->FindString(kBaseURLField, &fBaseURL);
|
||||||
if (fBaseURL.Length() == 0) {
|
switch (baseUrlResult) {
|
||||||
fBaseURL = fIdentifier;
|
case B_OK:
|
||||||
// In that case make sure the identifier is indeed an http URL
|
case B_NAME_NOT_FOUND:
|
||||||
// (in the new format, the protocol is not required to be http anymore)
|
break;
|
||||||
if (!fBaseURL.StartsWith("http"))
|
default:
|
||||||
return B_BAD_DATA;
|
return baseUrlResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* licenseName;
|
const char* licenseName;
|
||||||
|
Loading…
Reference in New Issue
Block a user