nixpkgs/pkgs/applications/networking/mailreaders/thunderbird-bin/generate_sources.rb

47 lines
1 KiB
Ruby
Raw Normal View History

2016-05-11 20:39:03 +02:00
require "open-uri"
version =
if ARGV.empty?
$stderr.puts("Usage: ruby generate_sources.rb <version> > sources.nix")
exit(-1)
else
ARGV[0]
2015-11-28 04:00:44 +01:00
end
2016-05-11 20:39:03 +02:00
base_path = "http://archive.mozilla.org/pub/thunderbird/releases"
2015-11-28 04:00:44 +01:00
2016-05-11 20:39:03 +02:00
Source = Struct.new(:hash, :arch, :locale, :filename)
2015-11-28 04:00:44 +01:00
2016-05-11 20:39:03 +02:00
sources = open("#{base_path}/#{version}/SHA512SUMS") 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]
2015-11-28 04:00:44 +01:00
end
2016-05-11 20:39:03 +02:00
arches = ["linux-i686", "linux-x86_64"]
puts(<<"EOH")
2015-11-28 04:00:44 +01:00
# This file is generated from generate_sources.rb. DO NOT EDIT.
2016-05-11 20:39:03 +02:00
# Execute the following command to update the file.
#
2016-05-11 20:39:03 +02:00
# ruby generate_sources.rb 45.1.0 > sources.nix
{
2016-05-11 20:39:03 +02:00
version = "#{version}";
sources = [
EOH
2016-05-11 20:39:03 +02:00
sources.each do |source|
puts(%Q| { locale = "#{source.locale}"; arch = "#{source.arch}"; sha512 = "#{source.hash}"; }|)
end
puts(<<'EOF')
];
}
EOF