diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 20e0848e..9224a1d2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -76,13 +76,6 @@ jobs: run: make build binaries working-directory: src/github.com/containerd/continuity - - name: Cross-compile - if: startsWith(matrix.os, 'ubuntu') - shell: bash - run: | - GOOS=freebsd make build binaries - working-directory: src/github.com/containerd/continuity - - name: Linux Tests if: startsWith(matrix.os, 'ubuntu') run: | @@ -95,3 +88,36 @@ jobs: shell: bash run: make test-compile working-directory: src/github.com/containerd/continuity + + cross: + name: Cross-compile + runs-on: ubuntu-18.04 + timeout-minutes: 10 + needs: [project] + + strategy: + matrix: + goos: [freebsd, openbsd, netbsd, darwin, solaris] + + steps: + - name: Set up Go + uses: actions/setup-go@v1 + with: + go-version: 1.15 + + - name: Setup Go binary path + shell: bash + run: | + echo "GOPATH=${{ github.workspace }}" >> $GITHUB_ENV + echo "${{ github.workspace }}/bin" >> $GITHUB_PATH + + - name: Check out code + uses: actions/checkout@v2 + with: + path: src/github.com/containerd/continuity + + - name: Cross-compile ${{matrix.goos}} + shell: bash + run: | + GOOS=${{matrix.goos}} make build binaries + working-directory: src/github.com/containerd/continuity diff --git a/commands/mount_unsupported.go b/commands/mount_unsupported.go index 14bb87a7..e626ca37 100644 --- a/commands/mount_unsupported.go +++ b/commands/mount_unsupported.go @@ -1,5 +1,5 @@ -//go:build windows || solaris -// +build windows solaris +//go:build windows || solaris || openbsd || netbsd +// +build windows solaris openbsd netbsd /* Copyright The containerd Authors. diff --git a/continuityfs/provider.go b/continuityfs/provider.go index 90b3467e..9eafe4c3 100644 --- a/continuityfs/provider.go +++ b/continuityfs/provider.go @@ -1,6 +1,3 @@ -//go:build linux || darwin || freebsd -// +build linux darwin freebsd - /* Copyright The containerd Authors. diff --git a/devices/devices_unix.go b/devices/devices_unix.go index 4177e54f..3dd3bb42 100644 --- a/devices/devices_unix.go +++ b/devices/devices_unix.go @@ -1,5 +1,5 @@ -//go:build linux || darwin || freebsd || solaris -// +build linux darwin freebsd solaris +//go:build !windows +// +build !windows /* Copyright The containerd Authors. diff --git a/devices/mknod_unix.go b/devices/mknod_unix.go index 52932029..5c7f5525 100644 --- a/devices/mknod_unix.go +++ b/devices/mknod_unix.go @@ -1,5 +1,5 @@ -//go:build linux || darwin || solaris -// +build linux darwin solaris +//go:build !(freebsd || windows) +// +build !freebsd,!windows /* Copyright The containerd Authors. diff --git a/driver/driver_unix.go b/driver/driver_unix.go index fe67cf04..d64dd503 100644 --- a/driver/driver_unix.go +++ b/driver/driver_unix.go @@ -1,5 +1,5 @@ -//go:build linux || darwin || freebsd || solaris -// +build linux darwin freebsd solaris +//go:build !windows +// +build !windows /* Copyright The containerd Authors. diff --git a/driver/lchmod_unix.go b/driver/lchmod_unix.go index d1954ae1..161c79fa 100644 --- a/driver/lchmod_unix.go +++ b/driver/lchmod_unix.go @@ -1,5 +1,5 @@ -//go:build darwin || freebsd || solaris -// +build darwin freebsd solaris +//go:build darwin || freebsd || netbsd || openbsd || solaris +// +build darwin freebsd netbsd openbsd solaris /* Copyright The containerd Authors. diff --git a/fs/copy_darwin.go b/fs/copy_darwin.go index 1a837d58..ce55f0aa 100644 --- a/fs/copy_darwin.go +++ b/fs/copy_darwin.go @@ -34,10 +34,3 @@ func copyDevice(dst string, fi os.FileInfo) error { } return unix.Mknod(dst, uint32(fi.Mode()), int(st.Rdev)) } - -func utimesNano(name string, atime, mtime syscall.Timespec) error { - at := unix.NsecToTimespec(atime.Nano()) - mt := unix.NsecToTimespec(mtime.Nano()) - utimes := [2]unix.Timespec{at, mt} - return unix.UtimesNanoAt(unix.AT_FDCWD, name, utimes[0:], unix.AT_SYMLINK_NOFOLLOW) -} diff --git a/fs/copy_openbsdsolaris.go b/fs/copy_device_unix.go similarity index 80% rename from fs/copy_openbsdsolaris.go rename to fs/copy_device_unix.go index 9791fd4a..f821890c 100644 --- a/fs/copy_openbsdsolaris.go +++ b/fs/copy_device_unix.go @@ -1,5 +1,5 @@ -//go:build openbsd || solaris -// +build openbsd solaris +//go:build openbsd || solaris || netbsd +// +build openbsd solaris netbsd /* Copyright The containerd Authors. @@ -34,8 +34,3 @@ func copyDevice(dst string, fi os.FileInfo) error { } return unix.Mknod(dst, uint32(fi.Mode()), int(st.Rdev)) } - -func utimesNano(name string, atime, mtime syscall.Timespec) error { - timespec := []syscall.Timespec{atime, mtime} - return syscall.UtimesNano(name, timespec) -} diff --git a/fs/copy_freebsd.go b/fs/copy_freebsd.go index 61af4c48..4aaf743e 100644 --- a/fs/copy_freebsd.go +++ b/fs/copy_freebsd.go @@ -34,10 +34,3 @@ func copyDevice(dst string, fi os.FileInfo) error { } return unix.Mknod(dst, uint32(fi.Mode()), st.Rdev) } - -func utimesNano(name string, atime, mtime syscall.Timespec) error { - at := unix.NsecToTimespec(atime.Nano()) - mt := unix.NsecToTimespec(mtime.Nano()) - utimes := [2]unix.Timespec{at, mt} - return unix.UtimesNanoAt(unix.AT_FDCWD, name, utimes[0:], unix.AT_SYMLINK_NOFOLLOW) -} diff --git a/fs/copy_unix.go b/fs/copy_unix.go index 8bb456da..0e68ba9e 100644 --- a/fs/copy_unix.go +++ b/fs/copy_unix.go @@ -1,5 +1,5 @@ -//go:build darwin || freebsd || openbsd || solaris -// +build darwin freebsd openbsd solaris +//go:build darwin || freebsd || openbsd || netbsd || solaris +// +build darwin freebsd openbsd netbsd solaris /* Copyright The containerd Authors. diff --git a/fs/stat_linuxopenbsd.go b/fs/stat_atim.go similarity index 94% rename from fs/stat_linuxopenbsd.go rename to fs/stat_atim.go index 4a4c8a94..995bf832 100644 --- a/fs/stat_linuxopenbsd.go +++ b/fs/stat_atim.go @@ -1,5 +1,5 @@ -//go:build linux || openbsd -// +build linux openbsd +//go:build linux || openbsd || solaris +// +build linux openbsd solaris /* Copyright The containerd Authors. diff --git a/fs/utimesnanoat.go b/fs/utimesnanoat.go new file mode 100644 index 00000000..5435398d --- /dev/null +++ b/fs/utimesnanoat.go @@ -0,0 +1,33 @@ +//go:build !(windows || linux) +// +build !windows,!linux + +/* + Copyright The containerd Authors. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +package fs + +import ( + "syscall" + + "golang.org/x/sys/unix" +) + +func utimesNano(name string, atime, mtime syscall.Timespec) error { + at := unix.NsecToTimespec(atime.Nano()) + mt := unix.NsecToTimespec(mtime.Nano()) + utimes := [2]unix.Timespec{at, mt} + return unix.UtimesNanoAt(unix.AT_FDCWD, name, utimes[0:], unix.AT_SYMLINK_NOFOLLOW) +} diff --git a/hardlinks_unix.go b/hardlinks_unix.go index 40aa99fe..a1fafb0a 100644 --- a/hardlinks_unix.go +++ b/hardlinks_unix.go @@ -1,5 +1,5 @@ -//go:build linux || darwin || freebsd || solaris -// +build linux darwin freebsd solaris +//go:build !windows +// +build !windows /* Copyright The containerd Authors. diff --git a/resource_unix.go b/resource_unix.go index 7f01425a..eaf7c1da 100644 --- a/resource_unix.go +++ b/resource_unix.go @@ -1,5 +1,5 @@ -//go:build linux || darwin || freebsd || solaris -// +build linux darwin freebsd solaris +//go:build !windows +// +build !windows /* Copyright The containerd Authors. diff --git a/sysx/nodata_unix.go b/sysx/nodata_unix.go index 3c704c4f..e78f77f6 100644 --- a/sysx/nodata_unix.go +++ b/sysx/nodata_unix.go @@ -1,5 +1,5 @@ -//go:build darwin || freebsd || openbsd -// +build darwin freebsd openbsd +//go:build !(linux || solaris || windows) +// +build !linux,!solaris,!windows /* Copyright The containerd Authors.