mirror of
https://github.com/clearlinux/rkt.git
synced 2026-08-18 13:05:57 +00:00
build: allow setting of stage1 image path
This introduces the ability to set the default stage1 image path for `rkt run` by setting the environment variable RKT_STAGE1_IMAGE at build time (i.e when invoking ./build). The variable should be set to the fully qualified path at which rkt can find the stage1 image - for example: RKT_STAGE1_IMAGE=/usr/lib/rkt/stage1.aci ./build Rocket will use this environment variable to set the default value for the stage1-image flag. If the value is _not_ set, it will continue to use the heuristic it does today to guess the location of the stage1 image, by looking for a file called stage1.aci that is in the same directory as rkt itself.
This commit is contained in:
@@ -14,7 +14,9 @@ export GOPATH=${PWD}/gopath
|
||||
eval $(go env)
|
||||
|
||||
echo "Building rkt (stage0)..."
|
||||
go build -o $GOBIN/rkt ${REPO_PATH}/rkt
|
||||
go build -o ${GOBIN}/rkt \
|
||||
${RKT_STAGE1_IMAGE:+-ldflags "-X main.defaultStage1Image '${RKT_STAGE1_IMAGE}'"} \
|
||||
${REPO_PATH}/rkt
|
||||
|
||||
if [[ "$OSTYPE" == "linux-gnu" ]]; then
|
||||
echo "Building network plugins..."
|
||||
|
||||
+9
-6
@@ -31,6 +31,8 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
defaultStage1Image string // either set by linker, or guessed in init()
|
||||
|
||||
flagStage1Image string
|
||||
flagVolumes volumeList
|
||||
flagPrivateNet bool
|
||||
@@ -48,14 +50,15 @@ They will be checked in that order and the first match will be used.`,
|
||||
func init() {
|
||||
commands = append(commands, cmdRun)
|
||||
|
||||
// try discover the directory rkt is running from, assume the default stage1.aci is stored alongside it.
|
||||
defaultStage1Image := ""
|
||||
exePath, err := os.Readlink("/proc/self/exe")
|
||||
if err == nil {
|
||||
defaultStage1Image = filepath.Join(filepath.Dir(exePath), "stage1.aci")
|
||||
// if not set by linker, try discover the directory rkt is running
|
||||
// from, and assume the default stage1.aci is stored alongside it.
|
||||
if defaultStage1Image == "" {
|
||||
if exePath, err := os.Readlink("/proc/self/exe"); err == nil {
|
||||
defaultStage1Image = filepath.Join(filepath.Dir(exePath), "stage1.aci")
|
||||
}
|
||||
}
|
||||
|
||||
cmdRun.Flags.StringVar(&flagStage1Image, "stage1-image", defaultStage1Image, `image to use as stage1. Local paths and http/https URLs are supported. By default, Rocket will look for a file called "stage1.aci" in the same directory as rkt itself`)
|
||||
cmdRun.Flags.StringVar(&flagStage1Image, "stage1-image", defaultStage1Image, `image to use as stage1. Local paths and http/https URLs are supported. If empty, Rocket will look for a file called "stage1.aci" in the same directory as rkt itself`)
|
||||
cmdRun.Flags.Var(&flagVolumes, "volume", "volumes to mount into the shared container environment")
|
||||
cmdRun.Flags.BoolVar(&flagPrivateNet, "private-net", false, "give container a private network")
|
||||
cmdRun.Flags.BoolVar(&flagSpawnMetadataSvc, "spawn-metadata-svc", false, "launch metadata svc if not running")
|
||||
|
||||
Reference in New Issue
Block a user