hrev52072 adds 1 changeset to branch 'master'
old head: a00c8c44916b03c90884d495db99d3b11fddef1d
new head: 3b17d8dd7f1f25ad91f64ea12770200043d56af1
overview:
https://git.haiku-os.org/haiku/log/?qt=range&q=3b17d8dd7f1f+%5Ea00c8c44916b
----------------------------------------------------------------------------
3b17d8dd7f1f: HaikuDepot / PackageKit: Repositories 'Identifier' URL
Repositories are identified with a 'url' in the
remote 'repo.info' file. There is also a
'base url' which is the URL locally with which
the system is able to access the repository
data on. There is some confusion between these
two terms in the source. This change aims to
separate the two out and consistently name them.
The settings for the repository locally also was
not storing these values and that has been fixed.
Debug info about the repositories also did not
display the two urls consistently and will now
also do so. Finally, HaikuDepot now correlates
locally configured repositories with the data in
HaikuDepotServer using the identifier URL; this
makes the use of mirrors with HaikuDepot possible.
Fixes #13888
Change-Id: I66dfe589b05c24e1ab123a6945352e0f24b60bf1
[ Andrew Lindesay <apl@xxxxxxxxxxxxxx> ]
----------------------------------------------------------------------------
Revision: hrev52072
Commit: 3b17d8dd7f1f25ad91f64ea12770200043d56af1
URL: https://git.haiku-os.org/haiku/commit/?id=3b17d8dd7f1f
Author: Andrew Lindesay <apl@xxxxxxxxxxxxxx>
Date: Wed Jun 27 21:01:51 2018 UTC
Committer: Kacper Kasper <kacperkasper@xxxxxxxxx>
Commit-Date: Thu Jul 5 20:06:54 2018 UTC
Ticket: https://dev.haiku-os.org/ticket/13888
----------------------------------------------------------------------------
21 files changed, 314 insertions(+), 84 deletions(-)
headers/os/package/RepositoryConfig.h | 9 ++-
headers/os/package/RepositoryInfo.h | 15 +++--
src/apps/haikudepot/Jamfile | 1 +
src/apps/haikudepot/model/Model.cpp | 38 +++++------
src/apps/haikudepot/model/Model.h | 3 +-
src/apps/haikudepot/model/PackageInfo.cpp | 11 +++-
src/apps/haikudepot/model/PackageInfo.h | 8 +++
.../server/RepositoryDataUpdateProcess.cpp | 13 ++--
src/apps/haikudepot/ui/MainWindow.cpp | 67 ++++++++++++++------
src/apps/haikudepot/util/RepositoryUrlUtils.cpp | 50 +++++++++++++++
src/apps/haikudepot/util/RepositoryUrlUtils.h | 26 ++++++++
src/bin/package_repo/command_list.cpp | 3 +-
src/bin/pkgman/command_list_repos.cpp | 7 +-
src/data/repository_infos/haiku | 3 +-
src/data/repository_infos/haikuports | 1 +
src/kits/package/ActivateRepositoryConfigJob.cpp | 13 +++-
src/kits/package/RepositoryConfig.cpp | 62 +++++++++++++++---
src/kits/package/RepositoryInfo.cpp | 45 ++++++++++---
src/tests/kits/package/make_repo.cpp | 2 +-
.../create_repository_config.cpp | 16 +++--
.../get_package_dependencies.cpp | 5 +-
----------------------------------------------------------------------------
diff --git a/headers/os/package/RepositoryConfig.h
b/headers/os/package/RepositoryConfig.h
index b9d08906aa..3d798a1bc5 100644
--- a/headers/os/package/RepositoryConfig.h
+++ b/headers/os/package/RepositoryConfig.h
@@ -1,5 +1,5 @@
/*
- * Copyright 2011, Haiku, Inc.
+ * Copyright 2011-2018, Haiku, Inc.
* Distributed under the terms of the MIT License.
*/
#ifndef _PACKAGE__REPOSITORY_CONFIG_H_
@@ -28,6 +28,7 @@ public:
const BString& Name() const;
const BString& BaseURL() const;
+ const BString& URL() const;
uint8 Priority() const;
bool IsUserSpecific() const;
@@ -37,6 +38,7 @@ public:
void SetName(const BString&
name);
void SetBaseURL(const
BString& url);
+ void SetURL(const BString&
url);
void SetPriority(uint8
priority);
void SetIsUserSpecific(bool
isUserSpecific);
@@ -48,6 +50,11 @@ private:
BString fName;
BString fBaseURL;
+ // this URL is the URL that can be used to
access the data of
+ // the repository - it points to a single
mirror.
+ BString fURL;
+ // this URL is actually an identifier for the
repository
+ // that is consistent across mirrors.
uint8 fPriority;
bool fIsUserSpecific;
diff --git a/headers/os/package/RepositoryInfo.h
b/headers/os/package/RepositoryInfo.h
index 32aa05d6c2..9b7f7396c6 100644
--- a/headers/os/package/RepositoryInfo.h
+++ b/headers/os/package/RepositoryInfo.h
@@ -1,5 +1,5 @@
/*
- * Copyright 2011, Haiku, Inc.
+ * Copyright 2011-2018, Haiku, Inc.
* Distributed under the terms of the MIT License.
*/
#ifndef _PACKAGE__REPOSITORY_INFO_H_
@@ -33,7 +33,8 @@ public:
status_t InitCheck() const;
const BString& Name() const;
- const BString& OriginalBaseURL() const;
+ const BString& BaseURL() const;
+ const BString& URL() const;
const BString& Vendor() const;
const BString& Summary() const;
uint8 Priority() const;
@@ -42,7 +43,8 @@ public:
const BStringList& LicenseTexts() const;
void SetName(const BString&
name);
- void
SetOriginalBaseURL(const BString& url);
+ void SetBaseURL(const
BString& url);
+ void SetURL(const BString&
url);
void SetVendor(const
BString& vendor);
void SetSummary(const
BString& summary);
void SetPriority(uint8
priority);
@@ -59,6 +61,7 @@ public:
static const char* const kNameField;
static const char* const kURLField;
+ static const char* const kBaseURLField;
static const char* const kVendorField;
static const char* const kSummaryField;
static const char* const kPriorityField;
@@ -74,7 +77,11 @@ private:
status_t fInitStatus;
BString fName;
- BString fOriginalBaseURL;
+ BString fBaseURL;
+ // This is the URL to a single mirror. This
field is optional.
+ BString fURL;
+ // This is an identifier for the repository
that applies
+ // across mirrors.
BString fVendor;
BString fSummary;
uint8 fPriority;
diff --git a/src/apps/haikudepot/Jamfile b/src/apps/haikudepot/Jamfile
index c95e0fafe6..96195dd4ed 100644
--- a/src/apps/haikudepot/Jamfile
+++ b/src/apps/haikudepot/Jamfile
@@ -116,6 +116,7 @@ Application HaikuDepot :
#util
DataIOUtils.cpp
+ RepositoryUrlUtils.cpp
StorageUtils.cpp
ToFileUrlProtocolListener.cpp
diff --git a/src/apps/haikudepot/model/Model.cpp
b/src/apps/haikudepot/model/Model.cpp
index d5803c07cc..f1238c604f 100644
--- a/src/apps/haikudepot/model/Model.cpp
+++ b/src/apps/haikudepot/model/Model.cpp
@@ -24,6 +24,7 @@
#include "Logger.h"
#include "StorageUtils.h"
+#include "RepositoryUrlUtils.h"
#undef B_TRANSLATION_CONTEXT
@@ -1057,20 +1058,6 @@ Model::_NotifyAuthorizationChanged()
}
-// temporary - should not be required once the repo info url is used.
-static void
-normalize_repository_base_url(BUrl& url)
-{
- if (url.Protocol() == "https")
- url.SetProtocol("http");
-
- BString path(url.Path());
-
- if (path.EndsWith("/"))
- url.SetPath(path.Truncate(path.Length() - 1));
-}
-
-
void
Model::ForAllDepots(void (*func)(const DepotInfo& depot, void* context),
void* context)
@@ -1082,21 +1069,28 @@ Model::ForAllDepots(void (*func)(const DepotInfo&
depot, void* context),
}
-// TODO; should use the repo.info url and not the base url.
+/*! This method will find the stored 'DepotInfo' that correlates to the
+ supplied 'url' or 'baseUrl' and will invoke the mapper function in
+ order to get a replacement for the 'DepotInfo'. The two URLs are
+ different. The 'url' is a unique identifier for the repository that
+ holds across mirrors. The 'baseUrl' is the URL stem that was used
+ to access the repository data in the first place. The 'baseUrl' is
+ a legacy construct that exists from a time where the identifying
+ 'url' was not being relayed properly.
+*/
void
-Model::ReplaceDepotByUrl(const BString& url,
+Model::ReplaceDepotByUrl(
+ const BString& URL,
+ const BString& baseURL,
+ // deprecated
DepotMapper* depotMapper, void* context)
{
- BUrl filterUrl(url);
- normalize_repository_base_url(filterUrl);
-
for (int32 i = 0; i < fDepots.CountItems(); i++) {
DepotInfo depotInfo = fDepots.ItemAtFast(i);
- BUrl depotUrlNormalized(depotInfo.BaseURL());
- normalize_repository_base_url(depotUrlNormalized);
- if (filterUrl == depotUrlNormalized) {
+ if (RepositoryUrlUtils::EqualsOnUrlOrBaseUrl(URL,
depotInfo.URL(),
+ baseURL, depotInfo.BaseURL())) {
BAutolock locker(&fLock);
fDepots.Replace(i, depotMapper->MapDepot(depotInfo,
context));
}
diff --git a/src/apps/haikudepot/model/Model.h
b/src/apps/haikudepot/model/Model.h
index 986e70840d..52c01b1d54 100644
--- a/src/apps/haikudepot/model/Model.h
+++ b/src/apps/haikudepot/model/Model.h
@@ -167,7 +167,8 @@ public:
{
return fWebAppInterface; }
void ReplaceDepotByUrl(
- const
BString& url,
+ const
BString& URL,
+ const
BString& baseURL,
DepotMapper* depotMapper,
void*
context);
diff --git a/src/apps/haikudepot/model/PackageInfo.cpp
b/src/apps/haikudepot/model/PackageInfo.cpp
index 15e803885b..7eed1adab1 100644
--- a/src/apps/haikudepot/model/PackageInfo.cpp
+++ b/src/apps/haikudepot/model/PackageInfo.cpp
@@ -1064,7 +1064,8 @@ DepotInfo::DepotInfo(const DepotInfo& other)
fPackages(other.fPackages),
fWebAppRepositoryCode(other.fWebAppRepositoryCode),
fWebAppRepositorySourceCode(other.fWebAppRepositorySourceCode),
- fBaseURL(other.fBaseURL)
+ fBaseURL(other.fBaseURL),
+ fURL(other.fURL)
{
}
@@ -1075,6 +1076,7 @@ DepotInfo::operator=(const DepotInfo& other)
fName = other.fName;
fPackages = other.fPackages;
fBaseURL = other.fBaseURL;
+ fURL = other.fURL;
fWebAppRepositoryCode = other.fWebAppRepositoryCode;
fWebAppRepositorySourceCode = other.fWebAppRepositorySourceCode;
return *this;
@@ -1174,6 +1176,13 @@ DepotInfo::SetBaseURL(const BString& baseURL)
}
+void
+DepotInfo::SetURL(const BString& URL)
+{
+ fURL = URL;
+}
+
+
void
DepotInfo::SetWebAppRepositoryCode(const BString& code)
{
diff --git a/src/apps/haikudepot/model/PackageInfo.h
b/src/apps/haikudepot/model/PackageInfo.h
index 1d83dc823d..28e98f33ff 100644
--- a/src/apps/haikudepot/model/PackageInfo.h
+++ b/src/apps/haikudepot/model/PackageInfo.h
@@ -431,6 +431,10 @@ public:
const BString& BaseURL() const
{
return fBaseURL; }
+ void SetURL(const BString&
URL);
+ const BString& URL() const
+ {
return fURL; }
+
void
SetWebAppRepositoryCode(const BString& code);
const BString& WebAppRepositoryCode() const
{
return fWebAppRepositoryCode; }
@@ -446,6 +450,10 @@ private:
BString fWebAppRepositoryCode;
BString
fWebAppRepositorySourceCode;
BString fBaseURL;
+ // this is the URL at which the configured
repository will be
+ // accessed to get data.
+ BString fURL;
+ // this is actually a unique identifier for the
repository.
};
diff --git a/src/apps/haikudepot/server/RepositoryDataUpdateProcess.cpp
b/src/apps/haikudepot/server/RepositoryDataUpdateProcess.cpp
index bbd0eac64f..b2563e427d 100644
--- a/src/apps/haikudepot/server/RepositoryDataUpdateProcess.cpp
+++ b/src/apps/haikudepot/server/RepositoryDataUpdateProcess.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright 2017, Andrew Lindesay <apl@xxxxxxxxxxxxxx>.
+ * Copyright 2017-2018, Andrew Lindesay <apl@xxxxxxxxxxxxxx>.
* All rights reserved. Distributed under the terms of the MIT License.
*/
@@ -116,11 +116,14 @@
DepotMatchingRepositoryListener::Handle(DumpExportRepository* repository)
repositoryAndRepositorySource.repositorySource =
repository->RepositorySourcesItemAt(i);
- // TODO; replace with the repo info url
- BString* url =
repositoryAndRepositorySource.repositorySource->Url();
+ BString* baseURL = repositoryAndRepositorySource
+ .repositorySource->Url();
+ BString* URL = repositoryAndRepositorySource
+ .repositorySource->RepoInfoUrl();
- if (url->Length() > 0) {
- fModel->ReplaceDepotByUrl(*url, this,
+
+ if (!baseURL->IsEmpty() || !URL->IsEmpty()) {
+ fModel->ReplaceDepotByUrl(*URL, *baseURL, this,
&repositoryAndRepositorySource);
}
}
diff --git a/src/apps/haikudepot/ui/MainWindow.cpp
b/src/apps/haikudepot/ui/MainWindow.cpp
index f6f81ce113..7cfe02ca40 100644
--- a/src/apps/haikudepot/ui/MainWindow.cpp
+++ b/src/apps/haikudepot/ui/MainWindow.cpp
@@ -12,9 +12,9 @@
#include "MainWindow.h"
#include <map>
+#include <vector>
#include <stdio.h>
-
#include <Alert.h>
#include <Autolock.h>
#include <Application.h>
@@ -55,6 +55,7 @@
#include "PackageListView.h"
#include "PackageManager.h"
#include "RatePackageWindow.h"
+#include "RepositoryUrlUtils.h"
#include "support.h"
#include "ScreenshotWindow.h"
#include "UserLoginWindow.h"
@@ -87,7 +88,6 @@ using namespace BPackageKit::BManager::BPrivate;
typedef std::map<BString, PackageInfoRef> PackageInfoMap;
-typedef std::map<BString, DepotInfo> DepotInfoMap;
struct RefreshWorkerParameters {
@@ -943,7 +943,7 @@ MainWindow::_RefreshPackageList(bool force)
if (result != B_OK)
return;
- DepotInfoMap depots;
+ std::vector<DepotInfo> depots(repositoryNames.CountStrings());
for (int32 i = 0; i < repositoryNames.CountStrings(); i++) {
const BString& repoName = repositoryNames.StringAt(i);
DepotInfo depotInfo = DepotInfo(repoName);
@@ -954,13 +954,22 @@ MainWindow::_RefreshPackageList(bool force)
if (getRepositoryConfigStatus == B_OK) {
depotInfo.SetBaseURL(repoConfig.BaseURL());
+ depotInfo.SetURL(repoConfig.URL());
+
+ if (Logger::IsDebugEnabled()) {
+ printf("local repository [%s] info;\n"
+ " * base url [%s]\n"
+ " * url [%s]\n",
+ repoName.String(),
repoConfig.BaseURL().String(),
+ repoConfig.URL().String());
+ }
} else {
printf("unable to obtain the repository config for
local "
"repository '%s'; %s\n",
repoName.String(),
strerror(getRepositoryConfigStatus));
}
- depots[repoName] = depotInfo;
+ depots[i] = depotInfo;
}
PackageManager manager(B_PACKAGE_INSTALLATION_LOCATION_HOME);
@@ -1039,16 +1048,34 @@ MainWindow::_RefreshPackageList(bool force)
modelInfo->AddListener(this);
BSolverRepository* repository = package->Repository();
- if (dynamic_cast<BPackageManager::RemoteRepository*>(repository)
- != NULL) {
- if (depots.count(repositoryName) == 0) {
+ BPackageManager::RemoteRepository* remoteRepository =
+
dynamic_cast<BPackageManager::RemoteRepository*>(repository);
+
+ if (remoteRepository != NULL) {
+
+ std::vector<DepotInfo>::iterator it;
+
+ for (it = depots.begin(); it != depots.end(); it++) {
+ if (RepositoryUrlUtils::EqualsOnUrlOrBaseUrl(
+ it->URL(),
remoteRepository->Config().URL(),
+ it->BaseURL(),
remoteRepository->Config().BaseURL())) {
+ break;
+ }
+ }
+
+ if (it == depots.end()) {
if (Logger::IsDebugEnabled()) {
- printf("pkg [%s] is in an unknown
repository [%s] so will "
- "be excluded from the list of
managed packages\n",
+ printf("pkg [%s] repository [%s] not
recognized"
+ " --> ignored\n",
modelInfo->Name().String(),
repositoryName.String());
}
} else {
- depots[repositoryName].AddPackage(modelInfo);
+ it->AddPackage(modelInfo);
+
+ if (Logger::IsTraceEnabled()) {
+ printf("pkg [%s] assigned to [%s]\n",
+ modelInfo->Name().String(),
repositoryName.String());
+ }
}
remotePackages[modelInfo->Name()] = modelInfo;
@@ -1091,19 +1118,23 @@ MainWindow::_RefreshPackageList(bool force)
if (!foundPackages.empty()) {
BString repoName = B_TRANSLATE("Local");
- depots[repoName] = DepotInfo(repoName);
- DepotInfoMap::iterator depot = depots.find(repoName);
+ depots.push_back(DepotInfo(repoName));
+
for (PackageInfoMap::iterator it = foundPackages.begin();
it != foundPackages.end(); ++it) {
- depot->second.AddPackage(it->second);
+ depots.back().AddPackage(it->second);
}
}
- for (DepotInfoMap::iterator it = depots.begin(); it != depots.end();
it++) {
- if (fModel.HasDepot(it->second.Name()))
- fModel.SyncDepot(it->second);
- else
- fModel.AddDepot(it->second);
+ {
+ std::vector<DepotInfo>::iterator it;
+
+ for (it = depots.begin(); it != depots.end(); it++) {
+ if (fModel.HasDepot(it->Name()))
+ fModel.SyncDepot(*it);
+ else
+ fModel.AddDepot(*it);
+ }
}
// start retrieving package icons and average ratings
diff --git a/src/apps/haikudepot/util/RepositoryUrlUtils.cpp
b/src/apps/haikudepot/util/RepositoryUrlUtils.cpp
new file mode 100644
index 0000000000..55365deacd
--- /dev/null
+++ b/src/apps/haikudepot/util/RepositoryUrlUtils.cpp
@@ -0,0 +1,50 @@
+/*
+ * Copyright 2018, Andrew Lindesay <apl@xxxxxxxxxxxxxx>.
+ * All rights reserved. Distributed under the terms of the MIT License.
+ */
+
+
+#include "RepositoryUrlUtils.h"
+
+
+void
+RepositoryUrlUtils::NormalizeUrl(BUrl& url)
+{
+ if (url.Protocol() == "https")
+ url.SetProtocol("http");
+
+ BString path(url.Path());
+
+ if (path.EndsWith("/"))
+ url.SetPath(path.Truncate(path.Length() - 1));
+}
+
+
+bool
+RepositoryUrlUtils::EqualsNormalized(const BString& url1, const BString& url2)
+{
+ if (url1.IsEmpty())
+ return false;
+
+ BUrl normalizedUrl1(url1);
+ NormalizeUrl(normalizedUrl1);
+ BUrl normalizedUrl2(url2);
+ NormalizeUrl(normalizedUrl2);
+
+ return normalizedUrl1 == normalizedUrl2;
+}
+
+
+/*! Matches on either the identifier URL of the repo or the 'base' URL that was
+ used to access the repository over the internet. The use of the 'base' URL
+ is deprecated.
+*/
+
+bool
+RepositoryUrlUtils::EqualsOnUrlOrBaseUrl(const BString& url1,
+ const BString& url2, const BString& baseUrl1,
+ const BString& baseUrl2)
+{
+ return (!url1.IsEmpty() && url1 == url2)
+ || EqualsNormalized(baseUrl1, baseUrl2);
+}
\ No newline at end of file
diff --git a/src/apps/haikudepot/util/RepositoryUrlUtils.h
b/src/apps/haikudepot/util/RepositoryUrlUtils.h
new file mode 100644
index 0000000000..f7342a2e5f
--- /dev/null
+++ b/src/apps/haikudepot/util/RepositoryUrlUtils.h
@@ -0,0 +1,26 @@
+/*
+ * Copyright 2018, Andrew Lindesay <apl@xxxxxxxxxxxxxx>.
+ * All rights reserved. Distributed under the terms of the MIT License.
+ */
+#ifndef REPOSITORY_URL_UTILS_H
+#define REPOSITORY_URL_UTILS_H
+
+
+#include <Url.h>
+
+
+class RepositoryUrlUtils {
+
+public:
+ static void NormalizeUrl(BUrl& url);
+ static bool EqualsNormalized(const BString&
url1,
+ const BString&
url2);
+ static bool EqualsNormalized(const BUrl&
normalizedUrl1,
+ const BString&
url2);
+ static bool EqualsOnUrlOrBaseUrl(const
BString& url1,
+ const BString&
url2, const BString& baseUrl1,
+ const BString&
baseUrl2);
+};
+
+
+#endif // REPOSITORY_URL_UTILS_H
diff --git a/src/bin/package_repo/command_list.cpp
b/src/bin/package_repo/command_list.cpp
index c2dcd12203..bcb5ede6de 100644
--- a/src/bin/package_repo/command_list.cpp
+++ b/src/bin/package_repo/command_list.cpp
@@ -69,7 +69,8 @@ struct RepositoryContentListHandler :
BRepositoryContentHandler {
printf("repository-info:\n");
printf("\tname: %s\n", repositoryInfo.Name().String());
printf("\tsummary: %s\n", repositoryInfo.Summary().String());
- printf("\turl: %s\n",
repositoryInfo.OriginalBaseURL().String());
+ printf("\tbase-url: %s\n", repositoryInfo.BaseURL().String());
+ printf("\turl: %s\n", repositoryInfo.URL().String());
printf("\tvendor: %s\n", repositoryInfo.Vendor().String());
printf("\tpriority: %u\n", repositoryInfo.Priority());
printf("\tarchitecture: %s\n",
diff --git a/src/bin/pkgman/command_list_repos.cpp
b/src/bin/pkgman/command_list_repos.cpp
index 677983a8f6..cc97b888cb 100644
--- a/src/bin/pkgman/command_list_repos.cpp
+++ b/src/bin/pkgman/command_list_repos.cpp
@@ -104,6 +104,7 @@ ListReposCommand::Execute(int argc, const char* const* argv)
repoConfig.IsUserSpecific() ? "[User]" : " ",
repoConfig.Name().String());
printf("\t\tbase-url: %s\n", repoConfig.BaseURL().String());
+ printf("\t\turl: %s\n", repoConfig.URL().String());
printf("\t\tpriority: %u\n", repoConfig.Priority());
if (verbose) {
@@ -118,8 +119,10 @@ ListReposCommand::Execute(int argc, const char* const*
argv)
repoCache.Info().Architecture()]);
printf("\t\tpkg-count: %" B_PRIu32 "\n",
repoCache.CountPackages());
- printf("\t\torig-url: %s\n",
-
repoCache.Info().OriginalBaseURL().String());
+ printf("\t\tbase-url: %s\n",
+ repoCache.Info().BaseURL().String());
+ printf("\t\turl: %s\n",
+ repoCache.Info().URL().String());
printf("\t\torig-prio: %u\n",
repoCache.Info().Priority());
} else
printf("\t\t<no repository cache found>\n");
diff --git a/src/data/repository_infos/haiku b/src/data/repository_infos/haiku
index 99ecd60867..7f2e5a165e 100644
--- a/src/data/repository_infos/haiku
+++ b/src/data/repository_infos/haiku
@@ -2,5 +2,6 @@ name Haiku
vendor "Haiku Project"
summary "The Haiku repository (for Haiku %HAIKU_VERSION_NO_REVISION%)"
priority 1
-url https://packages.haiku-os.org/haiku/master/%HAIKU_PACKAGING_ARCH%/current
+baseurl
https://download.haiku-os.org/haiku-repositories/master/%HAIKU_PACKAGING_ARCH%/current
+url
https://download.haiku-os.org/haiku-repositories/master/%HAIKU_PACKAGING_ARCH%/current
architecture %HAIKU_PACKAGING_ARCH%
diff --git a/src/data/repository_infos/haikuports
b/src/data/repository_infos/haikuports
index 9893e70049..7e6ddc0ed4 100644
--- a/src/data/repository_infos/haikuports
+++ b/src/data/repository_infos/haikuports
@@ -2,5 +2,6 @@ name HaikuPorts
vendor "Haiku Project"
summary "The HaikuPorts repository (for Haiku %HAIKU_VERSION_NO_REVISION%)"
priority 1
+baseurl
https://eu.hpkg.haiku-os.org/haikuports/master/repository/%HAIKU_PACKAGING_ARCH%/current
url
https://eu.hpkg.haiku-os.org/haikuports/master/repository/%HAIKU_PACKAGING_ARCH%/current
architecture %HAIKU_PACKAGING_ARCH%
diff --git a/src/kits/package/ActivateRepositoryConfigJob.cpp
b/src/kits/package/ActivateRepositoryConfigJob.cpp
index a1aadb4a8b..f2bf86162c 100644
--- a/src/kits/package/ActivateRepositoryConfigJob.cpp
+++ b/src/kits/package/ActivateRepositoryConfigJob.cpp
@@ -1,9 +1,10 @@
/*
- * Copyright 2011-2015, Haiku, Inc. All Rights Reserved.
+ * Copyright 2011-2018, Haiku, Inc. All Rights Reserved.
* Distributed under the terms of the MIT License.
*
* Authors:
* Oliver Tappe <zooey@xxxxxxxxxxxxxxx>
+ * Andrew Lindesay <apl@xxxxxxxxxxxxxx>
*/
@@ -59,11 +60,19 @@ ActivateRepositoryConfigJob::Execute()
}
// create and store the configuration (injecting the BaseURL that was
- // actually used)
+ // actually used).
BRepositoryConfig repoConfig;
repoConfig.SetName(repoInfo.Name());
repoConfig.SetBaseURL(fRepositoryBaseURL);
+ repoConfig.SetURL(repoInfo.URL());
repoConfig.SetPriority(repoInfo.Priority());
+
+ if (fRepositoryBaseURL.IsEmpty()) {
+ repoConfig.SetBaseURL(repoInfo.BaseURL());
+ } else {
+ repoConfig.SetBaseURL(fRepositoryBaseURL);
+ }
+
if ((result = repoConfig.Store(fTargetEntry)) != B_OK)
return result;
diff --git a/src/kits/package/RepositoryConfig.cpp
b/src/kits/package/RepositoryConfig.cpp
index a5eeb49447..2f40083a68 100644
--- a/src/kits/package/RepositoryConfig.cpp
+++ b/src/kits/package/RepositoryConfig.cpp
@@ -1,9 +1,10 @@
/*
- * Copyright 2011-2013, Haiku, Inc. All Rights Reserved.
+ * Copyright 2011-2018, Haiku, Inc. All Rights Reserved.
* Distributed under the terms of the MIT License.
*
* Authors:
* Oliver Tappe <zooey@xxxxxxxxxxxxxxx>
+ * Andrew Lindesay <apl@xxxxxxxxxxxxxx>
*/
@@ -22,6 +23,15 @@
#include <DriverSettings.h>
+#define STORAGE_VERSION 2
+
+#define KEY_BASE_URL "baseurl"
+#define KEY_BASE_URL_LEGACY "url"
+ // deprecated
+#define KEY_URL "url"
+#define KEY_PRIORITY "priority"
+#define KEY_CONFIG_VERSION "cfgversion"
+
namespace BPackageKit {
@@ -66,9 +76,21 @@ BRepositoryConfig::Store(const BEntry& entry) const
return result;
BString configString;
- configString
- << "url=" << fBaseURL << "\n"
- << "priority=" << fPriority << "\n";
+ configString << KEY_CONFIG_VERSION << "=" << STORAGE_VERSION << "\n";
+ configString << "\n";
+ configString << "# This is the URL where the repository data can be "
+ "accessed.\n";
+ configString << KEY_BASE_URL << "=" << fBaseURL << "\n";
+ configString << "\n";
+ configString << "# This URL is an identifier for the repository that is
"
+ "consistent across mirrors\n";
+
+ if (fURL.IsEmpty())
+ configString << "# " << KEY_URL << "=???\n";
+ else
+ configString << KEY_URL << "=" << fURL << "\n";
+ configString << "\n";
+ configString << KEY_PRIORITY << "=" << fPriority << "\n";
int32 size = configString.Length();
if ((result = file.Write(configString.String(), size)) < size)
@@ -101,16 +123,26 @@ BRepositoryConfig::SetTo(const BEntry& entry)
if (result != B_OK)
return result;
- const char* url = driverSettings.GetParameterValue("url");
- const char* priorityString =
driverSettings.GetParameterValue("priority");
+ const char* url = NULL;
+ const char* version =
driverSettings.GetParameterValue(KEY_CONFIG_VERSION);
+ const char *baseUrlKey = KEY_BASE_URL;
+
+ if (version == NULL || atoi(version) < 2)
+ baseUrlKey = KEY_BASE_URL_LEGACY;
+ else
+ url = driverSettings.GetParameterValue(KEY_URL);
+
+ const char* baseUrl = driverSettings.GetParameterValue(baseUrlKey);
+ const char* priorityString =
driverSettings.GetParameterValue(KEY_PRIORITY);
- if (url == NULL || *url == '\0')
+ if (baseUrl == NULL || *baseUrl == '\0')
return B_BAD_DATA;
fName = entry.Name();
- fBaseURL = url;
+ fBaseURL = baseUrl;
fPriority = priorityString == NULL
? kUnsetPriority : atoi(priorityString);
+ fURL = url == NULL ? "" : url;
BPath userSettingsPath;
if (find_directory(B_USER_SETTINGS_DIRECTORY, &userSettingsPath) ==
B_OK) {
@@ -139,6 +171,13 @@ BRepositoryConfig::BaseURL() const
}
+const BString&
+BRepositoryConfig::URL() const
+{
+ return fURL;
+}
+
+
uint8
BRepositoryConfig::Priority() const
{
@@ -183,6 +222,13 @@ BRepositoryConfig::SetBaseURL(const BString& baseURL)
}
+void
+BRepositoryConfig::SetURL(const BString& URL)
+{
+ fURL = URL;
+}
+
+
void
BRepositoryConfig::SetPriority(uint8 priority)
{
diff --git a/src/kits/package/RepositoryInfo.cpp
b/src/kits/package/RepositoryInfo.cpp
index aaff367a6e..09c722c96d 100644
--- a/src/kits/package/RepositoryInfo.cpp
+++ b/src/kits/package/RepositoryInfo.cpp
@@ -1,9 +1,10 @@
/*
- * Copyright 2011, Haiku, Inc. All Rights Reserved.
+ * Copyright 2011-2018, Haiku, Inc. All Rights Reserved.
* Distributed under the terms of the MIT License.
*
* Authors:
* Oliver Tappe <zooey@xxxxxxxxxxxxxxx>
+ * Andrew Lindesay <apl@xxxxxxxxxxxxxx>
*/
@@ -28,6 +29,7 @@ const uint8 BRepositoryInfo::kDefaultPriority = 50;
const char* const BRepositoryInfo::kNameField = "name";
const char* const BRepositoryInfo::kURLField = "url";
+const char* const BRepositoryInfo::kBaseURLField = "baseUrl";
const char* const BRepositoryInfo::kVendorField =
"vendor";
const char* const BRepositoryInfo::kSummaryField = "summary";
const char* const BRepositoryInfo::kPriorityField = "priority";
@@ -82,9 +84,14 @@ BRepositoryInfo::Archive(BMessage* data, bool deep) const
if (result != B_OK)
return result;
+ if (!fBaseURL.IsEmpty()) {
+ if ((result = data->AddString(kBaseURLField, fBaseURL)) != B_OK)
+ return result;
+ }
+
if ((result = data->AddString(kNameField, fName)) != B_OK)
return result;
- if ((result = data->AddString(kURLField, fOriginalBaseURL)) != B_OK)
+ if ((result = data->AddString(kURLField, fURL)) != B_OK)
return result;
if ((result = data->AddString(kVendorField, fVendor)) != B_OK)
return result;
@@ -139,9 +146,16 @@ BRepositoryInfo::Name() const
const BString&
-BRepositoryInfo::OriginalBaseURL() const
+BRepositoryInfo::BaseURL() const
+{
+ return fBaseURL;
+}
+
+
+const BString&
+BRepositoryInfo::URL() const
{
- return fOriginalBaseURL;
+ return fURL;
}
@@ -195,9 +209,16 @@ BRepositoryInfo::SetName(const BString& name)
void
-BRepositoryInfo::SetOriginalBaseURL(const BString& url)
+BRepositoryInfo::SetURL(const BString& url)
{
- fOriginalBaseURL = url;
+ fURL = url;
+}
+
+
+void
+BRepositoryInfo::SetBaseURL(const BString& url)
+{
+ fBaseURL = url;
}
@@ -254,15 +275,17 @@ BRepositoryInfo::_SetTo(const BMessage* data)
if (data == NULL)
return B_BAD_VALUE;
+ data->FindString(kBaseURLField, &fBaseURL);
+ // optional value for historical reasons
+
status_t result;
if ((result = data->FindString(kNameField, &fName)) != B_OK)
return result;
- if ((result = data->FindString(kURLField, &fOriginalBaseURL)) != B_OK)
+ if ((result = data->FindString(kURLField, &fURL)) != B_OK)
return result;
if ((result = data->FindString(kVendorField, &fVendor)) != B_OK)
return result;
- result = data->FindString(kSummaryField, &fSummary);
- if (result != B_OK)
+ if ((result = data->FindString(kSummaryField, &fSummary)) != B_OK)
return result;
if ((result = data->FindUInt8(kPriorityField, &fPriority)) != B_OK)
return result;
@@ -319,6 +342,7 @@ BRepositoryInfo::_SetTo(const BEntry& entry)
const char* name = get_driver_parameter(settingsHandle, "name", NULL,
NULL);
const char* url = get_driver_parameter(settingsHandle, "url", NULL,
NULL);
+ const char* baseUrl = get_driver_parameter(settingsHandle, "baseurl",
NULL, NULL);
const char* vendor
= get_driver_parameter(settingsHandle, "vendor", NULL, NULL);
const char* summary
@@ -343,7 +367,8 @@ BRepositoryInfo::_SetTo(const BEntry& entry)
}
fName = name;
- fOriginalBaseURL = url;
+ fBaseURL = baseUrl;
+ fURL = url;
fVendor = vendor;
fSummary = summary;
fPriority = atoi(priorityString);
diff --git a/src/tests/kits/package/make_repo.cpp
b/src/tests/kits/package/make_repo.cpp
index 4b0f442929..500fdc1203 100644
--- a/src/tests/kits/package/make_repo.cpp
+++ b/src/tests/kits/package/make_repo.cpp
@@ -22,7 +22,7 @@ main(int argc, const char** argv)
BRepositoryInfo repoInfo;
repoInfo.SetName(argv[1]);
- repoInfo.SetOriginalBaseURL(argv[2]);
+ repoInfo.SetURL(argv[2]);
repoInfo.SetPriority(atoi(argv[3]));
BMessage repoInfoArchive;
diff --git a/src/tools/create_repository_config/create_repository_config.cpp
b/src/tools/create_repository_config/create_repository_config.cpp
index 9837945b31..fda2939afc 100644
--- a/src/tools/create_repository_config/create_repository_config.cpp
+++ b/src/tools/create_repository_config/create_repository_config.cpp
@@ -1,9 +1,10 @@
/*
- * Copyright 2013, Haiku, Inc. All Rights Reserved.
+ * Copyright 2013-2018, Haiku, Inc. All Rights Reserved.
* Distributed under the terms of the MIT License.
*
* Authors:
* Ingo Weinhold <ingo_weinhold@xxxxxx>
+ * Andrew Lindesay <apl@xxxxxxxxxxxxxx>
*/
@@ -59,7 +60,7 @@ main(int argc, const char* const* argv)
}
int argi = 1;
- const char* url = argc == 4 ? argv[argi++] : NULL;
+ const char* baseUrl = argc == 4 ? argv[argi++] : NULL;
const char* infoPath = argv[argi++];
const char* configPath = argv[argi++];
@@ -68,13 +69,18 @@ main(int argc, const char* const* argv)
DIE_ON_ERROR(repoInfo.SetTo(infoPath),
"failed to read repository info file \"%s\"", infoPath);
- if (url == NULL)
- url = repoInfo.OriginalBaseURL();
+ if (baseUrl == NULL) {
+ if (repoInfo.BaseURL().IsEmpty())
+ baseUrl = repoInfo.URL();
+ else
+ baseUrl = repoInfo.BaseURL();
+ }
// init and write the config
BPackageKit::BRepositoryConfig repoConfig;
repoConfig.SetName(repoInfo.Name());
- repoConfig.SetBaseURL(url);
+ repoConfig.SetBaseURL(baseUrl);
+ repoConfig.SetURL(repoInfo.URL());
repoConfig.SetPriority(repoInfo.Priority());
DIE_ON_ERROR(repoConfig.Store(configPath),
"failed to write repository config file \"%s\"", configPath);
diff --git a/src/tools/get_package_dependencies/get_package_dependencies.cpp
b/src/tools/get_package_dependencies/get_package_dependencies.cpp
index ec213db8d9..9da69d4c82 100644
--- a/src/tools/get_package_dependencies/get_package_dependencies.cpp
+++ b/src/tools/get_package_dependencies/get_package_dependencies.cpp
@@ -1,9 +1,10 @@
/*
- * Copyright 2013, Haiku, Inc. All Rights Reserved.
+ * Copyright 2013-2018, Haiku, Inc. All Rights Reserved.
* Distributed under the terms of the MIT License.
*
* Authors:
* Ingo Weinhold <ingo_weinhold@xxxxxx>
+ * Andrew Lindesay <apl@xxxxxxxxxxxxxx>
*/
@@ -154,7 +155,7 @@ main(int argc, const char* const* argv)
if (package->Repository() !=
&installedRepository) {
const BRepositoryInfo& info
=
repositoryInfos[package->Repository()];
- BString url = info.OriginalBaseURL();
+ BString url = info.URL();
url << "/packages/" <<
package->Info().CanonicalFileName();
printf("%s\n", url.String());
}