Skip to content

Commit a33d0b2

Browse files
authored
Merge pull request #3763 from slonopotamus/darwin
Darwin build
2 parents 4f54d76 + 660c9a8 commit a33d0b2

25 files changed

+183
-143
lines changed

Diff for: .github/workflows/lint.yml

+2
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ jobs:
2727
goos: linux
2828
- os: ubuntu-24.04
2929
goos: freebsd
30+
- os: ubuntu-24.04
31+
goos: darwin
3032
# FIXME: this is currently failing in a non-sensical way, so, running on linux instead...
3133
# - os: windows-2022
3234
- os: ubuntu-24.04

Diff for: .github/workflows/test.yml

+2
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ jobs:
7070
goos: windows
7171
- os: ubuntu-24.04
7272
goos: linux
73+
- os: macos-15
74+
goos: darwin
7375
steps:
7476
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
7577
with:

Diff for: cmd/nerdctl/completion/completion_freebsd.go renamed to cmd/nerdctl/completion/completion_unix_nolinux.go

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//go:build unix && !linux
2+
13
/*
24
Copyright The containerd Authors.
35

Diff for: cmd/nerdctl/container/container_cp_freebsd.go renamed to cmd/nerdctl/container/container_cp_nolinux.go

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//go:build !linux
2+
13
/*
24
Copyright The containerd Authors.
35

Diff for: cmd/nerdctl/container/container_cp_windows.go

-23
This file was deleted.

Diff for: cmd/nerdctl/container/container_run_windows.go renamed to cmd/nerdctl/container/container_run_nolinux.go

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//go:build !linux
2+
13
/*
24
Copyright The containerd Authors.
35

Diff for: cmd/nerdctl/main_freebsd.go renamed to cmd/nerdctl/main_nolinux.go

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//go:build !linux
2+
13
/*
24
Copyright The containerd Authors.
35

Diff for: pkg/buildkitutil/buildkitutil_test.go

+2
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ func TestBuildKitFile(t *testing.T) {
3535
var tmp = t.TempDir()
3636
var wd, err = os.Getwd()
3737
assert.NilError(t, err)
38+
tmp, err = filepath.EvalSymlinks(tmp)
39+
assert.NilError(t, err)
3840
err = os.Chdir(tmp)
3941
assert.NilError(t, err)
4042
defer os.Chdir(wd)

Diff for: pkg/buildkitutil/buildkitutil_freebsd.go renamed to pkg/buildkitutil/buildkitutil_unix_nolinux.go

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//go:build unix && !linux
2+
13
/*
24
Copyright The containerd Authors.
35

Diff for: pkg/cmd/container/exec_freebsd.go renamed to pkg/cmd/container/exec_nolinux.go

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//go:build !linux
2+
13
/*
24
Copyright The containerd Authors.
35

Diff for: pkg/cmd/container/exec_windows.go

-26
This file was deleted.

Diff for: pkg/cmd/container/run_freebsd.go renamed to pkg/cmd/container/run_unix_nolinux.go

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//go:build unix && !linux
2+
13
/*
24
Copyright The containerd Authors.
35

Diff for: pkg/cmd/container/stats_freebsd.go renamed to pkg/cmd/container/stats_nolinux.go

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//go:build !linux
2+
13
/*
24
Copyright The containerd Authors.
35

Diff for: pkg/cmd/container/stats_windows.go

-26
This file was deleted.

Diff for: pkg/cmd/namespace/namespace_freebsd.go renamed to pkg/cmd/namespace/namespace_nolinux.go

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//go:build !linux
2+
13
/*
24
Copyright The containerd Authors.
35

Diff for: pkg/cmd/namespace/namespace_windows.go

-26
This file was deleted.

Diff for: pkg/containerinspector/containerinspector_freebsd.go renamed to pkg/containerinspector/containerinspector_unix_nolinux.go

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//go:build unix && !linux
2+
13
/*
24
Copyright The containerd Authors.
35

Diff for: pkg/defaults/defaults_darwin.go

+23-3
Original file line numberDiff line numberDiff line change
@@ -20,22 +20,42 @@
2020

2121
package defaults
2222

23+
import gocni "github.com/containerd/go-cni"
24+
25+
const (
26+
AppArmorProfileName = ""
27+
SeccompProfileName = ""
28+
Runtime = ""
29+
)
30+
2331
func CNIPath() string {
24-
return ""
32+
return gocni.DefaultCNIDir
33+
}
34+
35+
func CNIRuntimeDir() (string, error) {
36+
return "/var/run/cni", nil
2537
}
2638

2739
func CNINetConfPath() string {
28-
return ""
40+
return gocni.DefaultNetDir
2941
}
3042

3143
func DataRoot() string {
32-
return ""
44+
return "/var/lib/nerdctl"
3345
}
3446

3547
func CgroupManager() string {
3648
return ""
3749
}
3850

51+
func CgroupnsMode() string {
52+
return ""
53+
}
54+
55+
func NerdctlTOML() string {
56+
return "/etc/nerdctl/nerdctl.toml"
57+
}
58+
3959
func HostsDirs() []string {
4060
return []string{}
4161
}

Diff for: pkg/defaults/defaults_freebsd.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ func CNINetConfPath() string {
4040
}
4141

4242
func CNIRuntimeDir() (string, error) {
43-
return "/run/cni", nil
43+
return "/var/run/cni", nil
4444
}
4545

4646
func CgroupManager() string {

Diff for: cmd/nerdctl/main_windows.go renamed to pkg/infoutil/infoutil_darwin.go

+13-9
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,25 @@
1414
limitations under the License.
1515
*/
1616

17-
package main
17+
package infoutil
1818

1919
import (
20-
"github.com/spf13/cobra"
20+
"github.com/docker/docker/pkg/sysinfo"
21+
22+
"github.com/containerd/nerdctl/v2/pkg/inspecttypes/dockercompat"
2123
)
2224

23-
func appNeedsRootlessParentMain(cmd *cobra.Command, args []string) bool {
24-
return false
25+
const UnameO = "Darwin"
26+
27+
func CgroupsVersion() string {
28+
return ""
2529
}
2630

27-
func addApparmorCommand(rootCmd *cobra.Command) {
28-
// NOP
31+
func fulfillPlatformInfo(info *dockercompat.Info) {
32+
// unimplemented
2933
}
3034

31-
func resetSavedSETUID() error {
32-
// NOP
33-
return nil
35+
func mobySysInfo(info *dockercompat.Info) *sysinfo.SysInfo {
36+
var sysinfo sysinfo.SysInfo
37+
return &sysinfo
3438
}

Diff for: pkg/mountutil/mountutil_darwin.go

+72
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
/*
2+
Copyright The containerd Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package mountutil
18+
19+
import (
20+
"fmt"
21+
"strings"
22+
23+
"github.com/containerd/containerd/v2/pkg/oci"
24+
"github.com/containerd/errdefs"
25+
"github.com/containerd/log"
26+
27+
"github.com/containerd/nerdctl/v2/pkg/mountutil/volumestore"
28+
)
29+
30+
const (
31+
DefaultMountType = ""
32+
33+
DefaultPropagationMode = ""
34+
)
35+
36+
func UnprivilegedMountFlags(path string) ([]string, error) {
37+
m := []string{}
38+
return m, nil
39+
}
40+
41+
// parseVolumeOptions parses specified optsRaw with using information of
42+
// the volume type and the src directory when necessary.
43+
func parseVolumeOptions(vType, src, optsRaw string) ([]string, []oci.SpecOpts, error) {
44+
var writeModeRawOpts []string
45+
for _, opt := range strings.Split(optsRaw, ",") {
46+
switch opt {
47+
case "rw":
48+
writeModeRawOpts = append(writeModeRawOpts, opt)
49+
case "ro":
50+
writeModeRawOpts = append(writeModeRawOpts, opt)
51+
case "":
52+
// NOP
53+
default:
54+
log.L.Warnf("unsupported volume option %q", opt)
55+
}
56+
}
57+
var opts []string
58+
if len(writeModeRawOpts) > 1 {
59+
return nil, nil, fmt.Errorf("duplicated read/write volume option: %+v", writeModeRawOpts)
60+
} else if len(writeModeRawOpts) > 0 && writeModeRawOpts[0] == "ro" {
61+
opts = append(opts, "ro")
62+
} // No need to return option when "rw"
63+
return opts, nil, nil
64+
}
65+
66+
func ProcessFlagTmpfs(s string) (*Processed, error) {
67+
return nil, errdefs.ErrNotImplemented
68+
}
69+
70+
func ProcessFlagMount(s string, volStore volumestore.VolumeStore) (*Processed, error) {
71+
return nil, errdefs.ErrNotImplemented
72+
}

Diff for: pkg/ocihook/ocihook_freebsd.go renamed to pkg/ocihook/ocihook_nolinux.go

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//go:build !linux
2+
13
/*
24
Copyright The containerd Authors.
35

Diff for: pkg/ocihook/ocihook_windows.go

-21
This file was deleted.

0 commit comments

Comments
 (0)