Fix behaviour of 'package_repo update':

* Instead of copying over the repository info from the source 
  repository, we need to read the repository info from a repository 
  info file corresponding to the target repository. Among other 
  problems, copying over the repository info from the source repo 
  put the wrong repository URL into the new repository, which in
  turn caused the package resolution done by Haiku's build system to
  fail (it tried to download packages from the wrong URL).
Additionally, I have updated the incorrect repository on the server, so
building Haiku-x86 should work again.
This commit is contained in:
Oliver Tappe 2013-11-14 01:51:33 +01:00
parent c9db30cd7f
commit 8e72745123
2 changed files with 43 additions and 23 deletions

View File

@ -15,7 +15,7 @@
#include <Entry.h>
#include <ObjectList.h>
#include <Path.h>
#include <String.h>
#include <package/hpkg/HPKGDefs.h>
#include <package/hpkg/PackageInfoAttributeValue.h>
@ -257,27 +257,47 @@ command_update(int argc, const char* const* argv)
const char* targetRepositoryFileName = argv[optind++];
const char* packageListFileName = argv[optind++];
// open source repository
BStandardErrorOutput errorOutput;
BRepositoryReader repositoryReader(&errorOutput);
status_t error = repositoryReader.Init(sourceRepositoryFileName);
if (error != B_OK)
return 1;
// collect package infos and repository info from source repository
PackageInfos packageInfos;
PackageInfosCollector packageInfosCollector(packageInfos, &errorOutput);
error = repositoryReader.ParseContent(&packageInfosCollector);
if (error != B_OK)
return 1;
RepositoryWriterListener listener(verbose, quiet);
BRepositoryInfo repositoryInfo = packageInfosCollector.RepositoryInfo();
BEntry sourceRepositoryEntry(sourceRepositoryFileName);
if (!sourceRepositoryEntry.Exists()) {
listener.PrintError(
"Error: given source repository file '%s' doesn't exist!\n",
sourceRepositoryFileName);
return 1;
}
// determine path for 'repo.info' file from given new repository file
BString repositoryInfoFileName(targetRepositoryFileName);
repositoryInfoFileName.Append(".info");
BEntry repositoryInfoEntry(repositoryInfoFileName.String());
BRepositoryInfo repositoryInfo(repositoryInfoEntry);
status_t result = repositoryInfo.InitCheck();
if (result != B_OK) {
listener.PrintError(
"Error: didn't get a proper repository-info from source repository"
": %s - error: %s\n", sourceRepositoryFileName, strerror(result));
"Error: can't parse/read repository-info file %s : %s\n",
repositoryInfoFileName.String(), strerror(result));
return 1;
}
// open source repository
BRepositoryReader repositoryReader(&errorOutput);
result = repositoryReader.Init(sourceRepositoryFileName);
if (result != B_OK) {
listener.PrintError(
"Error: can't read from old repository file : %s\n",
strerror(result));
return 1;
}
// collect package infos from source repository
PackageInfos packageInfos;
PackageInfosCollector packageInfosCollector(packageInfos, &errorOutput);
result = repositoryReader.ParseContent(&packageInfosCollector);
if (result != B_OK) {
listener.PrintError(
"Error: couldn't fetch package infos from old repository : %s\n",
strerror(result));
return 1;
}

View File

@ -21,9 +21,9 @@ static const char* kUsage =
"Creates or inspects a Haiku package repository file.\n"
"\n"
"Commands:\n"
" create [ <options> ] <package-repo> <package-file ...> \n"
" Creates package repository file <package-repo> from the given\n"
" package files.\n"
" create [ <options> ] <repo-info> <package-file ...> \n"
" Creates a package repository from the information found in \n"
" <repo-info>, adding the given package files.\n"
"\n"
" -C <dir> - Change to directory <dir> before starting.\n"
" -q - be quiet (don't show any output except for errors).\n"
@ -34,11 +34,11 @@ static const char* kUsage =
"\n"
" -v - be verbose (list attributes of all packages found).\n"
"\n"
" update [ <options> ] <old-repo> <new-repo> <package-list-file> \n"
" update [ <options> ] <source-repo> <new-repo> <package-list-file> \n"
" Creates package repository file <new-repo> with all the packages\n"
" contained in <package-list-file>. If possible, package-infos are\n"
" taken from <old-repo> to avoid the need for recomputing the checksum\n"
" of all packages.\n"
" taken from <source-repo> to avoid the need for recomputing the\n"
" checksum of all packages.\n"
" <old-repo> and <new-repo> can be the same file.\n"
"\n"
" -C <dir> - Change to directory <dir> before starting.\n"