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 cc1b05f5a00..1857375ecd4 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 01b167c56c0..3eb6e5affa7 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 63cf57b099b..7d992d23663 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 5d389909d36..fe34473cdf6 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 985c9250403..5bbe2920217 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 1d4f5033aa2..f10efa36635 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 12e5800fc0e..aa2be8ffc17 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 73a6f594655..0ec1a55c3f5 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 80859c61e12..cf0f90f4d2c 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 8e3d4fd0de6..821536c8da0 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 e1649876b1d..ba025812364 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 3c3fc0d1130..19bc96d55d0 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 1bfe7c66322..e3bfdc50315 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 ccf929d7219..e5f867ec6ed 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 ce5f02545f8..04328862ea3 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 58cad90262b..e86d0a95488 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 89b5609a6b6..09a7d895379 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 868bbeee7f0..f0d3506e6e7 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 316a21e8747..a81090be154 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 f1e20207ae0..c02f0c45d9b 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 3b71a0b0381..aa6259b157d 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 a4558a5b736..413626d5118 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 2ddd3ff966d..90d9270db6f 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 3c21053846b..ae01703365d 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 8b8d9e57eaf..2dfa63ded62 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 5c75411682d..d7797653379 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 bf773a9ba08..699284f609b 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 fc0c73f930b..6e6b463efe7 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 0d1510667eb..6cdc01cdd3a 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 f8baff3d152..3649bdc1bbd 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 46ea7003b53..e5b13b1230d 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 5a1c0850351..38d9869d41b 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 e578dbf8a6d..00ca672d356 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 224c79f3368..a7f0aaccc4e 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 cbbb670bf1b..4083e559d75 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 f7081e4cf5f..4e2841ba22b 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 f8d6317844d..584adbb1ff5 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 250764c7616..2555b765bdd 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 4dc4c028bdc..87d6ebea871 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 718813c36be..b645e5ab62b 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 310643847ac..10106a95476 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 7db5879d210..d02e7af90d3 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 68a346ca531..ba2b2266c9d 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 9efb83ec5be..b31412f5a04 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 d50fc91b4da..97ba3f82105 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 4b2cb895007..0a5b941faad 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 5e1b42a8e6b..2d764001ead 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 860628c7e12..eb6257c0d41 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 657570a279f..cd81cabc185 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 77d12af8998..958e6040e72 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 dab4a3db8c7..076704ab742 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 aaae0aa4ec9..753a0194b71 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 8c49a300146..d4edfaafad2 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 17de7bfa15b..4918aaa2867 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 dcf69ce13e7..2c8917049ea 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 a091543e4de..b2d1624cec8 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 4baa2798ac9..cf1c5efb0a5 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 4f9584979b8..b441bf74b69 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 c1aa22354c0..1c1e3f3e63e 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 1d16ca5e76d..b4430603f1e 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 3c1b78cb7d6..8477fa6b356 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 33c8b6d20b7..ac4ec1533f5 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 2c9f1d0186f..8e10c22b2e7 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 82adafc5672..7d13d250111 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 94a94b5e8d0..ce9f4a0a5ff 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 f2617aa4442..d1364292697 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 7c0ba03dc2c..6c36f055597 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 d0ac5e66bbb..cdc810baea6 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 a1bb2ce4dc4..7983041a41e 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 1a306fbe3f7..8ffa83e094e 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 83aa6bffff4..55bb91fa6e8 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 50777716bca..d05ec7215e6 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 757e65b63ce..9b7d840a7c2 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 7b7858f65d7..4a4013774df 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 83578a34029..bbbae4d58c4 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 da29d7f2bbb..16c45bad8f0 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 5abddb367b0..0d23456072c 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 bdba120d5f5..8917a6411d6 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 84e4ba89539..e6d38408cc7 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 1606f1d63d6..aed81a4b3ed 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 2771e1ef324..b2ff7d34086 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 7ef6b133a42..adbc4b23086 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 f4c70179cd5..c8c4a365894 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 196abf95d52..f4a51c9e56f 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 d429db93b51..6470a47a1c6 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 b218744e42e..09c01fb6f55 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 5d55a685dab..2672dd722e3 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 b6100686ef4..e6b06323786 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 aa257d9c6c4..40a81dd5a86 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 a70a9df43e8..e69469b718d 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 55d97c737d4..0f50f76eee4 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 551b052ef69..54266901ac1 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 43d416046f8..106720d84b2 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 b31705bed06..ec4e70198d8 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 816bdc83368..929cf511a83 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 0d5628b3be3..dcf231b63f8 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 2525789690f..09ced52923e 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 0fbecdeb228..13f31ac7a08 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 319f8de2bca..4f22cbd0ab2 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 4f3bd84eaf1..a5eb2541e81 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 a471c5e26f9..a5fcc97b6f5 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 412b724ee12..f3a6c5343fa 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 6987c8fd524..cdffbd3aff5 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 c8a9364d54d..52a6165503d 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 278d507e288..00000000000 --- 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 3ef9e031586..00000000000 --- 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 cb4d00c88b3..00000000000 --- 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 1adadafec8e..684248f2559 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 1099d32b146..7e938d3f505 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 a3e82ac1fd4..0eafa4f2c2c 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 2672dd722e3..6b645ef644e 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 2a519f582d2..7e383020f4c 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 93bf41c8def..bce829e290a 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 2dc7adfc966..0516dba8d09 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 5d9a5c81f3f..fbb0d49071e 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 cc76e2f586a..946db30a549 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 9369c6f70ed..e2af4ff2cce 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 118c3bfa9d9..9a93359f4ff 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 b25413060d0..ea8ee419942 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 07f4d63e433..2d1f3e11cf7 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 63c7a3ec221..86bad539e0c 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 2459c6367e4..a7e049c6163 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 e5f867ec6ed..37a05b5a20e 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 04328862ea3..b2ee6255bb4 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 682131e49cc..d23167ae357 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 e86d0a95488..f46250825e7 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 8b7973e9a13..6e593dbec14 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 b9fd0832d56..bb612daa641 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 c5ca5d86235..1acc5cb03d0 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 e05e30adc3b..1ed0dba1709 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 967717a1b1c..f95c1409fce 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 8c9bb5df39c..e018eae614e 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 529f8eaea2f..1e00ab8b505 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 f45bb0c3156..f35c13a10e0 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 387ae509dde..3b303e189ef 100644 --- a/libcontainer/utils/utils_unix.go +++ b/libcontainer/utils/utils_unix.go @@ -1,3 +1,4 @@ +//go:build !windows // +build !windows package utils