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

Proposed by Sergio Schvezov on 2015-06-17
Status: Merged
Approved by: John Lenton on 2015-06-18
Approved revision: 200
Merged at revision: 190
Proposed branch: lp:~sergiusens/goget-ubuntu-touch/personalCmd
Merge into: lp:goget-ubuntu-touch
Prerequisite: lp:~sergiusens/goget-ubuntu-touch/sizeMatters
Diff against target: 213 lines (+76/-11)
6 files modified
diskimage/common.go (+1/-0)
diskimage/core_grub.go (+4/-3)
diskimage/core_uboot.go (+2/-1)
ubuntu-device-flash/core.go (+3/-1)
ubuntu-device-flash/personal.go (+43/-0)
ubuntu-device-flash/snappy.go (+23/-6)
To merge this branch: bzr merge lp:~sergiusens/goget-ubuntu-touch/personalCmd
Reviewer Review Type Date Requested Status
John Lenton 2015-06-17 Approve on 2015-06-18
Review via email: mp+262174@code.launchpad.net

Commit Message

Allow creating snappy personal images

Description of the Change

I increased the min size for personal as my original thought of / fitting 2048 was not correct. I set it to 4096, the personal folk can iterate from here

To post a comment you must log in.
197. By Sergio Schvezov on 2015-06-17

Update help for personal's size to 10

198. By Sergio Schvezov on 2015-06-17

Merged sizeMatters into personalCmd.

199. By Sergio Schvezov on 2015-06-17

Merged sizeMatters into personalCmd.

200. By Sergio Schvezov on 2015-06-18

Merged sizeMatters into personalCmd.

John Lenton (chipaca) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'diskimage/common.go'
2--- diskimage/common.go 2015-06-18 20:45:47 +0000
3+++ diskimage/common.go 2015-06-18 20:45:47 +0000
4@@ -171,6 +171,7 @@
5 parts []partition
6 partCount int
7 size int64
8+ rootSize int
9 }
10
11 // Mount mounts the image. This also maps the loop device.
12
13=== modified file 'diskimage/core_grub.go'
14--- diskimage/core_grub.go 2015-06-18 20:45:47 +0000
15+++ diskimage/core_grub.go 2015-06-18 20:45:47 +0000
16@@ -35,11 +35,12 @@
17 BaseImage
18 }
19
20-func NewCoreGrubImage(location string, size int64, hw HardwareDescription, oem OemDescription) *CoreGrubImage {
21+func NewCoreGrubImage(location string, size int64, rootSize int, hw HardwareDescription, oem OemDescription) *CoreGrubImage {
22 return &CoreGrubImage{
23 BaseImage{
24 location: location,
25 size: size,
26+ rootSize: rootSize,
27 hardware: hw,
28 oem: oem,
29 partCount: 5,
30@@ -71,8 +72,8 @@
31
32 parted.addPart(grubLabel, "", fsNone, 4)
33 parted.addPart(bootLabel, bootDir, fsFat32, 64)
34- parted.addPart(systemALabel, systemADir, fsExt4, 1024)
35- parted.addPart(systemBLabel, systemBDir, fsExt4, 1024)
36+ parted.addPart(systemALabel, systemADir, fsExt4, img.rootSize)
37+ parted.addPart(systemBLabel, systemBDir, fsExt4, img.rootSize)
38 parted.addPart(writableLabel, writableDir, fsExt4, -1)
39
40 parted.setBoot(2)
41
42=== modified file 'diskimage/core_uboot.go'
43--- diskimage/core_uboot.go 2015-06-18 20:45:47 +0000
44+++ diskimage/core_uboot.go 2015-06-18 20:45:47 +0000
45@@ -66,13 +66,14 @@
46 Bootloader []string `yaml:"bootloader"`
47 }
48
49-func NewCoreUBootImage(location string, size int64, hw HardwareDescription, oem OemDescription) *CoreUBootImage {
50+func NewCoreUBootImage(location string, size int64, rootSize int, hw HardwareDescription, oem OemDescription) *CoreUBootImage {
51 return &CoreUBootImage{
52 BaseImage{
53 hardware: hw,
54 oem: oem,
55 location: location,
56 size: size,
57+ rootSize: rootSize,
58 partCount: 4,
59 },
60 }
61
62=== modified file 'ubuntu-device-flash/core.go'
63--- ubuntu-device-flash/core.go 2015-06-18 20:45:47 +0000
64+++ ubuntu-device-flash/core.go 2015-06-18 20:45:47 +0000
65@@ -39,7 +39,8 @@
66 }
67
68 type CoreCmd struct {
69- EnableSsh bool `long:"enable-ssh" description:"Enable ssh on the image through cloud-init(not needed with developer mode)"`
70+ EnableSsh bool `long:"enable-ssh" description:"Enable ssh on the image through cloud-init(not needed with developer mode)"`
71+ Size int64 `long:"size" short:"s" description:"Size of image file to create in GB (min 4)" default:"4"`
72
73 Deprecated struct {
74 Cloud bool `long:"cloud" description:"Generate a pure cloud image without setting up cloud-init"`
75@@ -63,6 +64,7 @@
76
77 func (coreCmd *CoreCmd) Execute(args []string) error {
78 coreCmd.flavor = flavorCore
79+ coreCmd.size = coreCmd.Size
80
81 if coreCmd.EnableSsh && coreCmd.Deprecated.Cloud {
82 return errors.New("--cloud and --enable-ssh cannot be used together")
83
84=== added file 'ubuntu-device-flash/personal.go'
85--- ubuntu-device-flash/personal.go 1970-01-01 00:00:00 +0000
86+++ ubuntu-device-flash/personal.go 2015-06-18 20:45:47 +0000
87@@ -0,0 +1,43 @@
88+//
89+// ubuntu-device-flash - Tool to download and flash devices with an Ubuntu Image
90+// based system
91+//
92+// Copyright (c) 2013 Canonical Ltd.
93+//
94+// Written by Sergio Schvezov <sergio.schvezov@canonical.com>
95+//
96+package main
97+
98+// This program is free software: you can redistribute it and/or modify it
99+// under the terms of the GNU General Public License version 3, as published
100+// by the Free Software Foundation.
101+//
102+// This program is distributed in the hope that it will be useful, but
103+// WITHOUT ANY WARRANTY; without even the implied warranties of
104+// MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
105+// PURPOSE. See the GNU General Public License for more details.
106+//
107+// You should have received a copy of the GNU General Public License along
108+// with this program. If not, see <http://www.gnu.org/licenses/>.
109+
110+func init() {
111+ parser.AddCommand("personal",
112+ "Creates ubuntu personal images",
113+ "",
114+ &personalCmd)
115+}
116+
117+type PersonalCmd struct {
118+ Size int64 `long:"size" short:"s" description:"Size of image file to create in GB (min 10)" default:"10"`
119+
120+ Snapper
121+}
122+
123+var personalCmd PersonalCmd
124+
125+func (personalCmd *PersonalCmd) Execute(args []string) error {
126+ personalCmd.flavor = flavorPersonal
127+ personalCmd.size = personalCmd.Size
128+
129+ return personalCmd.create()
130+}
131
132=== modified file 'ubuntu-device-flash/snappy.go'
133--- ubuntu-device-flash/snappy.go 2015-06-18 20:45:47 +0000
134+++ ubuntu-device-flash/snappy.go 2015-06-18 20:45:47 +0000
135@@ -34,11 +34,16 @@
136 type imageFlavor string
137
138 const (
139- minSizePersonal = 8
140+ minSizePersonal = 10
141 minSizeCore = 4
142 )
143
144 const (
145+ rootSizePersonal = 4096
146+ rootSizeCore = 1024
147+)
148+
149+const (
150 flavorPersonal imageFlavor = "personal"
151 flavorCore imageFlavor = "core"
152 )
153@@ -58,10 +63,20 @@
154 }
155 }
156
157+func (f imageFlavor) rootSize() int {
158+ switch f {
159+ case flavorPersonal:
160+ return rootSizePersonal
161+ case flavorCore:
162+ return rootSizeCore
163+ default:
164+ panic("invalid flavor")
165+ }
166+}
167+
168 type Snapper struct {
169 Channel string `long:"channel" description:"Specify the channel to use" default:"stable"`
170 Output string `long:"output" short:"o" description:"Name of the image file to create" required:"true"`
171- Size int64 `long:"size" short:"s" description:"Size of image file to create in GB (min 4)" default:"4"`
172 Oem string `long:"oem" description:"The snappy oem package to base the image out of" default:"generic-amd64"`
173
174 Development struct {
175@@ -79,6 +94,8 @@
176 oem diskimage.OemDescription
177 stagingRootPath string
178
179+ size int64
180+
181 flavor imageFlavor
182 device string
183
184@@ -91,7 +108,7 @@
185 return fmt.Errorf("Giving up, the desired target output file %#v already exists", s.Output)
186 }
187
188- if s.Size < s.flavor.minSize() {
189+ if s.size < s.flavor.minSize() {
190 return fmt.Errorf("minimum size for %s is %d", s.flavor, s.flavor.minSize())
191 }
192
193@@ -270,7 +287,7 @@
194 // Version: "???",
195 },
196 InstallOptions: provisioning.InstallOptions{
197- Size: s.Size,
198+ Size: s.size,
199 SizeUnit: "GB",
200 Output: s.Output,
201 Channel: s.Channel,
202@@ -500,9 +517,9 @@
203 loader := s.oem.OEM.Hardware.Bootloader
204 switch loader {
205 case "grub":
206- s.img = diskimage.NewCoreGrubImage(s.Output, s.Size, s.hardware, s.oem)
207+ s.img = diskimage.NewCoreGrubImage(s.Output, s.size, s.flavor.rootSize(), s.hardware, s.oem)
208 case "u-boot":
209- s.img = diskimage.NewCoreUBootImage(s.Output, s.Size, s.hardware, s.oem)
210+ s.img = diskimage.NewCoreUBootImage(s.Output, s.size, s.flavor.rootSize(), s.hardware, s.oem)
211 default:
212 return errors.New("no hardware description in OEM snap")
213 }

Subscribers

People subscribed via source and target branches