Change repository directory layout

* Under the base URL there are supposed to be the repository files and a
  subdirectory "packages".
* Fix the repository URL related confusion introduced earlier. The URL
in
  the repository info (and thus in the repository file) is supposed to
  be the base URL for the repository. It is not a (potentially)
  different base URL for the package files. Package and repository
  files were supposed to live in the same directory. Now, by requiring
  the package files to live in a subdirectory -- which can also be a
  symlink -- we gain some flexibility.
  The URL in the repository config is usually the same as the in the
  repository info, unless it refers to a mirror site. This allows for
  mirrors to copy the original repository verbatim.
* Remove the PackageURL rule and introduce a DownloadPackage rule
  instead. The URL for a package file cannot be computed in the jam
  parsing phase anymore, as it contains the hash value of the package
  list.
* BRepositoryConfig: Add PackagesURL() for convenience.
This commit is contained in:
Ingo Weinhold 2013-07-06 18:06:02 +02:00
parent 600620e790
commit 014eed80e2
8 changed files with 42 additions and 17 deletions

View File

@ -1006,6 +1006,8 @@ rule AddHaikuImagePackages packages : installationLocation
# is either "system" or "common" (the default) and specifies where the
# packages shall be installed.
installationLocation ?= common ;
local package ;
for package in $(packages) {
if ! [ on $(package) return $(HAIKU_PACKAGE_ADDED) ] {
@ -1018,8 +1020,14 @@ rule AddHaikuImagePackages packages : installationLocation
HAIKU_PACKAGE_ADDED on $(package) = 1 ;
HAIKU_ADDED_PACKAGES += $(package) ;
InstallOptionalHaikuImagePackage [ PackageURL $(package) ]
: $(installationLocation) ;
# download the package file and add it to the image
local file = [ DownloadPackage $(package) ] ;
if $(HAIKU_UPDATE_ALL_PACKAGES) {
HAIKU_INCLUDE_IN_IMAGE on $(file) = 1 ;
}
AddPackageFilesToHaikuImage $(installationLocation) : $(file) ;
}
}
}

View File

@ -695,12 +695,10 @@ rule ExtractBuildFeatureArchives feature : list
}
local package = $(list[2]) ;
local url = [ PackageURL $(list[3]) ] ;
local fileName = $(url:BS) ;
local file = [ DownloadPackage $(list[3]) ] ;
local fileName = $(file:BS) ;
list = $(list[4-]) ;
local file = [ DownloadFile $(fileName) : $(url) ] ;
local directory = [ FDirName $(HAIKU_OPTIONAL_BUILD_PACKAGES_DIR)
$(fileName:B) ] ;
directory = $(directory:G=$(package)) ;

View File

@ -39,8 +39,8 @@ rule AddRepositoryPackages repository : architecture : packages : sourcePackages
}
rule PackageRepository repository : architecture : repositoryUrl : packagesUrl
: anyPackages : packages : sourcePackages
rule PackageRepository repository : architecture : repositoryUrl : anyPackages
: packages : sourcePackages
{
repository = $(repository:G=repository) ;
@ -50,7 +50,6 @@ rule PackageRepository repository : architecture : repositoryUrl : packagesUrl
HAIKU_REPOSITORIES += $(repository) ;
HAIKU_REPOSITORY_URL on $(repository) = $(repositoryUrl) ;
HAIKU_REPOSITORY_PACKAGES_URL on $(repository) = $(packagesUrl) ;
HAIKU_REPOSITORY_DEFINITION_FILE on $(repository)
= $(HAIKU_REPOSITORY_JAMFILE) ;
@ -95,6 +94,8 @@ rule PackageRepository repository : architecture : repositoryUrl : packagesUrl
HAIKU_REPOSITORY_CACHE_FILE on $(repository) = $(repositoryFile) ;
HAIKU_REPOSITORY_CONFIG_FILE on $(repository) = $(repositoryConfig) ;
HAIKU_REPOSITORY_PACKAGES_CHECKSUM_FILE on $(repository)
= $(packagesChecksumFile) ;
}
@ -156,10 +157,10 @@ rule IsPackageAvailable package
}
rule PackageURL packageName
rule DownloadPackage packageName
{
if ! [ IsPackageAvailable $(packageName) ] {
Exit "PackageURL: package" $(packageName) "not available!" ;
Exit "DownloadPackage: package" $(packageName) "not available!" ;
return ;
}
@ -171,8 +172,16 @@ rule PackageURL packageName
= [ on $(packageFamily) return $(HAIKU_PACKAGE_VERSIONS[1]) ] ;
local fileName = [ on $(package) return $(HAIKU_PACKAGE_FILE_NAME) ] ;
local repository = [ on $(package) return $(HAIKU_PACKAGE_REPOSITORY) ] ;
local baseUrl
= [ on $(repository) return $(HAIKU_REPOSITORY_PACKAGES_URL) ] ;
local baseUrl = [ on $(repository) return $(HAIKU_REPOSITORY_URL) ] ;
local packagesChecksumFile
= [ on $(repository)
return $(HAIKU_REPOSITORY_PACKAGES_CHECKSUM_FILE) ] ;
return $(baseUrl)/$(fileName) ;
local downloadedFile = [ DownloadFile $(fileName)
: "$(baseUrl)/`cat $source`/packages/$(fileName)"
: $(packagesChecksumFile) ] ;
NoUpdate $(downloadedFile) ;
# Don't download the file again when something in the repository
# changes. It is (supposed to be) still the same file.
return $(downloadedFile) ;
}

View File

@ -1,7 +1,6 @@
PackageRepository HaikuPorts
: x86_gcc2
: http://haiku-files.org/files/repo
: http://haiku-files.org/files/hpkg
:
# architecture "any" packages
be_book-2008_10_26-1

View File

@ -33,6 +33,8 @@ public:
const BEntry& Entry() const;
BString PackagesURL() const;
void SetName(const BString& name);
void SetBaseURL(const BString& url);
void SetPriority(uint8 priority);

View File

@ -398,7 +398,7 @@ PackageManager::_ApplyPackageChanges()
// get package URL and target entry
Repository* repository
= static_cast<Repository*>(package->Repository());
BString url = repository->Config().BaseURL();
BString url = repository->Config().PackagesURL();
BString fileName(package->Info().CanonicalFileName());
if (fileName.IsEmpty())
DIE(B_NO_MEMORY, "failed to allocate file name");

View File

@ -160,6 +160,15 @@ BRepositoryConfig::Entry() const
}
BString
BRepositoryConfig::PackagesURL() const
{
if (fBaseURL.IsEmpty())
return BString();
return BString().SetToFormat("%s/packages", fBaseURL.String());
}
void
BRepositoryConfig::SetName(const BString& name)
{

View File

@ -143,7 +143,7 @@ main(int argc, const char* const* argv)
const BRepositoryInfo& info
= repositoryInfos[package->Repository()];
BString url = info.OriginalBaseURL();
url << '/' << package->Info().CanonicalFileName();
url << "/packages/" << package->Info().CanonicalFileName();
printf("%s\n", url.String());
}
break;