diff options
-rw-r--r-- | doc/installerfw.qdoc | 41 | ||||
-rw-r--r-- | src/libs/installer/metadatajob.cpp | 16 |
2 files changed, 51 insertions, 6 deletions
diff --git a/doc/installerfw.qdoc b/doc/installerfw.qdoc index a937631bd..c126e3467 100644 --- a/doc/installerfw.qdoc +++ b/doc/installerfw.qdoc @@ -1228,6 +1228,14 @@ displayname="Example Repository" /> \endcode + \c{url} will be used as a base url to resolve an \c{Updates.xml} file against. + If \c{url} is itself relative, it will be resolved against the base url of the current document. + + \c{displayname} specifies how the repository should be named in the \gui Settings page + of the Maintenance Tool. + + \c{name} and \c{password} optionally specify credentials for a protected repository. + \section2 Removing Repositories To remove a repository, add a \c <Repository> child element to the \c <RepositoryUpdate> element with the following options: @@ -1236,15 +1244,44 @@ <Repository action="remove" url="http://www.example.com/repository" /> \endcode + \c{url} must match exactly the url that is to be removed. + \section2 Replacing Repositories To replace one repository with another, add a \c <Repository> child element to the \c <RepositoryUpdate> element with the following options: \code - <Repository action="replace" oldurl="http://www.example.com/repository" - newurl="http://www.example.com/newrepository" name="user" password="password" + <Repository action="replace" oldUrl="http://www.example.com/repository" + newUrl="http://www.example.com/newrepository" name="user" password="password" displayname="New Example Repository" /> \endcode + + \c{oldUrl} must match exactly the url that is to be replaced. + + \c{newUrl} must match exactly the url that is replace to. + + \section1 Relocatable Repositories + + Some projects contain multiple repositories. To create relocatable set + of repositories you should use relative paths. + + So if generic repository available at address \c{http://www.example.com/repositories/generic} + and \c{Updates.xml} contains \c <Repository> element with the following options: + + \code + <Repository action="add" url="../module" name="user" password="password" + displayname="Module Repository" /> + \endcode + + Resolved address of added repository will be \c{http://www.example.com/repositories/module}. + So that the repository does not contain information about their absolute location. + + If you want to change the address, you can simply copy a set of repositories as is. + It recommended for some time to maintain the old generic repository and replace addresses + as described above. You can also provide the updated installer with the new generic address. + + You can use relative path for arguments \c url, \c oldUrl and \c newUrl at + \c <Repository> element. */ /*! diff --git a/src/libs/installer/metadatajob.cpp b/src/libs/installer/metadatajob.cpp index aad387232..584d23b0d 100644 --- a/src/libs/installer/metadatajob.cpp +++ b/src/libs/installer/metadatajob.cpp @@ -44,6 +44,14 @@ namespace QInstaller { +static QUrl resolveUrl(const FileTaskResult &result, const QString &url) +{ + QUrl u(url); + if (u.isRelative()) + return QUrl(result.taskItem().source()).resolved(u); + return u; +} + MetadataJob::MetadataJob(QObject *parent) : KDJob(parent) , m_core(0) @@ -379,7 +387,7 @@ MetadataJob::Status MetadataJob::parseUpdatesXml(const QList<FileTaskResult> &re const QString action = el.attribute(QLatin1String("action")); if (action == QLatin1String("add")) { // add a new repository to the defaults list - Repository repository(el.attribute(QLatin1String("url")), true); + Repository repository(resolveUrl(result, el.attribute(QLatin1String("url"))), true); repository.setUsername(el.attribute(QLatin1String("username"))); repository.setPassword(el.attribute(QLatin1String("password"))); repository.setDisplayName(el.attribute(QLatin1String("displayname"))); @@ -389,15 +397,15 @@ MetadataJob::Status MetadataJob::parseUpdatesXml(const QList<FileTaskResult> &re } } else if (action == QLatin1String("remove")) { // remove possible default repositories using the given server url - Repository repository(el.attribute(QLatin1String("url")), true); + Repository repository(resolveUrl(result, el.attribute(QLatin1String("url"))), true); repository.setDisplayName(el.attribute(QLatin1String("displayname"))); repositoryUpdates.insertMulti(action, qMakePair(repository, Repository())); qDebug() << "Repository to remove:" << repository.displayname(); } else if (action == QLatin1String("replace")) { // replace possible default repositories using the given server url - Repository oldRepository(el.attribute(QLatin1String("oldUrl")), true); - Repository newRepository(el.attribute(QLatin1String("newUrl")), true); + Repository oldRepository(resolveUrl(result, el.attribute(QLatin1String("oldUrl"))), true); + Repository newRepository(resolveUrl(result, el.attribute(QLatin1String("newUrl"))), true); newRepository.setUsername(el.attribute(QLatin1String("username"))); newRepository.setPassword(el.attribute(QLatin1String("password"))); newRepository.setDisplayName(el.attribute(QLatin1String("displayname"))); |