jdk_package.py 1.0 KB

12345678910111213141516171819202122232425262728293031323334
  1. #!/usr/bin/env python
  2. import os
  3. from pisi.util import join_path
  4. executables = (
  5. 'jstatd', 'jshell', 'jarsigner', 'javap', 'jstack', 'javadoc', 'jdeprscan', 'jmap', 'jconsole',
  6. 'jmod', 'jcmd', 'jar', 'javac', 'rmic', 'jps', 'serialver', 'jstat', 'jdb', 'jinfo', 'jhsdb',
  7. 'jlink', 'jimage', 'jdeps'
  8. )
  9. bin_dir = '/usr/bin'
  10. jvm_dir = '/usr/lib/jvm/java-openjdk'
  11. def postInstall(fromVersion, fromRelease, toVersion, toRelease):
  12. for executable in executables:
  13. try:
  14. os.system('update-alternatives --install %s %s %s 2' % (
  15. join_path(bin_dir, executable), executable, join_path(jvm_dir, 'bin', executable)
  16. ))
  17. os.system('update-alternatives --auto %s' % executable)
  18. except:
  19. pass
  20. def postRemove():
  21. for executable in executables:
  22. try:
  23. os.system('update-alternatives --remove %s %s' % (executable, join_path(jvm_dir, 'bin', executable)))
  24. os.system('update-alternatives --auto %s' % executable)
  25. except:
  26. pass