packages.py 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  1. from urllib.parse import urljoin
  2. class Package(object):
  3. '''Abstract base class for packages.
  4. '''
  5. niceName = None
  6. sourceName = None
  7. @classmethod
  8. def getMakeName(cls):
  9. return cls.sourceName.upper().replace('-', '_')
  10. class DownloadablePackage(Package):
  11. '''Abstract base class for packages that can be downloaded.
  12. '''
  13. downloadURL = None
  14. version = None
  15. fileLength = None
  16. checksums = None
  17. @classmethod
  18. def getSourceDirName(cls):
  19. '''Returns the desired name of the top-level source directory.
  20. This might not match the actual name inside the downloaded archive,
  21. but we can perform a rename on extraction to fix that.
  22. '''
  23. return '%s-%s' % (cls.sourceName, cls.version)
  24. @classmethod
  25. def getTarballName(cls):
  26. return '%s-%s.tar.gz' % (cls.sourceName, cls.version)
  27. @classmethod
  28. def getURL(cls):
  29. return urljoin(cls.downloadURL + '/', cls.getTarballName())
  30. class ALSA(DownloadablePackage):
  31. downloadURL = 'ftp://ftp.alsa-project.org/pub/lib/'
  32. niceName = 'ALSA'
  33. sourceName = 'alsa-lib'
  34. version = '1.1.7'
  35. fileLength = 1005257
  36. checksums = {
  37. 'sha256':
  38. '9d6000b882a3b2df56300521225d69717be6741b71269e488bb20a20783bdc09',
  39. }
  40. @classmethod
  41. def getTarballName(cls):
  42. return '%s-%s.tar.bz2' % (cls.sourceName, cls.version)
  43. @classmethod
  44. def getMakeName(cls):
  45. return 'ALSA'
  46. class FreeType(DownloadablePackage):
  47. downloadURL = 'http://downloads.sourceforge.net/freetype'
  48. niceName = 'FreeType'
  49. sourceName = 'freetype'
  50. version = '2.9.1'
  51. fileLength = 2533956
  52. checksums = {
  53. 'sha256':
  54. 'ec391504e55498adceb30baceebd147a6e963f636eb617424bcfc47a169898ce',
  55. }
  56. class GLEW(DownloadablePackage):
  57. downloadURL = 'http://downloads.sourceforge.net/glew'
  58. niceName = 'GLEW'
  59. sourceName = 'glew'
  60. version = '2.1.0'
  61. fileLength = 764073
  62. checksums = {
  63. 'sha256':
  64. '04de91e7e6763039bc11940095cd9c7f880baba82196a7765f727ac05a993c95',
  65. }
  66. @classmethod
  67. def getTarballName(cls):
  68. return '%s-%s.tgz' % (cls.sourceName, cls.version)
  69. class LibPNG(DownloadablePackage):
  70. downloadURL = 'http://downloads.sourceforge.net/libpng'
  71. niceName = 'libpng'
  72. sourceName = 'libpng'
  73. version = '1.6.36'
  74. fileLength = 1496022
  75. checksums = {
  76. 'sha256':
  77. 'ca13c548bde5fb6ff7117cc0bdab38808acb699c0eccb613f0e4697826e1fd7d',
  78. }
  79. @classmethod
  80. def getMakeName(cls):
  81. return 'PNG'
  82. class OGG(DownloadablePackage):
  83. downloadURL = 'http://downloads.xiph.org/releases/ogg'
  84. niceName = 'libogg'
  85. sourceName = 'libogg'
  86. version = '1.3.3'
  87. fileLength = 579853
  88. checksums = {
  89. 'sha256':
  90. 'c2e8a485110b97550f453226ec644ebac6cb29d1caef2902c007edab4308d985',
  91. }
  92. @classmethod
  93. def getMakeName(cls):
  94. return 'OGG'
  95. class OpenGL(Package):
  96. niceName = 'OpenGL'
  97. sourceName = 'gl'
  98. class PkgConfig(DownloadablePackage):
  99. downloadURL = 'https://pkg-config.freedesktop.org/releases'
  100. niceName = 'pkg-config'
  101. sourceName = 'pkg-config'
  102. version = '0.29.2'
  103. fileLength = 2016830
  104. checksums = {
  105. 'sha256':
  106. '6fc69c01688c9458a57eb9a1664c9aba372ccda420a02bf4429fe610e7e7d591',
  107. }
  108. class SDL2(DownloadablePackage):
  109. downloadURL = 'http://www.libsdl.org/release'
  110. niceName = 'SDL2'
  111. sourceName = 'SDL2'
  112. version = '2.0.10'
  113. fileLength = 5550762
  114. checksums = {
  115. 'sha256':
  116. 'b4656c13a1f0d0023ae2f4a9cf08ec92fffb464e0f24238337784159b8b91d57',
  117. }
  118. class SDL2_ttf(DownloadablePackage):
  119. downloadURL = 'http://www.libsdl.org/projects/SDL_ttf/release'
  120. niceName = 'SDL2_ttf'
  121. sourceName = 'SDL2_ttf'
  122. version = '2.0.15'
  123. fileLength = 4479718
  124. checksums = {
  125. 'sha256':
  126. 'a9eceb1ad88c1f1545cd7bd28e7cbc0b2c14191d40238f531a15b01b1b22cd33',
  127. }
  128. class TCL(DownloadablePackage):
  129. downloadURL = 'http://downloads.sourceforge.net/tcl'
  130. niceName = 'Tcl'
  131. sourceName = 'tcl'
  132. version = '8.6.9'
  133. fileLength = 10000896
  134. checksums = {
  135. 'sha256':
  136. 'ad0cd2de2c87b9ba8086b43957a0de3eb2eb565c7159d5f53ccbba3feb915f4e',
  137. }
  138. @classmethod
  139. def getSourceDirName(cls):
  140. return '%s%s' % (cls.sourceName, cls.version)
  141. @classmethod
  142. def getTarballName(cls):
  143. return '%s%s-src.tar.gz' % (cls.sourceName, cls.version)
  144. class Theora(DownloadablePackage):
  145. downloadURL = 'http://downloads.xiph.org/releases/theora'
  146. niceName = 'libtheora'
  147. sourceName = 'libtheora'
  148. version = '1.1.1'
  149. fileLength = 2111877
  150. checksums = {
  151. 'sha256':
  152. '40952956c47811928d1e7922cda3bc1f427eb75680c3c37249c91e949054916b',
  153. }
  154. @classmethod
  155. def getMakeName(cls):
  156. return 'THEORA'
  157. class Vorbis(DownloadablePackage):
  158. downloadURL = 'http://downloads.xiph.org/releases/vorbis'
  159. niceName = 'libvorbis'
  160. sourceName = 'libvorbis'
  161. version = '1.3.6'
  162. fileLength = 1634357
  163. checksums = {
  164. 'sha256':
  165. '6ed40e0241089a42c48604dc00e362beee00036af2d8b3f46338031c9e0351cb',
  166. }
  167. @classmethod
  168. def getMakeName(cls):
  169. return 'VORBIS'
  170. class ZLib(DownloadablePackage):
  171. downloadURL = 'http://downloads.sourceforge.net/libpng'
  172. niceName = 'zlib'
  173. sourceName = 'zlib'
  174. version = '1.2.11'
  175. fileLength = 607698
  176. checksums = {
  177. 'sha256':
  178. 'c3e5e9fdd5004dcb542feda5ee4f0ff0744628baf8ed2dd5d66f8ca1197cb1a1',
  179. }
  180. # Build a dictionary of packages using introspection.
  181. _packagesByName = {
  182. obj.getMakeName(): obj
  183. for obj in locals().values()
  184. if isinstance(obj, type)
  185. and issubclass(obj, Package)
  186. and obj is not Package
  187. and obj is not DownloadablePackage
  188. }
  189. def getPackage(makeName):
  190. return _packagesByName[makeName]
  191. def iterDownloadablePackages():
  192. for package in _packagesByName.values():
  193. if issubclass(package, DownloadablePackage):
  194. yield package