2012-06-15 09:23:33 +01:00
|
|
|
#!/bin/sh
|
|
|
|
|
2012-11-19 20:29:27 +00:00
|
|
|
channels_url="http://omahaproxy.appspot.com/all?csv=1";
|
2013-06-14 13:10:47 +01:00
|
|
|
history_url="http://omahaproxy.appspot.com/history";
|
2012-06-15 09:23:33 +01:00
|
|
|
bucket_url="http://commondatastorage.googleapis.com/chromium-browser-official/";
|
2014-03-27 06:20:20 +00:00
|
|
|
base_path="$(cd "$(dirname "$0")" && pwd)";
|
2012-06-15 09:23:33 +01:00
|
|
|
|
2014-03-27 06:20:20 +00:00
|
|
|
source "$(nix-build --no-out-link "$base_path/update.nix" -A updateHelpers)";
|
2012-08-17 11:42:51 +01:00
|
|
|
|
|
|
|
### 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";
|
|
|
|
}
|
|
|
|
|
2013-06-14 13:41:16 +01:00
|
|
|
get_newest_ver()
|
|
|
|
{
|
|
|
|
versions="$(for v in $@; do echo "$v"; done)";
|
|
|
|
if oldest="$(echo "$versions" | sort -V 2> /dev/null | tail -n1)";
|
|
|
|
then
|
|
|
|
echo "$oldest";
|
|
|
|
else
|
|
|
|
echo "$versions" | sort -t. -k 1,1n -k 2,2n -k 3,3n -k 4,4n | tail -n1;
|
|
|
|
fi;
|
|
|
|
}
|
|
|
|
|
2013-06-14 13:10:47 +01:00
|
|
|
fetch_filtered_history()
|
|
|
|
{
|
|
|
|
curl -s "$history_url" | sed -nr 's/^'"linux,$1"',([^,]+).*$/\1/p';
|
|
|
|
}
|
|
|
|
|
|
|
|
get_prev_sha256()
|
|
|
|
{
|
|
|
|
channel="$1";
|
|
|
|
current_version="$2";
|
|
|
|
|
|
|
|
for version in $(fetch_filtered_history "$channel");
|
|
|
|
do
|
|
|
|
[ "x$version" = "x$current_version" ] && continue;
|
2014-03-27 06:20:20 +00:00
|
|
|
sha256="$(get_sha256 "$channel" "$version")" || continue;
|
|
|
|
echo "$sha256:$version";
|
2013-06-14 13:10:47 +01:00
|
|
|
return 0;
|
|
|
|
done;
|
|
|
|
}
|
|
|
|
|
2012-08-17 11:42:51 +01:00
|
|
|
get_channel_exprs()
|
2012-06-15 09:23:33 +01:00
|
|
|
{
|
2013-06-14 12:24:40 +01:00
|
|
|
for chline in $1;
|
2012-07-03 20:48:19 +01:00
|
|
|
do
|
|
|
|
channel="${chline%%,*}";
|
2013-06-14 13:10:47 +01:00
|
|
|
version="${chline##*,}";
|
2013-02-01 07:33:01 +00:00
|
|
|
|
2012-08-17 11:42:51 +01:00
|
|
|
echo -n "Checking if sha256 of version $version is cached..." >&2;
|
|
|
|
if sha256="$(sha_lookup "$version")";
|
|
|
|
then
|
2012-08-26 01:52:33 +01:00
|
|
|
echo " yes: $sha256" >&2;
|
2012-08-17 11:42:51 +01:00
|
|
|
else
|
2012-08-26 01:52:33 +01:00
|
|
|
echo " no." >&2;
|
2014-03-27 06:20:20 +00:00
|
|
|
sha256="$(get_sha256 "$channel" "$version")";
|
2013-06-14 12:24:40 +01:00
|
|
|
if [ $? -ne 0 ];
|
|
|
|
then
|
|
|
|
echo "Whoops, failed to fetch $version, trying previous" \
|
2013-06-14 13:10:47 +01:00
|
|
|
"versions:" >&2;
|
|
|
|
|
2014-03-27 06:20:20 +00:00
|
|
|
sha_ver="$(get_prev_sha256 "$channel" "$version")";
|
|
|
|
sha256="${sha_ver%:*}";
|
|
|
|
version="${sha_ver#*:}";
|
2013-06-14 12:24:40 +01:00
|
|
|
fi;
|
2012-08-17 11:42:51 +01:00
|
|
|
fi;
|
|
|
|
|
|
|
|
sha_insert "$version" "$sha256";
|
2012-07-03 20:48:19 +01:00
|
|
|
|
2014-03-27 08:40:21 +00:00
|
|
|
main="${sha256%%.*}";
|
|
|
|
deb="${sha256#*.}";
|
|
|
|
deb32="${deb%.*}";
|
|
|
|
deb64="${deb#*.}";
|
|
|
|
|
2012-07-03 20:48:19 +01:00
|
|
|
echo " $channel = {";
|
|
|
|
echo " version = \"$version\";";
|
2014-03-27 08:40:21 +00:00
|
|
|
echo " sha256 = \"$main\";";
|
|
|
|
if [ "x${deb#*[a-z0-9].[a-z0-9]}" != "x$deb" ];
|
|
|
|
then
|
|
|
|
echo " sha256bin32 = \"$deb32\";";
|
|
|
|
echo " sha256bin64 = \"$deb64\";";
|
|
|
|
fi;
|
2012-07-03 20:48:19 +01:00
|
|
|
echo " };";
|
|
|
|
done;
|
2012-06-15 09:23:33 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
cd "$(dirname "$0")";
|
|
|
|
|
2012-08-17 11:42:51 +01:00
|
|
|
omaha="$(curl -s "$channels_url")";
|
2013-06-14 13:10:47 +01:00
|
|
|
versions="$(echo "$omaha" | sed -nr -e 's/^linux,([^,]+,[^,]+).*$/\1/p')";
|
2012-08-17 11:42:51 +01:00
|
|
|
channel_exprs="$(get_channel_exprs "$versions")";
|
2012-06-15 09:23:33 +01:00
|
|
|
|
2014-03-27 06:20:20 +00:00
|
|
|
cat > "$base_path/sources.nix" <<-EOF
|
2012-07-03 20:48:19 +01:00
|
|
|
# This file is autogenerated from update.sh in the same directory.
|
2012-06-15 09:23:33 +01:00
|
|
|
{
|
2012-08-17 11:42:51 +01:00
|
|
|
$channel_exprs
|
2012-06-15 09:23:33 +01:00
|
|
|
}
|
|
|
|
EOF
|