Merge lp:~sergiusens/goget-ubuntu-touch/built_using_for_do into lp:goget-ubuntu-touch

Proposed by Sergio Schvezov
Status: Superseded
Proposed branch: lp:~sergiusens/goget-ubuntu-touch/built_using_for_do
Merge into: lp:goget-ubuntu-touch
Diff against target: 243 lines (+150/-12)
9 files modified
debian/changelog (+7/-0)
debian/control (+9/-0)
debian/rules (+1/-0)
debian/ubuntu-device-do.install (+1/-0)
ubuntu-device-do/factory_reset.go (+69/-0)
ubuntu-device-do/main.go (+38/-0)
ubuntu-device-flash/args.go (+1/-0)
ubuntu-device-flash/main.go (+6/-1)
ubuntuimage/images.go (+18/-11)
To merge this branch: bzr merge lp:~sergiusens/goget-ubuntu-touch/built_using_for_do
Reviewer Review Type Date Requested Status
Ubuntu Phablet Team Pending
Review via email: mp+223647@code.launchpad.net

This proposal has been superseded by a proposal from 2014-06-18.

Description of the change

debian/control: add Built-Using for ubuntu-device-do

To post a comment you must log in.

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'debian/changelog'
2--- debian/changelog 2014-06-10 16:12:34 +0000
3+++ debian/changelog 2014-06-18 20:51:44 +0000
4@@ -1,3 +1,10 @@
5+goget-ubuntu-touch (0.3-0ubuntu1) UNRELEASED; urgency=medium
6+
7+ * ubuntu-touch-do: new tool to interact with ubuntu devices.
8+ * ubuntu-device-flash: option to flash with developer mode enabled.
9+
10+ -- Sergio Schvezov <sergio.schvezov@canonical.com> Fri, 30 May 2014 09:28:52 -0300
11+
12 goget-ubuntu-touch (0.2+14.10.20140610-0ubuntu1) utopic; urgency=low
13
14 [ Dimitri John Ledkov ]
15
16=== modified file 'debian/control'
17--- debian/control 2014-03-10 13:03:23 +0000
18+++ debian/control 2014-06-18 20:51:44 +0000
19@@ -24,6 +24,15 @@
20 bootstrapping from fastboot or reflashing from an already
21 supported device.
22
23+Package: ubuntu-device-do
24+Architecture: any
25+Depends: android-tools-adb,
26+ ${misc:Depends},
27+ ${shlibs:Depends},
28+Built-Using: ${misc:Built-Using}
29+Description: Tool to interact with Ubuntu Touch devices
30+ Use this tool to interact with your Ubuntu Touch device
31+
32 Package: ubuntu-emulator
33 Architecture: i386 amd64
34 Depends: ubuntu-emulator-runtime,
35
36=== modified file 'debian/rules'
37--- debian/rules 2014-01-09 17:42:55 +0000
38+++ debian/rules 2014-06-18 20:51:44 +0000
39@@ -12,3 +12,4 @@
40 rm -rf ${CURDIR}/debian/tmp/usr/bin/abootimg-extract
41 rm -rf ${CURDIR}/debian/tmp/usr/share/gocode/src/launchpad.net/goget-ubuntu-touch/ubuntu-emulator
42 rm -rf ${CURDIR}/debian/tmp/usr/share/gocode/src/launchpad.net/goget-ubuntu-touch/ubuntu-device-flash
43+ rm -rf ${CURDIR}/debian/tmp/usr/share/gocode/src/launchpad.net/goget-ubuntu-touch/ubuntu-device-do
44
45=== added file 'debian/ubuntu-device-do.install'
46--- debian/ubuntu-device-do.install 1970-01-01 00:00:00 +0000
47+++ debian/ubuntu-device-do.install 2014-06-18 20:51:44 +0000
48@@ -0,0 +1,1 @@
49+usr/bin/ubuntu-device-do
50
51=== added directory 'ubuntu-device-do'
52=== added file 'ubuntu-device-do/factory_reset.go'
53--- ubuntu-device-do/factory_reset.go 1970-01-01 00:00:00 +0000
54+++ ubuntu-device-do/factory_reset.go 2014-06-18 20:51:44 +0000
55@@ -0,0 +1,69 @@
56+//
57+// ubuntu-device-do - Tool to send commands to an Ubuntu device
58+//
59+// Copyright (c) 2013 Canonical Ltd.
60+//
61+// Written by Sergio Schvezov <sergio.schvezov@canonical.com>
62+//
63+package main
64+
65+// This program is free software: you can redistribute it and/or modify it
66+// under the terms of the GNU General Public License version 3, as published
67+// by the Free Software Foundation.
68+//
69+// This program is distributed in the hope that it will be useful, but
70+// WITHOUT ANY WARRANTY; without even the implied warranties of
71+// MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
72+// PURPOSE. See the GNU General Public License for more details.
73+//
74+// You should have received a copy of the GNU General Public License along
75+// with this program. If not, see <http://www.gnu.org/licenses/>.
76+
77+import (
78+ "fmt"
79+
80+ "log"
81+
82+ "launchpad.net/goget-ubuntu-touch/devices"
83+ "launchpad.net/goget-ubuntu-touch/ubuntuimage"
84+)
85+
86+type FactoryResetCmd struct {
87+ DeveloperMode bool `long:"developer-mode" description:"Enables developer mode after the factory reset"`
88+ Serial string `long:"serial" description:"Serial of the device to operate"`
89+}
90+
91+var factoryResetCmd FactoryResetCmd
92+
93+func init() {
94+ parser.AddCommand("factory-reset",
95+ "Resets to stock install",
96+ "Resets a device to its stock install with the possibility to enable developer mode by default",
97+ &factoryResetCmd)
98+}
99+
100+func (factoryResetCmd *FactoryResetCmd) Execute(args []string) error {
101+ var enableList []string
102+ if factoryResetCmd.DeveloperMode {
103+ enableList = append(enableList, "developer_mode")
104+ }
105+ //files: nil, files location: "", wipe: true, enable: enableList
106+ ubuntuCommands, err := ubuntuimage.GetUbuntuCommands(nil, "", true, enableList)
107+ if err != nil {
108+ return fmt.Errorf("cannot create commands file: %s", err)
109+ }
110+
111+ adb, err := devices.NewUbuntuDebugBridge()
112+ if err != nil {
113+ log.Fatal(err)
114+ }
115+ if factoryResetCmd.Serial != "" {
116+ adb.SetSerial(factoryResetCmd.Serial)
117+ }
118+ if err := adb.Push(ubuntuCommands, "/cache/recovery/ubuntu_command"); err != nil {
119+ return err
120+ }
121+ fmt.Println("Rebooting to finish factory reset")
122+ adb.RebootRecovery()
123+ return nil
124+}
125
126=== added file 'ubuntu-device-do/main.go'
127--- ubuntu-device-do/main.go 1970-01-01 00:00:00 +0000
128+++ ubuntu-device-do/main.go 2014-06-18 20:51:44 +0000
129@@ -0,0 +1,38 @@
130+//
131+// ubuntu-device-do - Tool to send commands to an Ubuntu device
132+//
133+// Copyright (c) 2013 Canonical Ltd.
134+//
135+// Written by Sergio Schvezov <sergio.schvezov@canonical.com>
136+//
137+package main
138+
139+// This program is free software: you can redistribute it and/or modify it
140+// under the terms of the GNU General Public License version 3, as published
141+// by the Free Software Foundation.
142+//
143+// This program is distributed in the hope that it will be useful, but
144+// WITHOUT ANY WARRANTY; without even the implied warranties of
145+// MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
146+// PURPOSE. See the GNU General Public License for more details.
147+//
148+// You should have received a copy of the GNU General Public License along
149+// with this program. If not, see <http://www.gnu.org/licenses/>.
150+
151+import (
152+ "os"
153+
154+ flags "github.com/jessevdk/go-flags"
155+)
156+
157+var parser = flags.NewParser(nil, flags.Default)
158+
159+func init() {
160+
161+}
162+
163+func main() {
164+ if _, err := parser.Parse(); err != nil {
165+ os.Exit(1)
166+ }
167+}
168
169=== modified file 'ubuntu-device-flash/args.go'
170--- ubuntu-device-flash/args.go 2014-05-15 13:21:24 +0000
171+++ ubuntu-device-flash/args.go 2014-06-18 20:51:44 +0000
172@@ -35,6 +35,7 @@
173 Server string `long:"server" description:"Use a different image server"`
174 CleanCache bool `long:"clean-cache" description:"Cleans up cache with all downloaded bits"`
175 TLSSkipVerify bool `long:"tls-skip-verify" description:"Skip TLS certificate validation"`
176+ DeveloperMode bool `long:"developer-mode" description:"Enables developer mode after the factory reset"`
177 RunScript string `long:"run-script" description:"Run a script given by path to finish the flashing process, instead of rebooting to recovery (mostly used during development to work around quirky or incomplete recovery images)"`
178 }
179
180
181=== modified file 'ubuntu-device-flash/main.go'
182--- ubuntu-device-flash/main.go 2014-05-27 19:02:35 +0000
183+++ ubuntu-device-flash/main.go 2014-06-18 20:51:44 +0000
184@@ -180,7 +180,12 @@
185 for i := 0; i < totalFiles; i++ {
186 <-done
187 }
188- ubuntuCommands, err := ubuntuimage.GetUbuntuCommands(image.Files, cacheDir, args.Wipe)
189+
190+ var enableList []string
191+ if args.DeveloperMode {
192+ enableList = append(enableList, "developer_mode")
193+ }
194+ ubuntuCommands, err := ubuntuimage.GetUbuntuCommands(image.Files, cacheDir, args.Wipe, enableList)
195 if err != nil {
196 log.Fatal("Cannot create commands file")
197 }
198
199=== modified file 'ubuntuimage/images.go'
200--- ubuntuimage/images.go 2014-04-16 15:01:28 +0000
201+++ ubuntuimage/images.go 2014-06-18 20:51:44 +0000
202@@ -56,7 +56,7 @@
203 mount system
204 `
205
206-func GetUbuntuCommands(files []File, downloadDir string, wipe bool) (commandsFile string, err error) {
207+func GetUbuntuCommands(files []File, downloadDir string, wipe bool, enable []string) (commandsFile string, err error) {
208 tmpFile, err := ioutil.TempFile(downloadDir, "ubuntu_commands")
209 if err != nil {
210 return commandsFile, err
211@@ -70,16 +70,23 @@
212 if wipe {
213 writer.WriteString("format data\n")
214 }
215- writer.WriteString(commandsStart)
216- order := func(f1, f2 *File) bool {
217- return f1.Order < f2.Order
218- }
219- By(order).Sort(files)
220- for _, file := range files {
221- writer.WriteString(
222- fmt.Sprintf("update %s %s\n", filepath.Base(file.Path), filepath.Base(file.Signature)))
223- }
224- writer.WriteString("unmount system\n")
225+ if files != nil {
226+ writer.WriteString(commandsStart)
227+ order := func(f1, f2 *File) bool {
228+ return f1.Order < f2.Order
229+ }
230+ By(order).Sort(files)
231+ for _, file := range files {
232+ writer.WriteString(
233+ fmt.Sprintf("update %s %s\n", filepath.Base(file.Path), filepath.Base(file.Signature)))
234+ }
235+ writer.WriteString("unmount system\n")
236+ }
237+
238+ //we cannot enable "things" outside of userdata
239+ for i := range enable {
240+ writer.WriteString(fmt.Sprintf("enable %s\n", enable[i]))
241+ }
242 return tmpFile.Name(), err
243 }
244

Subscribers

People subscribed via source and target branches