packages.py 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  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(Package):
  31. niceName = 'ALSA'
  32. sourceName = 'alsa-lib'
  33. @classmethod
  34. def getMakeName(cls):
  35. return 'ALSA'
  36. class FreeType(DownloadablePackage):
  37. downloadURL = 'http://downloads.sourceforge.net/freetype'
  38. niceName = 'FreeType'
  39. sourceName = 'freetype'
  40. version = '2.9.1'
  41. fileLength = 2533956
  42. checksums = {
  43. 'sha256':
  44. 'ec391504e55498adceb30baceebd147a6e963f636eb617424bcfc47a169898ce',
  45. }
  46. class GLEW(DownloadablePackage):
  47. downloadURL = 'http://downloads.sourceforge.net/glew'
  48. niceName = 'GLEW'
  49. sourceName = 'glew'
  50. version = '2.1.0'
  51. fileLength = 764073
  52. checksums = {
  53. 'sha256':
  54. '04de91e7e6763039bc11940095cd9c7f880baba82196a7765f727ac05a993c95',
  55. }
  56. @classmethod
  57. def getTarballName(cls):
  58. return '%s-%s.tgz' % (cls.sourceName, cls.version)
  59. class LibPNG(DownloadablePackage):
  60. downloadURL = 'http://downloads.sourceforge.net/libpng'
  61. niceName = 'libpng'
  62. sourceName = 'libpng'
  63. version = '1.6.37'
  64. fileLength = 1495748
  65. checksums = {
  66. 'sha256':
  67. 'daeb2620d829575513e35fecc83f0d3791a620b9b93d800b763542ece9390fb4',
  68. }
  69. @classmethod
  70. def getMakeName(cls):
  71. return 'PNG'
  72. class OGG(DownloadablePackage):
  73. downloadURL = 'http://downloads.xiph.org/releases/ogg'
  74. niceName = 'libogg'
  75. sourceName = 'libogg'
  76. version = '1.3.3'
  77. fileLength = 579853
  78. checksums = {
  79. 'sha256':
  80. 'c2e8a485110b97550f453226ec644ebac6cb29d1caef2902c007edab4308d985',
  81. }
  82. @classmethod
  83. def getMakeName(cls):
  84. return 'OGG'
  85. class OpenGL(Package):
  86. niceName = 'OpenGL'
  87. sourceName = 'gl'
  88. class PkgConfig(DownloadablePackage):
  89. downloadURL = 'https://pkg-config.freedesktop.org/releases'
  90. niceName = 'pkg-config'
  91. sourceName = 'pkg-config'
  92. version = '0.29.2'
  93. fileLength = 2016830
  94. checksums = {
  95. 'sha256':
  96. '6fc69c01688c9458a57eb9a1664c9aba372ccda420a02bf4429fe610e7e7d591',
  97. }
  98. class SDL2(DownloadablePackage):
  99. downloadURL = 'https://www.libsdl.org/release'
  100. niceName = 'SDL2'
  101. sourceName = 'SDL2'
  102. version = '2.0.12'
  103. fileLength = 5720162
  104. checksums = {
  105. 'sha256':
  106. '349268f695c02efbc9b9148a70b85e58cefbbf704abd3e91be654db7f1e2c863',
  107. }
  108. class SDL2_ttf(DownloadablePackage):
  109. downloadURL = 'http://www.libsdl.org/projects/SDL_ttf/release'
  110. niceName = 'SDL2_ttf'
  111. sourceName = 'SDL2_ttf'
  112. version = '2.0.15'
  113. fileLength = 4479718
  114. checksums = {
  115. 'sha256':
  116. 'a9eceb1ad88c1f1545cd7bd28e7cbc0b2c14191d40238f531a15b01b1b22cd33',
  117. }
  118. class TCL(DownloadablePackage):
  119. downloadURL = 'http://downloads.sourceforge.net/tcl'
  120. niceName = 'Tcl'
  121. sourceName = 'tcl'
  122. version = '8.6.10'
  123. fileLength = 10144235
  124. checksums = {
  125. 'sha256':
  126. '5196dbf6638e3df8d5c87b5815c8c2b758496eb6f0e41446596c9a4e638d87ed',
  127. }
  128. @classmethod
  129. def getSourceDirName(cls):
  130. return '%s%s' % (cls.sourceName, cls.version)
  131. @classmethod
  132. def getTarballName(cls):
  133. return '%s%s-src.tar.gz' % (cls.sourceName, cls.version)
  134. class Theora(DownloadablePackage):
  135. downloadURL = 'http://downloads.xiph.org/releases/theora'
  136. niceName = 'libtheora'
  137. sourceName = 'libtheora'
  138. version = '1.1.1'
  139. fileLength = 2111877
  140. checksums = {
  141. 'sha256':
  142. '40952956c47811928d1e7922cda3bc1f427eb75680c3c37249c91e949054916b',
  143. }
  144. @classmethod
  145. def getMakeName(cls):
  146. return 'THEORA'
  147. class Vorbis(DownloadablePackage):
  148. downloadURL = 'http://downloads.xiph.org/releases/vorbis'
  149. niceName = 'libvorbis'
  150. sourceName = 'libvorbis'
  151. version = '1.3.6'
  152. fileLength = 1634357
  153. checksums = {
  154. 'sha256':
  155. '6ed40e0241089a42c48604dc00e362beee00036af2d8b3f46338031c9e0351cb',
  156. }
  157. @classmethod
  158. def getMakeName(cls):
  159. return 'VORBIS'
  160. class ZLib(DownloadablePackage):
  161. downloadURL = 'http://downloads.sourceforge.net/libpng'
  162. niceName = 'zlib'
  163. sourceName = 'zlib'
  164. version = '1.2.11'
  165. fileLength = 607698
  166. checksums = {
  167. 'sha256':
  168. 'c3e5e9fdd5004dcb542feda5ee4f0ff0744628baf8ed2dd5d66f8ca1197cb1a1',
  169. }
  170. # Build a dictionary of packages using introspection.
  171. _packagesByName = {
  172. obj.getMakeName(): obj
  173. for obj in locals().values()
  174. if isinstance(obj, type)
  175. and issubclass(obj, Package)
  176. and obj is not Package
  177. and obj is not DownloadablePackage
  178. }
  179. def getPackage(makeName):
  180. return _packagesByName[makeName]
  181. def iterDownloadablePackages():
  182. for package in _packagesByName.values():
  183. if issubclass(package, DownloadablePackage):
  184. yield package