Added upgrade scription now that we are in extras
[quicknote] / 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__ = """Simple note taking application in a similar vein as PalmOS Memos
16 .
17 Homepage: http://quicknote.garage.maemo.org/
18 """
19 __author__ = "Christoph Wurstle"
20 __email__ = "n800@axique.net"
21 __version__ = constants.__version__
22 __build__ = constants.__build__
23 __changelog__ = """
24 0.7.10
25  * Moved history to the menu/appmenu
26  * Switched category selection over to a touch selector entry, making it prettier and easier
27  * Ctrl+w/q to quit
28
29 0.7.9
30  * UI Tweak: Removed "New Note..." due to weirdness and duplicated behavior
31  * UI Tweak: Added App Menu to access some category functionality
32  * Bugfix: Move To Category
33  * Bugfix: Removed carriage return on Ctrl+Enter
34  * Added .deb package support
35
36 0.7.8
37  * Spell checking
38  * Fixing the application title
39  * Fremantle Support
40  * Ctrl+i and Ctrl+o to zoom in/out the interface
41  * Ctrl+enter to fullscreen app
42  * Ctrl+l to copy to clipboard the application debug log
43
44 0.7.7
45  * Slight modifications to the note history and SQL dialogs
46  * On zoom, also hiding the history status and button
47  * Touched up the note list, making it ellipsize at the end rather than scroll
48  * Storing of zoom, wordwrap, and fullscreen settings
49
50 0.7.6
51   * Line-wrap
52   * Zoom
53
54 0.7.4
55   * fixed small bugs
56   * move category
57
58 0.7.3
59   * fixed small bugs
60   * move category
61
62 0.7.2
63   * improved sync, fixed a small bug
64
65 0.7.1
66   * improved sync
67
68 0.7.0
69   * Initial Release.
70 """
71
72
73 __postinstall__ = """#!/bin/sh -e
74
75 gtk-update-icon-cache -f /usr/share/icons/hicolor
76 rm -f ~/.quicknote/quicknote.log
77 """
78
79
80 def find_files(path, root):
81         print path, root
82         for unusedRoot, dirs, files in os.walk(path):
83                 for file in files:
84                         if file.startswith(root+"-"):
85                                 print "\t", root, file
86                                 fileParts = file.split("-")
87                                 unused, relPathParts, newName = fileParts[0], fileParts[1:-1], fileParts[-1]
88                                 assert unused == root
89                                 relPath = os.sep.join(relPathParts)
90                                 yield relPath, file, newName
91
92
93 def unflatten_files(files):
94         d = {}
95         for relPath, oldName, newName in files:
96                 if relPath not in d:
97                         d[relPath] = []
98                 d[relPath].append((oldName, newName))
99         return d
100
101
102 def build_package(distribution):
103         try:
104                 os.chdir(os.path.dirname(sys.argv[0]))
105         except:
106                 pass
107
108         py2deb.Py2deb.SECTIONS = py2deb.SECTIONS_BY_POLICY[distribution]
109         p = py2deb.Py2deb(__appname__)
110         p.prettyName = constants.__pretty_app_name__
111         p.description = __description__
112         p.bugTracker = "https://bugs.maemo.org/enter_bug.cgi?product=quicknote"
113         p.upgradeDescription = __changelog__.split("\n\n", 1)[0]
114         p.author = __author__
115         p.mail = __email__
116         p.license = "gpl"
117         p.depends = ", ".join([
118                 "python2.6 | python2.5",
119                 "python-gtk2 | python2.5-gtk2",
120                 "python-xml | python2.5-xml",
121         ])
122         maemoSpecificDepends = ", python-osso | python2.5-osso, python-hildon | python2.5-hildon"
123         p.depends += {
124                 "debian": ", python-glade2",
125                 "chinook": maemoSpecificDepends,
126                 "diablo": maemoSpecificDepends,
127                 "fremantle": maemoSpecificDepends + ", python-glade2",
128                 "mer": maemoSpecificDepends + ", python-glade2",
129         }[distribution]
130         p.section = {
131                 "debian": "editors",
132                 "chinook": "accessories",
133                 "diablo": "user/office",
134                 "fremantle": "user/office",
135                 "mer": "user/office",
136         }[distribution]
137         p.arch = "all"
138         p.urgency = "low"
139         p.distribution = "chinook diablo fremantle mer debian"
140         p.repository = "extras"
141         p.changelog = __changelog__
142         p.postinstall = __postinstall__
143         p.icon = {
144                 "debian": "26x26-quicknote.png",
145                 "chinook": "26x26-quicknote.png",
146                 "diablo": "26x26-quicknote.png",
147                 "fremantle": "48x48-quicknote.png", # Fremantle natively uses 48x48
148                 "mer": "48x48-quicknote.png",
149         }[distribution]
150         p["/usr/bin"] = [ "quicknote.py" ]
151         for relPath, files in unflatten_files(find_files(".", "locale")).iteritems():
152                 fullPath = "/usr/share/locale"
153                 if relPath:
154                         fullPath += os.sep+relPath
155                 p[fullPath] = list(
156                         "|".join((oldName, newName))
157                         for (oldName, newName) in files
158                 )
159         for relPath, files in unflatten_files(find_files(".", "src")).iteritems():
160                 fullPath = "/usr/lib/quicknote"
161                 if relPath:
162                         fullPath += os.sep+relPath
163                 p[fullPath] = list(
164                         "|".join((oldName, newName))
165                         for (oldName, newName) in files
166                 )
167         p["/usr/share/applications/hildon"] = ["quicknote.desktop"]
168         p["/usr/share/icons/hicolor/26x26/hildon"] = ["26x26-quicknote.png|quicknote.png"]
169         p["/usr/share/icons/hicolor/40x40/hildon"] = ["40x40-quicknote.png|quicknote.png"]
170         p["/usr/share/icons/hicolor/48x48/hildon"] = ["48x48-quicknote.png|quicknote.png"]
171         p["/usr/share/icons/hicolor/scalable/hildon"] = ["scale-quicknote.png|quicknote.png"]
172
173         if distribution == "debian":
174                 print p
175                 print p.generate(
176                         version="%s-%s" % (__version__, __build__),
177                         changelog=__changelog__,
178                         build=True,
179                         tar=False,
180                         changes=False,
181                         dsc=False,
182                 )
183                 print "Building for %s finished" % distribution
184         else:
185                 print p
186                 print p.generate(
187                         version="%s-%s" % (__version__, __build__),
188                         changelog=__changelog__,
189                         build=False,
190                         tar=True,
191                         changes=True,
192                         dsc=True,
193                 )
194                 print "Building for %s finished" % distribution
195
196
197 if __name__ == "__main__":
198         if len(sys.argv) > 1:
199                 try:
200                         import optparse
201                 except ImportError:
202                         optparse = None
203
204                 if optparse is not None:
205                         parser = optparse.OptionParser()
206                         (commandOptions, commandArgs) = parser.parse_args()
207         else:
208                 commandArgs = None
209                 commandArgs = ["diablo"]
210         build_package(commandArgs[0])