From 9ff64c3d971254a678c38fa5d99d5a35ac8ae07b Mon Sep 17 00:00:00 2001 From: Kir Kolyshkin Date: Thu, 26 Aug 2021 17:34:16 -0700 Subject: [PATCH 1/5] *: rm redundant linux build tag For files that end with _linux.go or _linux_test.go, there is no need to specify linux build tag, as it is assumed from the file name. In addition, rename libcontainer/notify_linux_v2.go -> libcontainer/notify_v2_linux.go for the file name to make sense. Signed-off-by: Kir Kolyshkin --- libcontainer/container_linux.go | 2 -- libcontainer/container_linux_test.go | 2 -- libcontainer/factory_linux.go | 2 -- libcontainer/factory_linux_test.go | 2 -- libcontainer/init_linux.go | 2 -- libcontainer/message_linux.go | 2 -- libcontainer/network_linux.go | 2 -- libcontainer/notify_linux.go | 2 -- libcontainer/notify_linux_test.go | 2 -- libcontainer/{notify_linux_v2.go => notify_v2_linux.go} | 2 -- libcontainer/process_linux.go | 2 -- libcontainer/rootfs_linux.go | 2 -- libcontainer/rootfs_linux_test.go | 2 -- libcontainer/seccomp/patchbpf/enosys_linux.go | 2 +- libcontainer/seccomp/patchbpf/enosys_linux_test.go | 2 +- libcontainer/seccomp/seccomp_linux.go | 2 +- libcontainer/setns_init_linux.go | 2 -- libcontainer/specconv/spec_linux.go | 2 -- libcontainer/specconv/spec_linux_test.go | 2 -- libcontainer/standard_init_linux.go | 2 -- libcontainer/state_linux.go | 2 -- libcontainer/state_linux_test.go | 2 -- libcontainer/userns/userns_linux_test.go | 2 -- rootless_linux.go | 2 -- utils_linux.go | 2 -- 25 files changed, 3 insertions(+), 47 deletions(-) rename libcontainer/{notify_linux_v2.go => notify_v2_linux.go} (99%) diff --git a/libcontainer/container_linux.go b/libcontainer/container_linux.go index cc1b05f5a..1857375ec 100644 --- a/libcontainer/container_linux.go +++ b/libcontainer/container_linux.go @@ -1,5 +1,3 @@ -// +build linux - package libcontainer import ( diff --git a/libcontainer/container_linux_test.go b/libcontainer/container_linux_test.go index 01b167c56..3eb6e5aff 100644 --- a/libcontainer/container_linux_test.go +++ b/libcontainer/container_linux_test.go @@ -1,5 +1,3 @@ -// +build linux - package libcontainer import ( diff --git a/libcontainer/factory_linux.go b/libcontainer/factory_linux.go index 63cf57b09..7d992d236 100644 --- a/libcontainer/factory_linux.go +++ b/libcontainer/factory_linux.go @@ -1,5 +1,3 @@ -// +build linux - package libcontainer import ( diff --git a/libcontainer/factory_linux_test.go b/libcontainer/factory_linux_test.go index 5d389909d..fe34473cd 100644 --- a/libcontainer/factory_linux_test.go +++ b/libcontainer/factory_linux_test.go @@ -1,5 +1,3 @@ -// +build linux - package libcontainer import ( diff --git a/libcontainer/init_linux.go b/libcontainer/init_linux.go index 985c92504..5bbe29202 100644 --- a/libcontainer/init_linux.go +++ b/libcontainer/init_linux.go @@ -1,5 +1,3 @@ -// +build linux - package libcontainer import ( diff --git a/libcontainer/message_linux.go b/libcontainer/message_linux.go index 1d4f5033a..f10efa366 100644 --- a/libcontainer/message_linux.go +++ b/libcontainer/message_linux.go @@ -1,5 +1,3 @@ -// +build linux - package libcontainer import ( diff --git a/libcontainer/network_linux.go b/libcontainer/network_linux.go index 12e5800fc..aa2be8ffc 100644 --- a/libcontainer/network_linux.go +++ b/libcontainer/network_linux.go @@ -1,5 +1,3 @@ -// +build linux - package libcontainer import ( diff --git a/libcontainer/notify_linux.go b/libcontainer/notify_linux.go index 73a6f5946..0ec1a55c3 100644 --- a/libcontainer/notify_linux.go +++ b/libcontainer/notify_linux.go @@ -1,5 +1,3 @@ -// +build linux - package libcontainer import ( diff --git a/libcontainer/notify_linux_test.go b/libcontainer/notify_linux_test.go index 80859c61e..cf0f90f4d 100644 --- a/libcontainer/notify_linux_test.go +++ b/libcontainer/notify_linux_test.go @@ -1,5 +1,3 @@ -// +build linux - package libcontainer import ( diff --git a/libcontainer/notify_linux_v2.go b/libcontainer/notify_v2_linux.go similarity index 99% rename from libcontainer/notify_linux_v2.go rename to libcontainer/notify_v2_linux.go index 8e3d4fd0d..821536c8d 100644 --- a/libcontainer/notify_linux_v2.go +++ b/libcontainer/notify_v2_linux.go @@ -1,5 +1,3 @@ -// +build linux - package libcontainer import ( diff --git a/libcontainer/process_linux.go b/libcontainer/process_linux.go index e1649876b..ba0258123 100644 --- a/libcontainer/process_linux.go +++ b/libcontainer/process_linux.go @@ -1,5 +1,3 @@ -// +build linux - package libcontainer import ( diff --git a/libcontainer/rootfs_linux.go b/libcontainer/rootfs_linux.go index 3c3fc0d11..19bc96d55 100644 --- a/libcontainer/rootfs_linux.go +++ b/libcontainer/rootfs_linux.go @@ -1,5 +1,3 @@ -// +build linux - package libcontainer import ( diff --git a/libcontainer/rootfs_linux_test.go b/libcontainer/rootfs_linux_test.go index 1bfe7c663..e3bfdc503 100644 --- a/libcontainer/rootfs_linux_test.go +++ b/libcontainer/rootfs_linux_test.go @@ -1,5 +1,3 @@ -// +build linux - package libcontainer import ( diff --git a/libcontainer/seccomp/patchbpf/enosys_linux.go b/libcontainer/seccomp/patchbpf/enosys_linux.go index ccf929d72..e5f867ec6 100644 --- a/libcontainer/seccomp/patchbpf/enosys_linux.go +++ b/libcontainer/seccomp/patchbpf/enosys_linux.go @@ -1,4 +1,4 @@ -// +build linux,cgo,seccomp +// +build cgo,seccomp package patchbpf diff --git a/libcontainer/seccomp/patchbpf/enosys_linux_test.go b/libcontainer/seccomp/patchbpf/enosys_linux_test.go index ce5f02545..04328862e 100644 --- a/libcontainer/seccomp/patchbpf/enosys_linux_test.go +++ b/libcontainer/seccomp/patchbpf/enosys_linux_test.go @@ -1,4 +1,4 @@ -// +build linux,cgo,seccomp +// +build cgo,seccomp package patchbpf diff --git a/libcontainer/seccomp/seccomp_linux.go b/libcontainer/seccomp/seccomp_linux.go index 58cad9026..e86d0a954 100644 --- a/libcontainer/seccomp/seccomp_linux.go +++ b/libcontainer/seccomp/seccomp_linux.go @@ -1,4 +1,4 @@ -// +build linux,cgo,seccomp +// +build cgo,seccomp package seccomp diff --git a/libcontainer/setns_init_linux.go b/libcontainer/setns_init_linux.go index 89b5609a6..09a7d8953 100644 --- a/libcontainer/setns_init_linux.go +++ b/libcontainer/setns_init_linux.go @@ -1,5 +1,3 @@ -// +build linux - package libcontainer import ( diff --git a/libcontainer/specconv/spec_linux.go b/libcontainer/specconv/spec_linux.go index 868bbeee7..f0d3506e6 100644 --- a/libcontainer/specconv/spec_linux.go +++ b/libcontainer/specconv/spec_linux.go @@ -1,5 +1,3 @@ -// +build linux - // Package specconv implements conversion of specifications to libcontainer // configurations package specconv diff --git a/libcontainer/specconv/spec_linux_test.go b/libcontainer/specconv/spec_linux_test.go index 316a21e87..a81090be1 100644 --- a/libcontainer/specconv/spec_linux_test.go +++ b/libcontainer/specconv/spec_linux_test.go @@ -1,5 +1,3 @@ -// +build linux - package specconv import ( diff --git a/libcontainer/standard_init_linux.go b/libcontainer/standard_init_linux.go index f1e20207a..c02f0c45d 100644 --- a/libcontainer/standard_init_linux.go +++ b/libcontainer/standard_init_linux.go @@ -1,5 +1,3 @@ -// +build linux - package libcontainer import ( diff --git a/libcontainer/state_linux.go b/libcontainer/state_linux.go index 3b71a0b03..aa6259b15 100644 --- a/libcontainer/state_linux.go +++ b/libcontainer/state_linux.go @@ -1,5 +1,3 @@ -// +build linux - package libcontainer import ( diff --git a/libcontainer/state_linux_test.go b/libcontainer/state_linux_test.go index a4558a5b7..413626d51 100644 --- a/libcontainer/state_linux_test.go +++ b/libcontainer/state_linux_test.go @@ -1,5 +1,3 @@ -// +build linux - package libcontainer import ( diff --git a/libcontainer/userns/userns_linux_test.go b/libcontainer/userns/userns_linux_test.go index 2ddd3ff96..90d9270db 100644 --- a/libcontainer/userns/userns_linux_test.go +++ b/libcontainer/userns/userns_linux_test.go @@ -1,5 +1,3 @@ -// +build linux - package userns import ( diff --git a/rootless_linux.go b/rootless_linux.go index 3c2105384..ae0170336 100644 --- a/rootless_linux.go +++ b/rootless_linux.go @@ -1,5 +1,3 @@ -// +build linux - package main import ( diff --git a/utils_linux.go b/utils_linux.go index 8b8d9e57e..2dfa63ded 100644 --- a/utils_linux.go +++ b/utils_linux.go @@ -1,5 +1,3 @@ -// +build linux - package main import ( From c5b0be78e88513a2ddb8e33e8d6aaec5ea2a3d73 Mon Sep 17 00:00:00 2001 From: Kir Kolyshkin Date: Fri, 27 Aug 2021 08:40:28 -0700 Subject: [PATCH 2/5] Rm build tags from main pkg This was added by commit 5aa82c950 back in the day when we thought runc is going to be cross-platform. It's very clear now it's Linux-only package. While at it, further clarify it in README that we're Linux only. Signed-off-by: Kir Kolyshkin --- README.md | 5 ++--- checkpoint.go | 2 -- delete.go | 2 -- events.go | 2 -- exec.go | 2 -- kill.go | 2 -- list.go | 2 -- notify_socket.go | 2 -- pause.go | 2 -- ps.go | 2 -- restore.go | 2 -- run.go | 2 -- signals.go | 2 -- spec.go | 2 -- state.go | 2 -- tty.go | 2 -- update.go | 2 -- 17 files changed, 2 insertions(+), 35 deletions(-) diff --git a/README.md b/README.md index 5c7541168..d77976533 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ ## Introduction -`runc` is a CLI tool for spawning and running containers according to the OCI specification. +`runc` is a CLI tool for spawning and running containers on Linux according to the OCI specification. ## Releases @@ -23,8 +23,7 @@ A third party security audit was performed by Cure53, you can see the full repor ## Building -`runc` currently supports the Linux platform with various architecture support. -It must be built with Go version 1.15 or higher. +`runc` only supports Linux. It must be built with Go version 1.15 or higher. In order to enable seccomp support you will need to install `libseccomp` on your platform. > e.g. `libseccomp-devel` for CentOS, or `libseccomp-dev` for Ubuntu diff --git a/checkpoint.go b/checkpoint.go index bf773a9ba..699284f60 100644 --- a/checkpoint.go +++ b/checkpoint.go @@ -1,5 +1,3 @@ -// +build linux - package main import ( diff --git a/delete.go b/delete.go index fc0c73f93..6e6b463ef 100644 --- a/delete.go +++ b/delete.go @@ -1,5 +1,3 @@ -// +build !solaris - package main import ( diff --git a/events.go b/events.go index 0d1510667..6cdc01cdd 100644 --- a/events.go +++ b/events.go @@ -1,5 +1,3 @@ -// +build linux - package main import ( diff --git a/exec.go b/exec.go index f8baff3d1..3649bdc1b 100644 --- a/exec.go +++ b/exec.go @@ -1,5 +1,3 @@ -// +build linux - package main import ( diff --git a/kill.go b/kill.go index 46ea7003b..e5b13b123 100644 --- a/kill.go +++ b/kill.go @@ -1,5 +1,3 @@ -// +build linux - package main import ( diff --git a/list.go b/list.go index 5a1c08503..38d9869d4 100644 --- a/list.go +++ b/list.go @@ -1,5 +1,3 @@ -// +build linux - package main import ( diff --git a/notify_socket.go b/notify_socket.go index e578dbf8a..00ca672d3 100644 --- a/notify_socket.go +++ b/notify_socket.go @@ -1,5 +1,3 @@ -// +build linux - package main import ( diff --git a/pause.go b/pause.go index 224c79f33..a7f0aaccc 100644 --- a/pause.go +++ b/pause.go @@ -1,5 +1,3 @@ -// +build linux - package main import ( diff --git a/ps.go b/ps.go index cbbb670bf..4083e559d 100644 --- a/ps.go +++ b/ps.go @@ -1,5 +1,3 @@ -// +build linux - package main import ( diff --git a/restore.go b/restore.go index f7081e4cf..4e2841ba2 100644 --- a/restore.go +++ b/restore.go @@ -1,5 +1,3 @@ -// +build linux - package main import ( diff --git a/run.go b/run.go index f8d631784..584adbb1f 100644 --- a/run.go +++ b/run.go @@ -1,5 +1,3 @@ -// +build linux - package main import ( diff --git a/signals.go b/signals.go index 250764c76..2555b765b 100644 --- a/signals.go +++ b/signals.go @@ -1,5 +1,3 @@ -// +build linux - package main import ( diff --git a/spec.go b/spec.go index 4dc4c028b..87d6ebea8 100644 --- a/spec.go +++ b/spec.go @@ -1,5 +1,3 @@ -// +build linux - package main import ( diff --git a/state.go b/state.go index 718813c36..b645e5ab6 100644 --- a/state.go +++ b/state.go @@ -1,5 +1,3 @@ -// +build linux - package main import ( diff --git a/tty.go b/tty.go index 310643847..10106a954 100644 --- a/tty.go +++ b/tty.go @@ -1,5 +1,3 @@ -// +build linux - package main import ( diff --git a/update.go b/update.go index 7db5879d2..d02e7af90 100644 --- a/update.go +++ b/update.go @@ -1,5 +1,3 @@ -// +build linux - package main import ( From dbb9fc03ae59610bbd404f209d059790227ded04 Mon Sep 17 00:00:00 2001 From: Kir Kolyshkin Date: Mon, 30 Aug 2021 20:43:12 -0700 Subject: [PATCH 3/5] libct/*: remove linux build tag from some pkgs Only some libcontainer packages can be built on non-linux platforms (not that it make sense, but at least go build succeeds). Let's call these "good" packages. For all other packages (i.e. ones that fail to build with GOOS other than linux), it does not make sense to have linux build tag (as they are broken already, and thus are not and can not be used on anything other than Linux). Remove linux build tag for all non-"good" packages. This was mostly done by the following script, with just a few manual fixes on top. function list_good_pkgs() { for pkg in $(find . -type d -print); do GOOS=freebsd go build $pkg 2>/dev/null \ && GOOS=solaris go build $pkg 2>/dev/null \ && echo $pkg done | sed -e 's|^./||' | tr '\n' '|' | sed -e 's/|$//' } function remove_tag() { sed -i -e '\|^// +build linux$|d' $1 go fmt $1 } SKIP="^("$(list_good_pkgs)")" for f in $(git ls-files . | grep .go$); do if echo $f | grep -qE "$SKIP"; then echo skip $f continue fi echo proc $f remove_tag $f done Signed-off-by: Kir Kolyshkin --- libcontainer/cgroups/cgroups.go | 2 -- libcontainer/cgroups/cgroups_test.go | 2 -- libcontainer/cgroups/devices/devices_emulator.go | 2 -- libcontainer/cgroups/file_test.go | 2 -- libcontainer/cgroups/fs/blkio.go | 2 -- libcontainer/cgroups/fs/blkio_test.go | 2 -- libcontainer/cgroups/fs/cpu.go | 2 -- libcontainer/cgroups/fs/cpu_test.go | 2 -- libcontainer/cgroups/fs/cpuacct.go | 2 -- libcontainer/cgroups/fs/cpuacct_test.go | 2 -- libcontainer/cgroups/fs/cpuset.go | 2 -- libcontainer/cgroups/fs/cpuset_test.go | 2 -- libcontainer/cgroups/fs/devices.go | 2 -- libcontainer/cgroups/fs/devices_test.go | 2 -- libcontainer/cgroups/fs/freezer.go | 2 -- libcontainer/cgroups/fs/freezer_test.go | 2 -- libcontainer/cgroups/fs/fs.go | 2 -- libcontainer/cgroups/fs/fs_test.go | 2 -- libcontainer/cgroups/fs/hugetlb.go | 2 -- libcontainer/cgroups/fs/hugetlb_test.go | 2 -- libcontainer/cgroups/fs/memory.go | 2 -- libcontainer/cgroups/fs/memory_test.go | 2 -- libcontainer/cgroups/fs/name.go | 2 -- libcontainer/cgroups/fs/net_cls.go | 2 -- libcontainer/cgroups/fs/net_cls_test.go | 2 -- libcontainer/cgroups/fs/net_prio.go | 2 -- libcontainer/cgroups/fs/net_prio_test.go | 2 -- libcontainer/cgroups/fs/perf_event.go | 2 -- libcontainer/cgroups/fs/pids.go | 2 -- libcontainer/cgroups/fs/pids_test.go | 2 -- libcontainer/cgroups/fs/stats_util_test.go | 2 -- libcontainer/cgroups/fs/util_test.go | 2 -- libcontainer/cgroups/fs2/cpu.go | 2 -- libcontainer/cgroups/fs2/cpuset.go | 2 -- libcontainer/cgroups/fs2/devices.go | 2 -- libcontainer/cgroups/fs2/freezer.go | 2 -- libcontainer/cgroups/fs2/fs2.go | 2 -- libcontainer/cgroups/fs2/hugetlb.go | 2 -- libcontainer/cgroups/fs2/io.go | 2 -- libcontainer/cgroups/fs2/memory.go | 2 -- libcontainer/cgroups/fs2/pids.go | 2 -- libcontainer/cgroups/fscommon/utils.go | 2 -- libcontainer/cgroups/fscommon/utils_test.go | 2 -- libcontainer/cgroups/getallpids.go | 3 ++- libcontainer/cgroups/getallpids_go115.go | 2 +- libcontainer/cgroups/getallpids_test.go | 2 -- libcontainer/cgroups/stats.go | 2 -- libcontainer/cgroups/systemd/dbus.go | 2 -- libcontainer/cgroups/systemd/user.go | 2 -- libcontainer/cgroups/systemd/v1.go | 2 -- libcontainer/cgroups/systemd/v2.go | 2 -- libcontainer/cgroups/utils.go | 2 -- libcontainer/cgroups/utils_test.go | 2 -- libcontainer/intelrdt/intelrdt.go | 2 -- libcontainer/intelrdt/intelrdt_test.go | 2 -- libcontainer/intelrdt/mbm.go | 2 -- libcontainer/intelrdt/mbm_test.go | 2 -- libcontainer/intelrdt/stats.go | 2 -- libcontainer/intelrdt/util_test.go | 2 -- libcontainer/keys/keyctl.go | 2 -- libcontainer/restored_process.go | 2 -- libcontainer/utils/cmsg.go | 2 -- 62 files changed, 3 insertions(+), 122 deletions(-) diff --git a/libcontainer/cgroups/cgroups.go b/libcontainer/cgroups/cgroups.go index 68a346ca5..ba2b2266c 100644 --- a/libcontainer/cgroups/cgroups.go +++ b/libcontainer/cgroups/cgroups.go @@ -1,5 +1,3 @@ -// +build linux - package cgroups import ( diff --git a/libcontainer/cgroups/cgroups_test.go b/libcontainer/cgroups/cgroups_test.go index 9efb83ec5..b31412f5a 100644 --- a/libcontainer/cgroups/cgroups_test.go +++ b/libcontainer/cgroups/cgroups_test.go @@ -1,5 +1,3 @@ -// +build linux - package cgroups import ( diff --git a/libcontainer/cgroups/devices/devices_emulator.go b/libcontainer/cgroups/devices/devices_emulator.go index d50fc91b4..97ba3f821 100644 --- a/libcontainer/cgroups/devices/devices_emulator.go +++ b/libcontainer/cgroups/devices/devices_emulator.go @@ -1,5 +1,3 @@ -// +build linux - // SPDX-License-Identifier: Apache-2.0 /* * Copyright (C) 2020 Aleksa Sarai diff --git a/libcontainer/cgroups/file_test.go b/libcontainer/cgroups/file_test.go index 4b2cb8950..0a5b941fa 100644 --- a/libcontainer/cgroups/file_test.go +++ b/libcontainer/cgroups/file_test.go @@ -1,5 +1,3 @@ -// +build linux - package cgroups import ( diff --git a/libcontainer/cgroups/fs/blkio.go b/libcontainer/cgroups/fs/blkio.go index 5e1b42a8e..2d764001e 100644 --- a/libcontainer/cgroups/fs/blkio.go +++ b/libcontainer/cgroups/fs/blkio.go @@ -1,5 +1,3 @@ -// +build linux - package fs import ( diff --git a/libcontainer/cgroups/fs/blkio_test.go b/libcontainer/cgroups/fs/blkio_test.go index 860628c7e..eb6257c0d 100644 --- a/libcontainer/cgroups/fs/blkio_test.go +++ b/libcontainer/cgroups/fs/blkio_test.go @@ -1,5 +1,3 @@ -// +build linux - package fs import ( diff --git a/libcontainer/cgroups/fs/cpu.go b/libcontainer/cgroups/fs/cpu.go index 657570a27..cd81cabc1 100644 --- a/libcontainer/cgroups/fs/cpu.go +++ b/libcontainer/cgroups/fs/cpu.go @@ -1,5 +1,3 @@ -// +build linux - package fs import ( diff --git a/libcontainer/cgroups/fs/cpu_test.go b/libcontainer/cgroups/fs/cpu_test.go index 77d12af89..958e6040e 100644 --- a/libcontainer/cgroups/fs/cpu_test.go +++ b/libcontainer/cgroups/fs/cpu_test.go @@ -1,5 +1,3 @@ -// +build linux - package fs import ( diff --git a/libcontainer/cgroups/fs/cpuacct.go b/libcontainer/cgroups/fs/cpuacct.go index dab4a3db8..076704ab7 100644 --- a/libcontainer/cgroups/fs/cpuacct.go +++ b/libcontainer/cgroups/fs/cpuacct.go @@ -1,5 +1,3 @@ -// +build linux - package fs import ( diff --git a/libcontainer/cgroups/fs/cpuacct_test.go b/libcontainer/cgroups/fs/cpuacct_test.go index aaae0aa4e..753a0194b 100644 --- a/libcontainer/cgroups/fs/cpuacct_test.go +++ b/libcontainer/cgroups/fs/cpuacct_test.go @@ -1,5 +1,3 @@ -// +build linux - package fs import ( diff --git a/libcontainer/cgroups/fs/cpuset.go b/libcontainer/cgroups/fs/cpuset.go index 8c49a3001..d4edfaafa 100644 --- a/libcontainer/cgroups/fs/cpuset.go +++ b/libcontainer/cgroups/fs/cpuset.go @@ -1,5 +1,3 @@ -// +build linux - package fs import ( diff --git a/libcontainer/cgroups/fs/cpuset_test.go b/libcontainer/cgroups/fs/cpuset_test.go index 17de7bfa1..4918aaa28 100644 --- a/libcontainer/cgroups/fs/cpuset_test.go +++ b/libcontainer/cgroups/fs/cpuset_test.go @@ -1,5 +1,3 @@ -// +build linux - package fs import ( diff --git a/libcontainer/cgroups/fs/devices.go b/libcontainer/cgroups/fs/devices.go index dcf69ce13..2c8917049 100644 --- a/libcontainer/cgroups/fs/devices.go +++ b/libcontainer/cgroups/fs/devices.go @@ -1,5 +1,3 @@ -// +build linux - package fs import ( diff --git a/libcontainer/cgroups/fs/devices_test.go b/libcontainer/cgroups/fs/devices_test.go index a091543e4..b2d1624ce 100644 --- a/libcontainer/cgroups/fs/devices_test.go +++ b/libcontainer/cgroups/fs/devices_test.go @@ -1,5 +1,3 @@ -// +build linux - package fs import ( diff --git a/libcontainer/cgroups/fs/freezer.go b/libcontainer/cgroups/fs/freezer.go index 4baa2798a..cf1c5efb0 100644 --- a/libcontainer/cgroups/fs/freezer.go +++ b/libcontainer/cgroups/fs/freezer.go @@ -1,5 +1,3 @@ -// +build linux - package fs import ( diff --git a/libcontainer/cgroups/fs/freezer_test.go b/libcontainer/cgroups/fs/freezer_test.go index 4f9584979..b441bf74b 100644 --- a/libcontainer/cgroups/fs/freezer_test.go +++ b/libcontainer/cgroups/fs/freezer_test.go @@ -1,5 +1,3 @@ -// +build linux - package fs import ( diff --git a/libcontainer/cgroups/fs/fs.go b/libcontainer/cgroups/fs/fs.go index c1aa22354..1c1e3f3e6 100644 --- a/libcontainer/cgroups/fs/fs.go +++ b/libcontainer/cgroups/fs/fs.go @@ -1,5 +1,3 @@ -// +build linux - package fs import ( diff --git a/libcontainer/cgroups/fs/fs_test.go b/libcontainer/cgroups/fs/fs_test.go index 1d16ca5e7..b4430603f 100644 --- a/libcontainer/cgroups/fs/fs_test.go +++ b/libcontainer/cgroups/fs/fs_test.go @@ -1,5 +1,3 @@ -// +build linux - package fs import ( diff --git a/libcontainer/cgroups/fs/hugetlb.go b/libcontainer/cgroups/fs/hugetlb.go index 3c1b78cb7..8477fa6b3 100644 --- a/libcontainer/cgroups/fs/hugetlb.go +++ b/libcontainer/cgroups/fs/hugetlb.go @@ -1,5 +1,3 @@ -// +build linux - package fs import ( diff --git a/libcontainer/cgroups/fs/hugetlb_test.go b/libcontainer/cgroups/fs/hugetlb_test.go index 33c8b6d20..ac4ec1533 100644 --- a/libcontainer/cgroups/fs/hugetlb_test.go +++ b/libcontainer/cgroups/fs/hugetlb_test.go @@ -1,5 +1,3 @@ -// +build linux - package fs import ( diff --git a/libcontainer/cgroups/fs/memory.go b/libcontainer/cgroups/fs/memory.go index 2c9f1d018..8e10c22b2 100644 --- a/libcontainer/cgroups/fs/memory.go +++ b/libcontainer/cgroups/fs/memory.go @@ -1,5 +1,3 @@ -// +build linux - package fs import ( diff --git a/libcontainer/cgroups/fs/memory_test.go b/libcontainer/cgroups/fs/memory_test.go index 82adafc56..7d13d2501 100644 --- a/libcontainer/cgroups/fs/memory_test.go +++ b/libcontainer/cgroups/fs/memory_test.go @@ -1,5 +1,3 @@ -// +build linux - package fs import ( diff --git a/libcontainer/cgroups/fs/name.go b/libcontainer/cgroups/fs/name.go index 94a94b5e8..ce9f4a0a5 100644 --- a/libcontainer/cgroups/fs/name.go +++ b/libcontainer/cgroups/fs/name.go @@ -1,5 +1,3 @@ -// +build linux - package fs import ( diff --git a/libcontainer/cgroups/fs/net_cls.go b/libcontainer/cgroups/fs/net_cls.go index f2617aa44..d13642926 100644 --- a/libcontainer/cgroups/fs/net_cls.go +++ b/libcontainer/cgroups/fs/net_cls.go @@ -1,5 +1,3 @@ -// +build linux - package fs import ( diff --git a/libcontainer/cgroups/fs/net_cls_test.go b/libcontainer/cgroups/fs/net_cls_test.go index 7c0ba03dc..6c36f0555 100644 --- a/libcontainer/cgroups/fs/net_cls_test.go +++ b/libcontainer/cgroups/fs/net_cls_test.go @@ -1,5 +1,3 @@ -// +build linux - package fs import ( diff --git a/libcontainer/cgroups/fs/net_prio.go b/libcontainer/cgroups/fs/net_prio.go index d0ac5e66b..cdc810bae 100644 --- a/libcontainer/cgroups/fs/net_prio.go +++ b/libcontainer/cgroups/fs/net_prio.go @@ -1,5 +1,3 @@ -// +build linux - package fs import ( diff --git a/libcontainer/cgroups/fs/net_prio_test.go b/libcontainer/cgroups/fs/net_prio_test.go index a1bb2ce4d..7983041a4 100644 --- a/libcontainer/cgroups/fs/net_prio_test.go +++ b/libcontainer/cgroups/fs/net_prio_test.go @@ -1,5 +1,3 @@ -// +build linux - package fs import ( diff --git a/libcontainer/cgroups/fs/perf_event.go b/libcontainer/cgroups/fs/perf_event.go index 1a306fbe3..8ffa83e09 100644 --- a/libcontainer/cgroups/fs/perf_event.go +++ b/libcontainer/cgroups/fs/perf_event.go @@ -1,5 +1,3 @@ -// +build linux - package fs import ( diff --git a/libcontainer/cgroups/fs/pids.go b/libcontainer/cgroups/fs/pids.go index 83aa6bfff..55bb91fa6 100644 --- a/libcontainer/cgroups/fs/pids.go +++ b/libcontainer/cgroups/fs/pids.go @@ -1,5 +1,3 @@ -// +build linux - package fs import ( diff --git a/libcontainer/cgroups/fs/pids_test.go b/libcontainer/cgroups/fs/pids_test.go index 50777716b..d05ec7215 100644 --- a/libcontainer/cgroups/fs/pids_test.go +++ b/libcontainer/cgroups/fs/pids_test.go @@ -1,5 +1,3 @@ -// +build linux - package fs import ( diff --git a/libcontainer/cgroups/fs/stats_util_test.go b/libcontainer/cgroups/fs/stats_util_test.go index 757e65b63..9b7d840a7 100644 --- a/libcontainer/cgroups/fs/stats_util_test.go +++ b/libcontainer/cgroups/fs/stats_util_test.go @@ -1,5 +1,3 @@ -// +build linux - package fs import ( diff --git a/libcontainer/cgroups/fs/util_test.go b/libcontainer/cgroups/fs/util_test.go index 7b7858f65..4a4013774 100644 --- a/libcontainer/cgroups/fs/util_test.go +++ b/libcontainer/cgroups/fs/util_test.go @@ -1,5 +1,3 @@ -// +build linux - /* Utility for testing cgroup operations. diff --git a/libcontainer/cgroups/fs2/cpu.go b/libcontainer/cgroups/fs2/cpu.go index 83578a340..bbbae4d58 100644 --- a/libcontainer/cgroups/fs2/cpu.go +++ b/libcontainer/cgroups/fs2/cpu.go @@ -1,5 +1,3 @@ -// +build linux - package fs2 import ( diff --git a/libcontainer/cgroups/fs2/cpuset.go b/libcontainer/cgroups/fs2/cpuset.go index da29d7f2b..16c45bad8 100644 --- a/libcontainer/cgroups/fs2/cpuset.go +++ b/libcontainer/cgroups/fs2/cpuset.go @@ -1,5 +1,3 @@ -// +build linux - package fs2 import ( diff --git a/libcontainer/cgroups/fs2/devices.go b/libcontainer/cgroups/fs2/devices.go index 5abddb367..0d2345607 100644 --- a/libcontainer/cgroups/fs2/devices.go +++ b/libcontainer/cgroups/fs2/devices.go @@ -1,5 +1,3 @@ -// +build linux - package fs2 import ( diff --git a/libcontainer/cgroups/fs2/freezer.go b/libcontainer/cgroups/fs2/freezer.go index bdba120d5..8917a6411 100644 --- a/libcontainer/cgroups/fs2/freezer.go +++ b/libcontainer/cgroups/fs2/freezer.go @@ -1,5 +1,3 @@ -// +build linux - package fs2 import ( diff --git a/libcontainer/cgroups/fs2/fs2.go b/libcontainer/cgroups/fs2/fs2.go index 84e4ba895..e6d38408c 100644 --- a/libcontainer/cgroups/fs2/fs2.go +++ b/libcontainer/cgroups/fs2/fs2.go @@ -1,5 +1,3 @@ -// +build linux - package fs2 import ( diff --git a/libcontainer/cgroups/fs2/hugetlb.go b/libcontainer/cgroups/fs2/hugetlb.go index 1606f1d63..aed81a4b3 100644 --- a/libcontainer/cgroups/fs2/hugetlb.go +++ b/libcontainer/cgroups/fs2/hugetlb.go @@ -1,5 +1,3 @@ -// +build linux - package fs2 import ( diff --git a/libcontainer/cgroups/fs2/io.go b/libcontainer/cgroups/fs2/io.go index 2771e1ef3..b2ff7d340 100644 --- a/libcontainer/cgroups/fs2/io.go +++ b/libcontainer/cgroups/fs2/io.go @@ -1,5 +1,3 @@ -// +build linux - package fs2 import ( diff --git a/libcontainer/cgroups/fs2/memory.go b/libcontainer/cgroups/fs2/memory.go index 7ef6b133a..adbc4b230 100644 --- a/libcontainer/cgroups/fs2/memory.go +++ b/libcontainer/cgroups/fs2/memory.go @@ -1,5 +1,3 @@ -// +build linux - package fs2 import ( diff --git a/libcontainer/cgroups/fs2/pids.go b/libcontainer/cgroups/fs2/pids.go index f4c70179c..c8c4a3658 100644 --- a/libcontainer/cgroups/fs2/pids.go +++ b/libcontainer/cgroups/fs2/pids.go @@ -1,5 +1,3 @@ -// +build linux - package fs2 import ( diff --git a/libcontainer/cgroups/fscommon/utils.go b/libcontainer/cgroups/fscommon/utils.go index 196abf95d..f4a51c9e5 100644 --- a/libcontainer/cgroups/fscommon/utils.go +++ b/libcontainer/cgroups/fscommon/utils.go @@ -1,5 +1,3 @@ -// +build linux - package fscommon import ( diff --git a/libcontainer/cgroups/fscommon/utils_test.go b/libcontainer/cgroups/fscommon/utils_test.go index d429db93b..6470a47a1 100644 --- a/libcontainer/cgroups/fscommon/utils_test.go +++ b/libcontainer/cgroups/fscommon/utils_test.go @@ -1,5 +1,3 @@ -// +build linux - package fscommon import ( diff --git a/libcontainer/cgroups/getallpids.go b/libcontainer/cgroups/getallpids.go index b218744e4..09c01fb6f 100644 --- a/libcontainer/cgroups/getallpids.go +++ b/libcontainer/cgroups/getallpids.go @@ -1,4 +1,5 @@ -// +build linux,go1.16 +//go:build go1.16 +// +build go1.16 package cgroups diff --git a/libcontainer/cgroups/getallpids_go115.go b/libcontainer/cgroups/getallpids_go115.go index 5d55a685d..2672dd722 100644 --- a/libcontainer/cgroups/getallpids_go115.go +++ b/libcontainer/cgroups/getallpids_go115.go @@ -1,4 +1,4 @@ -// +build linux,!go1.16 +// +build !go1.16 package cgroups diff --git a/libcontainer/cgroups/getallpids_test.go b/libcontainer/cgroups/getallpids_test.go index b6100686e..e6b063237 100644 --- a/libcontainer/cgroups/getallpids_test.go +++ b/libcontainer/cgroups/getallpids_test.go @@ -1,5 +1,3 @@ -// +build linux - package cgroups import ( diff --git a/libcontainer/cgroups/stats.go b/libcontainer/cgroups/stats.go index aa257d9c6..40a81dd5a 100644 --- a/libcontainer/cgroups/stats.go +++ b/libcontainer/cgroups/stats.go @@ -1,5 +1,3 @@ -// +build linux - package cgroups type ThrottlingData struct { diff --git a/libcontainer/cgroups/systemd/dbus.go b/libcontainer/cgroups/systemd/dbus.go index a70a9df43..e69469b71 100644 --- a/libcontainer/cgroups/systemd/dbus.go +++ b/libcontainer/cgroups/systemd/dbus.go @@ -1,5 +1,3 @@ -// +build linux - package systemd import ( diff --git a/libcontainer/cgroups/systemd/user.go b/libcontainer/cgroups/systemd/user.go index 55d97c737..0f50f76ee 100644 --- a/libcontainer/cgroups/systemd/user.go +++ b/libcontainer/cgroups/systemd/user.go @@ -1,5 +1,3 @@ -// +build linux - package systemd import ( diff --git a/libcontainer/cgroups/systemd/v1.go b/libcontainer/cgroups/systemd/v1.go index 551b052ef..54266901a 100644 --- a/libcontainer/cgroups/systemd/v1.go +++ b/libcontainer/cgroups/systemd/v1.go @@ -1,5 +1,3 @@ -// +build linux - package systemd import ( diff --git a/libcontainer/cgroups/systemd/v2.go b/libcontainer/cgroups/systemd/v2.go index 43d416046..106720d84 100644 --- a/libcontainer/cgroups/systemd/v2.go +++ b/libcontainer/cgroups/systemd/v2.go @@ -1,5 +1,3 @@ -// +build linux - package systemd import ( diff --git a/libcontainer/cgroups/utils.go b/libcontainer/cgroups/utils.go index b31705bed..ec4e70198 100644 --- a/libcontainer/cgroups/utils.go +++ b/libcontainer/cgroups/utils.go @@ -1,5 +1,3 @@ -// +build linux - package cgroups import ( diff --git a/libcontainer/cgroups/utils_test.go b/libcontainer/cgroups/utils_test.go index 816bdc833..929cf511a 100644 --- a/libcontainer/cgroups/utils_test.go +++ b/libcontainer/cgroups/utils_test.go @@ -1,5 +1,3 @@ -// +build linux - package cgroups import ( diff --git a/libcontainer/intelrdt/intelrdt.go b/libcontainer/intelrdt/intelrdt.go index 0d5628b3b..dcf231b63 100644 --- a/libcontainer/intelrdt/intelrdt.go +++ b/libcontainer/intelrdt/intelrdt.go @@ -1,5 +1,3 @@ -// +build linux - package intelrdt import ( diff --git a/libcontainer/intelrdt/intelrdt_test.go b/libcontainer/intelrdt/intelrdt_test.go index 252578969..09ced5292 100644 --- a/libcontainer/intelrdt/intelrdt_test.go +++ b/libcontainer/intelrdt/intelrdt_test.go @@ -1,5 +1,3 @@ -// +build linux - package intelrdt import ( diff --git a/libcontainer/intelrdt/mbm.go b/libcontainer/intelrdt/mbm.go index 0fbecdeb2..13f31ac7a 100644 --- a/libcontainer/intelrdt/mbm.go +++ b/libcontainer/intelrdt/mbm.go @@ -1,5 +1,3 @@ -// +build linux - package intelrdt // The flag to indicate if Intel RDT/MBM is enabled diff --git a/libcontainer/intelrdt/mbm_test.go b/libcontainer/intelrdt/mbm_test.go index 319f8de2b..4f22cbd0a 100644 --- a/libcontainer/intelrdt/mbm_test.go +++ b/libcontainer/intelrdt/mbm_test.go @@ -1,5 +1,3 @@ -// +build linux - package intelrdt import ( diff --git a/libcontainer/intelrdt/stats.go b/libcontainer/intelrdt/stats.go index 4f3bd84ea..a5eb2541e 100644 --- a/libcontainer/intelrdt/stats.go +++ b/libcontainer/intelrdt/stats.go @@ -1,5 +1,3 @@ -// +build linux - package intelrdt type L3CacheInfo struct { diff --git a/libcontainer/intelrdt/util_test.go b/libcontainer/intelrdt/util_test.go index a471c5e26..a5fcc97b6 100644 --- a/libcontainer/intelrdt/util_test.go +++ b/libcontainer/intelrdt/util_test.go @@ -1,5 +1,3 @@ -// +build linux - /* * Utility for testing Intel RDT operations. * Creates a mock of the Intel RDT "resource control" filesystem for the duration of the test. diff --git a/libcontainer/keys/keyctl.go b/libcontainer/keys/keyctl.go index 412b724ee..f3a6c5343 100644 --- a/libcontainer/keys/keyctl.go +++ b/libcontainer/keys/keyctl.go @@ -1,5 +1,3 @@ -// +build linux - package keys import ( diff --git a/libcontainer/restored_process.go b/libcontainer/restored_process.go index 6987c8fd5..cdffbd3af 100644 --- a/libcontainer/restored_process.go +++ b/libcontainer/restored_process.go @@ -1,5 +1,3 @@ -// +build linux - package libcontainer import ( diff --git a/libcontainer/utils/cmsg.go b/libcontainer/utils/cmsg.go index c8a9364d5..52a616550 100644 --- a/libcontainer/utils/cmsg.go +++ b/libcontainer/utils/cmsg.go @@ -1,5 +1,3 @@ -// +build linux - package utils /* From 1b17ec95affec83860fc83b08777a59017a5b898 Mon Sep 17 00:00:00 2001 From: Kir Kolyshkin Date: Mon, 30 Aug 2021 20:56:35 -0700 Subject: [PATCH 4/5] libct/cg: rm "unsupported.go" files These are not needed as these packages (libcontainer/cgroups, libcontainer/cgroups/fs, and libcontainer/cgroups/systemd) can not be built under non-linux anyway (for various reasons). Signed-off-by: Kir Kolyshkin --- libcontainer/cgroups/cgroups_unsupported.go | 3 - libcontainer/cgroups/fs/unsupported.go | 3 - libcontainer/cgroups/systemd/unsupported.go | 71 --------------------- 3 files changed, 77 deletions(-) delete mode 100644 libcontainer/cgroups/cgroups_unsupported.go delete mode 100644 libcontainer/cgroups/fs/unsupported.go delete mode 100644 libcontainer/cgroups/systemd/unsupported.go diff --git a/libcontainer/cgroups/cgroups_unsupported.go b/libcontainer/cgroups/cgroups_unsupported.go deleted file mode 100644 index 278d507e2..000000000 --- a/libcontainer/cgroups/cgroups_unsupported.go +++ /dev/null @@ -1,3 +0,0 @@ -// +build !linux - -package cgroups diff --git a/libcontainer/cgroups/fs/unsupported.go b/libcontainer/cgroups/fs/unsupported.go deleted file mode 100644 index 3ef9e0315..000000000 --- a/libcontainer/cgroups/fs/unsupported.go +++ /dev/null @@ -1,3 +0,0 @@ -// +build !linux - -package fs diff --git a/libcontainer/cgroups/systemd/unsupported.go b/libcontainer/cgroups/systemd/unsupported.go deleted file mode 100644 index cb4d00c88..000000000 --- a/libcontainer/cgroups/systemd/unsupported.go +++ /dev/null @@ -1,71 +0,0 @@ -// +build !linux - -package systemd - -import ( - "errors" - - "github.com/opencontainers/runc/libcontainer/cgroups" - "github.com/opencontainers/runc/libcontainer/configs" -) - -type Manager struct { - Cgroups *configs.Cgroup - Paths map[string]string -} - -func IsRunningSystemd() bool { - return false -} - -func NewSystemdCgroupsManager() (func(config *configs.Cgroup, paths map[string]string) cgroups.Manager, error) { - return nil, errors.New("Systemd not supported") -} - -func (m *Manager) Apply(pid int) error { - return errors.New("Systemd not supported") -} - -func (m *Manager) GetPids() ([]int, error) { - return nil, errors.New("Systemd not supported") -} - -func (m *Manager) GetAllPids() ([]int, error) { - return nil, errors.New("Systemd not supported") -} - -func (m *Manager) Destroy() error { - return errors.New("Systemd not supported") -} - -func (m *Manager) GetPaths() map[string]string { - return nil -} - -func (m *Manager) Path(_ string) string { - return "" -} - -func (m *Manager) GetStats() (*cgroups.Stats, error) { - return nil, errors.New("Systemd not supported") -} - -func (m *Manager) Set(container *configs.Config) error { - return errors.New("Systemd not supported") -} - -func (m *Manager) Freeze(state configs.FreezerState) error { - return errors.New("Systemd not supported") -} - -func Freeze(c *configs.Cgroup, state configs.FreezerState) error { - return errors.New("Systemd not supported") -} - -func (m *Manager) GetCgroups() (*configs.Cgroup, error) { - return nil, errors.New("Systemd not supported") -} - -func (m *Manager) Exists() bool { - return false -} From d8da00355e305f0564a9de6854bf5df1aa4b73d9 Mon Sep 17 00:00:00 2001 From: Kir Kolyshkin Date: Mon, 30 Aug 2021 20:58:22 -0700 Subject: [PATCH 5/5] *: add go-1.17+ go:build tags Go 1.17 introduce this new (and better) way to specify build tags. For more info, see https://golang.org/design/draft-gobuild. As a way to seamlessly switch from old to new build tags, gofmt (and gopls) from go 1.17 adds the new tags along with the old ones. Later, when go < 1.17 is no longer supported, the old build tags can be removed. Now, as I started to use latest gopls (v0.7.1), it adds these tags while I edit. Rather than to randomly add new build tags, I guess it is better to do it once for all files. Mind that previous commits removed some tags that were useless, so this one only touches packages that can at least be built on non-linux. Brought to you by go1.17 fmt ./... Signed-off-by: Kir Kolyshkin --- libcontainer/apparmor/apparmor_unsupported.go | 1 + libcontainer/capabilities/capabilities.go | 1 + libcontainer/capabilities/capabilities_unsupported.go | 1 + libcontainer/cgroups/getallpids_go115.go | 1 + libcontainer/configs/cgroup_unsupported.go | 1 + libcontainer/configs/configs_fuzzer.go | 1 + libcontainer/configs/namespaces_syscall.go | 1 + libcontainer/configs/namespaces_syscall_unsupported.go | 1 + libcontainer/configs/namespaces_unsupported.go | 1 + libcontainer/devices/device_unix.go | 1 + libcontainer/devices/device_unix_test.go | 1 + libcontainer/integration/seccomp_test.go | 1 + libcontainer/nsenter/nsenter.go | 1 + libcontainer/nsenter/nsenter_gccgo.go | 1 + libcontainer/nsenter/nsenter_unsupported.go | 1 + libcontainer/seccomp/patchbpf/enosys_linux.go | 1 + libcontainer/seccomp/patchbpf/enosys_linux_test.go | 1 + libcontainer/seccomp/patchbpf/enosys_unsupported.go | 1 + libcontainer/seccomp/seccomp_linux.go | 1 + libcontainer/seccomp/seccomp_unsupported.go | 1 + libcontainer/system/linux.go | 1 + libcontainer/system/syscall_linux_32.go | 1 + libcontainer/system/syscall_linux_64.go | 1 + libcontainer/user/lookup_unix.go | 1 + libcontainer/user/user_fuzzer.go | 1 + libcontainer/userns/userns_fuzzer.go | 1 + libcontainer/userns/userns_unsupported.go | 1 + libcontainer/utils/utils_unix.go | 1 + 28 files changed, 28 insertions(+) diff --git a/libcontainer/apparmor/apparmor_unsupported.go b/libcontainer/apparmor/apparmor_unsupported.go index 1adadafec..684248f25 100644 --- a/libcontainer/apparmor/apparmor_unsupported.go +++ b/libcontainer/apparmor/apparmor_unsupported.go @@ -1,3 +1,4 @@ +//go:build !linux // +build !linux package apparmor diff --git a/libcontainer/capabilities/capabilities.go b/libcontainer/capabilities/capabilities.go index 1099d32b1..7e938d3f5 100644 --- a/libcontainer/capabilities/capabilities.go +++ b/libcontainer/capabilities/capabilities.go @@ -1,3 +1,4 @@ +//go:build linux // +build linux package capabilities diff --git a/libcontainer/capabilities/capabilities_unsupported.go b/libcontainer/capabilities/capabilities_unsupported.go index a3e82ac1f..0eafa4f2c 100644 --- a/libcontainer/capabilities/capabilities_unsupported.go +++ b/libcontainer/capabilities/capabilities_unsupported.go @@ -1,3 +1,4 @@ +//go:build !linux // +build !linux package capabilities diff --git a/libcontainer/cgroups/getallpids_go115.go b/libcontainer/cgroups/getallpids_go115.go index 2672dd722..6b645ef64 100644 --- a/libcontainer/cgroups/getallpids_go115.go +++ b/libcontainer/cgroups/getallpids_go115.go @@ -1,3 +1,4 @@ +//go:build !go1.16 // +build !go1.16 package cgroups diff --git a/libcontainer/configs/cgroup_unsupported.go b/libcontainer/configs/cgroup_unsupported.go index 2a519f582..7e383020f 100644 --- a/libcontainer/configs/cgroup_unsupported.go +++ b/libcontainer/configs/cgroup_unsupported.go @@ -1,3 +1,4 @@ +//go:build !linux // +build !linux package configs diff --git a/libcontainer/configs/configs_fuzzer.go b/libcontainer/configs/configs_fuzzer.go index 93bf41c8d..bce829e29 100644 --- a/libcontainer/configs/configs_fuzzer.go +++ b/libcontainer/configs/configs_fuzzer.go @@ -1,3 +1,4 @@ +//go:build gofuzz // +build gofuzz package configs diff --git a/libcontainer/configs/namespaces_syscall.go b/libcontainer/configs/namespaces_syscall.go index 2dc7adfc9..0516dba8d 100644 --- a/libcontainer/configs/namespaces_syscall.go +++ b/libcontainer/configs/namespaces_syscall.go @@ -1,3 +1,4 @@ +//go:build linux // +build linux package configs diff --git a/libcontainer/configs/namespaces_syscall_unsupported.go b/libcontainer/configs/namespaces_syscall_unsupported.go index 5d9a5c81f..fbb0d4907 100644 --- a/libcontainer/configs/namespaces_syscall_unsupported.go +++ b/libcontainer/configs/namespaces_syscall_unsupported.go @@ -1,3 +1,4 @@ +//go:build !linux && !windows // +build !linux,!windows package configs diff --git a/libcontainer/configs/namespaces_unsupported.go b/libcontainer/configs/namespaces_unsupported.go index cc76e2f58..946db30a5 100644 --- a/libcontainer/configs/namespaces_unsupported.go +++ b/libcontainer/configs/namespaces_unsupported.go @@ -1,3 +1,4 @@ +//go:build !linux // +build !linux package configs diff --git a/libcontainer/devices/device_unix.go b/libcontainer/devices/device_unix.go index 9369c6f70..e2af4ff2c 100644 --- a/libcontainer/devices/device_unix.go +++ b/libcontainer/devices/device_unix.go @@ -1,3 +1,4 @@ +//go:build !windows // +build !windows package devices diff --git a/libcontainer/devices/device_unix_test.go b/libcontainer/devices/device_unix_test.go index 118c3bfa9..9a93359f4 100644 --- a/libcontainer/devices/device_unix_test.go +++ b/libcontainer/devices/device_unix_test.go @@ -1,3 +1,4 @@ +//go:build !windows // +build !windows package devices diff --git a/libcontainer/integration/seccomp_test.go b/libcontainer/integration/seccomp_test.go index b25413060..ea8ee4199 100644 --- a/libcontainer/integration/seccomp_test.go +++ b/libcontainer/integration/seccomp_test.go @@ -1,3 +1,4 @@ +//go:build linux && cgo && seccomp // +build linux,cgo,seccomp package integration diff --git a/libcontainer/nsenter/nsenter.go b/libcontainer/nsenter/nsenter.go index 07f4d63e4..2d1f3e11c 100644 --- a/libcontainer/nsenter/nsenter.go +++ b/libcontainer/nsenter/nsenter.go @@ -1,3 +1,4 @@ +//go:build linux && !gccgo // +build linux,!gccgo package nsenter diff --git a/libcontainer/nsenter/nsenter_gccgo.go b/libcontainer/nsenter/nsenter_gccgo.go index 63c7a3ec2..86bad539e 100644 --- a/libcontainer/nsenter/nsenter_gccgo.go +++ b/libcontainer/nsenter/nsenter_gccgo.go @@ -1,3 +1,4 @@ +//go:build linux && gccgo // +build linux,gccgo package nsenter diff --git a/libcontainer/nsenter/nsenter_unsupported.go b/libcontainer/nsenter/nsenter_unsupported.go index 2459c6367..a7e049c61 100644 --- a/libcontainer/nsenter/nsenter_unsupported.go +++ b/libcontainer/nsenter/nsenter_unsupported.go @@ -1,3 +1,4 @@ +//go:build !linux || !cgo // +build !linux !cgo package nsenter diff --git a/libcontainer/seccomp/patchbpf/enosys_linux.go b/libcontainer/seccomp/patchbpf/enosys_linux.go index e5f867ec6..37a05b5a2 100644 --- a/libcontainer/seccomp/patchbpf/enosys_linux.go +++ b/libcontainer/seccomp/patchbpf/enosys_linux.go @@ -1,3 +1,4 @@ +//go:build cgo && seccomp // +build cgo,seccomp package patchbpf diff --git a/libcontainer/seccomp/patchbpf/enosys_linux_test.go b/libcontainer/seccomp/patchbpf/enosys_linux_test.go index 04328862e..b2ee6255b 100644 --- a/libcontainer/seccomp/patchbpf/enosys_linux_test.go +++ b/libcontainer/seccomp/patchbpf/enosys_linux_test.go @@ -1,3 +1,4 @@ +//go:build cgo && seccomp // +build cgo,seccomp package patchbpf diff --git a/libcontainer/seccomp/patchbpf/enosys_unsupported.go b/libcontainer/seccomp/patchbpf/enosys_unsupported.go index 682131e49..d23167ae3 100644 --- a/libcontainer/seccomp/patchbpf/enosys_unsupported.go +++ b/libcontainer/seccomp/patchbpf/enosys_unsupported.go @@ -1,3 +1,4 @@ +//go:build !linux || !cgo || !seccomp // +build !linux !cgo !seccomp package patchbpf diff --git a/libcontainer/seccomp/seccomp_linux.go b/libcontainer/seccomp/seccomp_linux.go index e86d0a954..f46250825 100644 --- a/libcontainer/seccomp/seccomp_linux.go +++ b/libcontainer/seccomp/seccomp_linux.go @@ -1,3 +1,4 @@ +//go:build cgo && seccomp // +build cgo,seccomp package seccomp diff --git a/libcontainer/seccomp/seccomp_unsupported.go b/libcontainer/seccomp/seccomp_unsupported.go index 8b7973e9a..6e593dbec 100644 --- a/libcontainer/seccomp/seccomp_unsupported.go +++ b/libcontainer/seccomp/seccomp_unsupported.go @@ -1,3 +1,4 @@ +//go:build !linux || !cgo || !seccomp // +build !linux !cgo !seccomp package seccomp diff --git a/libcontainer/system/linux.go b/libcontainer/system/linux.go index b9fd0832d..bb612daa6 100644 --- a/libcontainer/system/linux.go +++ b/libcontainer/system/linux.go @@ -1,3 +1,4 @@ +//go:build linux // +build linux package system diff --git a/libcontainer/system/syscall_linux_32.go b/libcontainer/system/syscall_linux_32.go index c5ca5d862..1acc5cb03 100644 --- a/libcontainer/system/syscall_linux_32.go +++ b/libcontainer/system/syscall_linux_32.go @@ -1,3 +1,4 @@ +//go:build linux && (386 || arm) // +build linux // +build 386 arm diff --git a/libcontainer/system/syscall_linux_64.go b/libcontainer/system/syscall_linux_64.go index e05e30adc..1ed0dba17 100644 --- a/libcontainer/system/syscall_linux_64.go +++ b/libcontainer/system/syscall_linux_64.go @@ -1,3 +1,4 @@ +//go:build linux && (arm64 || amd64 || mips || mipsle || mips64 || mips64le || ppc || ppc64 || ppc64le || riscv64 || s390x) // +build linux // +build arm64 amd64 mips mipsle mips64 mips64le ppc ppc64 ppc64le riscv64 s390x diff --git a/libcontainer/user/lookup_unix.go b/libcontainer/user/lookup_unix.go index 967717a1b..f95c1409f 100644 --- a/libcontainer/user/lookup_unix.go +++ b/libcontainer/user/lookup_unix.go @@ -1,3 +1,4 @@ +//go:build darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris // +build darwin dragonfly freebsd linux netbsd openbsd solaris package user diff --git a/libcontainer/user/user_fuzzer.go b/libcontainer/user/user_fuzzer.go index 8c9bb5df3..e018eae61 100644 --- a/libcontainer/user/user_fuzzer.go +++ b/libcontainer/user/user_fuzzer.go @@ -1,3 +1,4 @@ +//go:build gofuzz // +build gofuzz package user diff --git a/libcontainer/userns/userns_fuzzer.go b/libcontainer/userns/userns_fuzzer.go index 529f8eaea..1e00ab8b5 100644 --- a/libcontainer/userns/userns_fuzzer.go +++ b/libcontainer/userns/userns_fuzzer.go @@ -1,3 +1,4 @@ +//go:build gofuzz // +build gofuzz package userns diff --git a/libcontainer/userns/userns_unsupported.go b/libcontainer/userns/userns_unsupported.go index f45bb0c31..f35c13a10 100644 --- a/libcontainer/userns/userns_unsupported.go +++ b/libcontainer/userns/userns_unsupported.go @@ -1,3 +1,4 @@ +//go:build !linux // +build !linux package userns diff --git a/libcontainer/utils/utils_unix.go b/libcontainer/utils/utils_unix.go index 387ae509d..3b303e189 100644 --- a/libcontainer/utils/utils_unix.go +++ b/libcontainer/utils/utils_unix.go @@ -1,3 +1,4 @@ +//go:build !windows // +build !windows package utils