OXYGENHUB
◆ main openmsx / build / packages.py
5.0 KiB · Python · last changed chore(): initial commit 1 month ago source blame history raw
1
from urllib.parse import urljoin
2
3
class Package(object):
4
	'''Abstract base class for packages.
5
	'''
6
	niceName = None
7
	sourceName = None
8
9
	@classmethod
10
	def getMakeName(cls):
11
		return cls.sourceName.upper().replace('-', '_')
12
13
class DownloadablePackage(Package):
14
	'''Abstract base class for packages that can be downloaded.
15
	'''
16
	downloadURL = None
17
	version = None
18
	fileLength = None
19
	checksums = None
20
21
	@classmethod
22
	def getSourceDirName(cls):
23
		'''Returns the desired name of the top-level source directory.
24
		This might not match the actual name inside the downloaded archive,
25
		but we can perform a rename on extraction to fix that.
26
		'''
27
		return '%s-%s' % (cls.sourceName, cls.version)
28
29
	@classmethod
30
	def getTarballName(cls):
31
		return '%s-%s.tar.gz' % (cls.sourceName, cls.version)
32
33
	@classmethod
34
	def getURL(cls):
35
		return urljoin(cls.downloadURL + '/', cls.getTarballName())
36
37
class ALSA(Package):
38
	niceName = 'ALSA'
39
	sourceName = 'alsa-lib'
40
41
	@classmethod
42
	def getMakeName(cls):
43
		return 'ALSA'
44
45
class FreeType(DownloadablePackage):
46
	downloadURL = 'http://downloads.sourceforge.net/freetype'
47
	niceName = 'FreeType'
48
	sourceName = 'freetype'
49
	version = '2.13.3'
50
	fileLength = 4063324
51
	checksums = {
52
		'sha256':
53
			'5c3a8e78f7b24c20b25b54ee575d6daa40007a5f4eea2845861c3409b3021747',
54
		}
55
56
class GLEW(DownloadablePackage):
57
	downloadURL = 'http://downloads.sourceforge.net/glew'
58
	niceName = 'GLEW'
59
	sourceName = 'glew'
60
	version = '2.2.0'
61
	fileLength = 835861
62
	checksums = {
63
		'sha256':
64
			'd4fc82893cfb00109578d0a1a2337fb8ca335b3ceccf97b97e5cc7f08e4353e1',
65
		}
66
67
	@classmethod
68
	def getTarballName(cls):
69
		return '%s-%s.tgz' % (cls.sourceName, cls.version)
70
71
class LibPNG(DownloadablePackage):
72
	downloadURL = 'http://downloads.sourceforge.net/libpng'
73
	niceName = 'libpng'
74
	sourceName = 'libpng'
75
	version = '1.6.44'
76
	fileLength = 1545850
77
	checksums = {
78
		'sha256':
79
			'8c25a7792099a0089fa1cc76c94260d0bb3f1ec52b93671b572f8bb61577b732',
80
		}
81
82
	@classmethod
83
	def getMakeName(cls):
84
		return 'PNG'
85
86
class OGG(DownloadablePackage):
87
	downloadURL = 'http://downloads.xiph.org/releases/ogg'
88
	niceName = 'libogg'
89
	sourceName = 'libogg'
90
	version = '1.3.5'
91
	fileLength = 593071
92
	checksums = {
93
		'sha256':
94
			'0eb4b4b9420a0f51db142ba3f9c64b333f826532dc0f48c6410ae51f4799b664',
95
		}
96
97
	@classmethod
98
	def getMakeName(cls):
99
		return 'OGG'
100
101
class OpenGL(Package):
102
	niceName = 'OpenGL'
103
	sourceName = 'gl'
104
105
class PkgConfig(DownloadablePackage):
106
	downloadURL = 'https://pkg-config.freedesktop.org/releases'
107
	niceName = 'pkg-config'
108
	sourceName = 'pkg-config'
109
	version = '0.29.2'
110
	fileLength = 2016830
111
	checksums = {
112
		'sha256':
113
			'6fc69c01688c9458a57eb9a1664c9aba372ccda420a02bf4429fe610e7e7d591',
114
		}
115
116
class SDL2(DownloadablePackage):
117
	downloadURL = 'https://www.libsdl.org/release'
118
	niceName = 'SDL2'
119
	sourceName = 'SDL2'
120
	version = '2.32.10'
121
	fileLength = 7630262
122
	checksums = {
123
		'sha256':
124
			'5f5993c530f084535c65a6879e9b26ad441169b3e25d789d83287040a9ca5165',
125
		}
126
127
class SDL2_ttf(DownloadablePackage):
128
	downloadURL = 'http://www.libsdl.org/projects/SDL_ttf/release'
129
	niceName = 'SDL2_ttf'
130
	sourceName = 'SDL2_ttf'
131
	version = '2.22.0'
132
	fileLength = 14314901
133
	checksums = {
134
		'sha256':
135
			'd48cbd1ce475b9e178206bf3b72d56b66d84d44f64ac05803328396234d67723',
136
		}
137
138
class TCL(DownloadablePackage):
139
	downloadURL = 'http://downloads.sourceforge.net/tcl'
140
	niceName = 'Tcl'
141
	sourceName = 'tcl'
142
	version = '8.6.15'
143
	fileLength = 11765231
144
	checksums = {
145
		'sha256':
146
			'861e159753f2e2fbd6ec1484103715b0be56be3357522b858d3cbb5f893ffef1',
147
		}
148
149
	@classmethod
150
	def getSourceDirName(cls):
151
		return '%s%s' % (cls.sourceName, cls.version)
152
153
	@classmethod
154
	def getTarballName(cls):
155
		return '%s%s-src.tar.gz' % (cls.sourceName, cls.version)
156
157
class Theora(DownloadablePackage):
158
	downloadURL = 'http://downloads.xiph.org/releases/theora'
159
	niceName = 'libtheora'
160
	sourceName = 'libtheora'
161
	version = '1.1.1'
162
	fileLength = 2111877
163
	checksums = {
164
		'sha256':
165
			'40952956c47811928d1e7922cda3bc1f427eb75680c3c37249c91e949054916b',
166
		}
167
168
	@classmethod
169
	def getMakeName(cls):
170
		return 'THEORA'
171
172
class Vorbis(DownloadablePackage):
173
	downloadURL = 'http://downloads.xiph.org/releases/vorbis'
174
	niceName = 'libvorbis'
175
	sourceName = 'libvorbis'
176
	version = '1.3.7'
177
	fileLength = 1658963
178
	checksums = {
179
		'sha256':
180
			'0e982409a9c3fc82ee06e08205b1355e5c6aa4c36bca58146ef399621b0ce5ab',
181
		}
182
183
	@classmethod
184
	def getMakeName(cls):
185
		return 'VORBIS'
186
187
class ZLib(DownloadablePackage):
188
	downloadURL = 'https://zlib.net/fossils/'
189
	niceName = 'zlib'
190
	sourceName = 'zlib'
191
	version = '1.3.1'
192
	fileLength = 1512791
193
	checksums = {
194
		'sha256':
195
			'9a93b2b7dfdac77ceba5a558a580e74667dd6fede4585b91eefb60f03b72df23',
196
		}
197
198
# Build a dictionary of packages using introspection.
199
_packagesByName = {
200
	obj.getMakeName(): obj
201
	for obj in locals().values()
202
	if isinstance(obj, type)
203
		and issubclass(obj, Package)
204
		and obj is not Package
205
		and obj is not DownloadablePackage
206
	}
207
208
def getPackage(makeName):
209
	return _packagesByName[makeName]
210
211
def iterDownloadablePackages():
212
	for package in _packagesByName.values():
213
		if issubclass(package, DownloadablePackage):
214
			yield package