Merging skeleton changes
[gonvert] / support / builddeb.py
1 #!/usr/bin/python2.5
2
3 import os
4 import sys
5
6 import py2deb
7
8 import constants
9
10
11 __appname__ = constants.__app_name__
12 __description__ = """Unit Conversions
13 A conversion utility that allows conversion between many units like CGS, Ancient, Imperial with many categories like length, mass, numbers, etc. All units converted values shown at once as you type
14 .
15 Homepage: http://www.unihedron.com/projects/gonvert/index.php
16 """
17 __author__ = "Anthony Tekatch"
18 __email__ = "anthony@unihedron.com"
19 __version__ = constants.__version__
20 __build__ = constants.__build__
21 __changelog__ = """
22 * A condensed view of unit conversion for those who so chose
23 * Changed the way windows handle closing
24 * Improved performance of jumping between some of the windows (including startup)
25 * Persisting the sort preference
26 """
27
28
29 __postinstall__ = """#!/bin/sh -e
30
31 gtk-update-icon-cache -f /usr/share/icons/hicolor
32 rm -f ~/.gonvert/gonvert.log ~/.gonvert/selections.dat ~/.gonvert/window.dat
33 """
34
35 __preremove__ = """#!/bin/sh -e
36 """
37
38
39 def find_files(prefix, path):
40         for root, dirs, files in os.walk(path):
41                 for file in files:
42                         if file.startswith(prefix+"-"):
43                                 fileParts = file.split("-")
44                                 unused, relPathParts, newName = fileParts[0], fileParts[1:-1], fileParts[-1]
45                                 assert unused == prefix
46                                 relPath = os.sep.join(relPathParts)
47                                 yield relPath, file, newName
48
49
50 def unflatten_files(files):
51         d = {}
52         for relPath, oldName, newName in files:
53                 if relPath not in d:
54                         d[relPath] = []
55                 d[relPath].append((oldName, newName))
56         return d
57
58
59 def build_package(distribution):
60         try:
61                 os.chdir(os.path.dirname(sys.argv[0]))
62         except:
63                 pass
64
65         py2deb.Py2deb.SECTIONS = py2deb.SECTIONS_BY_POLICY[distribution]
66         p = py2deb.Py2deb(__appname__)
67         p.prettyName = constants.__pretty_app_name__
68         p.description = __description__
69 <<<<<<< HEAD
70         p.bugTracker = "https://bugs.maemo.org/enter_bug.cgi?product=Gonvert"
71 =======
72         p.bugTracker = "REPLACEME"
73 >>>>>>> 6e3215856a887adc778853fcacf0dfcee13701bc
74         p.author = __author__
75         p.mail = __email__
76         p.license = "gpl"
77         p.depends = ", ".join([
78                 "python2.6 | python2.5",
79                 "python-simplejson",
80         ])
81         p.depends += {
82                 "debian": ", python-qt4",
83                 "diablo": ", python2.5-qt4-core, python2.5-qt4-gui",
84                 "fremantle": ", python2.5-qt4-core, python2.5-qt4-gui, python2.5-qt4-maemo5",
85         }[distribution]
86         p.recommends = ", ".join([
87         ])
88         p.section = {
89                 "debian": "science",
90                 "diablo": "user/science",
91                 "fremantle": "user/science",
92         }[distribution]
93         p.arch = "all"
94         p.urgency = "low"
95         p.distribution = "diablo fremantle debian"
96         p.repository = "extras"
97         p.changelog = __changelog__
98         p.postinstall = __postinstall__
99         p.preremove = __preremove__
100         p.icon = {
101                 "debian": "data-pixmaps-gonvert.png",
102                 "diablo": "data-pixmaps-gonvert.png",
103                 "fremantle": "data-pixmaps-gonvert.png", # Fremantle natively uses 48x48
104         }[distribution]
105 <<<<<<< HEAD
106         p["/opt/gonvert/bin"] = [ "gonvert.py" ]
107         for relPath, files in unflatten_files(find_files("src", ".")).iteritems():
108                 fullPath = "/opt/gonvert/lib"
109                 if relPath:
110                         fullPath += os.sep+relPath
111                 p[fullPath] = list(
112                         "|".join((oldName, newName))
113                         for (oldName, newName) in files
114                 )
115         for relPath, files in unflatten_files(find_files("data", ".")).iteritems():
116                 fullPath = "/opt/gonvert/share"
117 =======
118         p["/opt/REPLACEME/bin"] = [ "REPLACEME" ]
119         for relPath, files in unflatten_files(find_files("src", ".")).iteritems():
120                 fullPath = "/opt/REPLACEME/lib"
121 >>>>>>> 6e3215856a887adc778853fcacf0dfcee13701bc
122                 if relPath:
123                         fullPath += os.sep+relPath
124                 p[fullPath] = list(
125                         "|".join((oldName, newName))
126                         for (oldName, newName) in files
127                 )
128         p["/usr/share/applications/hildon"] = ["gonvert.desktop"]
129         p["/usr/share/icons/hicolor/26x26/hildon"] = ["data-pixmaps-gonvert.png|gonvert.png"]
130         p["/usr/share/icons/hicolor/64x64/hildon"] = ["data-pixmaps-gonvert.png|gonvert.png"]
131         p["/usr/share/icons/hicolor/scalable/hildon"] = ["data-pixmaps-gonvert.png|gonvert.png"]
132
133         if distribution == "debian":
134                 print p
135                 print p.generate(
136                         version="%s-%s" % (__version__, __build__),
137                         changelog=__changelog__,
138                         build=True,
139                         tar=False,
140                         changes=False,
141                         dsc=False,
142                 )
143                 print "Building for %s finished" % distribution
144         else:
145                 print p
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                 try:
160                         import optparse
161                 except ImportError:
162                         optparse = None
163
164                 if optparse is not None:
165                         parser = optparse.OptionParser()
166                         (commandOptions, commandArgs) = parser.parse_args()
167         else:
168                 commandArgs = None
169                 commandArgs = ["diablo"]
170         build_package(commandArgs[0])