+#!/usr/bin/python
+import os, stat
+
+def writeDebList(list):
+ return ', '.join(list)
+
+def createDebianFiles(config):
+ sourceName = config['sourceName']
+ binaryName = config.get('binaryName', sourceName+'-local')
+ name = config.get('name', os.getlogin())
+ email = config.get('email', os.getlogin()+'@'+os.uname()[1])
+ # source format file
+ if not os.path.exists('debian/source'): os.mkdir('debian/source')
+ with open('debian/source/format', 'w') as f:
+ print >>f, "3.0 (native)"
+ # compat file
+ with open('debian/compat', 'w') as f:
+ print >>f, "9"
+ # changelog file
+ with open('debian/changlog', 'w') as f:
+ print >>f, "Auto-generated by auto-debuild, not suited for distribution"
+ # control file
+ with open('debian/control', 'w') as f:
+ print >>f, "Source:",sourceName
+ print >>f, "Section: misc"
+ print >>f, "Priority: extra"
+ print >>f, "Maintainer: %s <%s>" % (name, email)
+ print >>f, "Build-Depends:",writeDebList(["debhelper (>= 9)"] + config.get('buildDepends', []))
+ print >>f, "Standards-Version: 3.9.3"
+ print >>f, ""
+ print >>f, "Package:",binaryName
+ print >>f, "Architecture:",config.get('architecture', 'any')
+ print >>f, "Depends:",writeDebList(["${shlibs:Depends}", "${misc:Depends}"] + config.get('binaryDepends', []))
+ print >>f, "Provides:",writeDebList(config.get('binaryProvides', [sourceName]))
+ print >>f, "Description:",sourceName
+ print >>f, " Auto-generated package for",sourceName
+ # rules file
+ with open('debian/rules', 'w') as f:
+ pass
+ mode = os.stat('debian/rules').st_mode
+ os.chmod('debian/rules', mode | stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH)
+
+if __name__ == "__main__":
+ import imp
+ config = imp.load_source('config', 'debian/auto-debuild.py')
+ createDebianFiles(config.__dict__)
+