haiku/build/jam/RepositoryRules

114 lines
3.0 KiB
Plaintext
Raw Normal View History

Switch build system from optional package to repositories * Build libsolv and the dependency solver part of the package kit for the build platform. * Add build tool get_package_dependencies. Given a list of package files and a list of repository files it determines the additional packages that need to be retrieved from the repositories and prints their URLs. * Add rules to work with external repositories in the build system (build/jam/RepositoryRules): - PackageRepository declares an external repository with all its packages. The URL of the repository file isn't specified. It is computed from a given base URL and the SHA256 hash of the list of package files. - GeneratedRepositoryPackageList generates a file containing the file names of all packages in a repository. - IsPackageAvailable returns whether a package is available in any repository. - PackageURL returns the URL for a package. * Declare the HaikuPorts repository for x86_gcc2 (build/jam/repositories/HaikuPorts/x86_gcc2). * Add rule AddHaikuImagePackages to add a package to the image and rule IsHaikuImagePackageAdded to determine whether a package has been added. * OptionalPackages: Remove all entries that just downloaded and installed an external package. AddHaikuImagePackages can be used instead and is used in the remaining entries. Also move the remaining optional package dependency declarations from OptionalPackageDependencies here. * ExtractBuildFeatureArchives: Instead of the URL parameter a package name must be specified now. This allows to simplify BuildFeatures significantly, since there's no dealing with URLs anymore. "if" out the entries that aren't supported yet. * build_haiku_image: For the packages installed in system and common resolve their dependencies and download and install them as well.
2013-07-05 12:51:42 +04:00
rule PackageFamily packageBaseName
{
return $(packageBaseName:G=package-family) ;
}
rule AddRepositoryPackage repository : architecture : baseName : version
{
local package = $(baseName)-$(version) ;
package = $(package:E=$(baseName):G=package-in-$(repository:G=)) ;
HAIKU_PACKAGE_REPOSITORY on $(package) = $(repository) ;
HAIKU_PACKAGE_ARCHITECTURE on $(package) = $(architecture) ;
HAIKU_PACKAGE_FILE_NAME on $(package) = $(package:G=)-$(architecture).hpkg ;
if ! $(baseName) in $(HAIKU_AVAILABLE_PACKAGES) {
HAIKU_AVAILABLE_PACKAGES += $(baseName) ;
}
local packageFamily = [ PackageFamily $(baseName) ] ;
HAIKU_PACKAGE_VERSIONS on $(packageFamily) += $(package) ;
HAIKU_REPOSITORY_PACKAGES on $(repository) += $(package) ;
}
rule AddRepositoryPackages repository : architecture : packages : sourcePackages
{
local package ;
for package in $(packages) {
local splitName = [ Match "([^-]*)-(.*)" : $(package) ] ;
local baseName = $(splitName[1]:E=$(package)) ;
local version = $(splitName[2]) ;
AddRepositoryPackage $(repository) : $(architecture) : $(baseName)
: $(version) ;
if $(baseName) in $(sourcePackages) {
AddRepositoryPackage $(repository) : source : $(baseName)_source
: $(version) ;
}
}
}
rule PackageRepository repository : architecture : url : anyPackages : packages
: sourcePackages
{
repository = $(repository:G=repository) ;
if $(architecture) != $(HAIKU_PACKAGING_ARCH) {
return ;
}
HAIKU_REPOSITORIES += $(repository) ;
HAIKU_REPOSITORY_URL on $(repository) = $(url) ;
AddRepositoryPackages $(repository) : any : $(anyPackages)
: $(sourcePackages) ;
AddRepositoryPackages $(repository) : $(architecture) : $(packages)
: $(sourcePackages) ;
}
rule GeneratedRepositoryPackageList target : repository
{
repository = $(repository:G=repository) ;
# construct a list of file names
local fileNames ;
local package ;
for package in [ on $(repository) return $(HAIKU_REPOSITORY_PACKAGES) ] {
fileNames += [ on $(package) return $(HAIKU_PACKAGE_FILE_NAME) ] ;
}
HAIKU_REPOSITORY_PACKAGE_FILE_NAMES on $(target) = $(fileNames) ;
GeneratedRepositoryPackageList1 $(target) ;
}
actions GeneratedRepositoryPackageList1
{
(for file in $(HAIKU_REPOSITORY_PACKAGE_FILE_NAMES) ; do
echo $file
done) | sort -u > $(1)
}
rule IsPackageAvailable package
{
if $(package) in $(HAIKU_AVAILABLE_PACKAGES) {
return 1 ;
}
return ;
}
rule PackageURL packageName
{
if ! [ IsPackageAvailable $(packageName) ] {
Exit "PackageURL: package" $(packageName) "not available!" ;
return ;
}
# TODO: We should support explicitly specified versions (or partial/minimum
# versions like gcc-2 or gcc-4).
local packageFamily = [ PackageFamily $(packageName) ] ;
local package
= [ 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_URL) ] ;
return $(baseUrl)/$(fileName) ;
}