checkdependencies.py 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. #!/usr/bin/env python
  2. import sys, os
  3. HOME = os.path.realpath(os.path.dirname(__file__))
  4. options = eval(open(os.path.join(HOME, '../tools/hooks', 'buildconf.py')).read())
  5. static = options.get('USE_STATIC', False)
  6. # list of (packagename, filename)
  7. if os.path.exists('/etc/redhat-release'):
  8. ostype = 'redhat'
  9. elif os.path.exists('/etc/debian_version'):
  10. ostype = 'debian'
  11. else:
  12. ostype = ''
  13. DEPENDENCIES = [
  14. ('/usr/bin/xsltproc', {'debian':'xsltproc', 'redhat':'libxslt'}),
  15. ('/usr/bin/pkg-config', {'debian':'pkg-config', 'redhat':'pkgconfig'}),
  16. ('/usr/bin/gettextize', {'debian':'gettext', 'redhat':'gettext'}),
  17. ('/usr/lib/libX11.so', {'debian':'libx11-dev', 'redhat':'libX11-devel'}),
  18. ('/usr/lib/libXext.so', {'debian':'libxext-dev', 'redhat':'libXext-devel'}),
  19. ('/usr/lib/libXt.so', {'debian':'libxt-dev', 'redhat':'libXt-devel'}),
  20. ('/usr/lib/libXmu.so', {'debian':'libxmu-dev', 'redhat':'libXmu-devel'}),
  21. ('/usr/lib/libXi.so', {'debian':'libxi-dev', 'redhat':'libXi-devel'}),
  22. ('/usr/bin/patch', {'debian':'patch', 'redhat':'patch'}),
  23. ]
  24. if static:
  25. DEPENDENCIES += [
  26. ('/usr/lib/libjpeg.a', {'debian':'libjpeg-dev', 'redhat':'libjpeg-static'}),
  27. ('/usr/lib/libglut.a', {'debian':'libglut3-dev', 'redhat':'freeglut-devel'}),
  28. ]
  29. missing = []
  30. for filename, package in DEPENDENCIES:
  31. if not os.path.exists(filename) and \
  32. not os.path.exists(filename.replace('/usr/lib', '/usr/lib64')) and \
  33. not os.path.exists(filename.replace('/usr/lib', '/usr/lib/x86_64-linux-gnu')) and \
  34. not os.path.exists(filename.replace('/usr/lib', '/usr/lib/i386-linux-gnu')) \
  35. :
  36. if ostype:
  37. missing.append(package[ostype])
  38. else:
  39. print '*** Cannot find the file %s' % filename
  40. if missing:
  41. print >> sys.stderr, '*** Please install the following package%s: %s' % \
  42. (len(missing)>1 and 's' or '', ' '.join(missing))
  43. sys.exit(1)
  44. else:
  45. sys.exit(0)