diff options
Diffstat (limited to 'pkgs/applications/networking/browsers/firefox-bin/generate_sources.rb')
-rw-r--r-- | pkgs/applications/networking/browsers/firefox-bin/generate_sources.rb | 68 |
1 files changed, 25 insertions, 43 deletions
diff --git a/pkgs/applications/networking/browsers/firefox-bin/generate_sources.rb b/pkgs/applications/networking/browsers/firefox-bin/generate_sources.rb index c4e140412881c..03acf17e426e5 100644 --- a/pkgs/applications/networking/browsers/firefox-bin/generate_sources.rb +++ b/pkgs/applications/networking/browsers/firefox-bin/generate_sources.rb @@ -1,63 +1,45 @@ -# TODO share code with thunderbird-bin/generate_nix.rb +# TODO share code with thunderbird-bin/generate_sources.rb -version = if ARGV.empty? - "latest" - else - ARGV[0] - end +require "open-uri" -base_path = "archive.mozilla.org/pub/firefox/releases" - -arches = ["linux-i686", "linux-x86_64"] - -arches.each do |arch| - system("wget", "--recursive", "--continue", "--no-parent", "--reject-regex", ".*\\?.*", "--reject", "xpi", "http://#{base_path}/#{version}/#{arch}/") -end - -locales = Dir.glob("#{base_path}/#{version}/#{arches[0]}/*").map do |path| - File.basename(path) -end.sort - -locales.delete("index.html") -locales.delete("xpi") - -# real version number, e.g. "30.0" instead of "latest". -real_version = Dir.glob("#{base_path}/#{version}/#{arches[0]}/#{locales[0]}/firefox-*")[0].match(/firefox-([0-9.]*)/)[1][0..-2] - -locale_arch_path_tuples = locales.flat_map do |locale| - arches.map do |arch| - path = Dir.glob("#{base_path}/#{version}/#{arch}/#{locale}/firefox-*")[0] - - [locale, arch, path] +version = + if ARGV.empty? + $stderr.puts("Usage: ruby generate_sources.rb <version> > sources.nix") + exit(-1) + else + ARGV[0] end -end -paths = locale_arch_path_tuples.map do |tuple| tuple[2] end +base_path = "http://archive.mozilla.org/pub/firefox/releases" -hashes = IO.popen(["sha256sum", "--binary", *paths]) do |input| - input.each_line.map do |line| - $stderr.puts(line) +Source = Struct.new(:hash, :arch, :locale, :filename) - line.match(/^[0-9a-f]*/)[0] - end +sources = open("#{base_path}/#{version}/SHA512SUMS") do |input| + input.readlines +end.select do |line| + /\/firefox-.*\.tar\.bz2$/ === line && !(/source/ === line) +end.map do |line| + hash, name = line.chomp.split(/ +/) + Source.new(hash, *(name.split("/"))) +end.sort_by do |source| + [source.locale, source.arch] end +arches = ["linux-i686", "linux-x86_64"] puts(<<"EOH") # This file is generated from generate_sources.rb. DO NOT EDIT. -# Execute the following command in a temporary directory to update the file. +# Execute the following command to update the file. # -# ruby generate_sources.rb > sources.nix +# ruby generate_sources.rb 46.0.1 > sources.nix { - version = "#{real_version}"; + version = "#{version}"; sources = [ EOH -locale_arch_path_tuples.zip(hashes) do |tuple, hash| - locale, arch, path = tuple - - puts(%Q| { locale = "#{locale}"; arch = "#{arch}"; sha256 = "#{hash}"; }|) +sources.each do |source| + puts(%Q| { locale = "#{source.locale}"; arch = "#{source.arch}"; sha512 = "#{source.hash}"; }|) end puts(<<'EOF') |