summaryrefslogtreecommitdiff
path: root/pkg/otbuiltin/deployment.go
blob: aa540ecac9aedd2b983b9a9eb794f58f037e9a79 (plain)
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
package otbuiltin

import (
	"runtime"
	"unsafe"

	glib "github.com/sjoerdsimons/ostree-go/pkg/glibobject"
)

// #cgo pkg-config: ostree-1
// #include <stdlib.h>
// #include <glib.h>
// #include <ostree.h>
// #include "builtin.go.h"
import "C"

type Deployment struct {
	*glib.Object
}

func wrapDeployment(d *C.OstreeDeployment) *Deployment {
	g := glib.ToGObject(unsafe.Pointer(d))
	obj := &glib.Object{g}
	deployment := &Deployment{obj}

	runtime.SetFinalizer(deployment, (*Deployment).Unref)

	return deployment
}

func (d *Deployment) native() *C.OstreeDeployment {
	if d == nil || d.GObject == nil {
		return nil
	}
	return (*C.OstreeDeployment)(unsafe.Pointer(d.GObject))
}

func (d *Deployment) Osname() string {
	return C.GoString(C.ostree_deployment_get_osname(d.native()))
}

func (d *Deployment) Csum() string {
	return C.GoString(C.ostree_deployment_get_csum(d.native()))
}

func (d *Deployment) Deployserial() int {
	return int(C.ostree_deployment_get_deployserial(d.native()))
}

func (d *Deployment) OriginRelpath() string {
	cstr := C.ostree_deployment_get_origin_relpath(d.native())

	str := C.GoString(cstr)
	C.free(unsafe.Pointer(cstr))

	return str
}