Skip to content
This repository has been archived by the owner on Feb 24, 2020. It is now read-only.

Default stage1 path should be configurable with a build option #520

Merged
merged 1 commit into from
Feb 13, 2015

Conversation

jonboulle
Copy link
Contributor

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.

@jonboulle
Copy link
Contributor

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}"\'} \
Copy link
Contributor Author

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.

Copy link
Contributor

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?

Copy link
Contributor Author

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

Copy link
Contributor

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.

Copy link
Contributor Author

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.
@philips
Copy link
Contributor

philips commented Feb 13, 2015

lgtm

jonboulle added a commit that referenced this pull request Feb 13, 2015
Default stage1 path should be configurable with a build option
@jonboulle jonboulle merged commit 97f1e29 into rkt:master Feb 13, 2015
@jonboulle jonboulle deleted the build branch February 13, 2015 01:46
@philips philips added this to the v0.4.0 milestone Feb 13, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants