From ec395a78ee87388b4f808a9d4efaa28fd518cea6 Mon Sep 17 00:00:00 2001 From: aszlig Date: Tue, 3 Jul 2012 21:48:19 +0200 Subject: [PATCH] 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. --- .../networking/browsers/chromium/update.sh | 48 ++++++++++++------- 1 file changed, 32 insertions(+), 16 deletions(-) diff --git a/pkgs/applications/networking/browsers/chromium/update.sh b/pkgs/applications/networking/browsers/chromium/update.sh index 066cd1c147f7..c9dd69df9a20 100755 --- a/pkgs/applications/networking/browsers/chromium/update.sh +++ b/pkgs/applications/networking/browsers/chromium/update.sh @@ -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-[^<]*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 < "$output_file" <<-EOF +# This file is autogenerated from update.sh in the same directory. +# VHASH: $vhash { - version = "$version"; - url = "$url"; - sha256 = "$sha256"; +$channels } EOF