summaryrefslogtreecommitdiff
blob: a355e5471243c69cbe2dca17f303afc513a8bf5c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
<?xml version='1.0' encoding='UTF-8'?>

<xs:schema xmlns:xs='http://www.w3.org/2001/XMLSchema'>
	<!-- top-level variants -->
	<xs:element name='pkgmetadata' type='pkgMetadataType'>
		<!-- note: restrict uniquity rules are simplified
			 the spec says: one for each matched package
			 we can only do: one for each restrict rule -->
		<xs:unique name='longDescUniquityConstraint'>
			<xs:selector xpath='longdescription'/>
			<xs:field xpath='@lang'/>
			<xs:field xpath='@restrict'/>
		</xs:unique>
		<xs:key name='maintainerKeyConstraint'>
			<xs:selector xpath='maintainer'/>
			<xs:field xpath='email'/>
			<xs:field xpath='@restrict'/>
		</xs:key>
		<xs:unique name='slotsUniquityConstraint'>
			<xs:selector xpath='slots'/>
			<xs:field xpath='@lang'/>
		</xs:unique>
		<xs:unique name='stabilizeAllArchesUniquityConstraint'>
			<xs:selector xpath='stabilize-all-arches'/>
			<xs:field xpath='@restrict'/>
		</xs:unique>
		<xs:unique name='upstreamSingleConstraint'>
			<xs:selector xpath='upstream'/>
			<xs:field xpath='@fake-only-once'/>
		</xs:unique>
		<xs:unique name='useUniquityConstraint'>
			<xs:selector xpath='use'/>
			<xs:field xpath='@lang'/>
		</xs:unique>
	</xs:element>
	<xs:element name='catmetadata' type='catMetadataType'>
		<xs:unique name='catLongDescUniquityConstraint'>
			<xs:selector xpath='longdescription'/>
			<xs:field xpath='@lang'/>
		</xs:unique>
	</xs:element>

	<!-- global elements -->
	<xs:complexType name='pkgMetadataType'>
		<xs:choice minOccurs='0' maxOccurs='unbounded'>
			<xs:element name='longdescription' type='longDescType'/>
			<xs:element name='maintainer' type='maintainerType'>
				<xs:unique name='maintainerNameSingleConstraint'>
					<xs:selector xpath='name'/>
					<xs:field xpath='@fake-only-once'/>
				</xs:unique>
				<xs:unique name='maintainerDescUniquityConstraint'>
					<xs:selector xpath='description'/>
					<xs:field xpath='@lang'/>
				</xs:unique>
			</xs:element>
			<xs:element name='slots' type='slotsType'>
				<xs:unique name='slotUniquityConstraint'>
					<xs:selector xpath='slot'/>
					<xs:field xpath='@name'/>
				</xs:unique>
				<xs:unique name='subslotsSingleConstraint'>
					<xs:selector xpath='subslots'/>
					<xs:field xpath='@fake-only-once'/>
				</xs:unique>
			</xs:element>
			<xs:element name='stabilize-allarches' type='stabilizeAllArchesType'/>
			<xs:element name='upstream' type='upstreamType'>
				<xs:unique name='upstreamMaintainerUniquityConstraint'>
					<xs:selector xpath='maintainer'/>
					<xs:field xpath='name'/>
				</xs:unique>
				<xs:unique name='bugsToSingleConstraint'>
					<xs:selector xpath='bugs-to'/>
					<xs:field xpath='@fake-only-once'/>
				</xs:unique>
				<xs:unique name='changelogSingleConstraint'>
					<xs:selector xpath='changelog'/>
					<xs:field xpath='@fake-only-once'/>
				</xs:unique>
				<!-- prevent accidentally repeating the same remote -->
				<xs:unique name='upstreamRemoteIdRepetitionConstraint'>
					<xs:selector xpath='remote-id'/>
					<xs:field xpath='@type'/>
					<xs:field xpath='.'/>
				</xs:unique>
				<xs:unique name='upstreamDocUniquityConstraint'>
					<xs:selector xpath='doc'/>
					<xs:field xpath='@lang'/>
				</xs:unique>
			</xs:element>
			<xs:element name='use' type='useType'>
				<xs:unique name='flagUniquityConstraint'>
					<xs:selector xpath='flag'/>
					<xs:field xpath='@name'/>
					<xs:field xpath='@restrict'/>
				</xs:unique>
			</xs:element>
		</xs:choice>
	</xs:complexType>

	<xs:complexType name='catMetadataType'>
		<xs:choice minOccurs='0' maxOccurs='unbounded'>
			<xs:element name='longdescription' type='catLongDescType'/>
		</xs:choice>
	</xs:complexType>

	<!-- the huge <upstream/> structure -->
	<xs:complexType name='upstreamType'>
		<xs:choice minOccurs='0' maxOccurs='unbounded'>
			<xs:element name='maintainer' type='upstreamMaintainerType'/>
			<xs:element name='changelog' type='urlOnceType'/>
			<xs:element name='doc' type='upstreamDocType'/>
			<xs:element name='bugs-to' type='urlOnceType'/>
			<xs:element name='remote-id' type='upstreamRemoteIdType'/>
		</xs:choice>
		<xs:attribute name='fake-only-once'
			fixed='there can be at most one &lt;upstream/&gt; element'/>
	</xs:complexType>

	<!-- maintainer in two variants -->
	<xs:complexType name='maintainerType'>
		<xs:choice minOccurs='0' maxOccurs='unbounded'>
			<xs:element name='email' type='emailType'/>
			<xs:element name='name' type='tokenOnceType'/>
			<xs:element name='description' type='maintainerDescType'/>
		</xs:choice>
		<xs:attribute name='type' type='maintainerTypeAttrType'
			use='required'/>
		<xs:attribute name='proxied' type='maintainerProxiedAttrType'
			default='no'/>
		<xs:attribute name='restrict' type='restrictAttrType'
			default=''/>
	</xs:complexType>

	<xs:simpleType name='maintainerTypeAttrType'>
		<xs:restriction base='xs:token'>
			<xs:enumeration value='person'/>
			<xs:enumeration value='project'/>
		</xs:restriction>
	</xs:simpleType>

	<xs:simpleType name='maintainerProxiedAttrType'>
		<xs:restriction base='xs:token'>
			<xs:enumeration value='yes'/>
			<xs:enumeration value='no'/>
			<xs:enumeration value='proxy'/>
		</xs:restriction>
	</xs:simpleType>

	<xs:complexType name='upstreamMaintainerType'>
		<xs:all>
			<xs:element name='email' type='emailType'
				minOccurs='0'/>
			<xs:element name='name' type='xs:token'
				minOccurs='1'/>
		</xs:all>
		<xs:attribute name='status' type='upstreamMaintainerStatusAttrType'
			default='unknown'/>
	</xs:complexType>

	<xs:simpleType name='upstreamMaintainerStatusAttrType'>
		<xs:restriction base='xs:token'>
			<xs:enumeration value='active'/>
			<xs:enumeration value='inactive'/>
			<xs:enumeration value='unknown'/>
		</xs:restriction>
	</xs:simpleType>

	<xs:complexType name='maintainerDescType'>
		<xs:simpleContent>
			<xs:extension base="xs:token">
				<xs:attribute name='lang' type='xs:language' default='en'/>
			</xs:extension>
		</xs:simpleContent>
	</xs:complexType>

	<!-- long description -->
	<xs:complexType name='longDescType' mixed='true'>
		<xs:choice minOccurs='0' maxOccurs='unbounded'>
			<xs:element name='pkg' type='pkgType'/>
			<xs:element name='cat' type='catType'/>
		</xs:choice>
		<xs:attribute name='lang' type='xs:language' default='en'/>
		<xs:attribute name='restrict' type='restrictAttrType' default=''/>
	</xs:complexType>

	<xs:complexType name='catLongDescType' mixed='true'>
		<xs:choice minOccurs='0' maxOccurs='unbounded'>
			<xs:element name='pkg' type='pkgType'/>
			<xs:element name='cat' type='catType'/>
		</xs:choice>
		<xs:attribute name='lang' type='xs:language' default='en'/>
	</xs:complexType>

	<!-- slots -->
	<xs:complexType name='slotsType'>
		<xs:choice minOccurs='0' maxOccurs='unbounded'>
			<xs:element name='slot' type='slotType'/>
			<xs:element name='subslots' type='tokenOnceType'/>
		</xs:choice>
		<xs:attribute name='lang' type='xs:language' default='en'/>
	</xs:complexType>

	<xs:complexType name='slotType'>
		<xs:simpleContent>
			<xs:extension base="xs:token">
				<xs:attribute name='name' type='slotNameAttrType'
					use='required'/>
			</xs:extension>
		</xs:simpleContent>
	</xs:complexType>

	<xs:simpleType name='slotNameAttrType'>
		<xs:restriction base='xs:token'>
			<!-- PMS 3.1.3 Slot Names + special value '*' -->
			<xs:pattern value="[A-Za-z0-9_][A-Za-z0-9+_.-]*|[*]"/>
		</xs:restriction>
	</xs:simpleType>

	<!-- stabilize-allarches -->
	<xs:complexType name='stabilizeAllArchesType'>
		<xs:attribute name='restrict' type='restrictAttrType'
			default=''/>
	</xs:complexType>

	<!-- use flags -->
	<xs:complexType name='useType'>
		<xs:choice minOccurs='0' maxOccurs='unbounded'>
			<xs:element name='flag' type='flagType'/>
		</xs:choice>
		<xs:attribute name='lang' type='xs:language' default='en'/>
	</xs:complexType>

	<xs:complexType name='flagType' mixed='true'>
		<xs:choice minOccurs='0' maxOccurs='unbounded'>
			<xs:element name='cat' type='catType'/>
			<xs:element name='pkg' type='pkgType'/>
		</xs:choice>
		<xs:attribute name='name' type='flagNameAttrType'
			use='required'/>
		<xs:attribute name='restrict' type='restrictAttrType'
			default=''/>
	</xs:complexType>

	<xs:simpleType name='flagNameAttrType'>
		<xs:restriction base='xs:token'>
			<!-- PMS 3.1.4 USE Flag Names -->
			<xs:pattern value="[A-Za-z0-9][A-Za-z0-9+_@-]*"/>
		</xs:restriction>
	</xs:simpleType>

	<!-- upstream-specific types -->
	<xs:complexType name='upstreamDocType'>
		<xs:simpleContent>
			<xs:extension base="urlType">
				<xs:attribute name='lang' type='xs:language' default='en'/>
			</xs:extension>
		</xs:simpleContent>
	</xs:complexType>

	<xs:complexType name='upstreamRemoteIdType'>
		<xs:simpleContent>
			<xs:extension base="xs:token">
				<xs:attribute name='type' type='upstreamRemoteIdTypeAttrType'
					use='required'/>
			</xs:extension>
		</xs:simpleContent>
	</xs:complexType>

	<xs:simpleType name='upstreamRemoteIdTypeAttrType'>
		<xs:restriction base='xs:token'>
			<xs:enumeration value='bitbucket'/>
			<xs:enumeration value='cpan'/>
			<xs:enumeration value='cpan-module'/>
			<xs:enumeration value='cpe'/>
			<xs:enumeration value='cran'/>
			<xs:enumeration value='ctan'/>
			<xs:enumeration value='gentoo'/>
			<xs:enumeration value='github'/>
			<xs:enumeration value='gitlab'/>
			<xs:enumeration value='gitorious'/>
			<xs:enumeration value='google-code'/>
			<xs:enumeration value='heptapod'/>
			<xs:enumeration value='launchpad'/>
			<xs:enumeration value='osdn'/>
			<xs:enumeration value='pear'/>
			<xs:enumeration value='pecl'/>
			<xs:enumeration value='pypi'/>
			<xs:enumeration value='rubygems'/>
			<xs:enumeration value='sourceforge'/>
			<xs:enumeration value='sourceforge-jp'/>
			<xs:enumeration value='vim'/>
		</xs:restriction>
	</xs:simpleType>

	<!-- creepy mixed-text types -->
	<xs:simpleType name='catType'>
		<xs:restriction base='xs:token'>
			<!-- PMS 3.1.1 Category Names -->
			<xs:pattern value="[A-Za-z0-9_][A-Za-z0-9+_.-]*"/>
		</xs:restriction>
	</xs:simpleType>
	<xs:simpleType name='pkgType'>
		<xs:restriction base='xs:token'>
			<!-- PMS 3.1.1 Category Names + 3.1.2 Package Names -->
			<!-- note: this does not enforce the 'anything matching
				 the version syntax' requirement -->
			<xs:pattern
				value="[A-Za-z0-9_][A-Za-z0-9+_.-]*/[A-Za-z0-9_][A-Za-z0-9+_-]*"/>
		</xs:restriction>
	</xs:simpleType>

	<!-- common attributes -->
	<xs:simpleType name='restrictAttrType'>
		<xs:restriction base='xs:token'>
			<!-- simplified package dependency syntax -->
			<!-- note: 'pure' package atom is technically valid too
				 but not really meaningful -->
			<xs:pattern
				value="(([&lt;&gt;]=?|[=~])[A-Za-z0-9_][A-Za-z0-9+_.-]*/[A-Za-z0-9_][A-Za-z0-9+_-]*-[0-9]+(\.[0-9]+)*[a-z]?((_alpha|_beta|_pre|_rc|_p)[0-9]*)*(-r[0-9]+)?\*?)?"/>
		</xs:restriction>
	</xs:simpleType>

	<!-- generic types -->
	<xs:simpleType name='emailType'>
		<xs:restriction base='xs:token'>
			<!-- minimal safe regex -->
			<xs:pattern value="[^@]+@[^.]+\..+"/>
		</xs:restriction>
	</xs:simpleType>

	<xs:complexType name='tokenOnceType'>
		<xs:simpleContent>
			<xs:extension base="xs:token">
				<xs:attribute name='fake-only-once'
					fixed='there can be at most one element of this type'/>
			</xs:extension>
		</xs:simpleContent>
	</xs:complexType>

	<xs:simpleType name='urlType'>
		<xs:restriction base='xs:anyURI'>
			<!-- TODO: something better? -->
			<xs:pattern value="(mailto:.+@.+|(ftp|https?)://\S+)"/>
		</xs:restriction>
	</xs:simpleType>

	<xs:complexType name='urlOnceType'>
		<xs:simpleContent>
			<xs:extension base="urlType">
				<xs:attribute name='fake-only-once'
					fixed='there can be at most one element of this type'/>
			</xs:extension>
		</xs:simpleContent>
	</xs:complexType>
</xs:schema>