Browse Source

Reformat: Imports acording to gofmt

Fixed: /rpool/boot did not exist
layerset
Till Wegmüller 6 years ago
parent
commit
0a293f58cc
  1. 35
      bootadm/config.go
  2. 10
      bootadm/install.go
  3. 9
      bootadm/update-archive.go
  4. 4
      common/common.go
  5. 9
      daemon/daemon.go
  6. 2
      devprop/devprop.go
  7. 2
      imaged/client.go
  8. 1
      installd/config.go
  9. 7
      installd/copyfile.go
  10. 5
      installd/filesystem.go
  11. 1
      installd/http.go
  12. 17
      installd/install.go
  13. 13
      installd/system_dirs.go
  14. 3
      installd/system_links.go
  15. 9
      main.go
  16. 6
      mount/solaris.go
  17. 3
      samples/install_solnetboot.json
  18. 2
      uname/command.go
  19. 11
      zfs/common.go
  20. 3
      zfs/dataset.go
  21. 5
      zfs/list.go
  22. 7
      zpool/common.go
  23. 5
      zpool/create.go
  24. 3
      zpool/pool.go
  25. 1
      zpool/property.go

35
bootadm/config.go

@ -1,12 +1,12 @@
package bootadm
import (
"github.com/toasterson/opencloud/uname"
"github.com/toasterson/opencloud/installd"
"text/template"
"os"
"fmt"
"bytes"
"fmt"
"os"
"text/template"
"github.com/toasterson/opencloud/uname"
)
const (
@ -14,12 +14,12 @@ const (
BootLoaderTypeGrub = 1
)
const loaderConfFile string = "/%s/boot/menu.lst"
const loaderBootConfig string = `title {.BEName}
bootfs {.RPoolName}/ROOT/{.BEName}`
const loaderConfFile string = "/%s/boot/menu.lst"
const grubConfig string = `default 0
const grubBootConfig string = `default 0
timeout 3
title {.BEName}
findroot (pool_{.RPoolName},0,a)
@ -37,18 +37,28 @@ bootfs {.RPoolName}/ROOT/{.BEName}
kernel$ /platform/i86pc/kernel/amd64/unix -B $ZFS-BOOTFS
module$ /platform/i86pc/amd64/boot_archive`
type loaderType int
type bootLoaderType int
type BootConfig struct {
Type loaderType
RPoolName string
BEName string
BootOptions []string //TODO Implement
}
func CreateBootConfiguration(loaderType bootLoaderType, rootDir string, bootOptions []string, conf *installd.InstallConfiguration) (err error){
func CreateBootConfigurationFiles(rootDir string, conf BootConfig) (err error){
if rootDir == "" {
rootDir = "/"
}
hplatform := uname.GetHardwarePlatform()
config := loaderBootConfig
confLocation := loaderConfFile
if hplatform == uname.HardwarePlatformXen || loaderType == BootLoaderTypeGrub {
config = grubConfig
if hplatform == uname.HardwarePlatformXen {
config = xenBootConfig
confLocation = grubConfFile
} else if conf.Type == BootLoaderTypeGrub {
config = grubBootConfig
confLocation = grubConfFile
}
tmplConfig, err := template.New("BootConfig").Parse(config)
@ -60,6 +70,7 @@ func CreateBootConfiguration(loaderType bootLoaderType, rootDir string, bootOpti
if err != nil {
return
}
os.MkdirAll(fmt.Sprintf("%s/boot", conf.RPoolName), os.ModeDir)
confFile, err := os.Create(fmt.Sprintf(confLocation, conf.RPoolName))
if err != nil {
return

10
bootadm/install.go

@ -7,19 +7,17 @@ import (
const bootadm_bin = "/sbin/bootadm"
func InstallBootLoader(rootDir string, pool string) error {
args := []string{}
args := []string{"install-bootloader"}
if rootDir != "" {
args = append(args, "-R", rootDir)
}
if pool != "" {
args = append(args, "-P", pool)
}
return execBootadmInstall(args)
return execBootadm(args)
}
func execBootadmInstall(args []string) error {
realArgs := []string{"install-bootloader"}
realArgs = append(realArgs, args...)
bootadm := exec.Command(bootadm_bin, realArgs...)
func execBootadm(args []string) error {
bootadm := exec.Command(bootadm_bin, args...)
return bootadm.Run()
}

9
bootadm/update-archive.go

@ -0,0 +1,9 @@
package bootadm
func UpdateBootArchive(rootDir string) error {
args := []string{"update-archive"}
if rootDir != "" && rootDir != "/"{
args = append(args, "-R", rootDir)
}
return execBootadm(args)
}

4
common/common.go

@ -1,10 +1,10 @@
package common
import (
"errors"
"fmt"
"os"
"log"
"errors"
"os"
)
var Stdlog, Errlog *log.Logger

9
daemon/daemon.go

@ -1,13 +1,14 @@
package daemon
import (
"github.com/takama/daemon"
"fmt"
"net"
"net/rpc"
"os"
"os/signal"
"syscall"
"net"
"fmt"
"net/rpc"
"github.com/takama/daemon"
"github.com/toasterson/opencloud/common"
)

2
devprop/devprop.go

@ -1,8 +1,8 @@
package devprop
import (
"os/exec"
"bytes"
"os/exec"
)
const devprop_bin string = "/sbin/devprop"

2
imaged/client.go

@ -1,8 +1,8 @@
package imaged
import (
"net/rpc"
"fmt"
"net/rpc"
)
func client() (string, error) {

1
installd/config.go

@ -29,4 +29,5 @@ type InstallConfiguration struct {
BEName string `json:"be_name"` //Name of the new Boot Environment defaults to openindiana
SwapSize string `json:"swap_size"` //Size of the SWAP Partition defaults to 2g
DumpSize string `json:"dump_size"` //Size of the Dump Partition defaults to swap_size
BootLoader string `json:"boot_loader"` //Valid values are Loader and Grub
}

7
installd/copyfile.go

@ -1,12 +1,13 @@
package installd
import (
"os"
"strings"
"github.com/toasterson/mozaik/logger"
"fmt"
"io"
"os"
"strings"
"syscall"
"github.com/toasterson/mozaik/logger"
"github.com/toasterson/mozaik/util"
)

5
installd/filesystem.go

@ -2,10 +2,11 @@ package installd
import (
"fmt"
"github.com/satori/go.uuid"
"github.com/toasterson/opencloud/zpool"
"github.com/toasterson/opencloud/zfs"
"github.com/toasterson/mozaik/util"
"github.com/toasterson/opencloud/zfs"
"github.com/toasterson/opencloud/zpool"
)
func CreateAndMountZpool(conf *InstallConfiguration) (err error) {

1
installd/http.go

@ -3,6 +3,7 @@ package installd
import (
"fmt"
"time"
"github.com/cavaliercoder/grab"
"github.com/toasterson/mozaik/logger"
)

17
installd/install.go

@ -1,13 +1,15 @@
package installd
import (
"github.com/toasterson/mozaik/util"
"github.com/toasterson/opencloud/zfs"
"fmt"
"github.com/toasterson/opencloud/common"
"github.com/toasterson/opencloud/mount"
"os"
"path/filepath"
"github.com/toasterson/mozaik/util"
"github.com/toasterson/opencloud/bootadm"
"github.com/toasterson/opencloud/common"
"github.com/toasterson/opencloud/mount"
"github.com/toasterson/opencloud/zfs"
)
const altRootLocation string = "/a"
@ -30,8 +32,11 @@ func Install(conf InstallConfiguration) {
MakeSystemDirectories(rootDir, []DirConfig{})
MakeDeviceLinks(rootDir, []LinkConfig{})
util.Must(CreateDeviceLinks(rootDir, []string{}))
//fixZfsMountPoints(&conf)
bconf := bootadm.BootConfig{Type: bootadm.BootLoaderTypeLoader, RPoolName: conf.RPoolName, BEName: conf.BEName, BootOptions: []string{}}
util.Must(bootadm.CreateBootConfigurationFiles(rootDir, bconf))
util.Must(bootadm.UpdateBootArchive(rootDir))
util.Must(bootadm.InstallBootLoader(rootDir, conf.RPoolName))
fixZfsMountPoints(&conf)
}
func fixZfsMountPoints(conf *InstallConfiguration) {

13
installd/system_dirs.go

@ -1,12 +1,15 @@
// +build solaris,cgo
package installd
import (
"os"
"fmt"
"syscall"
"os"
"os/user"
"github.com/toasterson/mozaik/logger"
"strconv"
"syscall"
"github.com/toasterson/mozaik/logger"
)
type DirConfig struct {
@ -53,7 +56,7 @@ func MakeSystemDirectories(rootDir string, dirs []DirConfig){
if dir.Owner != "" {
owner, err := user.Lookup(dir.Owner)
if err != nil {
logger.Error(fmt.Sprintf("User %s does not exist this should not happen", owner.Name))
logger.Error(fmt.Sprintf("User %s does not exist this should not happen %s", dir.Owner, err))
} else {
uid, _ = strconv.Atoi(owner.Uid)
}
@ -61,7 +64,7 @@ func MakeSystemDirectories(rootDir string, dirs []DirConfig){
if dir.Group != "" {
group, err := user.LookupGroup(dir.Group)
if err != nil {
logger.Error(fmt.Sprintf("User %s does not exist this should not happen", group.Name))
logger.Error(fmt.Sprintf("Group %s does not exist this should not happen: %s", dir.Group, err))
} else {
gid, _ = strconv.Atoi(group.Gid)
}

3
installd/system_links.go

@ -1,8 +1,9 @@
package installd
import (
"os"
"fmt"
"os"
"github.com/toasterson/mozaik/logger"
)

9
main.go

@ -1,13 +1,14 @@
package main
import (
"encoding/json"
"flag"
"io/ioutil"
"github.com/toasterson/mozaik/logger"
"github.com/toasterson/mozaik/util"
"github.com/toasterson/opencloud/devprop"
"github.com/toasterson/opencloud/installd"
"encoding/json"
"github.com/toasterson/mozaik/util"
"github.com/toasterson/mozaik/logger"
"io/ioutil"
)
func main() {

6
mount/solaris.go

@ -1,11 +1,15 @@
// +build solaris
package mount
import (
"os/exec"
"bytes"
"fmt"
"os/exec"
"strings"
"errors"
"github.com/toasterson/mozaik/logger"
)

3
samples/install_solnetboot.json

@ -12,5 +12,6 @@
"/export": "rpool/export",
"/export/home": "rpool/export/home"
},
"pool_type": "normal"
"pool_type": "normal",
"boot_loader": "loader"
}

2
uname/command.go

@ -1,8 +1,8 @@
package uname
import (
"os/exec"
"bytes"
"os/exec"
"strings"
)

11
zfs/common.go

@ -1,13 +1,14 @@
package zfs
import (
"github.com/c2h5oh/datasize"
"strings"
"strconv"
"fmt"
"os/exec"
"bytes"
"errors"
"fmt"
"os/exec"
"strconv"
"strings"
"github.com/c2h5oh/datasize"
"github.com/toasterson/mozaik/logger"
)

3
zfs/dataset.go

@ -1,9 +1,10 @@
package zfs
import (
"strings"
"fmt"
"regexp"
"strings"
"github.com/c2h5oh/datasize"
)

5
zfs/list.go

@ -1,11 +1,12 @@
package zfs
import (
"os/exec"
"bytes"
"errors"
"os/exec"
"strings"
"github.com/c2h5oh/datasize"
"errors"
)
func List(zpool string) (datasets []string, err error) {

7
zpool/common.go

@ -1,12 +1,13 @@
package zpool
import (
"os/exec"
"bytes"
"strings"
"errors"
"github.com/toasterson/mozaik/logger"
"fmt"
"os/exec"
"strings"
"github.com/toasterson/mozaik/logger"
"github.com/toasterson/opencloud/zfs"
)

5
zpool/create.go

@ -1,9 +1,10 @@
package zpool
import (
"github.com/toasterson/opencloud/zfs"
"runtime"
"fmt"
"runtime"
"github.com/toasterson/opencloud/zfs"
)
// Create a new Zfs Pool on the Followin disks with mode

3
zpool/pool.go

@ -1,8 +1,9 @@
package zpool
import (
"strings"
"regexp"
"strings"
"github.com/toasterson/opencloud/zfs"
)

1
zpool/property.go

@ -3,6 +3,7 @@ package zpool
import (
"fmt"
"strings"
"github.com/toasterson/opencloud/zfs"
)

Loading…
Cancel
Save