6eb481c69c0e9e8470a2247618e4b215f55acb20
[nqaap] / support / build_nqaap.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     print\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://nqaap.garage.maemo.org/"""\r
37     p.author="Soeren 'Pengman' Pedersen"\r
38     p.mail="pengmeister@gmail.com"\r
39     p.depends = ", ".join([\r
40         "python2.6 | python2.5",\r
41         "python-gtk2 | python2.5-gtk2",\r
42         "python-dbus | python2.5-dbus",\r
43         "python-telepathy | python2.5-telepathy",\r
44         "python-gobject | python2.5-gobject",\r
45     ])\r
46     maemoSpecificDepends = ", python-osso | python2.5-osso, python-hildon | python2.5-hildon"\r
47     p.depends += {\r
48         "debian": ", python-gst0.10",\r
49         "diablo": maemoSpecificDepends,\r
50         "fremantle": maemoSpecificDepends+", python-gst0.10",\r
51     }[distribution]\r
52     p.section = {\r
53         "debian": "sound",\r
54         "diablo": "user/multimedia",\r
55         "fremantle": "user/multimedia",\r
56     }[distribution]\r
57     p.icon = "src/usr/share/icons/hicolor/48x48/hildon/nqaap.png"\r
58     p.arch="all"                #should be all for python, any for all arch\r
59     p.urgency="low"             #not used in maemo onl for deb os\r
60     p.distribution=distribution\r
61     p.repository="extras"\r
62     p.bugTracker="http://talk.maemo.org/showthread.php?p=619738"\r
63     p.postinstall="""#!/bin/sh\r
64 rm -f ~/.nqaap/nqaap.log\r
65 """\r
66     #  p.postremove="""#!/bin/sh\r
67     #  chmod +x /usr/bin/mclock.py""" #Set here your post remove script\r
68     #  p.preinstall="""#!/bin/sh\r
69     #  chmod +x /usr/bin/mclock.py""" #Set here your pre install script\r
70     #  p.preremove="""#!/bin/sh\r
71     #  chmod +x /usr/bin/mclock.py""" #Set here your pre remove script\r
72     version = "0.8.0"           #Version of your software, e.g. "1.2.0" or "0.8.2"\r
73     build = "3" #Build number, e.g. "1" for the first build of this\r
74                                 #version of your software. Increment\r
75                                 #for later re-builds of the same\r
76                                 #version of your software.  Text with\r
77                                 #changelog information to be displayed\r
78                                 #in the package "Details" tab of the\r
79                                 #Maemo Application Manager\r
80     changeloginformation = "Merged changes from EPage (proper changelog later)\nNew Icon by Strutten."\r
81     # 0.7.2 : Seek bar now responds to clicks (rather than drags)\nFixed bug with wrong text showing on button after changed chapter.\r
82     # 0.7.1 : Fixed crash when current points to non existing book\r
83     # 0.7.0 : Now ignores pressed outside the chapter selection menu\nAdded help\r
84     # 0.6.1 : Fixed bug that prevented running on devices without Audiobook folder.\r
85     #         Added tip on where to place audiobooks.\r
86     # 0.6.0 : Now also plays .mp3 files\r
87     # 0.5.0 : Second release. Now shows which chapter is playing, and scrolls to it when changing.\r
88     # 0.4.9 : First release. Now it should work\r
89     #  \r
90     dir_name = "src" #Name of the subfolder containing your package\r
91                                 #source files\r
92                                 #(e.g. usr\share\icons\hicolor\scalable\myappicon.svg,\r
93                                 #usr\lib\myapp\somelib.py). We suggest\r
94                                 #to leave it named src in all projects\r
95                                 #and will refer to that in the wiki\r
96                                 #article on maemo.org\r
97     #Thanks to DareTheHair from talk.maemo.org for this snippet that\r
98     #recursively builds the file list\r
99     for root, dirs, files in os.walk(dir_name):\r
100         real_dir = root[len(dir_name):]\r
101         if '.' in real_dir:\r
102             continue # if some part of the dirname contains '.' we\r
103                                         # ignore all files (avoid .svn\r
104                                         # and others)\r
105         fake_file = []\r
106         for f in files:\r
107             fake_file.append(root + os.sep + f + "|" + f)\r
108         if len(fake_file) > 0:\r
109             p[real_dir] = fake_file\r
110 \r
111     print p\r
112     if distribution == "debian":\r
113         print p.generate(\r
114             version="%s-%s" % (version, build),\r
115             changelog=changeloginformation,\r
116             build=True,\r
117             tar=False,\r
118             changes=False,\r
119             dsc=False,\r
120         )\r
121     else:\r
122         print p.generate(\r
123             version="%s-%s" % (version, build),\r
124             changelog=changeloginformation,\r
125             build=False,\r
126             tar=True,\r
127             changes=True,\r
128             dsc=True,\r
129         )\r
130     print "Building for %s finished" % distribution\r
131 \r
132 \r
133 if __name__ == "__main__":\r
134     if len(sys.argv) == 1:\r
135         distribution = "fremantle"\r
136     else:\r
137         distribution = sys.argv[1]\r
138     build_package(distribution)\r