Skip to content

Commit

Permalink
allow buildah cross compile for a darwin target
Browse files Browse the repository at this point in the history
the goal here is to allow ourselves to cross compile buildah for a darwin
target.  we are doing this to eventually protect from regressions that could
creep into buildah so we don't dig ourselves a deeper hole.

the simplified and non-variable approach to the make darwin was done with
intent to keep this simple until we can exploit things a little more.

once this PR merges, i will create a CI test that will test for regressions
on a make darwin.  we should also be doing a gofmt with a darwin target so the
!linux|darwin tagged files are also checked for completeness.  initially the
test can be optional for passing with the long-term idea that it be made
a firm requirement at the buildah maintainers behest.

Signed-off-by: baude <bbaude@redhat.com>

Closes: #840
Approved by: rhatdan
  • Loading branch information
baude authored and rh-atomic-bot committed Jul 1, 2018
1 parent 6f72599 commit 5cd9be6
Show file tree
Hide file tree
Showing 9 changed files with 52 additions and 14 deletions.
3 changes: 3 additions & 0 deletions Makefile
Expand Up @@ -20,6 +20,9 @@ all: buildah imgtype docs
buildah: *.go imagebuildah/*.go bind/*.go cmd/buildah/*.go docker/*.go pkg/cli/*.go pkg/parse/*.go unshare/*.c unshare/*.go util/*.go
$(GO) build $(LDFLAGS) -o buildah $(BUILDFLAGS) ./cmd/buildah

darwin:
GOOS=darwin $(GO) build $(LDFLAGS) -o buildah.darwin -tags "containers_image_openpgp" ./cmd/buildah

imgtype: *.go docker/*.go util/*.go tests/imgtype/imgtype.go
$(GO) build $(LDFLAGS) -o imgtype $(BUILDFLAGS) ./tests/imgtype/imgtype.go

Expand Down
4 changes: 4 additions & 0 deletions cmd/buildah/unshare_unsupported.go
Expand Up @@ -2,6 +2,10 @@

package main

import (
"github.com/urfave/cli"
)

var (
unshareCommand = cli.Command{
Name: "unshare",
Expand Down
6 changes: 3 additions & 3 deletions run.go
Expand Up @@ -1145,9 +1145,9 @@ func runUsingRuntimeMain() {
os.Exit(1)
}
// Set ourselves up to read the container's exit status. We're doing this in a child process
// so that we won't mess with the setting in a caller of the library.
if err := unix.Prctl(unix.PR_SET_CHILD_SUBREAPER, uintptr(1), 0, 0, 0); err != nil {
fmt.Fprintf(os.Stderr, "prctl(PR_SET_CHILD_SUBREAPER, 1): %v\n", err)
// so that we won't mess with the setting in a caller of the library. This stubs to OS specific
// calls
if err := setChildProcess(); err != nil {
os.Exit(1)
}
// Run the container, start to finish.
Expand Down
17 changes: 17 additions & 0 deletions run_linux.go
@@ -0,0 +1,17 @@
// +build linux

package buildah

import (
"fmt"
"golang.org/x/sys/unix"
"os"
)

func setChildProcess() error {
if err := unix.Prctl(unix.PR_SET_CHILD_SUBREAPER, uintptr(1), 0, 0, 0); err != nil {
fmt.Fprintf(os.Stderr, "prctl(PR_SET_CHILD_SUBREAPER, 1): %v\n", err)
return err
}
return nil
}
11 changes: 11 additions & 0 deletions run_unsupport.go
@@ -0,0 +1,11 @@
// +build !linux

package buildah

import (
"github.com/pkg/errors"
)

func setChildProcess() error {
return errors.New("function not supported on non-linux systems")
}
2 changes: 1 addition & 1 deletion vendor.conf
Expand Up @@ -42,7 +42,7 @@ github.com/ostreedev/ostree-go aeb02c6b6aa2889db3ef62f7855650755befd460
github.com/pborman/uuid master
github.com/pkg/errors master
github.com/pquerna/ffjson d49c2bc1aa135aad0c6f4fc2056623ec78f5d5ac
github.com/projectatomic/libpod 781eec27b52c842fc83c8b1c97fbf825065f3b0c
github.com/projectatomic/libpod master
github.com/sirupsen/logrus master
github.com/syndtr/gocapability master
github.com/tchap/go-patricia master
Expand Down
6 changes: 6 additions & 0 deletions vendor/github.com/projectatomic/libpod/pkg/chrootuser/user.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 7 additions & 6 deletions vendor/github.com/projectatomic/libpod/vendor.conf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 5cd9be6

Please sign in to comment.