Skip to content

Commit

Permalink
osutil: reorg and stub out things to get it building on darwin
Browse files Browse the repository at this point in the history
With this, cmd/snap itself builds on darwin.
  • Loading branch information
chipaca committed Aug 21, 2018
1 parent f91340d commit 973cb65
Show file tree
Hide file tree
Showing 19 changed files with 143 additions and 10 deletions.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
25 changes: 25 additions & 0 deletions osutil/nfs_darwin.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// -*- Mode: Go; indent-tabs-mode: t -*-

/*
* Copyright (C) 2016 Canonical Ltd
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 3 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/

package osutil

// IsHomeUsingNFS is not implemented on darwin
func IsHomeUsingNFS() (bool, error) {
return false, ErrDarwin
}
File renamed without changes.
File renamed without changes.
27 changes: 27 additions & 0 deletions osutil/osutil_darwin.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// -*- Mode: Go; indent-tabs-mode: t -*-

/*
* Copyright (C) 2016-2018 Canonical Ltd
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 3 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/

package osutil

import (
"errors"
)

// Some things are not implemented on darwin
var ErrDarwin = errors.New("not implemented on darwin")
25 changes: 25 additions & 0 deletions osutil/overlay_darwin.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// -*- Mode: Go; indent-tabs-mode: t -*-

/*
* Copyright (C) 2016-2018 Canonical Ltd
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 3 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/

package osutil

// IsRootWritableOverlay is not implemented on darwin
func IsRootWritableOverlay() (string, error) {
return "", ErrDarwin
}
File renamed without changes.
File renamed without changes.
14 changes: 4 additions & 10 deletions osutil/uname.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,6 @@

package osutil

import (
"syscall"
)

var syscallUname = syscall.Uname

var KernelVersion = kernelVersion

// We have to implement separate functions for the kernel version and the
Expand All @@ -37,8 +31,8 @@ var KernelVersion = kernelVersion
// for details.

func kernelVersion() string {
var u syscall.Utsname
if err := syscallUname(&u); err != nil {
u, err := uname()
if err != nil {
return "unknown"
}

Expand All @@ -57,8 +51,8 @@ func kernelVersion() string {
}

func MachineName() string {
var u syscall.Utsname
if err := syscallUname(&u); err != nil {
u, err := uname()
if err != nil {
return "unknown"
}

Expand Down
30 changes: 30 additions & 0 deletions osutil/uname_darwin.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// -*- Mode: Go; indent-tabs-mode: t -*-

/*
* Copyright (C) 2014-2018 Canonical Ltd
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 3 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/

package osutil

import (
"golang.org/x/sys/unix"
)

func uname() (*unix.Utsname, error) {
var u unix.Utsname
err := unix.Uname(&u)
return &u, err
}
32 changes: 32 additions & 0 deletions osutil/uname_linux.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// -*- Mode: Go; indent-tabs-mode: t -*-

/*
* Copyright (C) 2014-2018 Canonical Ltd
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 3 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/

package osutil

import (
"syscall"
)

var syscallUname = syscall.Uname

func uname() (*syscall.Utsname, error) {
var u syscall.Utsname
err := syscallUname(&u)
return &u, err
}
File renamed without changes.

0 comments on commit 973cb65

Please sign in to comment.