about summary refs log tree commit diff
path: root/pkgs/applications/networking/mailreaders/thunderbird-bin/generate_sources.rb
blob: 308e0b71c05a6502c4553baf1437b55fe4e075c1 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
require "open-uri"

version = if ARGV.empty?
            "latest"
          else
            ARGV[0]
          end

base_path = "http://archive.mozilla.org/pub/thunderbird/releases"

Source = Struct.new(:hash, :arch, :locale, :filename)

sources = open("#{base_path}/#{version}/SHA1SUMS") do |input|
  input.readlines
end.select do |line|
  /\/thunderbird-.*\.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

real_version = sources[0].filename.match(/thunderbird-([0-9.]*)\.tar\.bz2/)[1]

arches = ["linux-i686", "linux-x86_64"]

puts(<<"EOH")
# This file is generated from generate_nix.rb. DO NOT EDIT.
# Execute the following command in a temporary directory to update the file.
#
# ruby generate_source.rb > source.nix

{
  version = "#{real_version}";
  sources = [
EOH

sources.each do |source|
  puts(%Q|    { locale = "#{source.locale}"; arch = "#{source.arch}"; sha1 = "#{source.hash}"; }|)
end

puts(<<'EOF')
  ];
}
EOF