Skip to content
This repository has been archived by the owner on Dec 13, 2018. It is now read-only.

Fix nsenter package on unsupported platforms. #596

Merged
merged 1 commit into from
May 17, 2015
Merged

Fix nsenter package on unsupported platforms. #596

merged 1 commit into from
May 17, 2015

Conversation

dmitshur
Copy link
Contributor

Commit 4d1d618 added this nsenter_unsupported.go file in order for nsenter to be a valid (but empty, non-functional) Go package on unsupported platforms. However, on such platforms, Go still complains because there exists a .c file in this folder, but the package doesn't use cgo.

Fix that by importing "C" pseudo-package.

I don't see any other ways of fixing this, since you can't add build tags to the .c file. But if someone has any additional thoughts here, please comment.

To illustrate the issue, if you are on OS X, which is an unsupported platform, and you do this innocent Go command to update the libcontainer package source to latest version (without building):

$ go get -u -d github.com/docker/libcontainer/...
package github.com/docker/libcontainer
    imports github.com/docker/docker/pkg/mount
    imports github.com/docker/libcontainer/cgroups
    imports github.com/docker/libcontainer/configs
    imports github.com/docker/libcontainer/stacktrace
    imports github.com/docker/libcontainer/apparmor
    imports github.com/docker/libcontainer/cgroups/fs
    imports github.com/docker/libcontainer/system
    imports github.com/docker/libcontainer/cgroups/systemd
    imports github.com/docker/libcontainer/configs/validate
    imports github.com/docker/libcontainer/devices
    imports github.com/docker/libcontainer/integration
    imports github.com/docker/libcontainer/label
    imports github.com/docker/libcontainer/netlink
    imports github.com/docker/libcontainer/nsenter
    imports github.com/docker/libcontainer/nsenter
    imports github.com/docker/libcontainer/nsenter: C source files not allowed when not using cgo: nsexec.c

Also, if you do:

$ go list github.com/docker/libcontainer/nsenter
can't load package: package github.com/docker/libcontainer/nsenter: C source files not allowed when not using cgo: nsexec.c
$ echo $?
1

This patch fixes those issues. It should have no affect on platforms where nsenter is supported because I'm only making a change to the nsenter_unsupported.go file which is hidden behind // +build !linux !cgo builds tags.

Commit 4d1d618 added this nsenter_unsupported.go file in order for nsenter to be a valid (but empty, non-functional) Go package on unsupported platforms. However, on such platforms, Go still complains because there exists a .c file in this folder, but the package doesn't use cgo.
Fix that by importing "C" pseudo-package.

Signed-off-by: Dmitri Shuralyov <[email protected]>
@LK4D4
Copy link
Contributor

LK4D4 commented May 16, 2015

LGTM

1 similar comment
@mrunalp
Copy link
Contributor

mrunalp commented May 17, 2015

LGTM

mrunalp pushed a commit that referenced this pull request May 17, 2015
Fix nsenter package on unsupported platforms.
@mrunalp mrunalp merged commit 94e6c73 into docker-archive:master May 17, 2015
@dmitshur dmitshur deleted the patch-1 branch May 17, 2015 06:53
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants