Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 54 lines (43 sloc) 1.307 kb
f236b33f »
2011-02-13 More work on the bootstrap script...
1 #! /usr/bin/env python
2
3 import re
4 import urllib
5 import sys
6
7 SPEC_URL = 'http://code.galois.com/darcs/haskell-platform/' \
8 'haskell-platform.cabal'
9 CABAL_INSTALL_DEPS = ['zlib', 'mtl', 'parsec', 'HTTP', 'network']
10
11 def get_cabal_install_version(f):
12 """File -> String"""
13 r = re.compile(r'cabal-install\s*==\s*([0-9\.]+)\s*,')
14
15 for l in f:
16 if l.find('cabal-install') != -1:
17 m = re.search(r, l)
18 if m is not None:
19 return m.group(1)
20 return None
21
22 def get_package_versions(f):
23 """File -> { String : String }"""
24 d = {}
25 r = re.compile(r'\s*([\w-]+)\s*==\s*([0-9.]+)\s*\,?\s*')
26
27 for l in f:
28 if l.find('library') == 0:
29 break
30 for l in f:
31 m = re.match(r,l)
32 if m:
33 d[m.group(1)] = m.group(2)
34
35 return d
36
37 def main(url):
38 print("Fetching the haskell-platform.cabal file from '" + url + "'...\n")
39 filename, headers = urllib.urlretrieve(url)
40
41 with open(filename) as f:
42 v = get_cabal_install_version(f)
43 f.seek(0)
44 d = get_package_versions(f)
45 d['cabal-install'] = v
46
47 for k,v in d.iteritems():
48 print(k + " version is " + v)
49
50 if __name__ == '__main__':
51 if len(sys.argv) > 1:
52 main(sys.argv[1])
53 else:
54 main(SPEC_URL)
Something went wrong with that request. Please try again.