From waddlesplash <waddlesplash@xxxxxxxxx>:
Hello Andrew Lindesay, Adrien Destugues,
I'd like you to do a code review. Please visit
https://review.haiku-os.org/c/haiku/+/2896
to review the following change.
Change subject: Revert "PackageKit: HPKR BMessage Format Fix"
......................................................................
Revert "PackageKit: HPKR BMessage Format Fix"
This reverts commit 82f985c036aaae979bd6f5a6b1a29bed03fa3fa0.
Reason for revert: Broke the build with this message:
/packages/groff-1.22.3-1-x86_64.hpkg: Scheme missing.
Change-Id: I9dea4986238cedfdc33c84739e69a331add09cdf
---
M src/kits/package/RepositoryInfo.cpp
1 file changed, 23 insertions(+), 23 deletions(-)
git pull ssh://git.haiku-os.org:22/haiku refs/changes/96/2896/1
diff --git a/src/kits/package/RepositoryInfo.cpp
b/src/kits/package/RepositoryInfo.cpp
index 270e466..e43ace7 100644
--- a/src/kits/package/RepositoryInfo.cpp
+++ b/src/kits/package/RepositoryInfo.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright 2011-2020, Haiku, Inc. All Rights Reserved.
+ * Copyright 2011-2018, Haiku, Inc. All Rights Reserved.
* Distributed under the terms of the MIT License.
*
* Authors:
@@ -92,14 +92,15 @@
if ((result = data->AddString(kNameField, fName)) != B_OK)
return result;
- if ((result = data->AddString(kIdentifierField, fIdentifier)) != B_OK)
- return result;
- // "url" is an older, deprecated key for "identifier"
+ // 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(kURLField, fIdentifier)) != B_OK)
return result;
if ((result = data->AddString(kVendorField, fVendor)) != B_OK)
return result;
- if ((result = data->AddString(kSummaryField, fSummary)) != B_OK)
+ result = data->AddString(kSummaryField, fSummary);
+ if (result != B_OK)
return result;
if ((result = data->AddUInt8(kPriorityField, fPriority)) != B_OK)
return result;
@@ -281,35 +282,34 @@
status_t result;
if ((result = data->FindString(kNameField, &fName)) != 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 = 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;
}
- 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;
- if ((result = data->FindUInt8(
- kArchitectureField, (uint8*)&fArchitecture)) != B_OK) {
+ result = data->FindUInt8(kArchitectureField, (uint8*)&fArchitecture);
+ if (result != B_OK)
return result;
- }
if (fArchitecture == B_PACKAGE_ARCHITECTURE_ANY)
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_OK:
- case B_NAME_NOT_FOUND:
- break;
- default:
- return baseUrlResult;
+ // 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;
}
const char* licenseName;
--
To view, visit https://review.haiku-os.org/c/haiku/+/2896
To unsubscribe, or for help writing mail filters, visit
https://review.haiku-os.org/settings
Gerrit-Project: haiku
Gerrit-Branch: master
Gerrit-Change-Id: I9dea4986238cedfdc33c84739e69a331add09cdf
Gerrit-Change-Number: 2896
Gerrit-PatchSet: 1
Gerrit-Owner: waddlesplash <waddlesplash@xxxxxxxxx>
Gerrit-Reviewer: Adrien Destugues <pulkomandy@xxxxxxxxx>
Gerrit-Reviewer: Andrew Lindesay <apl@xxxxxxxxxxxxxx>
Gerrit-MessageType: newchange