From 014eed80e289c2bbc187ac91bb7b3a35560a971f Mon Sep 17 00:00:00 2001 From: Ingo Weinhold Date: Sat, 6 Jul 2013 18:06:02 +0200 Subject: [PATCH] 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. --- build/jam/ImageRules | 12 +++++++-- build/jam/MiscRules | 6 ++--- build/jam/RepositoryRules | 25 +++++++++++++------ build/jam/repositories/HaikuPorts/x86_gcc2 | 1 - headers/os/package/RepositoryConfig.h | 2 ++ src/bin/pkgman/PackageManager.cpp | 2 +- src/kits/package/RepositoryConfig.cpp | 9 +++++++ .../get_package_dependencies.cpp | 2 +- 8 files changed, 42 insertions(+), 17 deletions(-) diff --git a/build/jam/ImageRules b/build/jam/ImageRules index 2faabf4420..a61747cb6c 100644 --- a/build/jam/ImageRules +++ b/build/jam/ImageRules @@ -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) ; } } } diff --git a/build/jam/MiscRules b/build/jam/MiscRules index dc2a185cf8..c7373fe106 100644 --- a/build/jam/MiscRules +++ b/build/jam/MiscRules @@ -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)) ; diff --git a/build/jam/RepositoryRules b/build/jam/RepositoryRules index 6b65180482..0c81e02e27 100644 --- a/build/jam/RepositoryRules +++ b/build/jam/RepositoryRules @@ -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) ; } diff --git a/build/jam/repositories/HaikuPorts/x86_gcc2 b/build/jam/repositories/HaikuPorts/x86_gcc2 index 0249ff6114..df28168473 100644 --- a/build/jam/repositories/HaikuPorts/x86_gcc2 +++ b/build/jam/repositories/HaikuPorts/x86_gcc2 @@ -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 diff --git a/headers/os/package/RepositoryConfig.h b/headers/os/package/RepositoryConfig.h index 9f35d1b40d..b9d08906aa 100644 --- a/headers/os/package/RepositoryConfig.h +++ b/headers/os/package/RepositoryConfig.h @@ -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); diff --git a/src/bin/pkgman/PackageManager.cpp b/src/bin/pkgman/PackageManager.cpp index 833d6ce56d..f7c4df991a 100644 --- a/src/bin/pkgman/PackageManager.cpp +++ b/src/bin/pkgman/PackageManager.cpp @@ -398,7 +398,7 @@ PackageManager::_ApplyPackageChanges() // get package URL and target entry Repository* repository = static_cast(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"); diff --git a/src/kits/package/RepositoryConfig.cpp b/src/kits/package/RepositoryConfig.cpp index e3708dc9e6..a5eeb49447 100644 --- a/src/kits/package/RepositoryConfig.cpp +++ b/src/kits/package/RepositoryConfig.cpp @@ -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) { diff --git a/src/tools/get_package_dependencies/get_package_dependencies.cpp b/src/tools/get_package_dependencies/get_package_dependencies.cpp index ecbf4deec0..189a8c7afb 100644 --- a/src/tools/get_package_dependencies/get_package_dependencies.cpp +++ b/src/tools/get_package_dependencies/get_package_dependencies.cpp @@ -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;