Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wjlroe/1173339 to your computer and use it in GitHub Desktop.
Save wjlroe/1173339 to your computer and use it in GitHub Desktop.
Script to take the output of the package.sh script in haskell-platform and generate a single register.sh script for fpm
#!/usr/bin/python
## -*- mode: python; python-indent: 4; -*-
import glob
import os.path
if __name__ == '__main__':
with open('unregister.sh', 'w') as unreg:
with open('register.sh','w') as reg:
[fd.write("#!/bin/sh\n") for fd in reg,unreg]
reg.write("/usr/bin/ghc-pkg recache\n")
for conf in glob.glob('/mnt/tmp/haskellplatform-conf/*.conf'):
reg.write("'/usr/bin/ghc-pkg' 'update' '-' '--global' '--no-user-package-conf' '--force' <<ENDOFINPUT\n")
with open(conf, 'r') as conf_fd:
reg.write(conf_fd.read())
reg.write("\nENDOFINPUT\n")
pkg_name = os.path.basename(conf).replace(".conf","")
unreg.write("'/usr/bin/ghc-pkg' 'unregister' '--global' '--force' '%s' \"$@\"\n" % pkg_name)
unreg.write("/usr/bin/ghc-pkg recache\n")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment