1#pragma mark - Private 2 3# default value for the build profile that defines the set of source packages 4# that will be put onto the bootstrap image 5HAIKU_BOOTSTRAP_SOURCES_PROFILE ?= @minimum-raw ; 6 7rule PackageFamily packageBaseName 8{ 9 return $(packageBaseName:G=package-family) ; 10} 11 12 13rule SetRepositoryMethod repository : methodName : method 14{ 15 HAIKU_REPOSITORY_METHOD_$(methodName) on $(repository) = $(method) ; 16} 17 18rule InvokeRepositoryMethod repository : methodName : arg1 : arg2 : arg3 : arg4 19 : arg5 : arg6 : arg7 20{ 21 local method 22 = [ on $(repository) return $(HAIKU_REPOSITORY_METHOD_$(methodName)) ] ; 23 if ! $(method) { 24 Exit "Method" $(methodName) " not defined for repository" 25 $(repository) ; 26 } 27 28 return [ $(method) $(repository) : $(arg1) : $(arg2) : $(arg3) : $(arg4) 29 : $(arg5) : $(arg6) : $(arg7) ] ; 30} 31 32 33rule AddRepositoryPackage repository : architecture : baseName : version 34{ 35 local package = $(baseName)-$(version) ; 36 package = $(package:E=$(baseName):G=package-in-$(repository:G=)) ; 37 HAIKU_PACKAGE_REPOSITORY on $(package) = $(repository) ; 38 HAIKU_PACKAGE_ARCHITECTURE on $(package) = $(architecture) ; 39 local packageFileName = $(package:G=)-$(architecture).hpkg ; 40 HAIKU_PACKAGE_FILE_NAME on $(package) = $(packageFileName) ; 41 42 local packageFamily = [ InvokeRepositoryMethod $(repository) : PackageFamily 43 : $(baseName) ] ; 44 baseName = $(packageFamily:G=) ; 45 46 if $(HAIKU_NO_DOWNLOADS) = 1 && $(HAIKU_IS_BOOTSTRAP) != 1 { 47 # Only add packages to repository that already exist in download 48 # directory. 49 if ! [ Glob $(HAIKU_DOWNLOAD_DIR) : $(packageFileName) ] { 50 return ; 51 } 52 } 53 54 if ! $(baseName) in $(HAIKU_AVAILABLE_PACKAGES) { 55 HAIKU_AVAILABLE_PACKAGES += $(baseName) ; 56 } 57 58 HAIKU_PACKAGE_VERSIONS on $(packageFamily) += $(package) ; 59 HAIKU_REPOSITORY_PACKAGES on $(repository) += $(package) ; 60 61 return $(package) ; 62} 63 64 65rule AddRepositoryPackages repository : architecture : packages : sourcePackages 66 : debugInfoPackages 67{ 68 local packageTargets ; 69 local package ; 70 for package in $(packages) { 71 local splitName = [ Match "([^-]*)-(.*)" : $(package) ] ; 72 local baseName = $(splitName[1]:E=$(package)) ; 73 local version = $(splitName[2]) ; 74 packageTargets += [ AddRepositoryPackage $(repository) : $(architecture) 75 : $(baseName) : $(version) ] ; 76 if $(baseName) in $(sourcePackages) { 77 AddRepositoryPackage $(repository) : source : $(baseName)_source 78 : $(version) ; 79 } 80 if $(baseName) in $(debugInfoPackages) { 81 packageTargets += [ AddRepositoryPackage $(repository) 82 : $(architecture) : $(baseName)_debuginfo : $(version) ] ; 83 } 84 } 85 86 return $(packageTargets) ; 87} 88 89 90rule PackageRepository repository : architecture : anyPackages : packages 91 : sourcePackages : debugInfoPackages 92{ 93 if $(architecture) != $(HAIKU_PACKAGING_ARCHS[1]) { 94 return ; 95 } 96 97 HAIKU_REPOSITORIES += $(repository) ; 98 HAIKU_REPOSITORY_DEFINITION_FILE on $(repository) 99 = $(HAIKU_REPOSITORY_JAMFILE) ; 100 101 return [ AddRepositoryPackages $(repository) : any : $(anyPackages) 102 : $(sourcePackages) : $(debugInfoPackages) ] 103 [ AddRepositoryPackages $(repository) : $(architecture) : $(packages) 104 : $(sourcePackages) : $(debugInfoPackages) ] ; 105} 106 107 108#pragma mark - Remote Repository 109 110 111rule RemoteRepositoryPackageFamily repository : packageBaseName 112{ 113 return [ PackageFamily $(packageBaseName) ] ; 114} 115 116 117rule RemoteRepositoryFetchPackage repository : package : fileName 118{ 119 local baseUrl = [ on $(repository) return $(HAIKU_REPOSITORY_URL) ] ; 120 local packagesChecksumFile 121 = [ on $(repository) 122 return $(HAIKU_REPOSITORY_PACKAGES_CHECKSUM_FILE) ] ; 123 124 local downloadedFile = [ DownloadFile $(fileName) 125 : "$(baseUrl)/`cat $source`/packages/$(fileName)" 126 : $(packagesChecksumFile) ] ; 127 NoUpdate $(downloadedFile) ; 128 # Don't download the file again when something in the repository 129 # changes. It is (supposed to be) still the same file. 130 return $(downloadedFile) ; 131} 132 133 134rule RemotePackageRepository repository : architecture : repositoryUrl 135 : anyPackages : packages : sourcePackages : debugInfoPackages 136{ 137 repository = $(repository:G=repository) ; 138 139 if ! $(HOST_EXTENDED_REGEX_SED) { 140 ECHO "Variable HOST_EXTENDED_REGEX_SED not set. Please run ./configure or" ; 141 EXIT "specify it manually." ; 142 } 143 144 SetRepositoryMethod $(repository) : PackageFamily 145 : RemoteRepositoryPackageFamily ; 146 SetRepositoryMethod $(repository) : FetchPackage 147 : RemoteRepositoryFetchPackage ; 148 149 HAIKU_REPOSITORY_URL on $(repository) = $(repositoryUrl) ; 150 151 PackageRepository $(repository) : $(architecture) : $(anyPackages) 152 : $(packages) : $(sourcePackages) : $(debugInfoPackages) ; 153 154 # build package list file 155 local packageListFile = $(repository:G=repository-package-list)-packages ; 156 local repositoriesDir = $(HAIKU_PACKAGE_REPOSITORIES_DIR_$(architecture)) ; 157 MakeLocate $(packageListFile) : $(repositoriesDir) ; 158 GeneratedRepositoryPackageList $(packageListFile) : $(repository) ; 159 160 # build package list checksum file 161 local packagesChecksumFile 162 = $(repository:G=repository-package-checksum)-checksum ; 163 local thisPackageRepositoryFile = [ Glob [ FDirName 164 $(HAIKU_BUILD_RULES_DIR) repositories HaikuPorts ] : 165 $(HAIKU_PACKAGING_ARCH) ] ; 166 MakeLocate $(packagesChecksumFile) : $(repositoriesDir) ; 167 Depends $(packagesChecksumFile) : $(thisPackageRepositoryFile) ; 168 ChecksumFileSHA256 $(packagesChecksumFile) : $(thisPackageRepositoryFile) ; 169 170 local repositoryInfo = $(repository:G=repository-info)-info ; 171 local repositoryFile = $(repository:G=repository-cache) ; 172 local repositoryConfig = $(repository:G=repository-config)-config ; 173 MakeLocate $(repositoryInfo) $(repositoryFile) $(repositoryConfig) 174 : $(repositoriesDir) ; 175 # Use a locally created dummy repository if downloads have been disabled. 176 # This is useful when trying to build everything locally from source. 177 if $(HAIKU_NO_DOWNLOADS) = 1 { 178 # build repository file 179 local packageFileNames = [ 180 on $(packageListFile) return $(HAIKU_REPOSITORY_PACKAGE_FILE_NAMES) 181 ] ; 182 local packageFiles ; 183 local packageFile ; 184 for packageFile in $(packageFileNames) { 185 MakeLocate $(packageFile) : $(HAIKU_DOWNLOAD_DIR) ; 186 packageFiles += $(packageFile) ; 187 } 188 RepositoryCache $(repositoryFile) : $(repositoryInfo) 189 : $(packageFiles) ; 190 } else { 191 # download repository file 192 local repoUrl = [ on $(repository) return $(HAIKU_REPOSITORY_URL) ] ; 193 DownloadLocatedFile $(repositoryFile) 194 : "$(repoUrl)/`cat $source`/repo" 195 : $(packagesChecksumFile) ; 196 } 197 198 # build the repository info file 199 local repositoryInfoTemplate = <repository-info-template>haikuports ; 200 SEARCH on $(repositoryInfoTemplate) 201 = $(HAIKU_TOP)/src/data/repository_infos ; 202 PreprocessPackageOrRepositoryInfo $(repositoryInfo) 203 : $(repositoryInfoTemplate) : $(architecture) ; 204 205 # build repository config file 206 RepositoryConfig $(repositoryConfig) : $(repositoryInfo) 207 : $(packagesChecksumFile) ; 208 209 HAIKU_REPOSITORY_CACHE_FILE on $(repository) = $(repositoryFile) ; 210 HAIKU_REPOSITORY_CONFIG_FILE on $(repository) = $(repositoryConfig) ; 211 HAIKU_REPOSITORY_PACKAGES_CHECKSUM_FILE on $(repository) 212 = $(packagesChecksumFile) ; 213} 214 215 216rule GeneratedRepositoryPackageList target : repository 217{ 218 repository = $(repository:G=repository) ; 219 220 # construct a list of file names 221 local fileNames ; 222 local package ; 223 for package in [ on $(repository) return $(HAIKU_REPOSITORY_PACKAGES) ] { 224 fileNames += [ on $(package) return $(HAIKU_PACKAGE_FILE_NAME) ] ; 225 } 226 227 local definitionFile 228 = [ on $(repository) return $(HAIKU_REPOSITORY_DEFINITION_FILE) ] ; 229 Depends $(target) : $(definitionFile) ; 230 231 HAIKU_REPOSITORY_PACKAGE_FILE_NAMES on $(target) = $(fileNames) ; 232 GeneratedRepositoryPackageList1 $(target) ; 233} 234 235 236actions GeneratedRepositoryPackageList1 237{ 238 (for file in $(HAIKU_REPOSITORY_PACKAGE_FILE_NAMES) ; do 239 echo $file 240 done) | LC_ALL=C sort -u > $(1) 241} 242 243 244rule RepositoryConfig repoConfig : repoInfo : checksumFile 245{ 246 Depends $(repoConfig) 247 : <build>create_repository_config $(repoInfo) $(checksumFile) ; 248 RepositoryConfig1 $(repoConfig) 249 : <build>create_repository_config $(repoInfo) $(checksumFile) ; 250} 251 252 253actions RepositoryConfig1 254{ 255 version= 256 if [ -n "$(2[3]:E)" ]; then 257 version=`cat "$(2[3]:E)"` 258 fi 259 $(HOST_ADD_BUILD_COMPATIBILITY_LIB_DIR) 260 $(2[1]) $(2[2]) $(1) 261} 262 263 264rule RepositoryCache repoCache : repoInfo : packageFiles 265{ 266 Depends $(repoCache) 267 : <build>package_repo $(repoInfo) $(packageFiles) ; 268 RepositoryCache1 $(repoCache) 269 : <build>package_repo $(repoInfo) $(packageFiles) ; 270} 271 272 273actions RepositoryCache1 274{ 275 $(HOST_ADD_BUILD_COMPATIBILITY_LIB_DIR) 276 $(2[1]) create -q $(2[2-]) 277 mv $(1:B=repo) $(1) 278} 279 280 281#pragma mark - Bootstrap Repository 282 283 284rule BootstrapRepositoryPackageFamily repository : packageBaseName 285{ 286 local splitBaseName = [ Match "(.*)_bootstrap(.*)" : $(packageBaseName) ] ; 287 if $(splitBaseName) { 288 packageBaseName = $(splitBaseName[1])$(splitBaseName[2]) ; 289 } 290 291 return [ PackageFamily $(packageBaseName) ] ; 292} 293 294 295rule BootstrapRepositoryFetchPackage repository : package : fileName 296{ 297 local outputDir 298 = [ on $(repository) return $(HAIKU_REPOSITORY_BUILD_DIRECTORY) ] ; 299 local configFile 300 = [ on $(repository) return $(HAIKU_REPOSITORY_BUILD_CONFIG_FILE) ] ; 301 local haikuCrossDevelPackages = [ on $(package) 302 return $(HAIKU_REPOSITORY_HAIKU_CROSS_DEVEL_PACKAGES) ] ; 303 304 local packageFile = <cross-built>$(fileName) ; 305 if [ on $(packageFile) return $(HAIKU_REPOSITORY_BUILD_DIRECTORY) ] { 306 # rule already called for this package 307 return $(packageFile) ; 308 } 309 310 HAIKU_REPOSITORY_BUILD_DIRECTORY on $(packageFile) = $(outputDir) ; 311 312 MakeLocate $(packageFile) : [ FDirName $(outputDir) packages ] ; 313 NoUpdate $(packageFile) ; 314 # Don't rebuild the file. Since the haiku cross devel package is 315 # a dependency and is updated always, this package would otherwise be 316 # rebuilt always as well. 317 318 Depends $(packageFile) : $(haikuCrossDevelPackages) $(configFile) ; 319 BootstrapRepositoryFetchPackage1 $(packageFile) 320 : $(haikuCrossDevelPackages) ; 321 322 return $(packageFile) ; 323} 324 325 326actions BootstrapRepositoryFetchPackage1 327{ 328 # don't rebuild existing package 329 package="$(1)" 330 if [ -e "$package" ]; then 331 exit 0 332 fi 333 334 # make Haiku cross devel package path absolute 335 haikuCrossDevelPackage="$(2[1])" 336 if [ "x$haikuCrossDevelPackage" = "x" ]; then 337 echo "$package does not have a cross-devel package defined!" 338 exit 1 339 fi 340 341 if [ "x$haikuCrossDevelPackage" = "x${haikuCrossDevelPackage#/}" ]; then 342 haikuCrossDevelPackage="`pwd`/$haikuCrossDevelPackage" 343 fi 344 345 # make secondary Haiku cross devel packages path absolute 346 secondaryCrossDevelPackages= 347 if [ -n "$(2[2-]:J)" ]; then 348 for secondaryCrossDevelPackage in "$(2[2-])" ; do 349 if [ "x$secondaryCrossDevelPackage" = "x${secondaryCrossDevelPackage#/}" ]; then 350 secondaryCrossDevelPackage="`pwd`/$secondaryCrossDevelPackage" 351 fi 352 if [ -n "$secondaryCrossDevelPackages" ]; then 353 secondaryCrossDevelPackages="$secondaryCrossDevelPackages,$secondaryCrossDevelPackage" 354 else 355 secondaryCrossDevelPackages="--secondary-cross-devel-package=$secondaryCrossDevelPackage" 356 fi 357 done 358 fi 359 360 # determine the port-specification from the package name 361 portSpec=`basename "$package" | sed 's@-.*@@'` 362 363 cd $(HAIKU_REPOSITORY_BUILD_DIRECTORY) 364 365 $(HOST_ADD_BUILD_COMPATIBILITY_LIB_DIR) 366 if [ -n "$secondaryCrossDevelPackages" ]; then 367 $(HOST_HAIKU_PORTER) -j$(HAIKU_PORTER_CONCURRENT_JOBS) \ 368 --all-dependencies $(HAIKU_PORTER_EXTRA_OPTIONS) \ 369 --cross-devel-package "$haikuCrossDevelPackage" \ 370 "$secondaryCrossDevelPackages" $portSpec 371 else 372 $(HOST_HAIKU_PORTER) -j$(HAIKU_PORTER_CONCURRENT_JOBS) \ 373 --all-dependencies $(HAIKU_PORTER_EXTRA_OPTIONS) \ 374 --cross-devel-package "$haikuCrossDevelPackage" $portSpec 375 fi 376} 377 378 379actions BuildBootstrapRepositoryConfig 380{ 381cat > $(1) << EOF 382PACKAGER="The Haiku build system <build-system@haiku-os.org>" 383TREE_PATH="$(HAIKU_REPOSITORY_TREE_PATH)" 384TARGET_ARCHITECTURE="$(HAIKU_PACKAGING_ARCH)" 385 386DOWNLOAD_IN_PORT_DIRECTORY="yes" 387PACKAGE_COMMAND="$(PWD)/$(2[1])" 388MIMESET_COMMAND="$(PWD)/$(2[2])" 389SYSTEM_MIME_DB="$(PWD)/$(2[3])" 390LICENSES_DIRECTORY="$(HAIKU_ABSOLUTE_TOP)/data/system/data/licenses" 391OUTPUT_DIRECTORY="$(HAIKU_REPOSITORY_BUILD_DIRECTORY)" 392EOF 393 394 # If we have cross tools, add the cross tools directory. 395 gcc=$(HAIKU_CC_$(HAIKU_PACKAGING_ARCH)) 396 if [ "x$gcc" != "x${gcc#/}" ]; then 397 if [ `basename $gcc` = \ 398 $(HAIKU_GCC_MACHINE_$(HAIKU_PACKAGING_ARCH))-gcc ]; then 399 dir=`dirname $gcc` 400 dir=`dirname $dir` 401 echo CROSS_TOOLS=\"$dir\" >> $(1) 402 fi 403 fi 404 405 # Add secondary architectures and cross tools. 406 secondaryArchs="$(HAIKU_PACKAGING_ARCHS[2-]:E=)" 407 if [ -n "$secondaryArchs" ]; then 408 echo SECONDARY_TARGET_ARCHITECTURES=\" >> $(1) 409 for arch in $secondaryArchs; do 410 echo " $arch" >> $(1) 411 done 412 echo \" >> $(1) 413 414 echo SECONDARY_CROSS_TOOLS=\" >> $(1) 415 for gcc in $(HAIKU_CC_$(HAIKU_PACKAGING_ARCHS[2-])) ; do 416 dir=`dirname $gcc` 417 dir=`dirname $dir` 418 echo " $dir" >> $(1) 419 done 420 echo \" >> $(1) 421 fi 422} 423 424 425rule BootstrapPackageRepository repository : architecture 426 : anyPackages : packagesStage0 : packagesStage1 : packagesStage2 427 : sourcePackages : debugInfoPackages 428{ 429 repository = $(repository:G=repository) ; 430 packagesStage0 = [ FFilterByBuildFeatures $(packagesStage0) ] ; 431 packagesStage1 = [ FFilterByBuildFeatures $(packagesStage1) ] ; 432 packagesStage2 = [ FFilterByBuildFeatures $(packagesStage2) ] ; 433 sourcePackages = [ FFilterByBuildFeatures $(sourcePackages) ] ; 434 debugInfoPackages = [ FFilterByBuildFeatures $(debugInfoPackages) ] ; 435 436 SetRepositoryMethod $(repository) : PackageFamily 437 : BootstrapRepositoryPackageFamily ; 438 SetRepositoryMethod $(repository) : FetchPackage 439 : BootstrapRepositoryFetchPackage ; 440 441 # register repository with stage 0 packages 442 local stage0PackageTargets = [ PackageRepository $(repository) 443 : $(architecture) : $(anyPackages) : $(packagesStage0) 444 : $(sourcePackages) : $(debugInfoPackages) ] ; 445 if ! $(stage0PackageTargets) { 446 return ; 447 } 448 local crossDevelPackageSuffixes = $(architecture) 449 $(architecture)_$(HAIKU_PACKAGING_ARCHS[2-]) ; 450 HAIKU_REPOSITORY_HAIKU_CROSS_DEVEL_PACKAGES on $(stage0PackageTargets) 451 = haiku_cross_devel_sysroot_stage0_$(crossDevelPackageSuffixes).hpkg ; 452 453 # register repository with stage 1 packages 454 local stage1PackageTargets = [ PackageRepository $(repository) 455 : $(architecture) : $(anyPackages) : $(packagesStage1) 456 : $(sourcePackages) : $(debugInfoPackages) ] ; 457 if ! $(stage1PackageTargets) { 458 return ; 459 } 460 HAIKU_REPOSITORY_HAIKU_CROSS_DEVEL_PACKAGES on $(stage1PackageTargets) 461 = haiku_cross_devel_sysroot_stage1_$(crossDevelPackageSuffixes).hpkg ; 462 463 # add stage 2 packages 464 local stage2PackageTargets = [ AddRepositoryPackages $(repository) 465 : $(architecture) : $(packagesStage2) : $(sourcePackages) 466 : $(debugInfoPackages) ] ; 467 HAIKU_REPOSITORY_HAIKU_CROSS_DEVEL_PACKAGES on $(stage2PackageTargets) 468 = haiku_cross_devel_sysroot_$(crossDevelPackageSuffixes).hpkg ; 469 470 # prepare the config file for the HaikuPorts cross build 471 # This path needs to be absolute due to haikuporter's cwd 472 local outputDir = [ FDirName 473 $(PWD) 474 $(HAIKU_PACKAGE_REPOSITORIES_DIR_$(architecture)) 475 $(repository:G=)-build ] ; 476 local configFile = haikuports.conf ; 477 configFile = $(configFile:G=repository-config-$(repository:G=)) ; 478 MakeLocate $(configFile) : $(outputDir) ; 479 NoUpdate $(configFile) ; 480 Depends $(configFile) : <build>package <build>mimeset <mimedb>mime_db ; 481 HAIKU_REPOSITORY_BUILD_DIRECTORY on $(configFile) = $(outputDir) ; 482 HAIKU_PACKAGING_ARCH on $(configFile) = $(architecture) ; 483 HAIKU_REPOSITORY_TREE_PATH on $(configFile) = $(HAIKU_PORTS_CROSS) ; 484 BuildBootstrapRepositoryConfig $(configFile) 485 : <build>package <build>mimeset <mimedb>mime_db ; 486 487 HAIKU_REPOSITORY_BUILD_CONFIG_FILE on $(repository) = $(configFile) ; 488 HAIKU_REPOSITORY_BUILD_DIRECTORY on $(repository) = $(outputDir) ; 489 490 # Serialize all package file targets. We need to do this, since 491 # haikuporter uses a common directory for building the ports, so building 492 # two ports concurrently isn't possible. 493 local previousPackageFile ; 494 local package ; 495 for package in $(stage1PackageTargets) $(stage2PackageTargets) { 496 local fileName = [ on $(package) return $(HAIKU_PACKAGE_FILE_NAME) ] ; 497 local packageFile = [ BootstrapRepositoryFetchPackage $(repository) 498 : $(package) : $(fileName) ] ; 499 Depends $(packageFile) : $(previousPackageFile) ; 500 501 previousPackageFile = $(packageFile) ; 502 } 503} 504 505 506#pragma mark - Public 507 508 509rule FSplitPackageName packageName 510{ 511 local splitName = [ Match "(.*)_([^_]*)" : $(packageName) ] ; 512 local knownPackageSuffixes = devel doc source debuginfo ; 513 if $(splitName[2]) && $(splitName[2]) in $(knownPackageSuffixes) { 514 return $(splitName) ; 515 } 516 517 return $(packageName) ; 518} 519 520 521rule IsPackageAvailable packageName : flags 522{ 523 # for a secondary architecture adjust the package name 524 if $(TARGET_PACKAGING_ARCH) != $(TARGET_PACKAGING_ARCHS[1]) 525 && ! nameResolved in $(flags) { 526 # The position of the secondary architecture within the package name 527 # is not well defined, so we scan for it starting from the back. 528 local packageNameHead = $(packageName) ; 529 local packageNameTail = ; 530 while $(packageNameHead) { 531 local splitName = [ FSplitPackageName $(packageNameHead) ] ; 532 splitName = $(splitName[1]) $(TARGET_PACKAGING_ARCH) $(splitName[2]) 533 $(packageNameTail) ; 534 packageName = $(splitName:J=_) ; 535 if $(packageName) in $(HAIKU_AVAILABLE_PACKAGES) { 536 return $(packageName) ; 537 } 538 local splitHead = [ Match "(.*)_([^_]*)" : $(packageNameHead) ] ; 539 packageNameHead = $(splitHead[1]) ; 540 packageNameTail = $(splitHead[2]) $(packageNameTail) ; 541 } 542 } 543 544 if $(packageName) in $(HAIKU_AVAILABLE_PACKAGES) { 545 return $(packageName) ; 546 } 547 548 return ; 549} 550 551 552rule FetchPackage packageName : flags 553{ 554 local foundPackageName = [ IsPackageAvailable $(packageName) : $(flags) ] ; 555 if ! $(foundPackageName) { 556 Exit "FetchPackage: package" $(packageName) "not available!" ; 557 return ; 558 } 559 packageName = $(foundPackageName) ; 560 561 # TODO: We should support explicitly specified versions (or partial/minimum 562 # versions like gcc-2 or gcc-4). 563 564 local packageFamily = [ PackageFamily $(packageName) ] ; 565 local package 566 = [ on $(packageFamily) return $(HAIKU_PACKAGE_VERSIONS[1]) ] ; 567 local fileName = [ on $(package) return $(HAIKU_PACKAGE_FILE_NAME) ] ; 568 local repository = [ on $(package) return $(HAIKU_PACKAGE_REPOSITORY) ] ; 569 570 if $(HAIKU_DONT_FETCH_PACKAGES) { 571 Exit "FetchPackage: file" $(fileName) "not found and fetching" 572 "disabled!" ; 573 return ; 574 } 575 576 return [ InvokeRepositoryMethod $(repository) : FetchPackage : $(package) 577 : $(fileName) ] ; 578} 579 580 581rule BuildHaikuPortsSourcePackageDirectory 582{ 583 local architecture = $(TARGET_PACKAGING_ARCH) ; 584 local outputDir = [ FDirName 585 $(PWD) 586 $(HAIKU_PACKAGE_REPOSITORIES_DIR_$(architecture)) 587 HaikuPorts-sources-build ] ; 588 589 local sourcePackageDir = <HaikuPorts-repository-source-packages>packages ; 590 MakeLocate $(sourcePackageDir) : $(outputDir) ; 591 592 # build the package list file 593 local packageList 594 = <repository-package-list-HaikuPorts-sources>package_list ; 595 MakeLocate $(packageList) : $(outputDir) ; 596 Depends $(packageList) : 597 [ FDirName $(HAIKU_BUILD_RULES_DIR) repositories HaikuPorts 598 $(architecture) ] ; 599 BuildHaikuPortsPackageList $(packageList) ; 600 601 # prepare the config file for the HaikuPorts build 602 local configFile = <repository-config-HaikuPorts-sources>haikuports.conf ; 603 MakeLocate $(configFile) : $(outputDir) ; 604 NoUpdate $(configFile) ; 605 Depends $(configFile) : <build>package <build>mimeset <mimedb>mime_db ; 606 HAIKU_REPOSITORY_BUILD_DIRECTORY on $(configFile) = $(outputDir) ; 607 HAIKU_PACKAGING_ARCH on $(configFile) = $(architecture) ; 608 HAIKU_REPOSITORY_TREE_PATH on $(configFile) = $(HAIKU_PORTS) ; 609 BuildBootstrapRepositoryConfig $(configFile) 610 : <build>package <build>mimeset <mimedb>mime_db ; 611 612 # get Haiku cross-devel packages and build the sources 613 local crossDevelPackageSuffixes = $(architecture) 614 $(architecture)_$(HAIKU_PACKAGING_ARCHS[2-]) ; 615 local haikuCrossDevelPackages 616 = haiku_cross_devel_sysroot_stage1_$(crossDevelPackageSuffixes).hpkg ; 617 618 HAIKU_REPOSITORY_BUILD_DIRECTORY on $(sourcePackageDir) = $(outputDir) ; 619 620 Depends $(sourcePackageDir) : $(packageList) $(haikuCrossDevelPackages) 621 $(configFile) ; 622 BuildHaikuPortsSourcePackageDirectory1 $(sourcePackageDir) 623 : $(packageList) $(haikuCrossDevelPackages) ; 624 625 return $(sourcePackageDir) ; 626} 627 628 629actions BuildHaikuPortsPackageList 630{ 631 $(JAM:E=jam) $(HAIKU_BOOTSTRAP_SOURCES_PROFILE) build-package-list $(1) \ 632 $(HAIKU_REPOSITORY_BUILD_ADDITIONAL_PACKAGES) 633} 634 635 636actions BuildHaikuPortsSourcePackageDirectory1 637{ 638 packageList="$(2[1])" 639 640 # make Haiku cross devel package path absolute 641 haikuCrossDevelPackage="$(2[2])" 642 if [ "x$haikuCrossDevelPackage" = "x${haikuCrossDevelPackage#/}" ]; then 643 haikuCrossDevelPackage="`pwd`/$haikuCrossDevelPackage" 644 fi 645 646 # make secondary Haiku cross devel packages path absolute 647 secondaryCrossDevelPackages= 648 if [ -n "$(2[3-]:J)" ]; then 649 for secondaryCrossDevelPackage in "$(2[3-])" ; do 650 if [ "x$secondaryCrossDevelPackage" = "x${secondaryCrossDevelPackage#/}" ]; then 651 secondaryCrossDevelPackage="`pwd`/$secondaryCrossDevelPackage" 652 fi 653 if [ -n "$secondaryCrossDevelPackages" ]; then 654 secondaryCrossDevelPackages="$secondaryCrossDevelPackages,$secondaryCrossDevelPackage" 655 else 656 secondaryCrossDevelPackages="--secondary-cross-devel-package=$secondaryCrossDevelPackage" 657 fi 658 done 659 fi 660 661 cd $(HAIKU_REPOSITORY_BUILD_DIRECTORY) 662 663 $(HOST_ADD_BUILD_COMPATIBILITY_LIB_DIR) 664 if [ -n "$secondaryCrossDevelPackages" ]; then 665 $(HOST_HAIKU_PORTER) --cross-devel-package "$haikuCrossDevelPackage" \ 666 "$secondaryCrossDevelPackages" \ 667 --all-dependencies $(HAIKU_PORTER_EXTRA_OPTIONS) \ 668 --create-source-packages-for-bootstrap --portsfile $packageList 669 else 670 $(HOST_HAIKU_PORTER) --cross-devel-package "$haikuCrossDevelPackage" \ 671 --all-dependencies $(HAIKU_PORTER_EXTRA_OPTIONS) \ 672 --create-source-packages-for-bootstrap --portsfile $packageList 673 fi 674} 675 676 677rule BuildHaikuPortsRepositoryConfig treePath 678{ 679 local architecture = $(TARGET_PACKAGING_ARCH) ; 680 local outputDir = [ FDirName 681 $(HAIKU_PACKAGE_REPOSITORIES_DIR_$(architecture)) 682 HaikuPorts-bootstrap ] ; 683 684 local configFile = <repository-config-HaikuPorts-bootstrap>haikuports.conf ; 685 MakeLocate $(configFile) : $(outputDir) ; 686 NoUpdate $(configFile) ; 687 688 HAIKU_REPOSITORY_TREE_PATH on $(configFile) = $(treePath) ; 689 BuildHaikuPortsRepositoryConfig1 $(configFile) ; 690 691 return $(configFile) ; 692} 693 694 695actions BuildHaikuPortsRepositoryConfig1 696{ 697 # use a specific packager for continuous integration builds (buildbot) 698 if [ "$(HAIKU_CONTINUOUS_INTEGRATION_BUILD)" = "1" ]; then 699 echo 'PACKAGER="Haiku buildmaster <buildmaster@haiku-os.org>"' > $(1) 700 else 701 echo '#PACKAGER="Joe Hacker <user@host.com>"' > $(1) 702 fi 703 cat >> $(1) << EOF 704TREE_PATH="$(HAIKU_REPOSITORY_TREE_PATH)" 705TARGET_ARCHITECTURE="$(HAIKU_PACKAGING_ARCH)" 706EOF 707} 708 709 710rule HaikuRepository repository : repoInfoTemplate : packages 711{ 712 # HaikuRepository <repository> : <repoInfoTemplate> : <packages> 713 # [ : <url> [ : <versionFile> ] ] ; 714 # Builds the Haiku repository from the given packages and repository info 715 # template. <repository> must already be located. 716 # 717 # <repository> - The repository target. Resolves to a directory that will be 718 # (removed,) created and populated with the package files and repository 719 # meta data files. 720 # <repoInfoTemplate> - The repository info template file to be used. 721 # <packages> - The packages to be added to the repository. 722 723 local architecture = $(HAIKU_PACKAGING_ARCH) ; 724 local secondaryArchitecture ; 725 if $(TARGET_PACKAGING_ARCH) != $(architecture) { 726 secondaryArchitecture = $(TARGET_PACKAGING_ARCH) ; 727 } 728 729 local repositoriesDir = $(HAIKU_PACKAGE_REPOSITORIES_DIR_$(architecture)) ; 730 731 # build the repository info 732 local repositoryInfo = $(repository:G=repository-info)-info ; 733 MakeLocate $(repositoryInfo) : $(repositoriesDir) ; 734 PreprocessPackageOrRepositoryInfo $(repositoryInfo) : $(repoInfoTemplate) 735 : $(architecture) : $(secondaryArchitecture) ; 736 737 # build the respository config 738 local repositoryConfig = $(repository:G=repository-config)-config ; 739 MakeLocate $(repositoryConfig) : $(repositoriesDir) ; 740 RepositoryConfig $(repositoryConfig) : $(repositoryInfo) ; 741 HAIKU_REPOSITORY_CONFIG_FILE on $(repository) = $(repositoryConfig) ; 742 743 # setup the repository cache file 744 local repositoryCache = $(repository:B=repo:G=repository-cache) ; 745 MakeLocate $(repositoryCache) 746 : [ FDirName $(repositoriesDir) $(repository:G=) ] ; 747 Depends $(repositoryCache) : $(repository) ; 748 HAIKU_REPOSITORY_CACHE_FILE on $(repository) = $(repositoryCache) ; 749 750 # add the repository to the list of known package repositories 751 HAIKU_REPOSITORIES += $(repository) ; 752 753 # prepare the script that initializes the shell variables 754 local initVariablesScript = $(repository)-repository-init-vars ; 755 MakeLocate $(initVariablesScript) 756 : $(HAIKU_PACKAGE_REPOSITORIES_DIR_$(architecture)) ; 757 Always $(initVariablesScript) ; 758 759 local script = $(initVariablesScript) ; 760 AddVariableToScript $(script) : addBuildCompatibilityLibDir 761 : $(HOST_ADD_BUILD_COMPATIBILITY_LIB_DIR) ; 762 AddVariableToScript $(script) : sha256 : $(HOST_SHA256) ; 763 AddVariableToScript $(script) : sedExtendedRegex 764 : $(HOST_EXTENDED_REGEX_SED) ; 765 AddTargetVariableToScript $(script) : <build>package ; 766 AddTargetVariableToScript $(script) : <build>package_repo : packageRepo ; 767 768 # call the build actions 769 local mainScript = build_haiku_repository ; 770 SEARCH on $(mainScript) = [ FDirName $(HAIKU_TOP) build scripts ] ; 771 772 Depends $(repository) : $(mainScript) $(initVariablesScript) 773 $(repositoryInfo) $(packages) ; 774 HaikuRepository1 $(repository) : $(mainScript) $(initVariablesScript) 775 $(repositoryInfo) $(packages) ; 776 Always $(repository) ; 777 778 RmTemps $(repository) : $(initVariablesScript) ; 779} 780 781 782actions HaikuRepository1 783{ 784 $(2[1]) "$(2[2])" "$(1)" "$(2[3-])" 785} 786