Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lxd-to-incus: Support Void Linux #511

Merged
merged 1 commit into from
Feb 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cmd/lxd-to-incus/sources.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,6 @@ var sources = []source{
&srcSnap{},
&srcDeb{},
&srcCOPR{},
&srcXbps{},
&srcManual{},
}
56 changes: 56 additions & 0 deletions cmd/lxd-to-incus/sources_xbps.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
package main

import (
"github.com/lxc/incus/client"
"github.com/lxc/incus/shared/subprocess"
"github.com/lxc/incus/shared/util"
)

type srcXbps struct{}

func (s *srcXbps) present() bool {
if !util.PathExists("/var/db/xbps/.lxd-files.plist") {
return false
}

if !util.PathExists("/var/service/lxd") {
return false
}

if !util.PathExists("/var/lib/lxd/unix.socket") {
return false
}

return true
}

func (s *srcXbps) name() string {
return "xbps"
}

func (s *srcXbps) stop() error {
_, err := subprocess.RunCommand("sv", "stop", "lxd")
return err
}

func (s *srcXbps) start() error {
_, err := subprocess.RunCommand("sv", "start", "lxd")
return err
}

func (s *srcXbps) purge() error {
_, err := subprocess.RunCommand("xbps-remove", "-R", "-y", "lxd")
return err
}

func (s *srcXbps) connect() (incus.InstanceServer, error) {
return incus.ConnectIncusUnix("/var/lib/lxd/unix.socket", &incus.ConnectionArgs{SkipGetServer: true})
}

func (s *srcXbps) paths() (*daemonPaths, error) {
return &daemonPaths{
daemon: "/var/lib/lxd",
logs: "/var/log/lxd",
cache: "/var/cache/lxd",
}, nil
}
2 changes: 1 addition & 1 deletion cmd/lxd-to-incus/targets.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ type target interface {
name() string
}

var targets = []target{&targetSystemd{}, &targetOpenRC{}}
var targets = []target{&targetSystemd{}, &targetOpenRC{}, &targetXbps{}}
60 changes: 60 additions & 0 deletions cmd/lxd-to-incus/targets_xbps.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
package main

import (
"time"

"github.com/lxc/incus/client"
"github.com/lxc/incus/shared/subprocess"
"github.com/lxc/incus/shared/util"
)

type targetXbps struct{}

func (s *targetXbps) present() bool {
if !util.PathExists("/var/db/xbps/.incus-files.plist") {
return false
}

if !util.PathExists("/var/service/incus") {
return false
}

if !util.PathExists("/var/lib/incus/unix.socket") {
return false
}

return true
}

func (s *targetXbps) stop() error {
_, err := subprocess.RunCommand("sv", "stop", "incus")
return err
}

func (s *targetXbps) start() error {
_, err := subprocess.RunCommand("sv", "start", "incus")
if err != nil {
return err
}

// Wait for the socket to become available.
time.Sleep(5 * time.Second)

return nil
}

func (s *targetXbps) connect() (incus.InstanceServer, error) {
return incus.ConnectIncusUnix("/var/lib/incus/unix.socket", &incus.ConnectionArgs{SkipGetServer: true})
}

func (s *targetXbps) paths() (*daemonPaths, error) {
return &daemonPaths{
daemon: "/var/lib/incus",
logs: "/var/log/incus",
cache: "/var/cache/incus",
}, nil
}

func (s *targetXbps) name() string {
return "xbps"
}
Loading