本文整理汇总了Golang中github.com/snapcore/snapd/asserts.Model类的典型用法代码示例。如果您正苦于以下问题:Golang Model类的具体用法?Golang Model怎么用?Golang Model使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Model类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: downloadUnpackGadget
func downloadUnpackGadget(sto Store, model *asserts.Model, opts *Options, local *localInfos) error {
if err := os.MkdirAll(opts.GadgetUnpackDir, 0755); err != nil {
return fmt.Errorf("cannot create gadget unpack dir %q: %s", opts.GadgetUnpackDir, err)
}
dlOpts := &DownloadOptions{
TargetDir: opts.GadgetUnpackDir,
Channel: opts.Channel,
}
snapFn, _, err := acquireSnap(sto, model.Gadget(), dlOpts, local)
if err != nil {
return err
}
// FIXME: jumping through layers here, we need to make
// unpack part of the container interface (again)
snap := squashfs.New(snapFn)
return snap.Unpack("*", opts.GadgetUnpackDir)
}
开发者ID:pedronis,项目名称:snappy,代码行数:18,代码来源:image.go
示例2: makeStore
func makeStore(model *asserts.Model) Store {
cfg := store.DefaultConfig()
cfg.Architecture = model.Architecture()
cfg.Series = model.Series()
cfg.StoreID = model.Store()
return store.New(cfg, nil)
}
开发者ID:pedronis,项目名称:snappy,代码行数:7,代码来源:image.go
示例3: bootstrapToRootDir
func bootstrapToRootDir(sto Store, model *asserts.Model, opts *Options, local *localInfos) error {
// FIXME: try to avoid doing this
if opts.RootDir != "" {
dirs.SetRootDir(opts.RootDir)
defer dirs.SetRootDir("/")
}
// sanity check target
if osutil.FileExists(dirs.SnapStateFile) {
return fmt.Errorf("cannot bootstrap over existing system")
}
// TODO: developer database in home or use snapd (but need
// a bit more API there, potential issues when crossing stores/series)
db, err := asserts.OpenDatabase(&asserts.DatabaseConfig{
Backstore: asserts.NewMemoryBackstore(),
Trusted: sysdb.Trusted(),
})
if err != nil {
return err
}
f := makeFetcher(sto, &DownloadOptions{}, db)
if err := f.Save(model); err != nil {
if !osutil.GetenvBool("UBUNTU_IMAGE_SKIP_COPY_UNVERIFIED_MODEL") {
return fmt.Errorf("cannot fetch and check prerequisites for the model assertion: %v", err)
} else {
logger.Noticef("Cannot fetch and check prerequisites for the model assertion, it will not be copied into the image: %v", err)
f.addedRefs = nil
}
}
// put snaps in place
if err := os.MkdirAll(dirs.SnapBlobDir, 0755); err != nil {
return err
}
snapSeedDir := filepath.Join(dirs.SnapSeedDir, "snaps")
assertSeedDir := filepath.Join(dirs.SnapSeedDir, "assertions")
dlOpts := &DownloadOptions{
TargetDir: snapSeedDir,
Channel: opts.Channel,
DevMode: false, // XXX: should this be true?
}
for _, d := range []string{snapSeedDir, assertSeedDir} {
if err := os.MkdirAll(d, 0755); err != nil {
return err
}
}
snaps := []string{}
// core,kernel,gadget first
snaps = append(snaps, local.PreferLocal(defaultCore))
snaps = append(snaps, local.PreferLocal(model.Kernel()))
snaps = append(snaps, local.PreferLocal(model.Gadget()))
// then required and the user requested stuff
for _, snapName := range model.RequiredSnaps() {
snaps = append(snaps, local.PreferLocal(snapName))
}
snaps = append(snaps, opts.Snaps...)
seen := make(map[string]bool)
downloadedSnapsInfo := map[string]*snap.Info{}
var seedYaml snap.Seed
for _, snapName := range snaps {
name := local.Name(snapName)
if seen[name] {
fmt.Fprintf(Stdout, "%s already prepared, skipping\n", name)
continue
}
if name != snapName {
fmt.Fprintf(Stdout, "Copying %q (%s)\n", snapName, name)
} else {
fmt.Fprintf(Stdout, "Fetching %s\n", snapName)
}
fn, info, err := acquireSnap(sto, name, dlOpts, local)
if err != nil {
return err
}
seen[name] = true
// if it comes from the store fetch the snap assertions too
// TODO: support somehow including available assertions
// also for local snaps
if info.SnapID != "" {
err = FetchAndCheckSnapAssertions(fn, info, f, db)
if err != nil {
return err
}
}
typ := info.Type
// kernel/os are required for booting
if typ == snap.TypeKernel || typ == snap.TypeOS {
dst := filepath.Join(dirs.SnapBlobDir, filepath.Base(fn))
if err := osutil.CopyFile(fn, dst, 0); err != nil {
//.........这里部分代码省略.........
开发者ID:pedronis,项目名称:snappy,代码行数:101,代码来源:image.go
注:本文中的github.com/snapcore/snapd/asserts.Model类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论