*: build a limited version of rkt on non-Linux

This introduces build tags to allow the actual rkt binary to be built on
platforms other than Linux. This does not change our current focus of rocket
being targeted at the Linux/amd64 platform, but means that users on e.g.
OS X and other operating systems can at least use `rkt fetch` to
retrieve ACI images and so forth.
This commit is contained in:
Jonathan Boulle
2014-12-03 17:00:15 -08:00
parent 1fa673cf48
commit cb78269134
9 changed files with 69 additions and 20 deletions
+21 -20
View File
@@ -19,29 +19,30 @@ go build -o $GOBIN/actool ${REPO_PATH}/app-container/actool
echo "Building ACE validator..."
GOOS=linux CGO_ENABLED=0 go build -a -ldflags '-extldflags "-static"' -o $GOBIN/ace-validator ${REPO_PATH}/app-container/ace
echo "Building init (stage1)..."
go build -o $GOBIN/init ${REPO_PATH}/stage1
if [[ "$OSTYPE" == "linux-gnu" ]]; then
echo "Building init (stage1)..."
go build -o $GOBIN/init ${REPO_PATH}/stage1
S1BINS=${PWD}/stage0
S1INIT=${S1BINS}/stage1_init
if [ $GOBIN/init -nt $S1INIT/bin.go ]; then
echo "Packaging init (stage1)..."
TMP=$(mktemp -d)
[ -d $S1INIT ] || mkdir -p $S1INIT
cp $GOBIN/init $TMP/s1init
go-bindata -o $S1INIT/bin.go -pkg="stage1_init" -prefix=$TMP $TMP
S1BINS=${PWD}/stage0
S1INIT=${S1BINS}/stage1_init
if [ $GOBIN/init -nt $S1INIT/bin.go ]; then
echo "Packaging init (stage1)..."
TMP=$(mktemp -d)
[ -d $S1INIT ] || mkdir -p $S1INIT
cp $GOBIN/init $TMP/s1init
go-bindata -o $S1INIT/bin.go -pkg="stage1_init" -prefix=$TMP $TMP
fi
S1ROOTFS=${S1BINS}/stage1_rootfs
if [ stage1/mkrootfs.sh -nt $S1ROOTFS/bin.go ]; then
echo "Generating and packaging rootfs (stage1)..."
[ -d "${S1ROOTFS}" ] || mkdir -p "${S1ROOTFS}"
pushd stage1
OUTPUT=$S1ROOTFS/bin.go ./mkrootfs.sh
popd
fi
fi
S1ROOTFS=${S1BINS}/stage1_rootfs
if [ stage1/mkrootfs.sh -nt $S1ROOTFS/bin.go ]; then
echo "Generating and packaging rootfs (stage1)..."
[ -d "${S1ROOTFS}" ] || mkdir -p "${S1ROOTFS}"
pushd stage1
OUTPUT=$S1ROOTFS/bin.go ./mkrootfs.sh
popd
fi
echo "Building rkt (stage0)..."
go build -o $GOBIN/rkt ${REPO_PATH}/rkt
+2
View File
@@ -1,3 +1,5 @@
//+build linux
package main
import (
+18
View File
@@ -0,0 +1,18 @@
//+build !linux
package main
import "fmt"
var (
cmdRun = &Command{
Name: "run",
Summary: "Run image(s) in an application container in rocket",
Run: runRun,
}
)
func runRun(args []string) (exit int) {
fmt.Println("run is not implemented on this platform.")
return
}
+2
View File
@@ -1,3 +1,5 @@
//+build linux
package main
import "fmt"
+18
View File
@@ -0,0 +1,18 @@
//+build !linux
package main
import "fmt"
var (
cmdStatus = &Command{
Name: "status",
Summary: "Check the status of a rkt job",
Run: runStatus,
}
)
func runStatus(args []string) (exit int) {
fmt.Println("status is not implemented on this platform.")
return
}
+2
View File
@@ -1,3 +1,5 @@
//+build linux
package stage0
//
+2
View File
@@ -1,3 +1,5 @@
//+build linux
package main
import (
+2
View File
@@ -1,3 +1,5 @@
//+build linux
package main
// this implements /init of stage1/nspawn+systemd
+2
View File
@@ -1,3 +1,5 @@
//+build linux
package main
import (