Changing whitespace and fixing a bug with reconfiguring
[nqaap] / support / builddeb.py
1 #!/usr/bin/env python\r
2 # -*- coding: utf-8 -*-\r
3 \r
4 """\r
5 This program is free software; you can redistribute it and/or modify\r
6 it under the terms of the GNU General Public License as published\r
7 by the Free Software Foundation; version 2 only.\r
8 \r
9 This program is distributed in the hope that it will be useful,\r
10 but WITHOUT ANY WARRANTY; without even the implied warranty of\r
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
12 GNU General Public License for more details.\r
13 """\r
14 \r
15 import os\r
16 import sys\r
17 \r
18 import py2deb\r
19 \r
20 \r
21 def build_package(distribution):\r
22         py2deb.Py2deb.SECTIONS = py2deb.SECTIONS_BY_POLICY[distribution]\r
23         try:\r
24                 os.chdir(os.path.dirname(sys.argv[0]))\r
25         except:\r
26                 pass\r
27 \r
28         p=py2deb.Py2deb("nqaap") #This is the package name and MUST be in\r
29                                                            #lowercase! (using e.g. "mClock" fails\r
30                                                            #miserably...)\r
31         p.prettyName="NQA Audiobook Player"\r
32         p.description="""Very simple Audiobook player.\r
33 Supports playing, pausing, seeking (sort of) and saving state when changing book/closing.\r
34 Plays books arranged as dirs under myDocs/Audiobooks\r
35 .\r
36 Homepage: http://wiki.maemo.org/Nqaap"""\r
37         p.author="Soeren 'Pengman' Pedersen"\r
38         p.mail="pengmeister@gmail.com"\r
39         p.license = "lgpl"\r
40         p.depends = ", ".join([\r
41                 "python2.6 | python2.5",\r
42                 "python-gtk2 | python2.5-gtk2",\r
43                 "python-dbus | python2.5-dbus",\r
44                 "python-telepathy | python2.5-telepathy",\r
45                 "python-gobject | python2.5-gobject",\r
46                 "python-simplejson",\r
47         ])\r
48         maemoSpecificDepends = ", python-osso | python2.5-osso, python-hildon | python2.5-hildon"\r
49         p.depends += {\r
50                 "debian": ", python-gst0.10",\r
51                 "diablo": maemoSpecificDepends,\r
52                 "fremantle": maemoSpecificDepends + ", python-gst0.10",\r
53         }[distribution]\r
54         p.section = {\r
55                 "debian": "sound",\r
56                 "diablo": "user/multimedia",\r
57                 "fremantle": "user/multimedia",\r
58         }[distribution]\r
59         p.icon = "src/usr/share/icons/hicolor/48x48/hildon/nqaap.png"\r
60         p.arch="all"                            #should be all for python, any for all arch\r
61         p.urgency="low"                  #not used in maemo onl for deb os\r
62         p.distribution=distribution\r
63         p.repository="extras"\r
64         p.bugTracker="https://bugs.maemo.org/enter_bug.cgi?product=nQa%%20Audiobook%%20Player"\r
65         p.postinstall="""#!/bin/sh\r
66 rm -f ~/.nqaap/nqaap.log\r
67 """\r
68         #  p.postremove="""#!/bin/sh\r
69         #  chmod +x /usr/bin/mclock.py""" #Set here your post remove script\r
70         #  p.preinstall="""#!/bin/sh\r
71         #  chmod +x /usr/bin/mclock.py""" #Set here your pre install script\r
72         #  p.preremove="""#!/bin/sh\r
73         #  chmod +x /usr/bin/mclock.py""" #Set here your pre remove script\r
74         version = "0.8.6"                  #Version of your software, e.g. "1.2.0" or "0.8.2"\r
75         build = "0" #Build number, e.g. "1" for the first build of this\r
76                                                                 #version of your software. Increment\r
77                                                                 #for later re-builds of the same\r
78                                                                 #version of your software.  Text with\r
79                                                                 #changelog information to be displayed\r
80                                                                 #in the package "Details" tab of the\r
81                                                                 #Maemo Application Manager\r
82         changeloginformation = """\r
83 * About window as requested by magnuslu\r
84 * Switched how storage of active book, chapter, and chapter position is stored\r
85 """.strip()\r
86         dir_name = "src" #Name of the subfolder containing your package\r
87                                                                 #source files\r
88                                                                 #(e.g. usr\share\icons\hicolor\scalable\myappicon.svg,\r
89                                                                 #usr\lib\myapp\somelib.py). We suggest\r
90                                                                 #to leave it named src in all projects\r
91                                                                 #and will refer to that in the wiki\r
92                                                                 #article on maemo.org\r
93         #Thanks to DareTheHair from talk.maemo.org for this snippet that\r
94         #recursively builds the file list\r
95         for root, dirs, files in os.walk(dir_name):\r
96                 if any(f.startswith(".") for f in root.split(os.sep)):\r
97                         continue # avoid hidden folders, esp svn ones\r
98 \r
99                 real_dir = root[len(dir_name):]\r
100                 fake_file = []\r
101                 for f in files:\r
102                         fake_file.append(root + os.sep + f + "|" + f)\r
103                 if len(fake_file) > 0:\r
104                         p[real_dir] = fake_file\r
105 \r
106         print p\r
107         if distribution == "debian":\r
108                 print p.generate(\r
109                         version="%s-%s" % (version, build),\r
110                         changelog=changeloginformation,\r
111                         build=True,\r
112                         tar=False,\r
113                         changes=False,\r
114                         dsc=False,\r
115                 )\r
116         else:\r
117                 print p.generate(\r
118                         version="%s-%s" % (version, build),\r
119                         changelog=changeloginformation,\r
120                         build=False,\r
121                         tar=True,\r
122                         changes=True,\r
123                         dsc=True,\r
124                 )\r
125         print "Building for %s finished" % distribution\r
126 \r
127 \r
128 if __name__ == "__main__":\r
129         if len(sys.argv) == 1:\r
130                 distribution = "fremantle"\r
131         else:\r
132                 distribution = sys.argv[1]\r
133         build_package(distribution)\r