Forked from anonymous/haskell-pkg-conf-to-register-script.py
Created
August 26, 2011 12:48
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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