Prepping for the Maemo 5 Beta
[theonering] / 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__ = """Send/receive texts and initiate GV callbacks all through Conversations and Phone
16 Features:
17 .
18 * Send Texts and Receive both Texts and Voicemail through your chat window (buggy on Maemo 4.1)
19 .
20 * Initiate Google Voice callbacks from the dialpad or your contacts
21 .
22 * Access to all of your Google Voice contacts (Maemo 4.1 only for now)
23 .
24 * Reduce battery drain by setting your status to "Away"
25 .
26 * Block incoming calls by switching your status to "Hidden"
27 .
28 Note: Google and Google Voice are probably trademarks of Google.  This software nor the author has any affiliation with Google
29 .
30 Homepage: http://theonering.garage.maemo.org
31 """
32 __author__ = "Ed Page"
33 __email__ = "eopage@byu.net"
34 __version__ = constants.__version__
35 __build__ = constants.__build__
36 __changelog__ = """
37 0.7.0
38 * Initial beta release for Maemo 5
39 * Late Alpha for Maemo 4.1 with horrible consequences like crashing RTComm
40
41 0.1.0
42 * Pre-Alpha Development Release
43 """
44
45
46 __postinstall__ = """#!/bin/sh -e
47
48 gtk-update-icon-cache -f /usr/share/icons/hicolor
49 rm -f ~/.telepathy-theonering/theonering.log
50 """
51
52 def find_files(path):
53         for root, dirs, files in os.walk(path):
54                 for file in files:
55                         if file.startswith("src!"):
56                                 fileParts = file.split("!")
57                                 unused, relPathParts, newName = fileParts[0], fileParts[1:-1], fileParts[-1]
58                                 assert unused == "src"
59                                 relPath = os.sep.join(relPathParts)
60                                 yield relPath, file, newName
61
62
63 def unflatten_files(files):
64         d = {}
65         for relPath, oldName, newName in files:
66                 if relPath not in d:
67                         d[relPath] = []
68                 d[relPath].append((oldName, newName))
69         return d
70
71
72 def build_package(distribution):
73         try:
74                 os.chdir(os.path.dirname(sys.argv[0]))
75         except:
76                 pass
77
78         py2deb.Py2deb.SECTIONS = py2deb.SECTIONS_BY_POLICY[distribution]
79         p = py2deb.Py2deb(__appname__)
80         if distribution == "debian":
81                 p.prettyName = constants.__pretty_app_name__
82         else:
83                 p.prettyName = "Google Voice plugin for Conversations and Calls"
84         p.description = __description__
85         p.bugTracker = "https://bugs.maemo.org/enter_bug.cgi?product=theonering"
86         #p.upgradeDescription = __changelog__.split("\n\n", 1)[0]
87         p.author = __author__
88         p.mail = __email__
89         p.license = "lgpl"
90         p.section = {
91                 "debian": "comm",
92                 "diablo": "user/network",
93                 "fremantle": "user/network",
94                 "mer": "user/network",
95         }[distribution]
96         p.depends = ", ".join([
97                 "python (>= 2.5) | python2.5",
98                 "python-dbus | python2.5-dbus",
99                 "python-gobject | python2.5-gobject",
100                 "python-telepathy | python2.5-telepathy",
101         ])
102         p.depends += {
103                 "debian": "",
104                 "chinook": "",
105                 "diablo": ", python2.5-conic, account-plugin-haze",
106                 "fremantle": ", account-plugin-haze",
107                 "mer": "",
108         }[distribution]
109         p.arch = "all"
110         p.urgency = "low"
111         p.distribution = "diablo fremantle mer debian"
112         p.repository = "extras"
113         p.changelog = __changelog__
114         p.postinstall = __postinstall__
115         p.icon = {
116                 "debian": "26x26-theonering.png",
117                 "diablo": "26x26-theonering.png",
118                 "fremantle": "64x64-theonering.png", # Fremantle natively uses 48x48
119                 "mer": "64x64-theonering.png",
120         }[distribution]
121         for relPath, files in unflatten_files(find_files(".")).iteritems():
122                 fullPath = "/usr/lib/theonering"
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/dbus-1/services"] = ["org.freedesktop.Telepathy.ConnectionManager.theonering.service"]
130         if distribution in ("debian", ):
131                 p["/usr/share/mission-control/profiles"] = ["theonering.profile.%s|theonering.profile"% distribution]
132         elif distribution in ("diablo", "fremantle", "mer"):
133                 p["/usr/share/osso-rtcom"] = ["theonering.profile.%s|theonering.profile"% distribution]
134         p["/usr/lib/telepathy"] = ["telepathy-theonering"]
135         p["/usr/share/telepathy/managers"] = ["theonering.manager"]
136         p["/usr/share/icons/hicolor/26x26/hildon"] = ["26x26-theonering.png|im-theonering.png"]
137
138         if distribution == "debian":
139                 print p
140                 print p.generate(
141                         version="%s-%s" % (__version__, __build__),
142                         changelog=__changelog__,
143                         build=True,
144                         tar=False,
145                         changes=False,
146                         dsc=False,
147                 )
148                 print "Building for %s finished" % distribution
149         else:
150                 print p
151                 print p.generate(
152                         version="%s-%s" % (__version__, __build__),
153                         changelog=__changelog__,
154                         build=False,
155                         tar=True,
156                         changes=True,
157                         dsc=True,
158                 )
159                 print "Building for %s finished" % distribution
160
161
162 if __name__ == "__main__":
163         if len(sys.argv) > 1:
164                 try:
165                         import optparse
166                 except ImportError:
167                         optparse = None
168
169                 if optparse is not None:
170                         parser = optparse.OptionParser()
171                         (commandOptions, commandArgs) = parser.parse_args()
172         else:
173                 commandArgs = None
174                 commandArgs = ["diablo"]
175         build_package(commandArgs[0])