~sergiusens/snappy/uflash

« back to all changes in this revision

Viewing changes to partition/bootloader_grub.go

  • Committer: Sergio Schvezov
  • Date: 2015-07-30 18:46:25 UTC
  • mfrom: (578.1.3 inhibitMore)
  • Revision ID: sergio.schvezov@canonical.com-20150730184625-an1rmlp20eztkxrp
Merged inhibitMore into uflash.

Show diffs side-by-side

added added

removed removed

Lines of Context:
32
32
        bootloaderGrubConfigFileReal = "/boot/grub/grub.cfg"
33
33
        bootloaderGrubEnvFileReal    = "/boot/grub/grubenv"
34
34
 
35
 
        bootloaderGrubEnvCmdReal       = "/usr/bin/grub-editenv"
36
 
        bootloaderGrubTrialBootVarReal = "snappy_trial_boot"
 
35
        bootloaderGrubEnvCmdReal = "/usr/bin/grub-editenv"
37
36
)
38
37
 
39
38
// var to make it testable
40
39
var (
41
 
        bootloaderGrubDir          = bootloaderGrubDirReal
42
 
        bootloaderGrubConfigFile   = bootloaderGrubConfigFileReal
43
 
        bootloaderGrubTrialBootVar = bootloaderGrubTrialBootVarReal
44
 
        bootloaderGrubEnvFile      = bootloaderGrubEnvFileReal
 
40
        bootloaderGrubDir        = bootloaderGrubDirReal
 
41
        bootloaderGrubConfigFile = bootloaderGrubConfigFileReal
 
42
        bootloaderGrubEnvFile    = bootloaderGrubEnvFileReal
45
43
 
46
44
        bootloaderGrubEnvCmd = bootloaderGrubEnvCmdReal
47
45
)
113
111
        return runCommand(bootloaderGrubEnvCmd, bootloaderGrubEnvFile, "set", arg)
114
112
}
115
113
 
116
 
func (g *grub) unsetBootVar(name string) (err error) {
117
 
        return runCommand(bootloaderGrubEnvCmd, bootloaderGrubEnvFile, "unset", name)
118
 
}
119
 
 
120
114
func (g *grub) GetNextBootRootFSName() (label string, err error) {
121
115
        return g.GetBootVar(bootloaderRootfsVar)
122
116
}
123
117
 
124
118
func (g *grub) MarkCurrentBootSuccessful(currentRootfs string) (err error) {
125
 
        // Clear the variable set by grub on boot to denote a good
126
 
        // boot.
127
 
        if err := g.unsetBootVar(bootloaderGrubTrialBootVar); err != nil {
 
119
        // Clear the variable set on boot to denote a good boot.
 
120
        if err := g.setBootVar(bootloaderTrialBootVar, "0"); err != nil {
128
121
                return err
129
122
        }
130
123