Permalink
Browse files

Add package (pkg) resource

This is based on PackageKit, which means events, *and* we automatically
get support for any of the backends that PackageKit supports. This means
dpkg, and rpm are both first class citizens! Many other backends will
surely work, although thorough testing is left as an exercise to the
reader, or to someone who would like to write more test cases!

Unfortunately at the moment, there are a few upstream PackageKit bugs
which cause us issues, but those have been apparently resolved upstream.
If you experience issues with an old version of PackageKit, test if it
is working correctly before blaming mgmt :)

In parallel, mgmt might increase the testing surface for PackageKit, so
hopefully this makes it more robust for everyone involved!

Lastly, I'd like to point out that many great things that are typically
used for servers do start in the GNOME desktop world. Help support your
GNOME GNU/Linux desktop today!
  • Loading branch information...
1 parent 82ff342 commit 3b5678dd91945427b0fb8a86992c7d9117819ff6 @purpleidea committed Feb 21, 2016
Showing with 937 additions and 1 deletion.
  1. +14 −0 config.go
  2. +7 −0 examples/pkg1.yaml
  3. +7 −0 examples/pkg2.yaml
  4. +20 −0 misc.go
  5. +479 −0 packagekit.go
  6. +302 −0 pkg.go
  7. +52 −0 test/omv/pkg1a.yaml
  8. +52 −0 test/omv/pkg1b.yaml
  9. +4 −1 test/test-omv.sh
View
@@ -45,6 +45,7 @@ type GraphConfig struct {
Graph string `yaml:"graph"`
Resources struct {
Noop []NoopRes `yaml:"noop"`
+ Pkg []PkgRes `yaml:"pkg"`
File []FileRes `yaml:"file"`
Svc []SvcRes `yaml:"svc"`
Exec []ExecRes `yaml:"exec"`
@@ -94,12 +95,14 @@ func ParseConfigFromFile(filename string) *GraphConfig {
func UpdateGraphFromConfig(config *GraphConfig, hostname string, g *Graph, etcdO *EtcdWObject) bool {
var NoopMap = make(map[string]*Vertex)
+ var PkgMap = make(map[string]*Vertex)
var FileMap = make(map[string]*Vertex)
var SvcMap = make(map[string]*Vertex)
var ExecMap = make(map[string]*Vertex)
var lookup = make(map[string]map[string]*Vertex)
lookup["noop"] = NoopMap
+ lookup["pkg"] = PkgMap
lookup["file"] = FileMap
lookup["svc"] = SvcMap
lookup["exec"] = ExecMap
@@ -121,6 +124,17 @@ func UpdateGraphFromConfig(config *GraphConfig, hostname string, g *Graph, etcdO
keep = append(keep, v) // append
}
+ for _, t := range config.Resources.Pkg {
+ obj := NewPkgRes(t.Name, t.State, false, false, false)
+ v := g.GetVertexMatch(obj)
+ if v == nil { // no match found
+ v = NewVertex(obj)
+ g.AddVertex(v) // call standalone in case not part of an edge
+ }
+ PkgMap[obj.Name] = v // used for constructing edges
+ keep = append(keep, v) // append
+ }
+
for _, t := range config.Resources.File {
// XXX: should we export based on a @@ prefix, or a metaparam
// like exported => true || exported => (host pattern)||(other pattern?)
View
@@ -0,0 +1,7 @@
+---
+graph: mygraph
+resources:
+ pkg:
+ - name: powertop
+ state: installed
+edges: []
View
@@ -0,0 +1,7 @@
+---
+graph: mygraph
+resources:
+ pkg:
+ - name: powertop
+ state: uninstalled
+edges: []
View
@@ -21,6 +21,7 @@ import (
"bytes"
"encoding/base64"
"encoding/gob"
+ "github.com/godbus/dbus"
"path"
"strings"
"time"
@@ -120,3 +121,22 @@ func TimeAfterOrBlock(t int) <-chan time.Time {
}
return time.After(time.Duration(t) * time.Second)
}
+
+// making using the private bus usable, should be upstream:
+// TODO: https://github.com/godbus/dbus/issues/15
+func SystemBusPrivateUsable() (conn *dbus.Conn, err error) {
+ conn, err = dbus.SystemBusPrivate()
+ if err != nil {
+ return nil, err
+ }
+ if err = conn.Auth(nil); err != nil {
+ conn.Close()
+ conn = nil
+ return
+ }
+ if err = conn.Hello(); err != nil {
+ conn.Close()
+ conn = nil
+ }
+ return conn, nil // success
+}
Oops, something went wrong.

0 comments on commit 3b5678d

Please sign in to comment.