Advertisement
Guest User

Untitled

a guest
Oct 9th, 2015
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. import os
  2.  
  3. PRIORITY = 60
  4. GHC_PATH = '/opt/ghc/'
  5. CABAL_PATH = '/opt/cabal/'
  6. LINK_PATH = '/usr/bin/'
  7.  
  8. ghc_executables = [
  9. 'ghc',
  10. 'ghc-pkg',
  11. 'ghci',
  12. 'haddock',
  13. 'hp2ps',
  14. 'hpc',
  15. 'hsc2hs'
  16. 'runghc',
  17. 'runhaskell'
  18. ]
  19.  
  20. cabal_executables = [
  21. 'cabal'
  22. ]
  23.  
  24. def update_alternatives(path, exes, ver):
  25.  
  26. origin_path = path + ver + '/bin/'
  27. command = "sudo update-alternatives --install %s %s %s %d " % \
  28. (LINK_PATH + exes[0], exes[0], origin_path + exes[0], PRIORITY)
  29. for exe in exes[1:]:
  30. command += "--slave %s %s %s " % (LINK_PATH + exe, exe, origin_path + exe)
  31. os.system(command)
  32.  
  33. if __name__ == '__main__':
  34. ghc_version = raw_input("input GHC version: ")
  35. update_alternatives(GHC_PATH, ghc_executables, ghc_version)
  36. cabal_version = raw_input("input Cabal version: ")
  37. update_alternatives(CABAL_PATH, cabal_executables, cabal_version)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement