3e93809ec4399a2eb1c813e51b35be0f9509a680
[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 various lists (for time ones, tried to balance heavy/light phone users)
36 * Condensed history
37 * Changed SMS Entry letter count style from GV to Nokia
38 * Tabs are cached between launches
39 * Display when history/messages tabs where last refreshed
40 """.strip()
41
42
43 __postinstall__ = """#!/bin/sh -e
44
45 gtk-update-icon-cache -f /usr/share/icons/hicolor
46 rm -f ~/.%(name)s/%(name)s.log
47 rm -f ~/.%(name)s/notifier.log
48 """ % {"name": constants.__app_name__}
49
50 __preremove__ = """#!/bin/sh -e
51
52 python /opt/dialcentral/lib/alarm_handler.py -d || true
53 """
54
55
56 def find_files(prefix, path):
57         for root, dirs, files in os.walk(path):
58                 for file in files:
59                         if file.startswith(prefix+"-"):
60                                 fileParts = file.split("-")
61                                 unused, relPathParts, newName = fileParts[0], fileParts[1:-1], fileParts[-1]
62                                 assert unused == prefix
63                                 relPath = os.sep.join(relPathParts)
64                                 yield relPath, file, newName
65
66
67 def unflatten_files(files):
68         d = {}
69         for relPath, oldName, newName in files:
70                 if relPath not in d:
71                         d[relPath] = []
72                 d[relPath].append((oldName, newName))
73         return d
74
75
76 def build_package(distribution):
77         try:
78                 os.chdir(os.path.dirname(sys.argv[0]))
79         except:
80                 pass
81
82         py2deb.Py2deb.SECTIONS = py2deb.SECTIONS_BY_POLICY[distribution]
83         p = py2deb.Py2deb(__appname__)
84         p.prettyName = constants.__pretty_app_name__
85         p.description = __description__
86         p.bugTracker = "https://bugs.maemo.org/enter_bug.cgi?product=Dialcentral"
87         p.author = __author__
88         p.mail = __email__
89         p.license = "lgpl"
90         p.depends = ", ".join([
91                 "python2.6 | python2.5",
92                 "python-simplejson",
93         ])
94         p.depends += {
95                 "debian": ", python-qt4",
96                 "diablo": ", python2.5-qt4-core, python2.5-qt4-gui",
97                 "fremantle": ", python2.5-qt4-core, python2.5-qt4-gui, python2.5-qt4-maemo5",
98         }[distribution]
99         p.recommends = ", ".join([
100         ])
101         p.section = {
102                 "debian": "comm",
103                 "diablo": "user/network",
104                 "fremantle": "user/network",
105         }[distribution]
106         p.arch = "all"
107         p.urgency = "low"
108         p.distribution = "diablo fremantle debian"
109         p.repository = "extras"
110         p.changelog = __changelog__
111         p.postinstall = __postinstall__
112         p.preremove = __preremove__
113         p.icon = {
114                 "debian": "26x26-dialcentral.png",
115                 "diablo": "26x26-dialcentral.png",
116                 "fremantle": "64x64-dialcentral.png", # Fremantle natively uses 48x48
117         }[distribution]
118         p["/opt/%s/bin" % __appname__] = [ "%s.py" % __appname__ ]
119         for relPath, files in unflatten_files(find_files("src", ".")).iteritems():
120                 fullPath = "/opt/%s/lib" % __appname__
121                 if relPath:
122                         fullPath += os.sep+relPath
123                 p[fullPath] = list(
124                         "|".join((oldName, newName))
125                         for (oldName, newName) in files
126                 )
127         for relPath, files in unflatten_files(find_files("data", ".")).iteritems():
128                 fullPath = "/opt/%s/share" % __appname__
129                 if relPath:
130                         fullPath += os.sep+relPath
131                 p[fullPath] = list(
132                         "|".join((oldName, newName))
133                         for (oldName, newName) in files
134                 )
135         p["/usr/share/applications/hildon"] = ["dialcentral.desktop"]
136         p["/usr/share/icons/hicolor/26x26/hildon"] = ["26x26-dialcentral.png|dialcentral.png"]
137         p["/usr/share/icons/hicolor/64x64/hildon"] = ["64x64-dialcentral.png|dialcentral.png"]
138         p["/usr/share/icons/hicolor/scalable/hildon"] = ["scale-dialcentral.png|dialcentral.png"]
139
140         if distribution == "debian":
141                 print p
142                 print p.generate(
143                         version="%s-%s" % (__version__, __build__),
144                         changelog=__changelog__,
145                         build=True,
146                         tar=False,
147                         changes=False,
148                         dsc=False,
149                 )
150                 print "Building for %s finished" % distribution
151         else:
152                 print p
153                 print p.generate(
154                         version="%s-%s" % (__version__, __build__),
155                         changelog=__changelog__,
156                         build=False,
157                         tar=True,
158                         changes=True,
159                         dsc=True,
160                 )
161                 print "Building for %s finished" % distribution
162
163
164 if __name__ == "__main__":
165         if len(sys.argv) > 1:
166                 try:
167                         import optparse
168                 except ImportError:
169                         optparse = None
170
171                 if optparse is not None:
172                         parser = optparse.OptionParser()
173                         (commandOptions, commandArgs) = parser.parse_args()
174         else:
175                 commandArgs = None
176                 commandArgs = ["diablo"]
177         build_package(commandArgs[0])