本文整理汇总了Golang中v/io/jiri/profiles.DB类的典型用法代码示例。如果您正苦于以下问题:Golang DB类的具体用法?Golang DB怎么用?Golang DB使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了DB类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: Uninstall
func (eg *exampleManager) Uninstall(jirix *jiri.X, pdb *profiles.DB, root jiri.RelPath, target profiles.Target) error {
version, err := eg.versionInfo.Select(target.Version())
if err != nil {
return err
}
dir := eg.filename(root, target).Abs(jirix)
if err := jirix.NewSeq().WriteFile(filepath.Join(dir, "version"), []byte(version), profilesutil.DefaultFilePerm).
WriteFile(filepath.Join(dir, version), []byte(version), profilesutil.DefaultFilePerm).
Remove(filepath.Join(dir, version)).
Done(); err != nil {
return err
}
if pdb.RemoveProfileTarget(eg.installer, eg.name, target) {
eg.profile = nil
}
return nil
}
示例2: Install
func (eg *exampleManager) Install(jirix *jiri.X, pdb *profiles.DB, root jiri.RelPath, target profiles.Target) error {
version, err := eg.versionInfo.Select(target.Version())
if err != nil {
return err
}
target.SetVersion(version)
dir := eg.filename(root, target).Abs(jirix)
if err := jirix.NewSeq().
MkdirAll(dir, profilesutil.DefaultDirPerm).
WriteFile(filepath.Join(dir, "version"), []byte(version), profilesutil.DefaultFilePerm).
WriteFile(filepath.Join(dir, version), []byte(version), profilesutil.DefaultFilePerm).
Done(); err != nil {
return err
}
eg.profile = pdb.InstallProfile(eg.installer, eg.name, string(root))
target.InstallationDir = string(root)
return pdb.AddProfileTarget(eg.installer, eg.name, target)
}
示例3: cleanupGC
func cleanupGC(jirix *jiri.X, db *profiles.DB, root jiri.RelPath, verbose bool, name string) error {
mgr := profilesmanager.LookupManager(name)
if mgr == nil {
fmt.Fprintf(jirix.Stderr(), "%s is not linked into this binary\n", name)
return nil
}
vi := mgr.VersionInfo()
installer, profileName := profiles.SplitProfileName(name)
profile := db.LookupProfile(installer, profileName)
for _, target := range profile.Targets() {
if vi.IsTargetOlderThanDefault(target.Version()) {
err := mgr.Uninstall(jirix, db, root, *target)
logResult(jirix, "Cleanup: -gc", mgr, *target, err)
if err != nil {
return err
}
}
}
return nil
}
示例4: writeDB
func writeDB(jirix *jiri.X, db *profiles.DB, installer, path string) error {
// Do nothing if the installer is not supplied. This will generally
// happen when/if writeDB is called from the top-level profile driver
// command rather than from a subcommand.
if installer == "" {
return nil
}
fi, err := os.Stat(path)
if err != nil {
if !os.IsNotExist(err) {
return err
}
// New setup, but the directory doesn't exist yet.
if err := os.MkdirAll(path, os.FileMode(0755)); err != nil {
return err
}
} else {
if !fi.IsDir() {
return fmt.Errorf("%s exists but is not a directory", path)
}
}
// New setup with installers writing their own file in a directory
return db.Write(jirix, installer, path)
}
示例5: ensureAction
// ensureAction ensures that the requested profile and target
// is installed/uninstalled, installing/uninstalling it if and only if necessary.
func ensureAction(jirix *jiri.X, pdb *profiles.DB, action profiles.Action, installer, profile string, root jiri.RelPath, target profiles.Target) error {
verb := ""
switch action {
case profiles.Install:
verb = "install"
case profiles.Uninstall:
verb = "uninstall"
default:
return fmt.Errorf("unrecognised action %v", action)
}
if jirix.Verbose() {
fmt.Fprintf(jirix.Stdout(), "%s %v %s\n", verb, action, target)
}
if t := pdb.LookupProfileTarget(installer, profile, target); t != nil {
if jirix.Verbose() {
fmt.Fprintf(jirix.Stdout(), "%v %v is already %sed as %v\n", profile, target, verb, t)
}
return nil
}
mgr := LookupManager(profiles.QualifiedProfileName(installer, profile))
if mgr == nil {
return fmt.Errorf("profile %v is not supported", profile)
}
version, err := mgr.VersionInfo().Select(target.Version())
if err != nil {
return err
}
target.SetVersion(version)
if jirix.Verbose() {
fmt.Fprintf(jirix.Stdout(), "%s %s %s\n", verb, profile, target.DebugString())
}
if action == profiles.Install {
return mgr.Install(jirix, pdb, root, target)
}
return mgr.Uninstall(jirix, pdb, root, target)
}
示例6: addProfileAndTargets
func addProfileAndTargets(t *testing.T, pdb *profiles.DB, name string) {
t1, _ := profiles.NewTarget("[email protected]", "A=B,C=D")
t2, _ := profiles.NewTarget("[email protected]", "A=B,C=D")
pdb.InstallProfile("test", name, "")
if err := pdb.AddProfileTarget("test", name, t1); err != nil {
t.Fatal(err)
}
t2.InstallationDir = "bar"
if err := pdb.AddProfileTarget("test", name, t2); err != nil {
t.Fatal(err)
}
}
示例7: cleanupRmAll
func cleanupRmAll(jirix *jiri.X, db *profiles.DB, root jiri.RelPath) error {
s := jirix.NewSeq()
if err := s.AssertFileExists(db.Path()).Remove(db.Path()).Done(); err != nil && !runutil.IsNotExist(err) {
return err
} else {
if err := s.AssertDirExists(db.Path()).RemoveAll(db.Path()).Done(); err != nil && !runutil.IsNotExist(err) {
return err
}
}
d := root.Abs(jirix)
err := s.AssertDirExists(d).
Run("chmod", "-R", "u+w", d).
RemoveAll(d).
Done()
if err == nil || runutil.IsNotExist(err) {
fmt.Fprintf(jirix.Stdout(), "success\n")
return nil
} else {
fmt.Fprintf(jirix.Stdout(), "%v\n", err)
}
return err
}
示例8: Uninstall
func (p *myNewProfileMgr) Uninstall(jirix *jiri.X, pdb *profiles.DB, root jiri.RelPath, target profiles.Target) error {
if pdb.RemoveProfileTarget(p.name, "", target) {
p.profile = nil
}
return nil
}
示例9: Install
func (p *myNewProfileMgr) Install(jirix *jiri.X, pdb *profiles.DB, root jiri.RelPath, target profiles.Target) error {
p.profile = pdb.InstallProfile(p.name, "", "root")
return pdb.AddProfileTarget(p.name, "", target)
}