Removing chinook/mer support
[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 0.9.2
23 * Added search toggle to the menu
24 * Maemo 5: Added sorting to the app menu
25
26 0.9.1
27 * Added support for creating generic .deb files
28 * Added an apothecary unit
29 * Bug fix: Can directly enter numbers after selecting category
30 * Bug fix: font of the category button was inconsistent
31 * Bug fix: Improved up/down arrow keys
32
33 0.9.0
34 * Added Radioactivity and Radiation dose categories.
35 * Aligning the numbers by their decimal place
36 * Added shortcuts for fullscreen
37 * Switched to Find being brought up by CTRL+F
38 * Added Find Previous and Find Next shortcuts (CTRL+P, CTRL+N)
39 * Adjusted the sizing on various widgets
40 * Removed unused UI features for polish
41 * Bug fix: improved behavior when corner case values are inputted (like floats for base conversions)
42 * Debugging: Added logging support
43 * Marketting: Huge version bump to express a basic level of feature complete
44 * Internal: Massive cleanup of code
45
46 0.2.23  - Added UK currency category and other UK measurements thanks to Dale Hair
47 0.2.22  - Restore previously used window size
48 0.2.21  - Category column widened. Maximize on start.
49 0.2.20  - correction in micron pressure conversion
50 0.2.19  - viscosity cP conversion correction
51 0.2.18  - addition of magnitudes per square arcsecond to Luminance category
52 0.2.17  - updated baud definitions
53         - fixed homepath location because new debian version changed
54 0.2.16  - fixed icon locating for display in about
55         - added alternate icon gonvert-icon_alernative.png (copy over gonvert.png)
56 0.2.15  - updated mainloop to main as discovered by Alexander Skwar
57 0.2.14  - added Calgary energy and volume suggestions per Kim Lux
58 0.2.13  - new more easily understandable icon
59         - nanotesla definition (nT).
60         - added shortlist feature.
61 0.2.12  - removed inoperable books feature.
62         - fixed up acre accuracy.
63 0.2.11  - miodified descriprion for silver, newton, sadzhens.
64 0.2.10  - \x90 changed to \u00C9 for Emile and similar for Reaumur utf-8 text.
65         - Added translation for "All" book text.
66         - The write units text is translatable.
67         - The pl_messages.po file has been updated
68 0.2.09  - Added utf-8 coding to all text strings in preparation for complete language translation.
69 0.2.08  - Added language translation for menus and labels.
70 0.2.07  - Added language translation changes and messages.pot.
71 0.2.06  - Fixed category list size to show preselected categorys on startup,
72           scroll window H&Vpolicy set to always.
73 0.2.05  - Spelling of Luminance category fixed.
74 0.2.04  - Modified unit clicking to force focus on value entry.
75           Modified Makefile to remove /share/share bug for desktop entry.
76 0.2.03  - Modified Makefile to allow better integration on other platforms.
77 0.2.01  - Added saved selections feature, creates ~/.gonvert/ and file. 
78 0.1.11  - fixed packaging for RPM
79 0.1.10  - added Current Loop category for PLCs and 4-20mA instrumentation.
80 0.1.9   - added kilobit, and more density units.
81 0.1.8   - Added Torque units
82 0.1.7   - Added many more pressure units
83         - Added thermal categories
84         - Added fuel consumption category
85         - Program extension to .pyw so that Windows startup without console
86 0.1.6   - add more frequency units
87         - fixed computer number bases nums was bad near "h" and "v"
88         - fixed error:
89           "GtkTextBuffer.insert_at_cursor() takes exactly 1 argument (2 given)"
90           thanks to Riccardo Galli
91 0.1.5   - put packages into /usr instead of /usr/local
92         - add gnome menu item back in
93 0.1.4   - remove dependency on gnome-config from Makefile, RPM, binary.
94 0.1.3   - touched up computer numbers units for better sorting
95         - limited up resizing of windows to prevent dissapearing areas
96         - fixed find bug that some users might notice (TreeViewColumn/None)
97 0.1.2   - Added description box when writing units
98 0.1.1   - Added help/about box
99         - fixed bug that sets focus on line 2480
100         - fixed temperature difference units labels
101         - all scroll bars only show when needed
102         - Added RPM distribution
103 0.1.0   - Major modifications for GTK2 (RedHat 8.0)
104         - addition of units column in display
105         - sorting for all units columns with sort pointer
106 0.0.15  - added Electromagnetic Radiation category
107 0.0.14  - fixed window close bug, attempt to fix libglade XML startup bug for
108           some machines
109 0.0.13  - changes for python2.2, had to remove gnome dependencies
110 0.0.12  - change contact information address
111 0.0.11  - addition of ppm to "find" utility
112 0.0.10  - addition of petabyte to computer data
113 0.0.9   - addition of cesium atom vibrations to Time category
114 0.0.8   - more accurate calculation of degrees F
115 0.0.7   - added 'Find unit' feature
116         - changed Category list to clist for ease of moveto (focus) after find
117 0.0.6   - added description for Amperes
118         - added DENSITY category
119         - added 4 new categories 101 new units
120         - added shoe size converter
121         - add a function to convert custom formulas (like area from diameter)
122           example: area = pi * (D/2)^2
123           base value = pi* (x/2)^2  #metres in diameter metres, cm, inch, foot.
124 0.0.5   - Tool for listing all categories and units to STDOUT.
125         - re-organization of project files.
126         - addition of suffixes between duodecillion and centillion.
127         - addition of Makefile to install onto Gnome based systems.
128         - sort Units or Value columns (ascending or descending)
129           by clicking on column.
130 0.0.4   - Prefixes and Suffixes addition of;
131           ppm, %, Marx brothers, various descriptions.
132         - addition of microgram to mass category.
133         - replaced base 63 with 62 from computer numbers since
134           only 62 characters can be represented.
135         - fixed error if second line has nothing it wouldn't get
136           updated.
137 0.0.3   - fix bug in labelling of base 36 (was base 37)
138           all numbering systems past 23 were at fault due
139           to improper nums string (fixed).
140 0.0.2   - Completion of second row data entry so that changes
141           to text are not cyclicly causing changes to all
142           values.
143 0.0.1   - Initial release.
144 """
145
146
147 __postinstall__ = """#!/bin/sh -e
148
149 gtk-update-icon-cache -f /usr/share/icons/hicolor
150 rm -f ~/.gonvert/gonvert.log ~/.gonvert/selections.dat ~/.gonvert/window.dat
151 """
152
153 __preremove__ = """#!/bin/sh -e
154 """
155
156
157 def find_files(prefix, path):
158         for root, dirs, files in os.walk(path):
159                 for file in files:
160                         if file.startswith(prefix+"-"):
161                                 fileParts = file.split("-")
162                                 unused, relPathParts, newName = fileParts[0], fileParts[1:-1], fileParts[-1]
163                                 assert unused == prefix
164                                 relPath = os.sep.join(relPathParts)
165                                 yield relPath, file, newName
166
167
168 def unflatten_files(files):
169         d = {}
170         for relPath, oldName, newName in files:
171                 if relPath not in d:
172                         d[relPath] = []
173                 d[relPath].append((oldName, newName))
174         return d
175
176
177 def build_package(distribution):
178         try:
179                 os.chdir(os.path.dirname(sys.argv[0]))
180         except:
181                 pass
182
183         py2deb.Py2deb.SECTIONS = py2deb.SECTIONS_BY_POLICY[distribution]
184         p = py2deb.Py2deb(__appname__)
185         p.prettyName = constants.__pretty_app_name__
186         p.description = __description__
187         p.bugTracker = "https://bugs.maemo.org/enter_bug.cgi?product=Gonvert"
188         p.upgradeDescription = __changelog__.split("\n\n", 1)[0]
189         p.author = __author__
190         p.mail = __email__
191         p.license = "gpl"
192         p.depends = ", ".join([
193                 "python2.6 | python2.5",
194                 "python-gtk2 | python2.5-gtk2",
195                 "python-xml | python2.5-xml",
196                 "python-dbus | python2.5-dbus",
197         ])
198         maemoSpecificDepends = ", python-osso | python2.5-osso, python-hildon | python2.5-hildon"
199         p.depends += {
200                 "debian": ", python-glade2",
201                 "diablo": maemoSpecificDepends,
202                 "fremantle": maemoSpecificDepends + ", python-glade2",
203         }[distribution]
204         p.recommends = ", ".join([
205         ])
206         p.section = {
207                 "debian": "science",
208                 "diablo": "user/science",
209                 "fremantle": "user/science",
210         }[distribution]
211         p.arch = "all"
212         p.urgency = "low"
213         p.distribution = "diablo fremantle debian"
214         p.repository = "extras"
215         p.changelog = __changelog__
216         p.postinstall = __postinstall__
217         p.preremove = __preremove__
218         p.icon = {
219                 "debian": "data-pixmaps-gonvert.png",
220                 "diablo": "data-pixmaps-gonvert.png",
221                 "fremantle": "data-pixmaps-gonvert.png", # Fremantle natively uses 48x48
222         }[distribution]
223         p["/usr/bin"] = [ "gonvert.py" ]
224         for relPath, files in unflatten_files(find_files("src", ".")).iteritems():
225                 fullPath = "/usr/lib/gonvert"
226                 if relPath:
227                         fullPath += os.sep+relPath
228                 p[fullPath] = list(
229                         "|".join((oldName, newName))
230                         for (oldName, newName) in files
231                 )
232         for relPath, files in unflatten_files(find_files("data", ".")).iteritems():
233                 fullPath = "/usr/share/gonvert"
234                 if relPath:
235                         fullPath += os.sep+relPath
236                 p[fullPath] = list(
237                         "|".join((oldName, newName))
238                         for (oldName, newName) in files
239                 )
240         p["/usr/share/applications/hildon"] = ["gonvert.desktop"]
241         p["/usr/share/icons/hicolor/26x26/hildon"] = ["data-pixmaps-gonvert.png|gonvert.png"]
242         p["/usr/share/icons/hicolor/64x64/hildon"] = ["data-pixmaps-gonvert.png|gonvert.png"]
243         p["/usr/share/icons/hicolor/scalable/hildon"] = ["data-pixmaps-gonvert.png|gonvert.png"]
244
245         if distribution == "debian":
246                 print p
247                 print p.generate(
248                         version="%s-%s" % (__version__, __build__),
249                         changelog=__changelog__,
250                         build=True,
251                         tar=False,
252                         changes=False,
253                         dsc=False,
254                 )
255                 print "Building for %s finished" % distribution
256         else:
257                 print p
258                 print p.generate(
259                         version="%s-%s" % (__version__, __build__),
260                         changelog=__changelog__,
261                         build=False,
262                         tar=True,
263                         changes=True,
264                         dsc=True,
265                 )
266                 print "Building for %s finished" % distribution
267
268
269 if __name__ == "__main__":
270         if len(sys.argv) > 1:
271                 try:
272                         import optparse
273                 except ImportError:
274                         optparse = None
275
276                 if optparse is not None:
277                         parser = optparse.OptionParser()
278                         (commandOptions, commandArgs) = parser.parse_args()
279         else:
280                 commandArgs = None
281                 commandArgs = ["diablo"]
282         build_package(commandArgs[0])