~sergiusens/goget-ubuntu-touch/snappy-catchup

« back to all changes in this revision

Viewing changes to diskimage/core_grub.go

  • Committer: Snappy Tarmac
  • Author(s): Sergio Schvezov
  • Date: 2015-07-03 19:12:24 UTC
  • mfrom: (181.7.4 legacyUpdateGrub)
  • Revision ID: snappy_tarmac-20150703191224-au0zyolbz4g7d66p
Separate grub setup logic as legacy(15.04). by sergiusens approved by chipaca

Show diffs side-by-side

added added

removed removed

Lines of Context:
33
33
 
34
34
type CoreGrubImage struct {
35
35
        BaseImage
 
36
 
 
37
        legacyGrub bool
36
38
}
37
39
 
38
 
func NewCoreGrubImage(location string, size int64, rootSize int, hw HardwareDescription, oem OemDescription) *CoreGrubImage {
 
40
func NewCoreGrubImage(location string, size int64, rootSize int, hw HardwareDescription, oem OemDescription, updateGrub bool) *CoreGrubImage {
39
41
        return &CoreGrubImage{
40
 
                BaseImage{
 
42
                BaseImage: BaseImage{
41
43
                        location:  location,
42
44
                        size:      size,
43
45
                        rootSize:  rootSize,
45
47
                        oem:       oem,
46
48
                        partCount: 5,
47
49
                },
 
50
                legacyGrub: updateGrub,
48
51
        }
49
52
}
50
53
 
85
88
}
86
89
 
87
90
func (img *CoreGrubImage) SetupBoot() error {
 
91
        return img.setupGrub()
 
92
}
 
93
 
 
94
func (img *CoreGrubImage) setupGrub() error {
88
95
        for _, dev := range []string{"dev", "proc", "sys"} {
89
96
                src := filepath.Join("/", dev)
90
97
                dst := filepath.Join(img.System(), dev)
136
143
        }
137
144
 
138
145
        bootGrubDir := filepath.Join(img.System(), "boot", "grub")
139
 
 
140
146
        if err := bindMount(efiGrubDir, bootGrubDir); err != nil {
141
147
                return err
142
148
        }
179
185
                return err
180
186
        }
181
187
 
 
188
        if img.legacyGrub {
 
189
                if err := img.updateGrub(); err != nil {
 
190
                        return err
 
191
                }
 
192
        }
 
193
 
 
194
        return nil
 
195
}
 
196
 
 
197
func (img *CoreGrubImage) updateGrub() error {
182
198
        // ensure we run not into recordfail issue
183
199
        grubDir := filepath.Join(img.System(), "etc", "default", "grub.d")
184
200
        if err := os.MkdirAll(grubDir, 0755); err != nil {