Skip to content

Commit

Permalink
Build containerd/continuity on multiple Unix OSes
Browse files Browse the repository at this point in the history
Fixes #183.

Signed-off-by: Kazuyoshi Kato <katokazu@amazon.com>
  • Loading branch information
kzys committed Dec 3, 2021
1 parent 8e53e7c commit fbb2850
Show file tree
Hide file tree
Showing 14 changed files with 128 additions and 34 deletions.
47 changes: 40 additions & 7 deletions .github/workflows/ci.yml
Expand Up @@ -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: |
Expand All @@ -95,3 +88,43 @@ 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: Git line endings
shell: bash
run: |
git config --global core.autocrlf false
git config --global core.eol lf
- name: Check out code
uses: actions/checkout@v2
with:
path: src/github.com/containerd/continuity
fetch-depth: 25

- name: Cross-compile ${{matrix.goos}}
shell: bash
run: |
GOOS=${{matrix.goos}} make build binaries
working-directory: src/github.com/containerd/continuity
4 changes: 2 additions & 2 deletions 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.
Expand Down
4 changes: 2 additions & 2 deletions continuityfs/provider.go
@@ -1,5 +1,5 @@
//go:build linux || darwin || freebsd
// +build linux darwin freebsd
//go:build linux || darwin || freebsd || netbsd
// +build linux darwin freebsd netbsd

/*
Copyright The containerd Authors.
Expand Down
4 changes: 2 additions & 2 deletions 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.
Expand Down
4 changes: 2 additions & 2 deletions devices/mknod_unix.go
@@ -1,5 +1,5 @@
//go:build linux || darwin || solaris
// +build linux darwin solaris
//go:build linux || darwin || netbsd || openbsd || solaris
// +build linux darwin netbsd openbsd solaris

/*
Copyright The containerd Authors.
Expand Down
4 changes: 2 additions & 2 deletions 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.
Expand Down
4 changes: 2 additions & 2 deletions 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.
Expand Down
9 changes: 2 additions & 7 deletions fs/copy_openbsdsolaris.go → 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.
Expand Down Expand Up @@ -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)
}
4 changes: 2 additions & 2 deletions 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.
Expand Down
33 changes: 33 additions & 0 deletions fs/utimesnano.go
@@ -0,0 +1,33 @@
//go:build solaris
// +build solaris

/*
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 (
"errors"
"os"
"syscall"

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

func utimesNano(name string, atime, mtime syscall.Timespec) error {
timespec := []syscall.Timespec{atime, mtime}
return syscall.UtimesNano(name, timespec)
}
33 changes: 33 additions & 0 deletions fs/utimesnanoat.go
@@ -0,0 +1,33 @@
//go:build openbsd || netbsd
// +build openbsd netbsd

/*
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)
}
4 changes: 2 additions & 2 deletions 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.
Expand Down
4 changes: 2 additions & 2 deletions 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.
Expand Down
4 changes: 2 additions & 2 deletions sysx/nodata_unix.go
@@ -1,5 +1,5 @@
//go:build darwin || freebsd || openbsd
// +build darwin freebsd openbsd
//go:build darwin || freebsd || openbsd || netbsd
// +build darwin freebsd openbsd netbsd

/*
Copyright The containerd Authors.
Expand Down

0 comments on commit fbb2850

Please sign in to comment.