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
1=== modified file 'diskimage/image.go'
2--- diskimage/image.go 2014-11-28 12:28:57 +0000
3+++ diskimage/image.go 2014-12-08 15:13:36 +0000
4@@ -130,22 +130,16 @@
5 }
6
7 //System returns the system path
8-func (img *DiskImage) System() ([]string, error) {
9+func (img *DiskImage) System() (string, error) {
10 if img.parts == nil {
11- return nil, errors.New("img is not setup with partitions")
12+ return "", errors.New("img is not setup with partitions")
13 }
14
15 if img.Mountpoint == "" {
16- return nil, errors.New("img not mounted")
17- }
18-
19- paths := []string{filepath.Join(img.Mountpoint, string(systemADir))}
20-
21- if len(img.parts) == 3 {
22- paths = append(paths, filepath.Join(img.Mountpoint, string(systemBDir)))
23- }
24-
25- return paths, nil
26+ return "", errors.New("img not mounted")
27+ }
28+
29+ return filepath.Join(img.Mountpoint, string(systemADir)), nil
30 }
31
32 //Mount the DiskImage
33
34=== modified file 'ubuntu-device-flash/core.go'
35--- ubuntu-device-flash/core.go 2014-12-04 20:56:49 +0000
36+++ ubuntu-device-flash/core.go 2014-12-08 15:13:36 +0000
37@@ -52,8 +52,10 @@
38 Keyboard string `long:"keyboard-layout" description:"Specify the keyboard layout" default:"us"`
39 Output string `long:"output" short:"o" description:"Name of the image file to create" required:"true"`
40 Size int64 `long:"size" short:"s" description:"Size of image file to create in GB (min 6)" default:"20"`
41- DeveloperMode bool `long:"developer-mode" description:"Finds the latest public key in your ~/.ssh and sets it up"`
42+ DeveloperMode bool `long:"developer-mode" description:"Finds the latest public key in your ~/.ssh and sets it up using cloud-init"`
43 Single bool `long:"single-partition" description:"Sets up a single system partiton"`
44+ EnableSsh bool `long:"enable-ssh" description:"Enable ssh on the image through cloud-init(not need with developer mode)"`
45+ Cloud bool `long:"cloud" description:"Generate a pure cloud image without setting up cloud-init"`
46 }
47
48 var coreCmd CoreCmd
49@@ -75,6 +77,10 @@
50 `
51
52 func (coreCmd *CoreCmd) Execute(args []string) error {
53+ if coreCmd.EnableSsh && coreCmd.Cloud {
54+ return errors.New("--cloud and --enable-ssh cannot be used together")
55+ }
56+
57 if syscall.Getuid() != 0 {
58 return errors.New("command requires sudo/pkexec (root)")
59 }
60@@ -212,25 +218,11 @@
61 }
62 }
63
64- systemPaths, err := img.System()
65- if err != nil {
66- return err
67- }
68-
69 userPath, err := img.User()
70 if err != nil {
71 return err
72 }
73
74- if !coreCmd.Single {
75- src := fmt.Sprintf("%s/system/.", img.Mountpoint)
76- dst := fmt.Sprintf("%s/system-b", img.Mountpoint)
77- cmd := exec.Command("cp", "-r", "--preserve=all", src, dst)
78- if out, err := cmd.CombinedOutput(); err != nil {
79- return fmt.Errorf("failed to replicate image contents: %s", out)
80- }
81- }
82-
83 for _, dir := range []string{"system-data", "cache"} {
84 dirPath := filepath.Join(userPath, dir)
85 if err := os.Mkdir(dirPath, 0755); err != nil {
86@@ -238,24 +230,29 @@
87 }
88 }
89
90- cloudBaseDir := filepath.Join("var", "lib", "cloud")
91-
92- for i := range systemPaths {
93- if err := coreCmd.setupBootloader(systemPaths[i]); err != nil {
94- return err
95- }
96-
97- if err := coreCmd.setupKeyboardLayout(systemPaths[i]); err != nil {
98- return err
99- }
100-
101- if err := os.MkdirAll(filepath.Join(systemPaths[i], cloudBaseDir), 0755); err != nil {
102- return err
103- }
104- }
105-
106- if err := coreCmd.setupCloudInit(cloudBaseDir, filepath.Join(userPath, "system-data")); err != nil {
107- return err
108+ systemPath, err := img.System()
109+ if err != nil {
110+ return err
111+ }
112+
113+ if err := coreCmd.setupBootloader(systemPath); err != nil {
114+ return err
115+ }
116+
117+ if err := coreCmd.setupKeyboardLayout(systemPath); err != nil {
118+ return err
119+ }
120+
121+ if !coreCmd.Cloud {
122+ cloudBaseDir := filepath.Join("var", "lib", "cloud")
123+
124+ if err := os.MkdirAll(filepath.Join(systemPath, cloudBaseDir), 0755); err != nil {
125+ return err
126+ }
127+
128+ if err := coreCmd.setupCloudInit(cloudBaseDir, filepath.Join(userPath, "system-data")); err != nil {
129+ return err
130+ }
131 }
132
133 return nil
134@@ -306,7 +303,7 @@
135 return err
136 }
137
138- if coreCmd.DeveloperMode {
139+ if coreCmd.DeveloperMode || coreCmd.EnableSsh {
140 if _, err := io.WriteString(userDataFile, "snappy:\n ssh_enabled: True\n"); err != nil {
141 return err
142 }

Subscribers

People subscribed via source and target branches