Bumping to 1.3.0
[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 * In-application alert system for new messages
34 * Auto-update of voicemail on missed calls
35 * Ability to only refresh SMS or Voicemail for faster refreshes
36 * Ability to refresh only parts of call history for faster refreshes
37 * Voicemail audio download and playback
38 * Account refresh for when connection has expired
39 * Improved look of refresh buttons (Maemo 4.1)
40 * Improved rotation settings
41 * Auto-scroll SMS window for the user when on-screen-keyboard pops up (Maemo 4.1)
42 * Added support for QtMobility Contacts (Note: there seems to be a bug in libraries I depend on when run as root)
43 * Improving the settings dialog
44 * Fixing message ordering
45 * Limited log size due to longer release cycles
46 * Some minor optimizations
47 * Reduced network timeout, connections while transition networks wouldn't immediately die but timeout which took too long
48 * Fixed text encoding issue for CSV contacts
49 """.strip()
50
51
52 __postinstall__ = """#!/bin/sh -e
53
54 gtk-update-icon-cache -f /usr/share/icons/hicolor
55 """ % {"name": constants.__app_name__}
56
57 __preremove__ = """#!/bin/sh -e
58
59 python /opt/dialcentral/lib/alarm_handler.py -d || true
60 """
61
62
63 def find_files(prefix, path):
64         for root, dirs, files in os.walk(path):
65                 for file in files:
66                         if file.startswith(prefix+"-"):
67                                 fileParts = file.split("-")
68                                 unused, relPathParts, newName = fileParts[0], fileParts[1:-1], fileParts[-1]
69                                 assert unused == prefix
70                                 relPath = os.sep.join(relPathParts)
71                                 yield relPath, file, newName
72
73
74 def unflatten_files(files):
75         d = {}
76         for relPath, oldName, newName in files:
77                 if relPath not in d:
78                         d[relPath] = []
79                 d[relPath].append((oldName, newName))
80         return d
81
82
83 def build_package(distribution):
84         try:
85                 os.chdir(os.path.dirname(sys.argv[0]))
86         except:
87                 pass
88
89         py2deb.Py2deb.SECTIONS = py2deb.SECTIONS_BY_POLICY[distribution]
90         p = py2deb.Py2deb(__appname__)
91         p.prettyName = constants.__pretty_app_name__
92         p.description = __description__
93         p.bugTracker = "https://bugs.maemo.org/enter_bug.cgi?product=Dialcentral"
94         p.author = __author__
95         p.mail = __email__
96         p.license = "lgpl"
97         p.depends = ", ".join([
98                 "python2.6 | python2.5",
99                 "python-xml | python2.5-xml",
100                 "python-dbus | python2.5-dbus",
101                 "python-simplejson",
102         ])
103         p.depends += {
104                 "debian": ", python-qt4",
105                 "diablo": ", python2.5-qt4-core, python2.5-qt4-gui",
106                 "fremantle": ", python-pyside.qtgui, python-pyside.qtcore, python-pyside.qtmaemo5, python-qtmobility.contacts",
107         }[distribution]
108         p.recommends = ", ".join([
109         ])
110         p.section = {
111                 "debian": "comm",
112                 "diablo": "user/network",
113                 "fremantle": "user/network",
114         }[distribution]
115         p.arch = "all"
116         p.urgency = "low"
117         p.distribution = "diablo fremantle debian"
118         p.repository = "extras"
119         p.changelog = __changelog__
120         p.postinstall = __postinstall__
121         p.preremove = __preremove__
122         p.icon = {
123                 "debian": "26x26-dialcentral.png",
124                 "diablo": "26x26-dialcentral.png",
125                 "fremantle": "64x64-dialcentral.png", # Fremantle natively uses 48x48
126         }[distribution]
127         p["/opt/%s/bin" % __appname__] = [ "%s.py" % __appname__ ]
128         for relPath, files in unflatten_files(find_files("src", ".")).iteritems():
129                 fullPath = "/opt/%s/lib" % __appname__
130                 if relPath:
131                         fullPath += os.sep+relPath
132                 p[fullPath] = list(
133                         "|".join((oldName, newName))
134                         for (oldName, newName) in files
135                 )
136         for relPath, files in unflatten_files(find_files("data", ".")).iteritems():
137                 fullPath = "/opt/%s/share" % __appname__
138                 if relPath:
139                         fullPath += os.sep+relPath
140                 p[fullPath] = list(
141                         "|".join((oldName, newName))
142                         for (oldName, newName) in files
143                 )
144         p["/usr/share/applications/hildon"] = ["dialcentral.desktop"]
145         p["/usr/share/icons/hicolor/26x26/hildon"] = ["26x26-dialcentral.png|dialcentral.png"]
146         p["/usr/share/icons/hicolor/64x64/hildon"] = ["64x64-dialcentral.png|dialcentral.png"]
147         p["/usr/share/icons/hicolor/scalable/hildon"] = ["scale-dialcentral.png|dialcentral.png"]
148
149         print p
150         if distribution == "debian":
151                 print p.generate(
152                         version="%s-%s" % (__version__, __build__),
153                         changelog=__changelog__,
154                         build=True,
155                         tar=False,
156                         changes=False,
157                         dsc=False,
158                 )
159         else:
160                 print p.generate(
161                         version="%s-%s" % (__version__, __build__),
162                         changelog=__changelog__,
163                         build=False,
164                         tar=True,
165                         changes=True,
166                         dsc=True,
167                 )
168         print "Building for %s finished" % distribution
169
170
171 if __name__ == "__main__":
172         if len(sys.argv) == 1:
173                 distribution = "fremantle"
174         else:
175                 distribution = sys.argv[1]
176         build_package(distribution)