3228eb30e8cf7eb2c23e2de235922f370fe6ca21
[gc-dialer] / support / builddeb.py
1 #!/usr/bin/python2.5
2
3 import os
4 import sys
5
6 try:
7         import py2deb
8 except ImportError:
9         import fake_py2deb as py2deb
10
11 import constants
12
13
14 __appname__ = constants.__app_name__
15 __description__ = """Touch screen enhanced interface to the GoogleVoice phone service"
16 Features:
17 .
18 * Dialpad for quick call
19 .
20 * Checking voicemails, texts, call history
21 .
22 * Sending texts
23 .
24 * Notification support for texts, voicemail, and/or missed calls
25 .
26 Homepage: http://gc-dialer.garage.maemo.org/
27 """
28 __author__ = "Ed Page"
29 __email__ = "eopage@byu.net"
30 __version__ = constants.__version__
31 __build__ = constants.__build__
32 __changelog__ = """
33 * First Qt Release (BETA)
34 * Access to call cancel
35 * Divider on contacts
36 * Condensed history
37 * Changed SMS Entry letter count style from GV to Nokia
38 * Tabs are cached between launches
39 """.strip()
40
41
42 __postinstall__ = """#!/bin/sh -e
43
44 gtk-update-icon-cache -f /usr/share/icons/hicolor
45 rm -f ~/.%(name)s/%(name)s.log
46 rm -f ~/.%(name)s/notifier.log
47 """ % {"name": constants.__app_name__}
48
49 __preremove__ = """#!/bin/sh -e
50
51 python /opt/dialcentral/lib/alarm_handler.py -d || true
52 """
53
54
55 def find_files(prefix, path):
56         for root, dirs, files in os.walk(path):
57                 for file in files:
58                         if file.startswith(prefix+"-"):
59                                 fileParts = file.split("-")
60                                 unused, relPathParts, newName = fileParts[0], fileParts[1:-1], fileParts[-1]
61                                 assert unused == prefix
62                                 relPath = os.sep.join(relPathParts)
63                                 yield relPath, file, newName
64
65
66 def unflatten_files(files):
67         d = {}
68         for relPath, oldName, newName in files:
69                 if relPath not in d:
70                         d[relPath] = []
71                 d[relPath].append((oldName, newName))
72         return d
73
74
75 def build_package(distribution):
76         try:
77                 os.chdir(os.path.dirname(sys.argv[0]))
78         except:
79                 pass
80
81         py2deb.Py2deb.SECTIONS = py2deb.SECTIONS_BY_POLICY[distribution]
82         p = py2deb.Py2deb(__appname__)
83         p.prettyName = constants.__pretty_app_name__
84         p.description = __description__
85         p.bugTracker = "https://bugs.maemo.org/enter_bug.cgi?product=Dialcentral"
86         p.author = __author__
87         p.mail = __email__
88         p.license = "lgpl"
89         p.depends = ", ".join([
90                 "python2.6 | python2.5",
91                 "python-gtk2 | python2.5-gtk2",
92                 "python-xml | python2.5-xml",
93                 "python-dbus | python2.5-dbus",
94         ])
95         maemoSpecificDepends = ", python-osso | python2.5-osso, python-hildon | python2.5-hildon"
96         p.depends += {
97                 "debian": ", python-glade2",
98                 "diablo": maemoSpecificDepends + ", python2.5-conic",
99                 "fremantle": maemoSpecificDepends + ", python-glade2, python-alarm",
100         }[distribution]
101         p.recommends = ", ".join([
102         ])
103         p.section = {
104                 "debian": "comm",
105                 "diablo": "user/network",
106                 "fremantle": "user/network",
107         }[distribution]
108         p.arch = "all"
109         p.urgency = "low"
110         p.distribution = "diablo fremantle debian"
111         p.repository = "extras"
112         p.changelog = __changelog__
113         p.postinstall = __postinstall__
114         p.preremove = __preremove__
115         p.icon = {
116                 "debian": "26x26-dialcentral.png",
117                 "diablo": "26x26-dialcentral.png",
118                 "fremantle": "64x64-dialcentral.png", # Fremantle natively uses 48x48
119         }[distribution]
120         p["/opt/%s/bin" % __appname__] = [ "%s.py" % __appname__ ]
121         for relPath, files in unflatten_files(find_files("src", ".")).iteritems():
122                 fullPath = "/opt/%s/lib" % __appname__
123                 if relPath:
124                         fullPath += os.sep+relPath
125                 p[fullPath] = list(
126                         "|".join((oldName, newName))
127                         for (oldName, newName) in files
128                 )
129         p["/usr/share/applications/hildon"] = ["dialcentral.desktop"]
130         p["/usr/share/icons/hicolor/26x26/hildon"] = ["26x26-dialcentral.png|dialcentral.png"]
131         p["/usr/share/icons/hicolor/64x64/hildon"] = ["64x64-dialcentral.png|dialcentral.png"]
132         p["/usr/share/icons/hicolor/scalable/hildon"] = ["scale-dialcentral.png|dialcentral.png"]
133
134         if distribution == "debian":
135                 print p
136                 print p.generate(
137                         version="%s-%s" % (__version__, __build__),
138                         changelog=__changelog__,
139                         build=True,
140                         tar=False,
141                         changes=False,
142                         dsc=False,
143                 )
144                 print "Building for %s finished" % distribution
145         else:
146                 print p
147                 print p.generate(
148                         version="%s-%s" % (__version__, __build__),
149                         changelog=__changelog__,
150                         build=False,
151                         tar=True,
152                         changes=True,
153                         dsc=True,
154                 )
155                 print "Building for %s finished" % distribution
156
157
158 if __name__ == "__main__":
159         if len(sys.argv) > 1:
160                 try:
161                         import optparse
162                 except ImportError:
163                         optparse = None
164
165                 if optparse is not None:
166                         parser = optparse.OptionParser()
167                         (commandOptions, commandArgs) = parser.parse_args()
168         else:
169                 commandArgs = None
170                 commandArgs = ["diablo"]
171         build_package(commandArgs[0])