Skip to content

Commit fad0ca2

Browse files
authored
Merge pull request #4822 from samuelkarp/freebsd
Build on FreeBSD
2 parents 7b0149a + 4bcfbfe commit fad0ca2

17 files changed

Lines changed: 232 additions & 25 deletions

File tree

.github/workflows/ci.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,13 @@ jobs:
157157
make binaries
158158
working-directory: src/github.com/containerd/containerd
159159

160+
- name: Cross-compile
161+
if: startsWith(matrix.os, 'ubuntu')
162+
run : |
163+
GOOS=freebsd make build
164+
GOOS=freebsd make binaries
165+
working-directory: src/github.com/containerd/containerd
166+
160167
#
161168
# Integration and CRI tests
162169
#

archive/tar_freebsd.go

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
// +build freebsd
2+
3+
/*
4+
Copyright The containerd Authors.
5+
6+
Licensed under the Apache License, Version 2.0 (the "License");
7+
you may not use this file except in compliance with the License.
8+
You may obtain a copy of the License at
9+
10+
http://www.apache.org/licenses/LICENSE-2.0
11+
12+
Unless required by applicable law or agreed to in writing, software
13+
distributed under the License is distributed on an "AS IS" BASIS,
14+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
See the License for the specific language governing permissions and
16+
limitations under the License.
17+
*/
18+
19+
package archive
20+
21+
import "golang.org/x/sys/unix"
22+
23+
// mknod wraps unix.Mknod. FreeBSD's unix.Mknod signature is different from
24+
// other Unix and Unix-like operating systems.
25+
func mknod(path string, mode uint32, dev uint64) error {
26+
return unix.Mknod(path, mode, dev)
27+
}
28+
29+
// lsetxattrCreate wraps unix.Lsetxattr with FreeBSD-specific flags and errors
30+
func lsetxattrCreate(link string, attr string, data []byte) error {
31+
err := unix.Lsetxattr(link, attr, data, 0)
32+
if err == unix.ENOTSUP|| err == unix.EEXIST {
33+
return nil
34+
}
35+
return err
36+
}

archive/tar_mostunix.go

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
// +build !windows,!freebsd
2+
3+
/*
4+
Copyright The containerd Authors.
5+
6+
Licensed under the Apache License, Version 2.0 (the "License");
7+
you may not use this file except in compliance with the License.
8+
You may obtain a copy of the License at
9+
10+
http://www.apache.org/licenses/LICENSE-2.0
11+
12+
Unless required by applicable law or agreed to in writing, software
13+
distributed under the License is distributed on an "AS IS" BASIS,
14+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
See the License for the specific language governing permissions and
16+
limitations under the License.
17+
*/
18+
19+
package archive
20+
21+
import "golang.org/x/sys/unix"
22+
23+
// mknod wraps Unix.Mknod and casts dev to int
24+
func mknod(path string, mode uint32, dev uint64) error {
25+
return unix.Mknod(path, mode, int(dev))
26+
}
27+
28+
// lsetxattrCreate wraps unix.Lsetxattr, passes the unix.XATTR_CREATE flag on
29+
// supported operating systems,and ignores appropriate errors
30+
func lsetxattrCreate(link string, attr string, data []byte) error {
31+
err := unix.Lsetxattr(link, attr, data, unix.XATTR_CREATE)
32+
if err == unix.ENOTSUP || err == unix.ENODATA || err == unix.EEXIST {
33+
return nil
34+
}
35+
return err
36+
}

archive/tar_unix.go

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ func handleTarTypeBlockCharFifo(hdr *tar.Header, path string) error {
108108
mode |= unix.S_IFIFO
109109
}
110110

111-
return unix.Mknod(path, mode, int(unix.Mkdev(uint32(hdr.Devmajor), uint32(hdr.Devminor))))
111+
return mknod(path, mode, unix.Mkdev(uint32(hdr.Devmajor), uint32(hdr.Devminor)))
112112
}
113113

114114
func handleLChmod(hdr *tar.Header, path string, hdrInfo os.FileInfo) error {
@@ -196,10 +196,7 @@ func copyUpXAttrs(dst, src string) error {
196196
}
197197
return errors.Wrapf(err, "failed to get xattr %q on %s", xattr, src)
198198
}
199-
if err := unix.Lsetxattr(dst, xattr, data, unix.XATTR_CREATE); err != nil {
200-
if err == unix.ENOTSUP || err == unix.ENODATA || err == unix.EEXIST {
201-
continue
202-
}
199+
if err := lsetxattrCreate(dst, xattr, data); err != nil {
203200
return errors.Wrapf(err, "failed to set xattr %q on %s", xattr, dst)
204201
}
205202
}

cmd/containerd-shim/shim_freebsd.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ import (
2222
"os"
2323
"os/signal"
2424

25-
"github.com/containerd/containerd/runtime/v1/shim"
25+
"github.com/containerd/containerd/sys/reaper"
26+
2627
runc "github.com/containerd/go-runc"
2728
"github.com/containerd/ttrpc"
2829
)
@@ -34,7 +35,7 @@ func setupSignals() (chan os.Signal, error) {
3435
signal.Notify(signals)
3536
// make sure runc is setup to use the monitor
3637
// for waiting on processes
37-
runc.Monitor = shim.Default
38+
runc.Monitor = reaper.Default
3839
return signals, nil
3940
}
4041

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ require (
1111
github.com/containerd/btrfs v0.0.0-20201111183144-404b9149801e
1212
github.com/containerd/cgroups v0.0.0-20200824123100-0b889c03f102
1313
github.com/containerd/console v1.0.1
14-
github.com/containerd/continuity v0.0.0-20201204184040-1d9893e5674b
14+
github.com/containerd/continuity v0.0.0-20201208142359-180525291bb7
1515
github.com/containerd/fifo v0.0.0-20201026212402-0724c46b320c
1616
github.com/containerd/go-cni v1.0.1
1717
github.com/containerd/go-runc v0.0.0-20200220073739-7016d3ce2328

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,8 @@ github.com/containerd/continuity v0.0.0-20190815185530-f2a389ac0a02/go.mod h1:GL
107107
github.com/containerd/continuity v0.0.0-20191127005431-f65d91d395eb/go.mod h1:GL3xCUCBDV3CZiTSEKksMWbLE66hEyuu9qyDOOqM47Y=
108108
github.com/containerd/continuity v0.0.0-20200710164510-efbc4488d8fe h1:PEmIrUvwG9Yyv+0WKZqjXfSFDeZjs/q15g0m08BYS9k=
109109
github.com/containerd/continuity v0.0.0-20200710164510-efbc4488d8fe/go.mod h1:cECdGN1O8G9bgKTlLhuPJimka6Xb/Gg7vYzCTNVxhvo=
110-
github.com/containerd/continuity v0.0.0-20201204184040-1d9893e5674b h1:CUx5QuAGQukRZT3ewWwEQK8RPPX043TJkeTuOd1vINw=
111-
github.com/containerd/continuity v0.0.0-20201204184040-1d9893e5674b/go.mod h1:kR3BEg7bDFaEddKm54WSmrol1fKWDU1nKYkgrcgZT7Y=
110+
github.com/containerd/continuity v0.0.0-20201208142359-180525291bb7 h1:6ejg6Lkk8dskcM7wQ28gONkukbQkM4qpj4RnYbpFzrI=
111+
github.com/containerd/continuity v0.0.0-20201208142359-180525291bb7/go.mod h1:kR3BEg7bDFaEddKm54WSmrol1fKWDU1nKYkgrcgZT7Y=
112112
github.com/containerd/fifo v0.0.0-20180307165137-3d5202aec260/go.mod h1:ODA38xgv3Kuk8dQz2ZQXpnv/UZZUHUCL7pnLehbXgQI=
113113
github.com/containerd/fifo v0.0.0-20190226154929-a9fb20d87448/go.mod h1:ODA38xgv3Kuk8dQz2ZQXpnv/UZZUHUCL7pnLehbXgQI=
114114
github.com/containerd/fifo v0.0.0-20200410184934-f15a3290365b/go.mod h1:jPQ2IAeZRCYxpS/Cm1495vGFww6ecHmMk1YJH2Q5ln0=

vendor/github.com/containerd/continuity/AUTHORS

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/containerd/continuity/README.md

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/containerd/continuity/devices/devices_unix.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)