File: equo.go

package info (click to toggle)
distrobuilder 3.3.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 1,436 kB
  • sloc: sh: 214; makefile: 76
file content (84 lines) | stat: -rw-r--r-- 1,543 bytes parent folder | download | duplicates (3)
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
package managers

import (
	"errors"

	"github.com/lxc/distrobuilder/shared"
)

type equo struct {
	common
}

func (m *equo) load() error {
	m.commands = managerCommands{
		clean:   "equo",
		install: "equo",
		refresh: "equo",
		remove:  "equo",
		update:  "equo",
	}

	m.flags = managerFlags{
		global: []string{},
		clean: []string{
			"cleanup",
		},
		install: []string{
			"install",
		},
		remove: []string{
			"remove",
		},
		refresh: []string{
			"update",
		},
		update: []string{
			"upgrade",
		},
	}

	return nil
}

func (m *equo) manageRepository(repoAction shared.DefinitionPackagesRepository) error {
	switch repoAction.Type {
	case "", "equo":
		return m.equoRepoCaller(repoAction)
	case "enman":
		return m.enmanRepoCaller(repoAction)
	}

	return errors.New("Invalid repository Type")
}

func (m *equo) enmanRepoCaller(repo shared.DefinitionPackagesRepository) error {
	args := []string{
		"add",
	}

	if repo.Name == "" && repo.URL == "" {
		return errors.New("Missing both repository url and repository name")
	}

	if repo.URL != "" {
		args = append(args, repo.URL)
	} else {
		args = append(args, repo.Name)
	}

	return shared.RunCommand(m.ctx, nil, nil, "enman", args...)
}

func (m *equo) equoRepoCaller(repo shared.DefinitionPackagesRepository) error {
	if repo.Name == "" {
		return errors.New("Invalid repository name")
	}

	if repo.URL == "" {
		return errors.New("Invalid repository url")
	}

	return shared.RunCommand(m.ctx, nil, nil, "equo", "repo", "add", "--repo", repo.URL, "--pkg", repo.URL,
		repo.Name)
}