Mirroring more of my other projects
[nqaap] / support / builddeb.py
diff --git a/support/builddeb.py b/support/builddeb.py
new file mode 100755 (executable)
index 0000000..072ed0e
--- /dev/null
@@ -0,0 +1,133 @@
+#!/usr/bin/env python\r
+# -*- coding: utf-8 -*-\r
+\r
+"""\r
+This program is free software; you can redistribute it and/or modify\r
+it under the terms of the GNU General Public License as published\r
+by the Free Software Foundation; version 2 only.\r
+\r
+This program is distributed in the hope that it will be useful,\r
+but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+GNU General Public License for more details.\r
+"""\r
+\r
+import os\r
+import sys\r
+\r
+import py2deb\r
+\r
+\r
+def build_package(distribution):\r
+    py2deb.Py2deb.SECTIONS = py2deb.SECTIONS_BY_POLICY[distribution]\r
+    try:\r
+        os.chdir(os.path.dirname(sys.argv[0]))\r
+    except:\r
+        pass\r
+\r
+    p=py2deb.Py2deb("nqaap") #This is the package name and MUST be in\r
+                               #lowercase! (using e.g. "mClock" fails\r
+                               #miserably...)\r
+    p.prettyName="NQA Audiobook Player"\r
+    p.description="""Very simple Audiobook player.\r
+Supports playing, pausing, seeking (sort of) and saving state when changing book/closing.\r
+Plays books arranged as dirs under myDocs/Audiobooks\r
+.\r
+Homepage: http://wiki.maemo.org/Nqaap"""\r
+    p.author="Soeren 'Pengman' Pedersen"\r
+    p.mail="pengmeister@gmail.com"\r
+    p.license = "lgpl"\r
+    p.depends = ", ".join([\r
+        "python2.6 | python2.5",\r
+        "python-gtk2 | python2.5-gtk2",\r
+        "python-dbus | python2.5-dbus",\r
+        "python-telepathy | python2.5-telepathy",\r
+        "python-gobject | python2.5-gobject",\r
+        "python-simplejson",\r
+    ])\r
+    maemoSpecificDepends = ", python-osso | python2.5-osso, python-hildon | python2.5-hildon"\r
+    p.depends += {\r
+        "debian": ", python-gst0.10",\r
+        "diablo": maemoSpecificDepends,\r
+        "fremantle": maemoSpecificDepends + ", python-gst0.10",\r
+    }[distribution]\r
+    p.section = {\r
+        "debian": "sound",\r
+        "diablo": "user/multimedia",\r
+        "fremantle": "user/multimedia",\r
+    }[distribution]\r
+    p.icon = "src/usr/share/icons/hicolor/48x48/hildon/nqaap.png"\r
+    p.arch="all"                #should be all for python, any for all arch\r
+    p.urgency="low"             #not used in maemo onl for deb os\r
+    p.distribution=distribution\r
+    p.repository="extras"\r
+    p.bugTracker="https://bugs.maemo.org/enter_bug.cgi?product=nQa%20Audiobook%20Player"\r
+    p.postinstall="""#!/bin/sh\r
+rm -f ~/.nqaap/nqaap.log\r
+"""\r
+    #  p.postremove="""#!/bin/sh\r
+    #  chmod +x /usr/bin/mclock.py""" #Set here your post remove script\r
+    #  p.preinstall="""#!/bin/sh\r
+    #  chmod +x /usr/bin/mclock.py""" #Set here your pre install script\r
+    #  p.preremove="""#!/bin/sh\r
+    #  chmod +x /usr/bin/mclock.py""" #Set here your pre remove script\r
+    version = "0.8.6"           #Version of your software, e.g. "1.2.0" or "0.8.2"\r
+    build = "0" #Build number, e.g. "1" for the first build of this\r
+                                #version of your software. Increment\r
+                                #for later re-builds of the same\r
+                                #version of your software.  Text with\r
+                                #changelog information to be displayed\r
+                                #in the package "Details" tab of the\r
+                                #Maemo Application Manager\r
+    changeloginformation = """\r
+* About window as requested by magnuslu\r
+* Switched how storage of active book, chapter, and chapter position is stored\r
+""".strip()\r
+    dir_name = "src" #Name of the subfolder containing your package\r
+                                #source files\r
+                                #(e.g. usr\share\icons\hicolor\scalable\myappicon.svg,\r
+                                #usr\lib\myapp\somelib.py). We suggest\r
+                                #to leave it named src in all projects\r
+                                #and will refer to that in the wiki\r
+                                #article on maemo.org\r
+    #Thanks to DareTheHair from talk.maemo.org for this snippet that\r
+    #recursively builds the file list\r
+    for root, dirs, files in os.walk(dir_name):\r
+        if any(f.startswith(".") for f in root.split(os.sep)):\r
+            continue # avoid hidden folders, esp svn ones\r
+\r
+        real_dir = root[len(dir_name):]\r
+        fake_file = []\r
+        for f in files:\r
+            fake_file.append(root + os.sep + f + "|" + f)\r
+        if len(fake_file) > 0:\r
+            p[real_dir] = fake_file\r
+\r
+    print p\r
+    if distribution == "debian":\r
+        print p.generate(\r
+            version="%s-%s" % (version, build),\r
+            changelog=changeloginformation,\r
+            build=True,\r
+            tar=False,\r
+            changes=False,\r
+            dsc=False,\r
+        )\r
+    else:\r
+        print p.generate(\r
+            version="%s-%s" % (version, build),\r
+            changelog=changeloginformation,\r
+            build=False,\r
+            tar=True,\r
+            changes=True,\r
+            dsc=True,\r
+        )\r
+    print "Building for %s finished" % distribution\r
+\r
+\r
+if __name__ == "__main__":\r
+    if len(sys.argv) == 1:\r
+        distribution = "fremantle"\r
+    else:\r
+        distribution = sys.argv[1]\r
+    build_package(distribution)\r