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

Proposed by Sergio Schvezov
Status: Rejected
Rejected by: Sergio Schvezov
Proposed branch: lp:~sergiusens/goget-ubuntu-touch/extra_options
Merge into: lp:goget-ubuntu-touch
Diff against target: 142 lines (+37/-46)
2 files modified
diskimage/image.go (+6/-12)
ubuntu-device-flash/core.go (+31/-34)
To merge this branch: bzr merge lp:~sergiusens/goget-ubuntu-touch/extra_options
Reviewer Review Type Date Requested Status
Sergio Schvezov Disapprove
PS Jenkins bot continuous-integration Approve
James Hunt (community) Approve
Review via email: mp+244001@code.launchpad.net

Commit message

ubuntu-device-flash: adding option to only enable ssh and another option to not pre provision cloud data

To post a comment you must log in.
Revision history for this message
James Hunt (jamesodhunt) wrote :

LGTM.

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Sergio Schvezov (sergiusens) wrote :

this seems to have been worked on somewhere else

review: Disapprove

Unmerged revisions

115. By Sergio Schvezov

Adding option to setup only ssh and another one to not provision cloud-init

114. By Sergio Schvezov

empty, unprovisioned formatted system-b

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'diskimage/image.go'
--- diskimage/image.go 2014-11-28 12:28:57 +0000
+++ diskimage/image.go 2014-12-08 15:13:36 +0000
@@ -130,22 +130,16 @@
130}130}
131131
132//System returns the system path132//System returns the system path
133func (img *DiskImage) System() ([]string, error) {133func (img *DiskImage) System() (string, error) {
134 if img.parts == nil {134 if img.parts == nil {
135 return nil, errors.New("img is not setup with partitions")135 return "", errors.New("img is not setup with partitions")
136 }136 }
137137
138 if img.Mountpoint == "" {138 if img.Mountpoint == "" {
139 return nil, errors.New("img not mounted")139 return "", errors.New("img not mounted")
140 }140 }
141141
142 paths := []string{filepath.Join(img.Mountpoint, string(systemADir))}142 return filepath.Join(img.Mountpoint, string(systemADir)), nil
143
144 if len(img.parts) == 3 {
145 paths = append(paths, filepath.Join(img.Mountpoint, string(systemBDir)))
146 }
147
148 return paths, nil
149}143}
150144
151//Mount the DiskImage145//Mount the DiskImage
152146
=== modified file 'ubuntu-device-flash/core.go'
--- ubuntu-device-flash/core.go 2014-12-04 20:56:49 +0000
+++ ubuntu-device-flash/core.go 2014-12-08 15:13:36 +0000
@@ -52,8 +52,10 @@
52 Keyboard string `long:"keyboard-layout" description:"Specify the keyboard layout" default:"us"`52 Keyboard string `long:"keyboard-layout" description:"Specify the keyboard layout" default:"us"`
53 Output string `long:"output" short:"o" description:"Name of the image file to create" required:"true"`53 Output string `long:"output" short:"o" description:"Name of the image file to create" required:"true"`
54 Size int64 `long:"size" short:"s" description:"Size of image file to create in GB (min 6)" default:"20"`54 Size int64 `long:"size" short:"s" description:"Size of image file to create in GB (min 6)" default:"20"`
55 DeveloperMode bool `long:"developer-mode" description:"Finds the latest public key in your ~/.ssh and sets it up"`55 DeveloperMode bool `long:"developer-mode" description:"Finds the latest public key in your ~/.ssh and sets it up using cloud-init"`
56 Single bool `long:"single-partition" description:"Sets up a single system partiton"`56 Single bool `long:"single-partition" description:"Sets up a single system partiton"`
57 EnableSsh bool `long:"enable-ssh" description:"Enable ssh on the image through cloud-init(not need with developer mode)"`
58 Cloud bool `long:"cloud" description:"Generate a pure cloud image without setting up cloud-init"`
57}59}
5860
59var coreCmd CoreCmd61var coreCmd CoreCmd
@@ -75,6 +77,10 @@
75`77`
7678
77func (coreCmd *CoreCmd) Execute(args []string) error {79func (coreCmd *CoreCmd) Execute(args []string) error {
80 if coreCmd.EnableSsh && coreCmd.Cloud {
81 return errors.New("--cloud and --enable-ssh cannot be used together")
82 }
83
78 if syscall.Getuid() != 0 {84 if syscall.Getuid() != 0 {
79 return errors.New("command requires sudo/pkexec (root)")85 return errors.New("command requires sudo/pkexec (root)")
80 }86 }
@@ -212,25 +218,11 @@
212 }218 }
213 }219 }
214220
215 systemPaths, err := img.System()
216 if err != nil {
217 return err
218 }
219
220 userPath, err := img.User()221 userPath, err := img.User()
221 if err != nil {222 if err != nil {
222 return err223 return err
223 }224 }
224225
225 if !coreCmd.Single {
226 src := fmt.Sprintf("%s/system/.", img.Mountpoint)
227 dst := fmt.Sprintf("%s/system-b", img.Mountpoint)
228 cmd := exec.Command("cp", "-r", "--preserve=all", src, dst)
229 if out, err := cmd.CombinedOutput(); err != nil {
230 return fmt.Errorf("failed to replicate image contents: %s", out)
231 }
232 }
233
234 for _, dir := range []string{"system-data", "cache"} {226 for _, dir := range []string{"system-data", "cache"} {
235 dirPath := filepath.Join(userPath, dir)227 dirPath := filepath.Join(userPath, dir)
236 if err := os.Mkdir(dirPath, 0755); err != nil {228 if err := os.Mkdir(dirPath, 0755); err != nil {
@@ -238,24 +230,29 @@
238 }230 }
239 }231 }
240232
241 cloudBaseDir := filepath.Join("var", "lib", "cloud")233 systemPath, err := img.System()
242234 if err != nil {
243 for i := range systemPaths {235 return err
244 if err := coreCmd.setupBootloader(systemPaths[i]); err != nil {236 }
245 return err237
246 }238 if err := coreCmd.setupBootloader(systemPath); err != nil {
247239 return err
248 if err := coreCmd.setupKeyboardLayout(systemPaths[i]); err != nil {240 }
249 return err241
250 }242 if err := coreCmd.setupKeyboardLayout(systemPath); err != nil {
251243 return err
252 if err := os.MkdirAll(filepath.Join(systemPaths[i], cloudBaseDir), 0755); err != nil {244 }
253 return err245
254 }246 if !coreCmd.Cloud {
255 }247 cloudBaseDir := filepath.Join("var", "lib", "cloud")
256248
257 if err := coreCmd.setupCloudInit(cloudBaseDir, filepath.Join(userPath, "system-data")); err != nil {249 if err := os.MkdirAll(filepath.Join(systemPath, cloudBaseDir), 0755); err != nil {
258 return err250 return err
251 }
252
253 if err := coreCmd.setupCloudInit(cloudBaseDir, filepath.Join(userPath, "system-data")); err != nil {
254 return err
255 }
259 }256 }
260257
261 return nil258 return nil
@@ -306,7 +303,7 @@
306 return err303 return err
307 }304 }
308305
309 if coreCmd.DeveloperMode {306 if coreCmd.DeveloperMode || coreCmd.EnableSsh {
310 if _, err := io.WriteString(userDataFile, "snappy:\n ssh_enabled: True\n"); err != nil {307 if _, err := io.WriteString(userDataFile, "snappy:\n ssh_enabled: True\n"); err != nil {
311 return err308 return err
312 }309 }

Subscribers

People subscribed via source and target branches