chromium: Remove URL in sources.nix and updater.

The updater is now splitted between a shellscript and a Nix expression
file which contains helpers and lookup functions to reconstruct all
information needed in order to fetch the source tarballs.

This means, that the sources.nix now doesn't contain URLs and only
versions and the corresponding SHA256 hashes. Of course, right now this
sounds like it's unnecessary, but we're going to fetch binaries soon so
it's a good idea to not unnecessarily clutter up sources.nix.

Signed-off-by: aszlig <aszlig@redmoonstudios.org>
This commit is contained in:
aszlig 2014-03-27 07:20:20 +01:00
parent 8bc8b51375
commit 2741523926
No known key found for this signature in database
GPG Key ID: D0EBD0EC8C2DC961
4 changed files with 71 additions and 59 deletions

View File

@ -4,7 +4,10 @@
}:
with stdenv.lib;
with getAttr channel (import ./sources.nix);
with (import ./update.nix {
inherit (stdenv) system;
}).getChannel channel;
stdenv.mkDerivation {
name = "chromium-source-${version}";

View File

@ -2,17 +2,14 @@
{
dev = {
version = "35.0.1883.0";
url = "http://commondatastorage.googleapis.com/chromium-browser-official/chromium-35.0.1883.0.tar.xz";
sha256 = "0qbv6prxl18y5824pfd13ng9798g561gzb6nypwp502hqr45jvb6";
};
beta = {
version = "34.0.1847.60";
url = "http://commondatastorage.googleapis.com/chromium-browser-official/chromium-34.0.1847.60.tar.xz";
sha256 = "1na5d6z4a0wkabn7cj62vyiv3mmvcb6qdvrkyy6fj79h7gk2hb7k";
};
stable = {
version = "34.0.1847.116";
url = "http://commondatastorage.googleapis.com/chromium-browser-official/chromium-34.0.1847.116.tar.xz";
sha256 = "04cpfav5rqa117igvzmrw0045r2ljxg5fqb46qgqvkgff30pjrfx";
};
}

View File

@ -0,0 +1,58 @@
{ system ? builtins.currentSystem }:
let
inherit (import <nixpkgs> {}) lib writeText;
sources = if builtins.pathExists ./sources.nix
then import ./sources.nix
else null;
bucketURL = "http://commondatastorage.googleapis.com/"
+ "chromium-browser-official";
tryChannel = channel: let
chanAttrs = builtins.getAttr channel sources;
in if sources != null then ''
oldver="${chanAttrs.version}";
echo -n "Checking if $oldver ($channel) is up to date..." >&2;
if [ "x$(get_newest_ver "$version" "$oldver")" != "x$oldver" ];
then
echo " no, getting sha256 for new version $version:" >&2;
sha256="$(nix-prefetch-url "$url")" || return 1;
else
echo " yes, keeping old sha256." >&2;
sha256="${chanAttrs.sha256}";
fi;
'' else ''
sha256="$(nix-prefetch-url "$url")" || return 1;
'';
caseChannel = channel: ''
${channel}) ${tryChannel channel};;
'';
in rec {
getChannel = channel: let
chanAttrs = builtins.getAttr channel sources;
in {
url = "${bucketURL}/chromium-${chanAttrs.version}.tar.xz";
inherit (chanAttrs) version sha256;
};
updateHelpers = writeText "update-helpers.sh" ''
get_sha256()
{
channel="$1";
version="$2";
url="${bucketURL}/chromium-$version.tar.xz";
case "$channel" in
${lib.concatMapStrings caseChannel [ "stable" "dev" "beta" ]}
esac;
sha_insert "$version" "$sha256";
echo "$sha256";
return 0;
}
'';
}

View File

@ -3,16 +3,9 @@
channels_url="http://omahaproxy.appspot.com/all?csv=1";
history_url="http://omahaproxy.appspot.com/history";
bucket_url="http://commondatastorage.googleapis.com/chromium-browser-official/";
output_file="$(cd "$(dirname "$0")" && pwd)/sources.nix";
base_path="$(cd "$(dirname "$0")" && pwd)";
nix_getattr()
{
input_file="$1";
attr="$2";
var="$(nix-instantiate --eval-only -A "$attr" "$output_file")";
echo "$var" | tr -d '\\"';
}
source "$(nix-build --no-out-link "$base_path/update.nix" -A updateHelpers)";
### poor mans key/value-store :-) ###
@ -53,39 +46,6 @@ get_newest_ver()
fi;
}
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$(get_newest_ver "$version" "$oldver")" != "x$oldver" ];
then
echo " no, getting sha256 for new version $version:" >&2;
sha256="$(nix-prefetch-url "$url")" || return 1;
else
echo " yes, keeping old sha256." >&2;
sha256="$(nix_getattr "$output_file" "$channel.sha256")" \
|| return 1;
fi;
sha_insert "$version" "$sha256";
echo "$sha256";
return 0;
}
else
get_sha256()
{
nix-prefetch-url "$3";
}
fi;
fetch_filtered_history()
{
curl -s "$history_url" | sed -nr 's/^'"linux,$1"',([^,]+).*$/\1/p';
@ -99,9 +59,8 @@ get_prev_sha256()
for version in $(fetch_filtered_history "$channel");
do
[ "x$version" = "x$current_version" ] && continue;
url="${bucket_url%/}/chromium-$version.tar.xz";
sha256="$(get_sha256 "$channel" "$version" "$url")" || continue;
echo "$sha256:$version:$url";
sha256="$(get_sha256 "$channel" "$version")" || continue;
echo "$sha256:$version";
return 0;
done;
}
@ -113,25 +72,21 @@ get_channel_exprs()
channel="${chline%%,*}";
version="${chline##*,}";
url="${bucket_url%/}/chromium-$version.tar.xz";
echo -n "Checking if sha256 of version $version is cached..." >&2;
if sha256="$(sha_lookup "$version")";
then
echo " yes: $sha256" >&2;
else
echo " no." >&2;
sha256="$(get_sha256 "$channel" "$version" "$url")";
sha256="$(get_sha256 "$channel" "$version")";
if [ $? -ne 0 ];
then
echo "Whoops, failed to fetch $version, trying previous" \
"versions:" >&2;
sha_ver_url="$(get_prev_sha256 "$channel" "$version")";
sha256="${sha_ver_url%%:*}";
ver_url="${sha_ver_url#*:}";
version="${ver_url%%:*}";
url="${ver_url#*:}";
sha_ver="$(get_prev_sha256 "$channel" "$version")";
sha256="${sha_ver%:*}";
version="${sha_ver#*:}";
fi;
fi;
@ -139,7 +94,6 @@ get_channel_exprs()
echo " $channel = {";
echo " version = \"$version\";";
echo " url = \"$url\";";
echo " sha256 = \"$sha256\";";
echo " };";
done;
@ -151,7 +105,7 @@ omaha="$(curl -s "$channels_url")";
versions="$(echo "$omaha" | sed -nr -e 's/^linux,([^,]+,[^,]+).*$/\1/p')";
channel_exprs="$(get_channel_exprs "$versions")";
cat > "$output_file" <<-EOF
cat > "$base_path/sources.nix" <<-EOF
# This file is autogenerated from update.sh in the same directory.
{
$channel_exprs