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