gcs

Merge lp:~ehbello/gcs/trunk into lp:gcs

Proposed by Roberto C. Morano
Status: Merged
Merge reported by: Roberto C. Morano
Merged at revision: not available
Proposed branch: lp:~ehbello/gcs/trunk
Merge into: lp:gcs
Diff against target: 397 lines (+196/-37)
11 files modified
builder.py (+12/-12)
config.py (+10/-0)
debian/changelog (+21/-2)
debian/control (+1/-1)
debian/lintian-overrides (+17/-0)
gcs.conf (+15/-8)
gcs_build (+7/-0)
generators/file.py (+75/-1)
generators/part.py (+30/-12)
skel/gcs/info (+6/-1)
templates/menu.template (+2/-0)
To merge this branch: bzr merge lp:~ehbello/gcs/trunk
Reviewer Review Type Date Requested Status
Roberto C. Morano Approve
Review via email: mp+158887@code.launchpad.net

Commit message

new merge from Enrique Bello's branch

Description of the change

new features, thx Enrique!

To post a comment you must log in.
Revision history for this message
Roberto C. Morano (rcmorano) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'builder.py'
2--- builder.py 2010-07-22 15:51:20 +0000
3+++ builder.py 2013-04-15 10:51:18 +0000
4@@ -21,6 +21,7 @@
5 from generators.file import ConfigGenerator
6 from generators.file import TemplatesGenerator
7 from generators.file import CopyrightGenerator
8+from generators.file import MenuGenerator
9
10
11 class Builder(object):
12@@ -30,14 +31,16 @@
13 def __init__(self, path):
14 config['source_path'] = path
15 config['info'] = yaml.load(open(path + '/gcs/info').read())
16- extension = config['info'].get('config_extension', None)
17- if extension:
18- config['config_extension'] = extension
19+ config['config_extension'] = config['info'].get('config_extension', None)
20+ if not config['config_extension']:
21+ config['config_extension'] = '.' + config['info'].get('name', None) + '.gcs'
22
23
24 def make_package(self):
25 """ Make the package. Use ScriptGenerator objects for this propouse.
26 """
27+ self.__delete_outputfiles()
28+
29 try:
30 os.mkdir(config['source_path'] + '/debian')
31 except OSError:
32@@ -58,16 +61,11 @@
33 ConfigGenerator().activate()
34 TemplatesGenerator().activate()
35 CopyrightGenerator().activate()
36-
37- # FIXME: At the moment we need to keep the configuration files because
38- # the conversion doesn't transparently (dh_install rename problem)
39- #self.__delete_tmpfiles()
40-
41-
42+ MenuGenerator().activate()
43
44
45 def build_package(self):
46- """ Build the package. Use a simply debuild for this propouse.
47+ """ Build the package. Use a simply debuild for this purpose.
48 """
49 try:
50 os.system('debuild -us -uc')
51@@ -93,8 +91,9 @@
52 copy_file, None)
53
54
55- def __delete_tmpfiles(self):
56- """ Add .gcs extension at all conffiles (making a copy)
57+ def __delete_outputfiles(self):
58+ """ Delete all files of conffiles with .gcs extension
59+ and Debian directory if it exists.
60 """
61 def delete_file(arg, dirname, file_names):
62
63@@ -106,4 +105,5 @@
64
65 os.path.walk(config['source_path'] + '/gcs/conffiles_skel/',
66 delete_file, None)
67+ shutil.rmtree(config['source_path'] + '/debian', True)
68
69
70=== modified file 'config.py'
71--- config.py 2010-07-16 10:26:35 +0000
72+++ config.py 2013-04-15 10:51:18 +0000
73@@ -14,6 +14,16 @@
74 print "Can't read /etc/gcs.conf file."
75 sys.exit(1)
76
77+try:
78+ userconf_path = os.path.join(os.getenv('HOME'), config['userconf_filename'])
79+ userconfig = yaml.load(open(userconf_path).read())
80+ for key in userconfig:
81+ config[key] = userconfig[key]
82+except (yaml.scanner.ScannerError):
83+ print "Can't parse %s file. Ignoring..." % userconf_path
84+except:
85+ pass
86+
87 # Add default options
88 config['source_path'] = './'
89 config['info'] = {}
90
91=== modified file 'debian/changelog'
92--- debian/changelog 2010-10-05 12:04:17 +0000
93+++ debian/changelog 2013-04-15 10:51:18 +0000
94@@ -1,4 +1,21 @@
95-gcs (0.3.20+ehbello3) UNRELEASED; urgency=low
96+gcs (0.3.20+ehbello5) UNRELEASED; urgency=low
97+
98+ * Added support for dh_installmenu to install a desktop menu entry.
99+ * Added support for multiple diverts from different packages.
100+
101+ -- Enrique Hernández Bello <quique@osl.ull.es> Mon, 31 Oct 2011 20:27:49 +0000
102+
103+gcs (0.3.20+ehbello4) maverick; urgency=low
104+
105+ * Resulting files are now deleted before a new build.
106+ * Now catches the exception and notice if we are not placed near gcs source
107+ when gcs_build.
108+ * Added support for an override file of configuration located at HOME of gcs
109+ users.
110+
111+ -- Enrique Hernández Bello <quique@osl.ull.es> Tue, 14 Dec 2010 22:24:14 +0000
112+
113+gcs (0.3.20+ehbello3) maverick; urgency=low
114
115 * Added a pseudo syntax check for package lists used in Debian control files.
116 Now supports packages with version and multiple dependences.
117@@ -6,8 +23,10 @@
118 them.
119 * Fixed the first template question of example skel removing non valid
120 tabulators.
121+ * Added lintian file to override warning messages.
122+ * Update to Standards-Version 3.9.1
123
124- -- Enrique Hernández Bello <quique@osl.ull.es> Sat, 25 Sep 2010 23:42:53 +0100
125+ -- Enrique Hernández Bello <quique@osl.ull.es> Fri, 12 Nov 2010 11:16:41 +0000
126
127 gcs (0.3.20+ehbello2) lucid; urgency=low
128
129
130=== modified file 'debian/control'
131--- debian/control 2010-07-16 13:53:43 +0000
132+++ debian/control 2013-04-15 10:51:18 +0000
133@@ -4,7 +4,7 @@
134 Maintainer: Junta de Andalucia <packmaster@guadalinex.org>
135 Uploaders: Juanje Ojeda Croissier <jojeda@emergya.es>
136 Build-Depends: debhelper (>= 7.0)
137-Standards-Version: 3.8.4
138+Standards-Version: 3.9.1
139 Homepage: http://launchpad.net/gcs
140 Vcs-Browser: http://codebrowse.launchpad.net/~guadalinex-members/gcs/trunk/changes
141 Vcs-Bzr: http://bazaar.launchpad.net/~guadalinex-members/gcs/trunk
142
143=== added file 'debian/lintian-overrides'
144--- debian/lintian-overrides 1970-01-01 00:00:00 +0000
145+++ debian/lintian-overrides 2013-04-15 10:51:18 +0000
146@@ -0,0 +1,17 @@
147+gcs: package-contains-empty-directory usr/share/gcs/skel/gcs/conffiles_skel/
148+gcs: package-contains-empty-directory usr/share/gcs/skel/gcs/install_scripts/pos/
149+gcs: package-contains-empty-directory usr/share/gcs/skel/gcs/install_scripts/pre/
150+gcs: package-contains-empty-directory usr/share/gcs/skel/gcs/newfiles_skel/
151+gcs: package-contains-empty-directory usr/share/gcs/skel/gcs/remove_scripts/pos/
152+gcs: package-contains-empty-directory usr/share/gcs/skel/gcs/remove_scripts/pre/
153+gcs: script-not-executable ./usr/share/gcs/templates/config.template
154+gcs: script-not-executable ./usr/share/gcs/templates/postinst.template
155+gcs: script-not-executable ./usr/share/gcs/templates/postrm.template
156+gcs: script-not-executable ./usr/share/gcs/templates/preinst.template
157+gcs: script-not-executable ./usr/share/gcs/templates/prerm.template
158+gcs: script-not-executable ./usr/share/gcs/templates/rules.template
159+gcs: shell-script-fails-syntax-check ./usr/share/gcs/templates/config.template
160+gcs: shell-script-fails-syntax-check ./usr/share/gcs/templates/postinst.template
161+gcs: shell-script-fails-syntax-check ./usr/share/gcs/templates/postrm.template
162+gcs: shell-script-fails-syntax-check ./usr/share/gcs/templates/preinst.template
163+gcs: shell-script-fails-syntax-check ./usr/share/gcs/templates/prerm.template
164
165=== modified file 'gcs.conf'
166--- gcs.conf 2010-10-05 12:04:17 +0000
167+++ gcs.conf 2013-04-15 10:51:18 +0000
168@@ -1,17 +1,24 @@
169-control_template: /usr/share/gcs/templates/control.template
170-rules_template: /usr/share/gcs/templates/rules.template
171 changelog_template: /usr/share/gcs/templates/changelog.template
172 compat_template: /usr/share/gcs/templates/compat.template
173+config_template: /usr/share/gcs/templates/config.template
174+control_template: /usr/share/gcs/templates/control.template
175+copyright_template: /usr/share/gcs/templates/copyright.template
176+menu_template: /usr/share/gcs/templates/menu.template
177+postinst_template: /usr/share/gcs/templates/postinst.template
178+postrm_template: /usr/share/gcs/templates/postrm.template
179 preinst_template: /usr/share/gcs/templates/preinst.template
180-postinst_template: /usr/share/gcs/templates/postinst.template
181 prerm_template: /usr/share/gcs/templates/prerm.template
182-postrm_template: /usr/share/gcs/templates/postrm.template
183-config_template: /usr/share/gcs/templates/config.template
184-copyright_template: /usr/share/gcs/templates/copyright.template
185+rules_template: /usr/share/gcs/templates/rules.template
186 sourceformat_template: /usr/share/gcs/templates/sourceformat.template
187
188-## Final extension for the configuration files.
189-config_extension: .gcs
190+## Final extension for all configuration files.
191+# (default: .[Package Name])
192+# config_extension: .gcs
193
194 ## This variable change the base path where you want to store the diversions.
195+# (default: None)
196 # diverts_basepath: /diverts
197+
198+## Users can override variables of above creating a file with this name.
199+## If no path is specified, default path comes from HOME variable.
200+userconf_filename: .gcs.conf
201
202=== modified file 'gcs_build'
203--- gcs_build 2010-07-16 15:59:10 +0000
204+++ gcs_build 2013-04-15 10:51:18 +0000
205@@ -19,6 +19,13 @@
206 help="debian source only, don't build binary files"
207 )
208 (options, args) = parser.parse_args()
209+
210+ if os.path.exists(os.getcwd() + '/../gcs/info'):
211+ os.chdir('..')
212+ if not os.path.isfile(os.getcwd() + '/gcs/info'):
213+ print "cannot find readable gcs/info anywhere!"
214+ print "Are you in the source code tree?"
215+ sys.exit(1)
216
217 builder = Builder(os.getcwd())
218 builder.make_package()
219
220=== modified file 'generators/file.py'
221--- generators/file.py 2010-09-25 22:40:59 +0000
222+++ generators/file.py 2013-04-15 10:51:18 +0000
223@@ -146,7 +146,10 @@
224
225
226 def __set_section(self):
227- section = config['info']['section']
228+ try:
229+ section = config['info']['package-section']
230+ except:
231+ section = config['info']['section']
232 newcontent = self.template_content.replace('<SECTION>', section)
233 self.template_content = newcontent
234
235@@ -658,3 +661,74 @@
236 author = "Copyright %s, %s" % (today.year, config['info']['author'])
237 newcontent = self.template_content.replace('<AUTHOR>', author)
238 self.template_content = newcontent
239+
240+class MenuGenerator(FileGenerator):
241+ """ Generate debian/menu file from gcs/info file.
242+ """
243+ def activate(self):
244+ """ Generate debian/menu file
245+
246+ Steps:
247+
248+ 1) Obtain menu template
249+ 2) Set template properties (using tags) from gcs/info file.
250+ 3) Write debian/menu file
251+ """
252+ self.set_template_content('menu_template')
253+
254+ self.__set_name()
255+ self.__set_title()
256+
257+ initial_content = self.template_content
258+ initial_content = initial_content.replace('<NEEDS>', '')
259+ initial_content = initial_content.replace('<SECTION>', '')
260+ initial_content = initial_content.replace('<COMMAND>', '')
261+
262+ self.__set_needs()
263+ self.__set_section()
264+ self.__set_command()
265+
266+ if initial_content != self.template_content:
267+ self._write_file('debian/menu')
268+ else:
269+ try:
270+ os.remove(config['source_path'] + '/menu')
271+ except:
272+ pass
273+
274+
275+ def __set_name(self):
276+ name = config['info']['name']
277+ newcontent = self.template_content.replace('<NAME>', name)
278+ self.template_content = newcontent
279+
280+ def __set_title(self):
281+ name = config['info']['name']
282+ shortdesc = config['info']['shortdesc']
283+ title = name + ' - ' + shortdesc
284+ newcontent = self.template_content.replace('<TITLE>', title)
285+ self.template_content = newcontent
286+
287+ def __set_needs(self):
288+ try:
289+ needs = config['info']['menu-needs']
290+ except:
291+ needs = ""
292+ newcontent = self.template_content.replace('<NEEDS>', needs)
293+ self.template_content = newcontent
294+
295+ def __set_section(self):
296+ try:
297+ section = config['info']['menu-section']
298+ except:
299+ section = ""
300+ newcontent = self.template_content.replace('<SECTION>', section)
301+ self.template_content = newcontent
302+
303+ def __set_command(self):
304+ try:
305+ command = config['info']['menu-command']
306+ except:
307+ command = ""
308+ newcontent = self.template_content.replace('<COMMAND>', command)
309+ self.template_content = newcontent
310
311=== modified file 'generators/part.py'
312--- generators/part.py 2010-05-10 12:23:45 +0000
313+++ generators/part.py 2013-04-15 10:51:18 +0000
314@@ -70,28 +70,46 @@
315 def __add_divert(self, dest_path):
316 extlen = len(config['config_extension'])
317 real_conf_path = dest_path[: -extlen]
318+ divert_conf_path = os.path.join(config['diverts_basepath'],
319+ dest_path[1:])
320+ distrib_conf_path = os.path.join(config['diverts_basepath'],
321+ real_conf_path[1:]) + '.' + config['info']['name'] + '.distrib'
322
323 pkg_name = config['info']['name']
324- divert_command = '[ "%s" != "$(dpkg-divert --truename %s)" ] && rm -f %s && dpkg-divert --rename --remove %s\n' % (real_conf_path, real_conf_path, real_conf_path, real_conf_path)
325-
326- divert_command += "dpkg-divert --package %s " % pkg_name
327- divert_command += "--divert %s.distrib " % os.path.join(config['diverts_basepath'], real_conf_path[1:])
328- divert_command += "--rename --quiet --add %s\n\n" % real_conf_path
329-
330- divert_command += "ln -fs %s %s\n\n" % (os.path.join(config['diverts_basepath'], dest_path[1:]), real_conf_path)
331-
332+ divert_command = '\n\
333+if [ "%s" != "$(dpkg-divert --truename %s)" ]; then\n\
334+ mv %s %s\n\
335+else\n\
336+ dpkg-divert --package %s --divert %s --rename --quiet --add %s\n\
337+fi\n\
338+ln -sf %s %s\n\
339+' % (real_conf_path, real_conf_path,
340+ real_conf_path, distrib_conf_path,
341+ pkg_name, distrib_conf_path, real_conf_path,
342+ divert_conf_path, real_conf_path)
343+
344 self.diverts.append(divert_command)
345
346
347-
348 def __rm_divert(self, dest_path):
349 extlen = len(config['config_extension'])
350 real_conf_path = dest_path[: -extlen]
351+ divert_conf_path = os.path.join(config['diverts_basepath'],
352+ dest_path[1:])
353+ distrib_conf_path = os.path.join(config['diverts_basepath'],
354+ real_conf_path[1:]) + '.' + config['info']['name'] + '.distrib'
355
356 pkg_name = config['info']['name']
357- command = "rm -f %s\n" % real_conf_path
358- command += "dpkg-divert --package %s " % pkg_name
359- command += "--rename --quiet --remove %s\n" % real_conf_path
360+ command = '\n\
361+rm -f %s\n\
362+if [ "%s" != "$(dpkg-divert --listpackage %s)" ]; then\n\
363+ mv %s %s\n\
364+else\n\
365+ dpkg-divert --rename --quiet --remove %s\n\
366+fi\n' % (real_conf_path,
367+ pkg_name, real_conf_path,
368+ distrib_conf_path, real_conf_path,
369+ real_conf_path)
370
371 # rm -f /etc/ejemplo.conf
372 # dpkg-divert --package dummy-conf --rename --quiet --remove /etc/ejemplo.conf
373
374=== modified file 'skel/gcs/info'
375--- skel/gcs/info 2009-12-14 19:59:38 +0000
376+++ skel/gcs/info 2013-04-15 10:51:18 +0000
377@@ -11,7 +11,12 @@
378 priority: optional
379
380 # Section
381-section: seccion_de_la_aplicacion
382+package-section: seccion_de_la_aplicacion
383+
384+# Desktop menu entry (man menufile)
385+#menu-needs="X11|text|vc|wm"
386+#menu-section="Applications/see-menu-manual"
387+#menu-command="/usr/bin/example"
388
389 # Descripción corta
390 shortdesc: "descripción corta"
391
392=== added file 'templates/menu.template'
393--- templates/menu.template 1970-01-01 00:00:00 +0000
394+++ templates/menu.template 2013-04-15 10:51:18 +0000
395@@ -0,0 +1,2 @@
396+?package(<NAME>):needs="<NEEDS>" section="<SECTION>"\
397+ title="<TITLE>" command="<COMMAND>"

Subscribers

People subscribed via source and target branches