Left: | ||
Right: |
LEFT | RIGHT |
---|---|
1 // Copyright 2013 Canonical Ltd. | 1 // Copyright 2013 Canonical Ltd. |
2 // Licensed under the AGPLv3, see LICENCE file for details. | 2 // Licensed under the AGPLv3, see LICENCE file for details. |
3 | 3 |
4 package sshinit | 4 package sshinit |
5 | 5 |
6 import ( | 6 import ( |
7 "fmt" | 7 "fmt" |
8 "io" | 8 "io" |
9 "strings" | 9 "strings" |
10 | 10 |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
134 // PPA keys are obtained by add-apt-repository, from launchpad. | 134 // PPA keys are obtained by add-apt-repository, from launchpad. |
135 if !strings.HasPrefix(src.Source, "ppa:") { | 135 if !strings.HasPrefix(src.Source, "ppa:") { |
136 if src.Key != "" { | 136 if src.Key != "" { |
137 key := utils.ShQuote(src.Key) | 137 key := utils.ShQuote(src.Key) |
138 cmd := fmt.Sprintf("printf '%%s\\n' %s | apt-key add -", key) | 138 cmd := fmt.Sprintf("printf '%%s\\n' %s | apt-key add -", key) |
139 cmds = append(cmds, cmd) | 139 cmds = append(cmds, cmd) |
140 } | 140 } |
141 } | 141 } |
142 cmds = append(cmds, cloudinit.LogProgressCmd("Adding apt reposit ory: %s", src.Source)) | 142 cmds = append(cmds, cloudinit.LogProgressCmd("Adding apt reposit ory: %s", src.Source)) |
143 cmds = append(cmds, "add-apt-repository -y "+utils.ShQuote(src.S ource)) | 143 cmds = append(cmds, "add-apt-repository -y "+utils.ShQuote(src.S ource)) |
144 if src.Prefs != nil { | 144 if src.Prefs != nil { |
axw
2014/02/12 01:25:42
Is there a good reason to duplicate this logic her
dimitern
2014/02/12 08:49:36
This is due to the fact that runcmds are run after
| |
145 path := utils.ShQuote(src.Prefs.Path) | 145 path := utils.ShQuote(src.Prefs.Path) |
146 » » » contents := utils.ShQuote(fmt.Sprintf( | 146 » » » contents := utils.ShQuote(src.Prefs.FileContents()) |
147 » » » » cloudinit.AptPreferencesTemplate, | |
148 » » » » src.Prefs.Explanation, | |
149 » » » » src.Prefs.Package, | |
150 » » » » src.Prefs.Pin, | |
151 » » » » src.Prefs.PinPriority, | |
152 » » » )) | |
153 cmds = append(cmds, "install -D -m 644 /dev/null "+path) | 147 cmds = append(cmds, "install -D -m 644 /dev/null "+path) |
154 cmds = append(cmds, `printf '%s\n' `+contents+` > `+path ) | 148 cmds = append(cmds, `printf '%s\n' `+contents+` > `+path ) |
155 } | 149 } |
156 } | 150 } |
157 if len(cfg.AptSources()) > 0 || cfg.AptUpdate() { | 151 if len(cfg.AptSources()) > 0 || cfg.AptUpdate() { |
158 cmds = append(cmds, cloudinit.LogProgressCmd("Running apt-get up date")) | 152 cmds = append(cmds, cloudinit.LogProgressCmd("Running apt-get up date")) |
159 cmds = append(cmds, aptget+"update") | 153 cmds = append(cmds, aptget+"update") |
160 } | 154 } |
161 if cfg.AptUpgrade() { | 155 if cfg.AptUpgrade() { |
162 cmds = append(cmds, cloudinit.LogProgressCmd("Running apt-get up grade")) | 156 cmds = append(cmds, cloudinit.LogProgressCmd("Running apt-get up grade")) |
(...skipping 28 matching lines...) Expand all Loading... | |
191 } | 185 } |
192 result = append(result, strings.Join(cmd, " ")) | 186 result = append(result, strings.Join(cmd, " ")) |
193 case string: | 187 case string: |
194 result = append(result, cmd) | 188 result = append(result, cmd) |
195 default: | 189 default: |
196 return nil, fmt.Errorf("unexpected command type: %T", cm d) | 190 return nil, fmt.Errorf("unexpected command type: %T", cm d) |
197 } | 191 } |
198 } | 192 } |
199 return result, nil | 193 return result, nil |
200 } | 194 } |
LEFT | RIGHT |