Initial commit: Creates some of the debian files
[auto-debuild.git] / auto_debuild.py
1 #!/usr/bin/python
2 import os, stat
3
4 def writeDebList(list):
5         return ', '.join(list)
6
7 def createDebianFiles(config):
8         sourceName = config['sourceName']
9         binaryName = config.get('binaryName', sourceName+'-local')
10         name = config.get('name', os.getlogin())
11         email = config.get('email', os.getlogin()+'@'+os.uname()[1])
12         # source format file
13         if not os.path.exists('debian/source'): os.mkdir('debian/source')
14         with open('debian/source/format', 'w') as f:
15                 print >>f, "3.0 (native)"
16         # compat file
17         with open('debian/compat', 'w') as f:
18                 print >>f, "9"
19         # changelog file
20         with open('debian/changlog', 'w') as f:
21                 print >>f, "Auto-generated by auto-debuild, not suited for distribution"
22         # control file
23         with open('debian/control', 'w') as f:
24                 print >>f, "Source:",sourceName
25                 print >>f, "Section: misc"
26                 print >>f, "Priority: extra"
27                 print >>f, "Maintainer: %s <%s>" % (name, email)
28                 print >>f, "Build-Depends:",writeDebList(["debhelper (>= 9)"] + config.get('buildDepends', []))
29                 print >>f, "Standards-Version: 3.9.3"
30                 print >>f, ""
31                 print >>f, "Package:",binaryName
32                 print >>f, "Architecture:",config.get('architecture', 'any')
33                 print >>f, "Depends:",writeDebList(["${shlibs:Depends}", "${misc:Depends}"] + config.get('binaryDepends', []))
34                 print >>f, "Provides:",writeDebList(config.get('binaryProvides', [sourceName]))
35                 print >>f, "Description:",sourceName
36                 print >>f, " Auto-generated package for",sourceName
37         # rules file
38         with open('debian/rules', 'w') as f:
39                 pass
40         mode = os.stat('debian/rules').st_mode
41         os.chmod('debian/rules', mode | stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH)
42
43 if __name__ == "__main__":
44         import imp
45         config = imp.load_source('config', 'debian/auto-debuild.py')
46         createDebianFiles(config.__dict__)
47