RepositoryRules revision d72ce066
1rule PackageFamily packageBaseName
2{
3	return $(packageBaseName:G=package-family) ;
4}
5
6
7rule AddRepositoryPackage repository : architecture : baseName : version
8{
9	local package = $(baseName)-$(version) ;
10	package = $(package:E=$(baseName):G=package-in-$(repository:G=)) ;
11	HAIKU_PACKAGE_REPOSITORY on $(package) = $(repository) ;
12	HAIKU_PACKAGE_ARCHITECTURE on $(package) = $(architecture) ;
13	HAIKU_PACKAGE_FILE_NAME on $(package) = $(package:G=)-$(architecture).hpkg ;
14
15	if ! $(baseName) in $(HAIKU_AVAILABLE_PACKAGES) {
16		HAIKU_AVAILABLE_PACKAGES += $(baseName) ;
17	}
18
19	local packageFamily = [ PackageFamily $(baseName) ] ;
20	HAIKU_PACKAGE_VERSIONS on $(packageFamily) += $(package) ;
21	HAIKU_REPOSITORY_PACKAGES on $(repository) += $(package) ;
22}
23
24
25rule AddRepositoryPackages repository : architecture : packages : sourcePackages
26{
27	local package ;
28	for package in $(packages) {
29		local splitName = [ Match "([^-]*)-(.*)" : $(package) ] ;
30		local baseName = $(splitName[1]:E=$(package)) ;
31		local version = $(splitName[2]) ;
32		AddRepositoryPackage $(repository) : $(architecture) : $(baseName)
33			: $(version) ;
34		if $(baseName) in $(sourcePackages) {
35			AddRepositoryPackage $(repository) : source : $(baseName)_source
36				: $(version) ;
37		}
38	}
39}
40
41
42rule PackageRepository repository : architecture : repositoryUrl : packagesUrl
43	: anyPackages : packages : sourcePackages
44{
45	repository = $(repository:G=repository) ;
46
47	if $(architecture) != $(HAIKU_PACKAGING_ARCH) {
48		return ;
49	}
50
51	HAIKU_REPOSITORIES += $(repository) ;
52	HAIKU_REPOSITORY_URL on $(repository) = $(repositoryUrl) ;
53	HAIKU_REPOSITORY_PACKAGES_URL on $(repository) = $(packagesUrl) ;
54	HAIKU_REPOSITORY_DEFINITION_FILE on $(repository)
55		= $(HAIKU_REPOSITORY_JAMFILE) ;
56
57	AddRepositoryPackages $(repository) : any : $(anyPackages)
58		: $(sourcePackages) ;
59	AddRepositoryPackages $(repository) : $(architecture) : $(packages)
60		: $(sourcePackages) ;
61
62	# build package list file
63	local packageListFile = $(repository:G=repository-package-list)-packages ;
64	MakeLocate $(packageListFile) : $(HAIKU_PACKAGE_REPOSITORIES_DIR) ;
65	GeneratedRepositoryPackageList $(packageListFile) : $(repository) ;
66
67	# build package list checksum file
68	local packagesChecksumFile
69		= $(repository:G=repository-package-checksum)-checksum ;
70	MakeLocate $(packagesChecksumFile) : $(HAIKU_PACKAGE_REPOSITORIES_DIR) ;
71	Depends $(packagesChecksumFile) : $(packageListFile) ;
72	ChecksumFileSHA256 $(packagesChecksumFile) : $(packageListFile) ;
73
74	# download repository info file
75	local repositoryInfo = $(repository:G=repository-info)-info ;
76	MakeLocate $(repositoryInfo) : $(HAIKU_PACKAGE_REPOSITORIES_DIR) ;
77	local repoUrl = [ on $(repository) return $(HAIKU_REPOSITORY_URL) ] ;
78	DownloadLocatedFile $(repositoryInfo)
79		: "$(repoUrl)/`cat $source`/repo.info"
80		: $(packagesChecksumFile) ;
81
82	# download repository file
83	local repositoryFile = $(repository:G=repository-cache) ;
84	MakeLocate $(repositoryFile) : $(HAIKU_PACKAGE_REPOSITORIES_DIR) ;
85	local repoUrl = [ on $(repository) return $(HAIKU_REPOSITORY_URL) ] ;
86	DownloadLocatedFile $(repositoryFile)
87		: "$(repoUrl)/`cat $source`/repo"
88		: $(packagesChecksumFile) ;
89
90	# build repository config file
91	local repositoryConfig = $(repository:G=repository-config)-config ;
92	MakeLocate $(repositoryConfig) : $(HAIKU_PACKAGE_REPOSITORIES_DIR) ;
93	RepositoryConfig $(repositoryConfig) : $(repositoryInfo)
94		: $(packagesChecksumFile) : $(repository) ;
95
96	HAIKU_REPOSITORY_CACHE_FILE on $(repository) = $(repositoryFile) ;
97	HAIKU_REPOSITORY_CONFIG_FILE on $(repository) = $(repositoryConfig) ;
98}
99
100
101rule GeneratedRepositoryPackageList target : repository
102{
103	repository = $(repository:G=repository) ;
104
105	# construct a list of file names
106	local fileNames ;
107	local package ;
108	for package in [ on $(repository) return $(HAIKU_REPOSITORY_PACKAGES) ] {
109		fileNames += [ on $(package) return $(HAIKU_PACKAGE_FILE_NAME) ] ;
110	}
111
112	local definitionFile
113		= [ on $(repository) return $(HAIKU_REPOSITORY_DEFINITION_FILE) ] ;
114	Depends $(target) : $(definitionFile) ;
115
116	HAIKU_REPOSITORY_PACKAGE_FILE_NAMES on $(target) = $(fileNames) ;
117	GeneratedRepositoryPackageList1 $(target) ;
118}
119
120
121actions GeneratedRepositoryPackageList1
122{
123	(for file in $(HAIKU_REPOSITORY_PACKAGE_FILE_NAMES) ; do
124		echo $file
125	done) | LC_ALL=C sort -u > $(1)
126}
127
128
129rule RepositoryConfig repoConfig : repoInfo : packagesChecksumFile : repository
130{
131	repository = $(repository:G=repository) ;
132
133	HAIKU_REPOSITORY_URL on $(repoConfig)
134		= [ on $(repository) return $(HAIKU_REPOSITORY_URL) ] ;
135	Depends $(repoConfig)
136		: <build>create_repository_config $(repoInfo) $(packagesChecksumFile) ;
137	RepositoryConfig1 $(repoConfig)
138		: <build>create_repository_config $(repoInfo) $(packagesChecksumFile) ;
139}
140
141
142actions RepositoryConfig1
143{
144	$(HOST_ADD_BUILD_COMPATIBILITY_LIB_DIR)
145	$(2[1]) $(HAIKU_REPOSITORY_URL)/`cat $(2[3])` $(2[2]) $(1)
146}
147
148
149rule IsPackageAvailable package
150{
151	if $(package) in $(HAIKU_AVAILABLE_PACKAGES) {
152		return 1 ;
153	}
154
155	return ;
156}
157
158
159rule PackageURL packageName
160{
161	if ! [ IsPackageAvailable $(packageName) ] {
162		Exit "PackageURL: package" $(packageName) "not available!" ;
163		return ;
164	}
165
166	# TODO: We should support explicitly specified versions (or partial/minimum
167	# versions like gcc-2 or gcc-4).
168
169	local packageFamily = [ PackageFamily $(packageName) ] ;
170	local package
171		= [ on $(packageFamily) return $(HAIKU_PACKAGE_VERSIONS[1]) ] ;
172	local fileName = [ on $(package) return $(HAIKU_PACKAGE_FILE_NAME) ] ;
173	local repository = [ on $(package) return $(HAIKU_PACKAGE_REPOSITORY) ] ;
174	local baseUrl
175		= [ on $(repository) return $(HAIKU_REPOSITORY_PACKAGES_URL) ] ;
176
177	return $(baseUrl)/$(fileName) ;
178}
179