Skip to content

Commit 5328c85

Browse files
committed
darwin build
Closes #732 Signed-off-by: Marat Radchenko <[email protected]>
1 parent 7e97f06 commit 5328c85

27 files changed

+155
-175
lines changed

.github/workflows/lint.yml

+2
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ jobs:
2525
goos: linux
2626
- os: ubuntu-24.04
2727
goos: freebsd
28+
- os: ubuntu-24.04
29+
goos: darwin
2830
# FIXME: this is currently failing in a non-sensical way, so, running on linux instead...
2931
# - os: windows-2022
3032
- os: ubuntu-24.04

.github/workflows/test.yml

+2
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@ jobs:
7272
goos: windows
7373
- os: ubuntu-24.04
7474
goos: linux
75+
- os: macos-15
76+
goos: darwin
7577
steps:
7678
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
7779
with:

cmd/nerdctl/completion/completion_freebsd.go 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

cmd/nerdctl/container/container_cp_freebsd.go 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

cmd/nerdctl/container/container_cp_windows.go

-23
This file was deleted.

cmd/nerdctl/container/container_run_windows.go 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

cmd/nerdctl/main_freebsd.go 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

go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ require (
3939
github.com/docker/docker v27.4.0+incompatible
4040
github.com/docker/go-connections v0.5.0
4141
github.com/docker/go-units v0.5.0
42-
github.com/fahedouch/go-logrotate v0.2.1
42+
github.com/fahedouch/go-logrotate v0.2.2-0.20241125150317-0240e7abd7a0
4343
github.com/fatih/color v1.18.0
4444
github.com/fluent/fluent-logger-golang v1.9.0
4545
github.com/fsnotify/fsnotify v1.8.0

go.sum

+4-4
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ github.com/AdamKorcz/go-118-fuzz-build v0.0.0-20231105174938-2b5cbb29f3e2/go.mod
66
github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161 h1:L/gRVlceqvL25UVaW/CKtUDjefjrs0SPonmDGUVOYP0=
77
github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161/go.mod h1:xomTg63KZ2rFqZQzSB4Vz2SUXa1BpHTVz9L5PTmPC4E=
88
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
9-
github.com/BurntSushi/toml v1.3.2 h1:o7IhLm0Msx3BaB+n3Ag7L8EVlByGnpq14C4YWiu/gL8=
10-
github.com/BurntSushi/toml v1.3.2/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ=
9+
github.com/BurntSushi/toml v1.4.0 h1:kuoIxZQy2WRRk1pttg9asf+WVv6tWQuBNVmK8+nqPr0=
10+
github.com/BurntSushi/toml v1.4.0/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2lLoLwho=
1111
github.com/Masterminds/semver/v3 v3.3.1 h1:QtNSWtVZ3nBfk8mAOu/B6v7FMJ+NHTIgUPi7rj+4nv4=
1212
github.com/Masterminds/semver/v3 v3.3.1/go.mod h1:4V+yj/TJE1HU9XfppCwVMZq3I84lprf4nC11bSS5beM=
1313
github.com/Microsoft/go-winio v0.6.2 h1:F2VQgta7ecxGYO8k3ZZz3RS8fVIXVxONVUPlNERoyfY=
@@ -104,8 +104,8 @@ github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymF
104104
github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
105105
github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98=
106106
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
107-
github.com/fahedouch/go-logrotate v0.2.1 h1:Q0Hk9Kp/Y4iwy9uR9e/60fEoxGhvfk8MG7WwtL9aarM=
108-
github.com/fahedouch/go-logrotate v0.2.1/go.mod h1:Mmyex1f9fGXBNnhS9uHsbnO9BGvADF4VGqVnqAJalgc=
107+
github.com/fahedouch/go-logrotate v0.2.2-0.20241125150317-0240e7abd7a0 h1:8G3ndPQqhkZPriZQrTX1AXM5uA6/Bqa1NelOCOwrftU=
108+
github.com/fahedouch/go-logrotate v0.2.2-0.20241125150317-0240e7abd7a0/go.mod h1:v58eXg33TCKxsBV7Qzgi6/IqgGaEC0i8cwZsrnHKtwM=
109109
github.com/fatih/color v1.18.0 h1:S8gINlzdQ840/4pfAwic/ZE0djQEH3wM94VfqLTZcOM=
110110
github.com/fatih/color v1.18.0/go.mod h1:4FelSpRwEGDpQ12mAdzqdOukCy4u8WUtOY6lkT/6HfU=
111111
github.com/felixge/httpsnoop v1.0.4 h1:NFTV2Zj1bL4mc9sqWACXbQFVBBg2W3GPvqp8/ESS2Wg=

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)

pkg/buildkitutil/buildkitutil_freebsd.go 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

pkg/cmd/container/exec_freebsd.go 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

pkg/cmd/container/exec_windows.go

-26
This file was deleted.

pkg/cmd/container/run_freebsd.go pkg/cmd/container/run_unix_nolinux.go

+2-6
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
@@ -20,17 +22,11 @@ import (
2022
"context"
2123

2224
containerd "github.com/containerd/containerd/v2/client"
23-
"github.com/containerd/containerd/v2/core/containers"
2425
"github.com/containerd/containerd/v2/pkg/oci"
2526

2627
"github.com/containerd/nerdctl/v2/pkg/api/types"
2728
)
2829

29-
func WithoutRunMount() func(ctx context.Context, client oci.Client, c *containers.Container, s *oci.Spec) error {
30-
// not valid on freebsd
31-
return func(_ context.Context, _ oci.Client, _ *containers.Container, s *oci.Spec) error { return nil }
32-
}
33-
3430
func setPlatformOptions(
3531
ctx context.Context,
3632
client *containerd.Client,

pkg/cmd/container/stats_freebsd.go 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

pkg/cmd/container/stats_windows.go

-26
This file was deleted.

pkg/cmd/namespace/namespace_freebsd.go 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

pkg/cmd/namespace/namespace_windows.go

-26
This file was deleted.

pkg/containerinspector/containerinspector_freebsd.go 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

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 {
36+
return "/var/run/cni"
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
}

cmd/nerdctl/main_windows.go pkg/infoutil/infoutil_darwin.go

+14-6
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,24 @@
1414
limitations under the License.
1515
*/
1616

17-
package main
17+
package infoutil
1818

1919
import (
20-
"github.com/spf13/cobra"
20+
"github.com/containerd/nerdctl/v2/pkg/inspecttypes/dockercompat"
21+
"github.com/containerd/nerdctl/v2/pkg/sysinfo"
2122
)
2223

23-
func appNeedsRootlessParentMain(cmd *cobra.Command, args []string) bool {
24-
return false
24+
const UnameO = "Darwin"
25+
26+
func CgroupsVersion() string {
27+
return ""
28+
}
29+
30+
func fulfillPlatformInfo(info *dockercompat.Info) {
31+
// unimplemented
2532
}
2633

27-
func addApparmorCommand(rootCmd *cobra.Command) {
28-
// NOP
34+
func mobySysInfo(info *dockercompat.Info) *sysinfo.SysInfo {
35+
var sysinfo sysinfo.SysInfo
36+
return &sysinfo
2937
}

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+
}

0 commit comments

Comments
 (0)