Ogeon / rust-on-raspberry-pi

[OUTDATED] Instructions for how to cross compile Rust projects for the Raspberry Pi
292 stars 15 forks source link

Automatically detect latest stable version for rust build #7

Closed schnupperboy closed 8 years ago

schnupperboy commented 8 years ago

I updated the git references for the rust repo inside the Dockerfile and it's documentation to 1.5.0 since it has been released as the new stable version...

Update: A mechanism was implemented which auto-detects the latest version number of rust stable by using the tags of the rust git repository. This avoids hard coding the version number.

Ogeon commented 8 years ago

Hmm... Wouldn't it be better to grab the latest version from the tag list? Doing this every six week won't be too fun...

Ogeon commented 8 years ago

I think this should do the trick, unless they decide to retroactively add tags:

git for-each-ref --sort=-taggerdate --count=1 --format '%(tag)' refs/tags

An other idea is to filter out the x.y.z formated tags and version sort them, but I don't know if there is a portable way to do that.

schnupperboy commented 8 years ago

I'd prefer the latter since it still works -- like you already said -- even if they decide to retroactively add tags.

Portability isn't important in my opinion because we control the build environment of the cross compiler (debian jessie at the moment).

What about something like:

git tag --list [[:digit:]].[[:digit:]].[[:digit:]] | sort | tail --lines 1
Ogeon commented 8 years ago

Portability isn't a big deal because we control the build environment of the cross compiler (debian jessie at the moment).

True. It's better than relying on the taggerdates.

git tag --list [[:digit:]].[[:digit:]].[[:digit:]] | sort | tail --lines 1

We have to take multi-digit numbers into account, so version sort (sort -V) is essential. Will [[:digit:]] match multiple digits?

schnupperboy commented 8 years ago

We have to take multi-digit numbers into account, so version sort (sort -V) is essential. Will [[:digit:]] match multiple digits?

No it doesn't. This is better:

git tag --list | grep "^[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}$" | sort -V
Ogeon commented 8 years ago

Yeah, that or without upper limits:

git tag --list | grep "^[0-9]\+\.[0-9]\+\.[0-9]\+$" | sort -V
schnupperboy commented 8 years ago

I implemented what you suggested in your last comment (version numbers without upper limits), see my latest commit. Anything missing?

Ogeon commented 8 years ago

I think that's it. I would appreciate it if you could squash the commits into one, and edit the PR title and description to reflect this new strategy.

schnupperboy commented 8 years ago

Done :)

Ogeon commented 8 years ago

Great, thank you!