2012-06-15 10:23:33 +02:00
|
|
|
#!/bin/sh
|
|
|
|
|
2012-11-19 21:29:27 +01:00
|
|
|
channels_url="http://omahaproxy.appspot.com/all?csv=1";
|
2012-06-15 10:23:33 +02:00
|
|
|
bucket_url="http://commondatastorage.googleapis.com/chromium-browser-official/";
|
2012-07-03 21:48:19 +02:00
|
|
|
output_file="$(cd "$(dirname "$0")" && pwd)/sources.nix";
|
2012-06-15 10:23:33 +02:00
|
|
|
|
2012-08-17 12:42:51 +02:00
|
|
|
nix_getattr()
|
|
|
|
{
|
|
|
|
input_file="$1";
|
|
|
|
attr="$2";
|
|
|
|
|
|
|
|
var="$(nix-instantiate --eval-only -A "$attr" "$output_file")";
|
|
|
|
echo "$var" | tr -d '\\"';
|
|
|
|
}
|
|
|
|
|
|
|
|
### poor mans key/value-store :-) ###
|
|
|
|
|
|
|
|
ver_sha_table=""; # list of version:sha256
|
|
|
|
|
|
|
|
sha_lookup()
|
|
|
|
{
|
|
|
|
version="$1";
|
|
|
|
|
|
|
|
for ver_sha in $ver_sha_table;
|
|
|
|
do
|
|
|
|
if [ "x${ver_sha%:*}" = "x$version" ];
|
|
|
|
then
|
|
|
|
echo "${ver_sha##*:}";
|
|
|
|
return 0;
|
|
|
|
fi;
|
|
|
|
done;
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
sha_insert()
|
|
|
|
{
|
|
|
|
version="$1";
|
|
|
|
sha256="$2";
|
|
|
|
|
|
|
|
ver_sha_table="$ver_sha_table $version:$sha256";
|
|
|
|
}
|
|
|
|
|
|
|
|
if [ -e "$output_file" ];
|
|
|
|
then
|
|
|
|
get_sha256()
|
|
|
|
{
|
|
|
|
channel="$1";
|
|
|
|
version="$2";
|
|
|
|
url="$3";
|
|
|
|
|
|
|
|
oldver="$(nix_getattr "$output_file" "$channel.version")";
|
|
|
|
|
|
|
|
echo -n "Checking if $oldver ($channel) is up to date..." >&2;
|
|
|
|
|
|
|
|
if [ "x$version" != "x$oldver" ];
|
|
|
|
then
|
|
|
|
echo " no, getting sha256 for new version $version:" >&2;
|
|
|
|
sha256="$(nix-prefetch-url "$url")";
|
|
|
|
else
|
|
|
|
echo " yes, keeping old sha256." >&2;
|
|
|
|
sha256="$(nix_getattr "$output_file" "$channel.sha256")";
|
|
|
|
fi;
|
|
|
|
|
2013-03-26 21:06:36 +01:00
|
|
|
sha_insert "$version" "$sha256";
|
2012-08-17 12:42:51 +02:00
|
|
|
echo "$sha256";
|
|
|
|
}
|
|
|
|
else
|
|
|
|
get_sha256()
|
|
|
|
{
|
|
|
|
nix-prefetch-url "$url";
|
|
|
|
}
|
|
|
|
fi;
|
|
|
|
|
|
|
|
get_channel_exprs()
|
2012-06-15 10:23:33 +02:00
|
|
|
{
|
2012-07-03 21:48:19 +02:00
|
|
|
for chline in $(echo "$1" | cut -d, -f-2);
|
|
|
|
do
|
|
|
|
channel="${chline%%,*}";
|
|
|
|
version="${chline##*,}";
|
2013-02-01 08:33:01 +01:00
|
|
|
|
2013-06-14 13:06:12 +02:00
|
|
|
url="${bucket_url%/}/chromium-$version.tar.xz";
|
2012-07-03 21:48:19 +02:00
|
|
|
|
2012-08-17 12:42:51 +02:00
|
|
|
echo -n "Checking if sha256 of version $version is cached..." >&2;
|
|
|
|
if sha256="$(sha_lookup "$version")";
|
|
|
|
then
|
2012-08-26 02:52:33 +02:00
|
|
|
echo " yes: $sha256" >&2;
|
2012-08-17 12:42:51 +02:00
|
|
|
else
|
2012-08-26 02:52:33 +02:00
|
|
|
echo " no." >&2;
|
2012-08-17 12:42:51 +02:00
|
|
|
sha256="$(get_sha256 "$channel" "$version" "$url")";
|
|
|
|
fi;
|
|
|
|
|
|
|
|
sha_insert "$version" "$sha256";
|
2012-07-03 21:48:19 +02:00
|
|
|
|
|
|
|
echo " $channel = {";
|
|
|
|
echo " version = \"$version\";";
|
|
|
|
echo " url = \"$url\";";
|
|
|
|
echo " sha256 = \"$sha256\";";
|
|
|
|
echo " };";
|
|
|
|
done;
|
2012-06-15 10:23:33 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
cd "$(dirname "$0")";
|
|
|
|
|
2012-08-17 12:42:51 +02:00
|
|
|
omaha="$(curl -s "$channels_url")";
|
|
|
|
versions="$(echo "$omaha" | sed -n -e 's/^linux,\(\([^,]\+,\)\{2\}\).*$/\1/p')";
|
|
|
|
channel_exprs="$(get_channel_exprs "$versions")";
|
2012-06-15 10:23:33 +02:00
|
|
|
|
2012-07-03 21:48:19 +02:00
|
|
|
cat > "$output_file" <<-EOF
|
|
|
|
# This file is autogenerated from update.sh in the same directory.
|
2012-06-15 10:23:33 +02:00
|
|
|
{
|
2012-08-17 12:42:51 +02:00
|
|
|
$channel_exprs
|
2012-06-15 10:23:33 +02:00
|
|
|
}
|
|
|
|
EOF
|