chromium: Extend update script to use channels.

The previos update script just used the last version of chromium that showed up
at the bucket list at:

http://commondatastorage.googleapis.com/chromium-browser-official/

I'm not sure which channel this list actually holds, so I'm going to switch now
using the official release channels grabbed by omahaproxy. This also has the
advantage that we can provide different versions/flavors of chromium.

We now also write our data to sources.nix instead of source.nix, as we have more
than one source.
This commit is contained in:
aszlig 2012-07-03 21:48:19 +02:00
parent cace272941
commit ec395a78ee

View File

@ -1,34 +1,50 @@
#!/bin/sh
channels_url="http://omahaproxy.appspot.com/";
bucket_url="http://commondatastorage.googleapis.com/chromium-browser-official/";
output_file="$(cd "$(dirname "$0")" && pwd)/sources.nix";
get_newest_version()
get_channels()
{
curl -s "$bucket_url" | sed -ne ' H;/<[Kk][Ee][Yy]>chromium-[^<]*</h;${
g;s/^.*<Key>chromium-\([^<.]\+\(\.[^<.]\+\)\+\)\.tar\.bz2<.*$/\1/p
}';
for chline in $(echo "$1" | cut -d, -f-2);
do
channel="${chline%%,*}";
version="${chline##*,}";
url="${bucket_url%/}/chromium-$version.tar.bz2";
sha256="$(nix-prefetch-url "$url")";
echo " $channel = {";
echo " version = \"$version\";";
echo " url = \"$url\";";
echo " sha256 = \"$sha256\";";
echo " };";
done;
}
cd "$(dirname "$0")";
version="$(get_newest_version)";
versions="$(curl -s "$channels_url" | sed -n -e 's/^linux,\(\([^,]\+,\)\{2\}\).*$/\1/p')";
if [ -e source.nix ]; then
oldver="$(sed -n 's/^ *version *= *"\([^"]\+\)".*$/\1/p' source.nix)";
if [ "x$oldver" = "x$version" ]; then
echo "Already the newest version: $version" >&2;
if [ -e "$output_file" ];
then
vhash="$(echo "$versions" | sha256sum | cut -d' ' -f1)";
old_vhash="$(sed -n 's/# *VHASH: *//p' "$output_file")";
if [ "x$vhash" = "x$old_vhash" ];
then
echo "$output_file is already up to date, bailing out." >&2;
exit 1;
fi;
fi;
url="${bucket_url%/}/chromium-$version.tar.bz2";
channels="$(get_channels "$versions")";
sha256="$(nix-prefetch-url "$url")";
cat > source.nix <<EOF
cat > "$output_file" <<-EOF
# This file is autogenerated from update.sh in the same directory.
# VHASH: $vhash
{
version = "$version";
url = "$url";
sha256 = "$sha256";
$channels
}
EOF