1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98
|
// -*- Mode: Go; indent-tabs-mode: t -*-
/*
* Copyright (C) 2017 Canonical Ltd
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 3 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
package bootloader
import (
"os"
"path/filepath"
"github.com/snapcore/snapd/bootloader/androidbootenv"
"github.com/snapcore/snapd/osutil"
"github.com/snapcore/snapd/snap"
)
type androidboot struct {
rootdir string
}
// newAndroidboot creates a new Androidboot bootloader object
func newAndroidBoot(rootdir string, _ *Options) Bootloader {
a := &androidboot{rootdir: rootdir}
return a
}
func (a *androidboot) Name() string {
return "androidboot"
}
func (a *androidboot) dir() string {
if a.rootdir == "" {
panic("internal error: unset rootdir")
}
return filepath.Join(a.rootdir, "/boot/androidboot")
}
func (a *androidboot) InstallBootConfig(gadgetDir string, opts *Options) error {
gadgetFile := filepath.Join(gadgetDir, a.Name()+".conf")
systemFile := a.configFile()
return genericInstallBootConfig(gadgetFile, systemFile)
}
func (a *androidboot) Present() (bool, error) {
return osutil.FileExists(a.configFile()), nil
}
func (a *androidboot) configFile() string {
return filepath.Join(a.dir(), "androidboot.env")
}
func (a *androidboot) GetBootVars(names ...string) (map[string]string, error) {
env := androidbootenv.NewEnv(a.configFile())
if err := env.Load(); err != nil {
return nil, err
}
out := make(map[string]string, len(names))
for _, name := range names {
out[name] = env.Get(name)
}
return out, nil
}
func (a *androidboot) SetBootVars(values map[string]string) error {
env := androidbootenv.NewEnv(a.configFile())
if err := env.Load(); err != nil && !os.IsNotExist(err) {
return err
}
for k, v := range values {
env.Set(k, v)
}
return env.Save()
}
func (a *androidboot) ExtractKernelAssets(s snap.PlaceInfo, snapf snap.Container) error {
return nil
}
func (a *androidboot) RemoveKernelAssets(s snap.PlaceInfo) error {
return nil
}
|