schroot

package module
v0.0.0-...-44738c1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 28, 2015 License: MIT Imports: 3 Imported by: 0

README

go-schroot

import "pault.ag/go/schroot"

package main

import (
	"log"

	"pault.ag/go/schroot"
)

func main() {
	chroot, err := schroot.NewSchroot("unstable")
	if err != nil {
		log.Fatalf("%s\n", err)
	}
	defer chroot.End()
	cmd, err := chroot.Command("ls", "/var")
	if err != nil {
		log.Fatalf("%s\n", err)
	}
	out, err := cmd.Output()
	if err != nil {
		log.Fatalf("%s\n", err)
		return
	}
	log.Printf("%s\n", out)

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Schroot

type Schroot struct {
	// contains filtered or unexported fields
}

Schroot object encapsulation. Contains lightweight amounts of state, so it's advised that you pass a pointer to this around.

func NewSchroot

func NewSchroot(name string) (*Schroot, error)

Create a new schroot based on the chroot name. To get an idea of what chroots exist on the system, run `schroot -l --all-chroots`.

func (*Schroot) Command

func (schroot *Schroot) Command(cmd string, args ...string) (*exec.Cmd, error)

Create a os/exec.Cmd to run the command inside the schroot chroot. Keep in mind that we're not currently smart enough to deal with things like the enviorn in a native way, so don't get too cute.

func (*Schroot) End

func (schroot *Schroot) End() error

Close the schroot session, killing the open session from schroot. To see how many you've left open because you forgot to call this method, run `schroot -l --all-sessions`. To close them, run `schroot -e -c session:xxxx` (where session:xxxx is the name, as seen in schroot -l output)

It's advised that you `defer` this whenever creating a new schroot.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL