Merge lp:~chipaca/ubuntu-push/nih into lp:ubuntu-push/automatic

Proposed by John Lenton on 2014-05-16
Status: Work in progress
Proposed branch: lp:~chipaca/ubuntu-push/nih
Merge into: lp:ubuntu-push/automatic
Diff against target: 192 lines (+132/-12)
6 files modified
.bzrignore (+1/-0)
Makefile (+11/-1)
PACKAGE_DEPS (+9/-0)
README (+17/-11)
client/service/nih.go (+56/-0)
client/service/nih_test.go (+38/-0)
To merge this branch: bzr merge lp:~chipaca/ubuntu-push/nih
Reviewer Review Type Date Requested Status
Samuele Pedroni 2014-05-16 Approve on 2014-05-16
Review via email: mp+219843@code.launchpad.net

Commit message

Wrap nih to provide an appid -> dbus object path map.

Description of the change

Wrap nih to provide an appid -> dbus object path map.

To post a comment you must log in.
Samuele Pedroni (pedronis) wrote :

70 +development environment. THe Ubuntu packagenames for these are listed

typo: THe

Samuele Pedroni (pedronis) :
review: Approve
Ubuntu One Auto Pilot (otto-pilot) wrote :
Download full text (5.2 KiB)

The attempt to merge lp:~chipaca/ubuntu-push/nih into lp:ubuntu-push/automatic failed. Below is the output from the failed tests.

rm -f -r /mnt/tarmac/cache/ubuntu-push-automatic/go-ws/pkg
mkdir -p /mnt/tarmac/cache/ubuntu-push-automatic/go-ws/bin
mkdir -p /mnt/tarmac/cache/ubuntu-push-automatic/go-ws/pkg
go get -u launchpad.net/godeps
go get -d -u launchpad.net/gocheck launchpad.net/go-dbus/v1 launchpad.net/go-xdg/v0 code.google.com/p/gosqlite/sqlite3 launchpad.net/~ubuntu-push-hackers/ubuntu-push/go-uuid/uuid
/mnt/tarmac/cache/ubuntu-push-automatic/go-ws/bin/godeps -u dependencies.tsv
"/mnt/tarmac/cache/ubuntu-push-automatic/go-ws/src/launchpad.net/gocheck" now at <email address hidden>
go install launchpad.net/gocheck launchpad.net/go-dbus/v1 launchpad.net/go-xdg/v0 code.google.com/p/gosqlite/sqlite3 launchpad.net/~ubuntu-push-hackers/ubuntu-push/go-uuid/uuid
go test launchpad.net/ubuntu-push launchpad.net/ubuntu-push/bus launchpad.net/ubuntu-push/bus/connectivity launchpad.net/ubuntu-push/bus/networkmanager launchpad.net/ubuntu-push/bus/notifications launchpad.net/ubuntu-push/bus/systemimage launchpad.net/ubuntu-push/bus/testing launchpad.net/ubuntu-push/bus/urldispatcher launchpad.net/ubuntu-push/client launchpad.net/ubuntu-push/client/gethosts launchpad.net/ubuntu-push/client/service launchpad.net/ubuntu-push/client/session launchpad.net/ubuntu-push/client/session/seenstate launchpad.net/ubuntu-push/config launchpad.net/ubuntu-push/external/murmur3 launchpad.net/ubuntu-push/logger launchpad.net/ubuntu-push/protocol launchpad.net/ubuntu-push/server launchpad.net/ubuntu-push/server/api launchpad.net/ubuntu-push/server/broker launchpad.net/ubuntu-push/server/broker/simple launchpad.net/ubuntu-push/server/broker/testing launchpad.net/ubuntu-push/server/broker/testsuite launchpad.net/ubuntu-push/server/dev launchpad.net/ubuntu-push/server/listener launchpad.net/ubuntu-push/server/session launchpad.net/ubuntu-push/server/store launchpad.net/ubuntu-push/testing launchpad.net/ubuntu-push/testing/condition launchpad.net/ubuntu-push/util launchpad.net/ubuntu-push/whoopsie launchpad.net/ubuntu-push/whoopsie/identifier launchpad.net/ubuntu-push/whoopsie/identifier/testing
? launchpad.net/ubuntu-push [no test files]
ok launchpad.net/ubuntu-push/bus 0.009s
ok launchpad.net/ubuntu-push/bus/connectivity 1.167s
ok launchpad.net/ubuntu-push/bus/networkmanager 0.096s
ok launchpad.net/ubuntu-push/bus/notifications 0.018s
ok launchpad.net/ubuntu-push/bus/systemimage 0.014s
ok launchpad.net/ubuntu-push/bus/testing 0.032s
ok launchpad.net/ubuntu-push/bus/urldispatcher 0.008s
FAIL launchpad.net/ubuntu-push/client [build failed]
ok launchpad.net/ubuntu-push/client/gethosts 0.711s
FAIL launchpad.net/ubuntu-push/client/service [build failed]
ok launchpad.net/ubuntu-push/client/session 0.197s
ok launchpad.net/ubuntu-push/client/session/seenstate 0.178s
ok launchpad.net/ubuntu-push/config 0.035s
ok launchpad.net/ubuntu-push/external/murmur3 0.008s
ok launchpad.net/ubuntu-push/logger 0.009s
ok launchpad.net/ubuntu-push/protocol 0.013s
ok launchpad.net/ubuntu-push/server 0.041s
ok launchpad.net/ubuntu...

Read more...

Unmerged revisions

162. By John Lenton on 2014-05-16

typo and doc improvement

161. By John Lenton on 2014-05-16

README/Makefile & PACKAGE_DEPS

160. By John Lenton on 2014-05-16

nih

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file '.bzrignore'
2--- .bzrignore 2014-05-08 22:42:35 +0000
3+++ .bzrignore 2014-05-16 16:25:28 +0000
4@@ -20,3 +20,4 @@
5 signing-helper/moc_signing.cpp
6 signing-helper/signing-helper
7 signing-helper/signing-helper_automoc.cpp
8+.has-fetched-deps
9
10=== modified file 'Makefile'
11--- Makefile 2014-05-08 22:42:35 +0000
12+++ Makefile 2014-05-16 16:25:28 +0000
13@@ -15,6 +15,15 @@
14
15 TOTEST = $(shell env GOPATH=$(GOPATH) go list $(PROJECT)/...|grep -v acceptance|grep -v http13client )
16
17+fetchdeps: .has-fetched-deps
18+
19+.has-fetched-deps: PACKAGE_DEPS
20+ @touch $@
21+ @$(MAKE) --no-print-directory refetchdeps
22+
23+refetchdeps:
24+ sudo apt-get install $$( cat PACKAGE_DEPS )
25+
26 bootstrap:
27 $(RM) -r $(GOPATH)/pkg
28 mkdir -p $(GOPATH)/bin
29@@ -78,4 +87,5 @@
30
31 .PHONY: bootstrap check check-race format check-format \
32 acceptance build-client build server-dev run-server-dev \
33- coverage-summary coverage-html protocol-diagrams
34+ coverage-summary coverage-html protocol-diagrams \
35+ fetchdeps refetchdeps
36
37=== added file 'PACKAGE_DEPS'
38--- PACKAGE_DEPS 1970-01-01 00:00:00 +0000
39+++ PACKAGE_DEPS 2014-05-16 16:25:28 +0000
40@@ -0,0 +1,9 @@
41+build-essential
42+cmake
43+libdbus-1-dev
44+libgcrypt11-dev
45+libglib2.0-dev
46+libnih-dbus-dev
47+libsqlite3-dev
48+libubuntuoneauth-2.0-dev
49+libwhoopsie-dev
50
51=== modified file 'README'
52--- README 2014-04-30 16:44:16 +0000
53+++ README 2014-05-16 16:25:28 +0000
54@@ -6,17 +6,23 @@
55 The code expects to be checked out as launchpad.net/ubuntu-push in a Go
56 workspace, see "go help gopath".
57
58-To setup Go dependencies, install the following dependencies:
59-
60- build-essential
61- libsqlite3-dev
62-
63-and run:
64-
65- make bootstrap
66-
67-To run tests, install libglib2.0-dev, libgcrypt11-dev, libwhoopsie-dev,
68-and run:
69+You need a somewhat long list of dependencies, as well as a working Go
70+development environment. The Ubuntu packagenames for these are listed
71+in the file PACKAGE_DEPS.
72+
73+On Ubuntu, if you have sudo, you can have all those installed for you
74+by do doing
75+
76+ make fetchdeps
77+
78+Once you have the packaged dependencies you can get the Go
79+dependencies via
80+
81+ make bootstrap
82+
83+and then you're set. Good luck!
84+
85+To run the tests:
86
87 make check
88
89
90=== added file 'client/service/nih.go'
91--- client/service/nih.go 1970-01-01 00:00:00 +0000
92+++ client/service/nih.go 2014-05-16 16:25:28 +0000
93@@ -0,0 +1,56 @@
94+/*
95+ Copyright 2013-2014 Canonical Ltd.
96+
97+ This program is free software: you can redistribute it and/or modify it
98+ under the terms of the GNU General Public License version 3, as published
99+ by the Free Software Foundation.
100+
101+ This program is distributed in the hope that it will be useful, but
102+ WITHOUT ANY WARRANTY; without even the implied warranties of
103+ MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
104+ PURPOSE. See the GNU General Public License for more details.
105+
106+ You should have received a copy of the GNU General Public License along
107+ with this program. If not, see <http://www.gnu.org/licenses/>.
108+*/
109+
110+package service
111+
112+/*
113+#cgo pkg-config: dbus-1 libnih libnih-dbus
114+#include <stdlib.h>
115+#include <nih/alloc.h>
116+#include <libnih-dbus.h>
117+
118+char *appid2objpath (const char *root, const char *id) {
119+ if (!strcmp (root, "")) return NULL;
120+ return nih_dbus_path (NULL, root, id, NULL);
121+}
122+*/
123+import "C"
124+
125+import (
126+ "errors"
127+ "unsafe"
128+
129+ "launchpad.net/go-dbus/v1"
130+)
131+
132+var AppId2ObjPathError = errors.New("Empty root, or out of memory")
133+
134+// AppId2ObjPath uses libnih-dbus to translate an app id to a valid
135+// component of an object path, and returns it under the given root.
136+func AppId2ObjPath(root string, id string) (dbus.ObjectPath, error) {
137+ cid := C.CString(id)
138+ defer C.free(unsafe.Pointer(cid))
139+ croot := C.CString(root)
140+ defer C.free(unsafe.Pointer(croot))
141+
142+ cop := C.appid2objpath(croot, cid)
143+ if cop == nil {
144+ return "", AppId2ObjPathError
145+ }
146+ defer C.nih_free(unsafe.Pointer(cop))
147+
148+ return dbus.ObjectPath(C.GoString(cop)), nil
149+}
150
151=== added file 'client/service/nih_test.go'
152--- client/service/nih_test.go 1970-01-01 00:00:00 +0000
153+++ client/service/nih_test.go 2014-05-16 16:25:28 +0000
154@@ -0,0 +1,38 @@
155+/*
156+ Copyright 2013-2014 Canonical Ltd.
157+
158+ This program is free software: you can redistribute it and/or modify it
159+ under the terms of the GNU General Public License version 3, as published
160+ by the Free Software Foundation.
161+
162+ This program is distributed in the hope that it will be useful, but
163+ WITHOUT ANY WARRANTY; without even the implied warranties of
164+ MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
165+ PURPOSE. See the GNU General Public License for more details.
166+
167+ You should have received a copy of the GNU General Public License along
168+ with this program. If not, see <http://www.gnu.org/licenses/>.
169+*/
170+
171+package service
172+
173+import (
174+ "launchpad.net/go-dbus/v1"
175+ . "launchpad.net/gocheck"
176+)
177+
178+type nihSuite struct{}
179+
180+var _ = Suite(&nihSuite{})
181+
182+func (ns *nihSuite) TestA2P(c *C) {
183+ op, err := AppId2ObjPath("/a/b", "hello")
184+ c.Check(op, Equals, dbus.ObjectPath("/a/b/hello"))
185+ c.Check(err, IsNil)
186+ op, err = AppId2ObjPath("/a/b", "hello world")
187+ c.Check(op, Equals, dbus.ObjectPath("/a/b/hello_20world"))
188+ c.Check(err, IsNil)
189+ op, err = AppId2ObjPath("", "hello world")
190+ c.Check(err, Equals, AppId2ObjPathError)
191+ c.Check(op, Equals, dbus.ObjectPath(""))
192+}

Subscribers

People subscribed via source and target branches