Initial commit: Creates some of the debian files
authorRalf Jung <post@ralfj.de>
Mon, 16 Jul 2012 19:47:38 +0000 (21:47 +0200)
committerRalf Jung <post@ralfj.de>
Mon, 16 Jul 2012 19:47:38 +0000 (21:47 +0200)
auto_debuild.py [new file with mode: 0755]

diff --git a/auto_debuild.py b/auto_debuild.py
new file mode 100755 (executable)
index 0000000..098bc89
--- /dev/null
@@ -0,0 +1,47 @@
+#!/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__)
+