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