Merge lp:~mterry/pkgme/vala into lp:pkgme

Proposed by Michael Terry on 2010-11-12
Status: Merged
Merged at revision: 35
Proposed branch: lp:~mterry/pkgme/vala
Merge into: lp:pkgme
Diff against target: 441 lines (+401/-0)
8 files modified
pkgme/backends/vala/architecture (+22/-0)
pkgme/backends/vala/build_depends (+50/-0)
pkgme/backends/vala/buildsystem (+21/-0)
pkgme/backends/vala/depends (+21/-0)
pkgme/backends/vala/homepage (+50/-0)
pkgme/backends/vala/package_name (+62/-0)
pkgme/backends/vala/want (+44/-0)
pkgme/tests/test_vala_backend.py (+131/-0)
To merge this branch: bzr merge lp:~mterry/pkgme/vala
Reviewer Review Type Date Requested Status
pkgme committers 2010-11-12 Pending
Review via email: mp+40746@code.launchpad.net

Description of the Change

build_depends is incomplete, but callable.

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added directory 'pkgme/backends/vala'
2=== added file 'pkgme/backends/vala/architecture'
3--- pkgme/backends/vala/architecture 1970-01-01 00:00:00 +0000
4+++ pkgme/backends/vala/architecture 2010-11-12 18:00:27 +0000
5@@ -0,0 +1,22 @@
6+#!/bin/sh
7+# -*- Mode: sh; indent-tabs-mode: nil; tab-width: 2 -*-
8+#
9+# © 2010 Canonical Ltd
10+#
11+# This program is free software; you can redistribute it and/or modify
12+# it under the terms of the GNU General Public License as published by
13+# the Free Software Foundation; version 3 of the License.
14+#
15+# This program is distributed in the hope that it will be useful, but
16+# WITHOUT ANY WARRANTY; without even the implied warranty of
17+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18+# General Public License for more details.
19+#
20+# You should have received a copy of the GNU General Public License
21+# along with this program. If not, see <http://www.gnu.org/licenses/>.
22+#
23+# Authors: Michael Terry <michael.terry@canonical.com>
24+# =====================================================================
25+
26+# Vala compiles to byte code
27+echo any
28
29=== added file 'pkgme/backends/vala/build_depends'
30--- pkgme/backends/vala/build_depends 1970-01-01 00:00:00 +0000
31+++ pkgme/backends/vala/build_depends 2010-11-12 18:00:27 +0000
32@@ -0,0 +1,50 @@
33+#!/bin/sh
34+# -*- Mode: sh; indent-tabs-mode: nil; tab-width: 2 -*-
35+#
36+# © 2010 Canonical Ltd
37+#
38+# This program is free software; you can redistribute it and/or modify
39+# it under the terms of the GNU General Public License as published by
40+# the Free Software Foundation; version 3 of the License.
41+#
42+# This program is distributed in the hope that it will be useful, but
43+# WITHOUT ANY WARRANTY; without even the implied warranty of
44+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
45+# General Public License for more details.
46+#
47+# You should have received a copy of the GNU General Public License
48+# along with this program. If not, see <http://www.gnu.org/licenses/>.
49+#
50+# Authors: Michael Terry <michael.terry@canonical.com>
51+# =====================================================================
52+
53+# The idea here is to gather all .vala files we find and pass them to
54+# vala-dep-scanner.
55+#
56+# TODO: Use gir files instead of vapi files. This currently doesn't work with
57+# vapi files, as the vapi->dev-package lookup is difficult/impossible?
58+
59+files=$(find . -maxdepth 2 -name '*.vala' 2>/dev/null)
60+if [ -z "$files" ]; then
61+ exit 0
62+fi
63+
64+vapinames=$(vala-dep-scanner $files 2>/dev/null)
65+if [ -z "$vapinames" ]; then
66+ exit 0
67+fi
68+
69+# Now for each vapi, determine which package owns it
70+pkgs=""
71+for name in $vapinames; do
72+ pkg=$(dpkg-query -S "$name.vapi" | cut -d: -f1 | head -n 1)
73+ if [ -z "$pkg" ]; then
74+ pkg=$(dpkg-query -S "$name.gir" | cut -d: -f1 | head -n 1)
75+ fi
76+ if [ -n "$pkg" ]; then
77+ pkgs="$pkgs\n$pkg"
78+ fi
79+done
80+
81+# tail to skip leading newline
82+echo $pkgs | sort | uniq | tail -n +2
83
84=== added file 'pkgme/backends/vala/buildsystem'
85--- pkgme/backends/vala/buildsystem 1970-01-01 00:00:00 +0000
86+++ pkgme/backends/vala/buildsystem 2010-11-12 18:00:27 +0000
87@@ -0,0 +1,21 @@
88+#!/bin/sh
89+# -*- Mode: sh; indent-tabs-mode: nil; tab-width: 2 -*-
90+#
91+# © 2010 Canonical Ltd
92+#
93+# This program is free software; you can redistribute it and/or modify
94+# it under the terms of the GNU General Public License as published by
95+# the Free Software Foundation; version 3 of the License.
96+#
97+# This program is distributed in the hope that it will be useful, but
98+# WITHOUT ANY WARRANTY; without even the implied warranty of
99+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
100+# General Public License for more details.
101+#
102+# You should have received a copy of the GNU General Public License
103+# along with this program. If not, see <http://www.gnu.org/licenses/>.
104+#
105+# Authors: Michael Terry <michael.terry@canonical.com>
106+# =====================================================================
107+
108+echo autoconf
109
110=== added file 'pkgme/backends/vala/depends'
111--- pkgme/backends/vala/depends 1970-01-01 00:00:00 +0000
112+++ pkgme/backends/vala/depends 2010-11-12 18:00:27 +0000
113@@ -0,0 +1,21 @@
114+#!/bin/sh
115+# -*- Mode: sh; indent-tabs-mode: nil; tab-width: 2 -*-
116+#
117+# © 2010 Canonical Ltd
118+#
119+# This program is free software; you can redistribute it and/or modify
120+# it under the terms of the GNU General Public License as published by
121+# the Free Software Foundation; version 3 of the License.
122+#
123+# This program is distributed in the hope that it will be useful, but
124+# WITHOUT ANY WARRANTY; without even the implied warranty of
125+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
126+# General Public License for more details.
127+#
128+# You should have received a copy of the GNU General Public License
129+# along with this program. If not, see <http://www.gnu.org/licenses/>.
130+#
131+# Authors: Michael Terry <michael.terry@canonical.com>
132+# =====================================================================
133+
134+echo "\${shlibs:Depends}"
135
136=== added file 'pkgme/backends/vala/homepage'
137--- pkgme/backends/vala/homepage 1970-01-01 00:00:00 +0000
138+++ pkgme/backends/vala/homepage 2010-11-12 18:00:27 +0000
139@@ -0,0 +1,50 @@
140+#!/bin/sh
141+# -*- Mode: sh; indent-tabs-mode: nil; tab-width: 2 -*-
142+#
143+# © 2010 Canonical Ltd
144+#
145+# This program is free software; you can redistribute it and/or modify
146+# it under the terms of the GNU General Public License as published by
147+# the Free Software Foundation; version 3 of the License.
148+#
149+# This program is distributed in the hope that it will be useful, but
150+# WITHOUT ANY WARRANTY; without even the implied warranty of
151+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
152+# General Public License for more details.
153+#
154+# You should have received a copy of the GNU General Public License
155+# along with this program. If not, see <http://www.gnu.org/licenses/>.
156+#
157+# Authors: Michael Terry <michael.terry@canonical.com>
158+# =====================================================================
159+
160+# The homepage may be in AC_INIT, in the 5th field
161+# AC_INIT([Example Project],[1.0],[http://bugs.example.com/],[example-project],[http://example.com/])
162+
163+CONFIG_NAME=configure.ac
164+if [ ! -e "$CONFIG_NAME" ]; then
165+ CONFIG_NAME=configure.in
166+ if [ ! -e "$CONFIG_NAME" ]; then
167+ # not an autotools project
168+ exit 0
169+ fi
170+fi
171+
172+acinit=$(grep --max-count=1 AC_INIT "$CONFIG_NAME" 2>/dev/null)
173+
174+initfield() {
175+ rv=$(echo $1 | sed 's/AC_INIT//')
176+ rv=$(echo $rv | cut -d, -f"$2")
177+ # Find end (either , or ending ')')
178+ rv=$(echo $rv | sed 's/[[( ]*\([^,)]*\).*/\1/')
179+ # chop off ending odd characters
180+ rv=$(echo $rv | sed 's/[] ]*$//')
181+ echo $rv
182+}
183+
184+tarname=$(initfield "$acinit" 5)
185+if [ -n "$tarname" ]; then
186+ echo "$tarname"
187+fi
188+
189+exit 0
190
191=== added file 'pkgme/backends/vala/package_name'
192--- pkgme/backends/vala/package_name 1970-01-01 00:00:00 +0000
193+++ pkgme/backends/vala/package_name 2010-11-12 18:00:27 +0000
194@@ -0,0 +1,62 @@
195+#!/bin/sh
196+# -*- Mode: sh; indent-tabs-mode: nil; tab-width: 2 -*-
197+#
198+# © 2010 Canonical Ltd
199+#
200+# This program is free software; you can redistribute it and/or modify
201+# it under the terms of the GNU General Public License as published by
202+# the Free Software Foundation; version 3 of the License.
203+#
204+# This program is distributed in the hope that it will be useful, but
205+# WITHOUT ANY WARRANTY; without even the implied warranty of
206+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
207+# General Public License for more details.
208+#
209+# You should have received a copy of the GNU General Public License
210+# along with this program. If not, see <http://www.gnu.org/licenses/>.
211+#
212+# Authors: Michael Terry <michael.terry@canonical.com>
213+# =====================================================================
214+
215+CONFIG_NAME=configure.ac
216+if [ ! -e "$CONFIG_NAME" ]; then
217+ CONFIG_NAME=configure.in
218+ if [ ! -e "$CONFIG_NAME"]; then
219+ # not an autotools project. Don't know how to grab name
220+ exit 0
221+ fi
222+fi
223+
224+# So this could be set up multiple ways.
225+# AC_INIT([Example Project],[1.0],[http://bugs.example.com/],[example-project],[http://example.com/])
226+# AC_INIT([Example Project],[1.0])
227+# First is easy, we just grab the 4th field. Second is harder, and requires us
228+# to simplify the string as autoconf would.
229+
230+acinit=$(grep --max-count=1 AC_INIT "$CONFIG_NAME" 2>/dev/null)
231+
232+initfield() {
233+ rv=$(echo $1 | sed 's/AC_INIT//')
234+ rv=$(echo $rv | cut -d, -f"$2")
235+ # Find end (either , or ending ')')
236+ rv=$(echo $rv | sed 's/[[( ]*\([^,)]*\).*/\1/')
237+ # chop off ending odd characters
238+ rv=$(echo $rv | sed 's/[] ]*$//')
239+ echo $rv
240+}
241+
242+tarname=$(initfield "$acinit" 4)
243+if [ -n "$tarname" ]; then
244+ echo "$tarname"
245+ exit 0
246+fi
247+
248+# Now we mangle the project name into a tarball name. From the autoconf manual:
249+# "... with `GNU ' stripped, lower-cased, and all characters
250+# other than alphanumerics and underscores are changed to `-'."
251+
252+pkgname=$(initfield "$acinit" 1)
253+pkgname=$(echo $pkgname | sed 's/^GNU //')
254+pkgname=$(echo $pkgname | tr [:upper:] [:lower:])
255+pkgname=$(echo -n $pkgname | tr -c [:alnum:]_ -)
256+echo $pkgname
257
258=== added file 'pkgme/backends/vala/want'
259--- pkgme/backends/vala/want 1970-01-01 00:00:00 +0000
260+++ pkgme/backends/vala/want 2010-11-12 18:00:27 +0000
261@@ -0,0 +1,44 @@
262+#!/bin/sh
263+# -*- Mode: sh; indent-tabs-mode: nil; tab-width: 2 -*-
264+#
265+# © 2010 Canonical Ltd
266+#
267+# This program is free software; you can redistribute it and/or modify
268+# it under the terms of the GNU General Public License as published by
269+# the Free Software Foundation; version 3 of the License.
270+#
271+# This program is distributed in the hope that it will be useful, but
272+# WITHOUT ANY WARRANTY; without even the implied warranty of
273+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
274+# General Public License for more details.
275+#
276+# You should have received a copy of the GNU General Public License
277+# along with this program. If not, see <http://www.gnu.org/licenses/>.
278+#
279+# Authors: Michael Terry <michael.terry@canonical.com>
280+# =====================================================================
281+
282+# Currently, just scan for vala files and return that we identified them.
283+# Don't bother trying to scan for AM_PROG_VALA, because it's not necessarily
284+# widely adopted.
285+
286+end() {
287+ echo $1
288+ exit 0
289+}
290+
291+CONFIG_NAME=configure.ac
292+if [ ! -e "$CONFIG_NAME" ]; then
293+ CONFIG_NAME=configure.in
294+ if [ ! -e "$CONFIG_NAME" ]; then
295+ # not an autotools project
296+ end 0
297+ fi
298+fi
299+
300+# Scan toplevel and immediate subdirectories for Vala files
301+if [ -n "$(find . -maxdepth 2 -name '*.vala' 2>/dev/null)" ]; then
302+ end 20
303+fi
304+
305+end 0
306
307=== added file 'pkgme/tests/test_vala_backend.py'
308--- pkgme/tests/test_vala_backend.py 1970-01-01 00:00:00 +0000
309+++ pkgme/tests/test_vala_backend.py 2010-11-12 18:00:27 +0000
310@@ -0,0 +1,131 @@
311+#!/usr/bin/python
312+# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
313+#
314+# © 2010 Canonical Ltd
315+#
316+# This program is free software; you can redistribute it and/or modify
317+# it under the terms of the GNU General Public License as published by
318+# the Free Software Foundation; version 3 of the License.
319+#
320+# This program is distributed in the hope that it will be useful, but
321+# WITHOUT ANY WARRANTY; without even the implied warranty of
322+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
323+# General Public License for more details.
324+#
325+# You should have received a copy of the GNU General Public License
326+# along with this program. If not, see <http://www.gnu.org/licenses/>.
327+#
328+# Authors: Michael Terry <michael.terry@canonical.com>
329+# =====================================================================
330+
331+import os
332+
333+from fixtures import TestWithFixtures
334+from testtools import TestCase
335+
336+from pkgme.backend import ExternalHelpersBackend
337+from pkgme.testing import TempdirFixture
338+
339+
340+backend_dir = os.path.join(
341+ os.path.dirname(os.path.abspath(__file__)), os.pardir,
342+ "backends", "vala")
343+
344+
345+class PythonBackendTests(TestCase, TestWithFixtures):
346+
347+ def test_want_zero_deep(self):
348+ tempdir = self.useFixture(TempdirFixture())
349+ # Use configure.in for this one, to make sure we handle it right
350+ with open(os.path.join(tempdir.path, "configure.in"), "w"):
351+ pass
352+ with open(os.path.join(tempdir.path, "main.vala"), "w"):
353+ pass
354+ backend = ExternalHelpersBackend("vala", backend_dir)
355+ self.assertEqual(20, backend.want(tempdir.path))
356+
357+ def test_want_one_deep(self):
358+ tempdir = self.useFixture(TempdirFixture())
359+ with open(os.path.join(tempdir.path, "configure.ac"), "w"):
360+ pass
361+ os.mkdir(os.path.join(tempdir.path, "one"))
362+ with open(os.path.join(tempdir.path, "one", "main.vala"), "w"):
363+ pass
364+ backend = ExternalHelpersBackend("vala", backend_dir)
365+ self.assertEqual(20, backend.want(tempdir.path))
366+
367+ def test_want_two_deep(self):
368+ tempdir = self.useFixture(TempdirFixture())
369+ with open(os.path.join(tempdir.path, "configure.ac"), "w"):
370+ pass
371+ os.mkdir(os.path.join(tempdir.path, "one"))
372+ os.mkdir(os.path.join(tempdir.path, "one", "two"))
373+ with open(os.path.join(tempdir.path, "one", "two", "main.vala"), "w"):
374+ pass
375+ backend = ExternalHelpersBackend("vala", backend_dir)
376+ self.assertEqual(0, backend.want(tempdir.path))
377+
378+ def test_want_without_configure_ac(self):
379+ tempdir = self.useFixture(TempdirFixture())
380+ backend = ExternalHelpersBackend("vala", backend_dir)
381+ with open(os.path.join(tempdir.path, "main.vala"), "w"):
382+ pass
383+ self.assertEqual(0, backend.want(tempdir.path))
384+
385+ def test_architecture(self):
386+ tempdir = self.useFixture(TempdirFixture())
387+ backend = ExternalHelpersBackend("vala", backend_dir)
388+ info = backend.get_info(tempdir.path)
389+ self.assertEqual(
390+ {"architecture": "any"}, info.get_all(["architecture"]))
391+
392+ def test_buildsystem(self):
393+ tempdir = self.useFixture(TempdirFixture())
394+ backend = ExternalHelpersBackend("vala", backend_dir)
395+ info = backend.get_info(tempdir.path)
396+ self.assertEqual(
397+ {"buildsystem": "autoconf"}, info.get_all(["buildsystem"]))
398+
399+ def test_depends(self):
400+ tempdir = self.useFixture(TempdirFixture())
401+ backend = ExternalHelpersBackend("vala", backend_dir)
402+ info = backend.get_info(tempdir.path)
403+ self.assertEqual(
404+ {"depends": "${shlibs:Depends}"}, info.get_all(["depends"]))
405+
406+ def test_homepage(self):
407+ tempdir = self.useFixture(TempdirFixture())
408+ with open(os.path.join(tempdir.path, "configure.ac"), "w") as f:
409+ f.write("AC_INIT([Example Project],[1.0],[http://bugs.example.com/],[example-project], [http://example.com/] )")
410+ backend = ExternalHelpersBackend("vala", backend_dir)
411+ info = backend.get_info(tempdir.path)
412+ self.assertEqual(
413+ {"homepage": "http://example.com/"}, info.get_all(["homepage"]))
414+
415+ def test_homepage_none(self):
416+ tempdir = self.useFixture(TempdirFixture())
417+ with open(os.path.join(tempdir.path, "configure.ac"), "w") as f:
418+ f.write("""AC_INIT([Example Project],[1.0],[http://bugs.example.com/],[example-project])""")
419+ backend = ExternalHelpersBackend("vala", backend_dir)
420+ info = backend.get_info(tempdir.path)
421+ self.assertEqual(
422+ {"homepage": ""}, info.get_all(["homepage"]))
423+
424+ def test_package_name(self):
425+ tempdir = self.useFixture(TempdirFixture())
426+ with open(os.path.join(tempdir.path, "configure.ac"), "w") as f:
427+ f.write("""AC_INIT([GNU Example Project],[1.0],[http://bugs.example.com/],[co ol-proj],[http://example.com/])""")
428+ backend = ExternalHelpersBackend("vala", backend_dir)
429+ info = backend.get_info(tempdir.path)
430+ self.assertEqual(
431+ {"package_name": "co ol-proj"}, info.get_all(["package_name"]))
432+
433+ def test_package_name_none(self):
434+ tempdir = self.useFixture(TempdirFixture())
435+ with open(os.path.join(tempdir.path, "configure.ac"), "w") as f:
436+ f.write("""AC_INIT( [GNU Example Project] , [1.0],[http://bugs.example.com/])""")
437+ backend = ExternalHelpersBackend("vala", backend_dir)
438+ info = backend.get_info(tempdir.path)
439+ self.assertEqual(
440+ {"package_name": "example-project"}, info.get_all(["package_name"]))
441+

Subscribers

People subscribed via source and target branches