-
Notifications
You must be signed in to change notification settings - Fork 883
Default stage1 path should be configurable with a build option #520
Conversation
You're totally right, I realised this late last night after I had told you it was possible! I'm proposing using an environment variable at build time to specify this. |
@@ -14,7 +14,9 @@ export GOPATH=${PWD}/gopath | |||
eval $(go env) | |||
|
|||
echo "Building rkt (stage0)..." | |||
go build -o $GOBIN/rkt ${REPO_PATH}/rkt | |||
eval go build -o ${GOBIN}/rkt \ | |||
${RKT_STAGE1_IMAGE:+-ldflags \'-X main.defaultStage1Image "${RKT_STAGE1_IMAGE}"\'} \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there is probably a better way of doing this than using eval but my bash fu is terrible, so improvements gladly welcomed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What am I missing here, just drop the eval?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+ go build -o /home/jon/git/rocket/bin/rkt -ldflags ''\''-X' main.defaultStage1Image '/foo'\''' github.com/coreos/rocket/rkt
invalid value "'-X" for flag -ldflags: unterminated ' string
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are escaping ' but not inside of another string. You probably want:
${RKT_STAGE1_IMAGE:+-ldflags "-X main.defaultStage1Image '${RKT_STAGE1_IMAGE}'"} \
And drop the eval. It is only going to make escaping more complicated.
Alternatively it may be clearer to construct arguments in an array:
args=( build -o "${GOBIN}/rkt" )
if [[ -n "${RKT_STAGE1_IMAGE}" ]]; then
args+=( -ldflags "-X main.defaultStage1Image '${RKT_STAGE1_IMAGE}'" )
fi
go "${args[@]}" "${REPO_PATH}/rkt"
or something like that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you're a wizard
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.
lgtm |
Default stage1 path should be configurable with a build option
As mentioned in #457 (comment), the path where the rkt binary looks for stage1 should be something you can specify when building rocket.
Looking at the code, this doesn't currently appear to be the case.
This is currently blocking a fix to the Arch Linux AUR package, and will probably be necessary for other distributions as well.