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
47
48
49
|
require 'date'
module Gentoo
class DownloadGenerator < Jekyll::Generator
DIR = '_data/downloads/'
def generate(site)
site.data['downloads'] ||= {}
Dir.glob(DIR + '*') do |raw_arch|
arch = File.basename(raw_arch)
site.data['downloads'][arch] = {}
File.readlines(raw_arch + '/iso.txt').each do |line|
next if line.start_with? '#'
if line =~ /^(\d{8})\/(\S+) (\d+)$/
date = Date.parse('%s-%s-%s' % [$1[0..3], $1[4..5], $1[6..7]])
site.data['downloads'][arch]['iso'] ||= {}
if $2.include? 'minimal'
site.data['downloads'][arch]['iso']['minimal'] = { 'date' => date, 'filename' => '%s/%s' % [$1, $2], 'size' => $3 }
else
subdir, filename, size = $1, $2, $3
iso_name = $2.gsub(/-#{$1}.*$/, '')
site.data['downloads'][arch]['iso'][iso_name] = { 'date' => date, 'filename' => '%s/%s' % [subdir, filename], 'size' => size }
end
end
end
File.readlines(raw_arch + '/stage3.txt').each do |line|
next if line.start_with? '#'
if line =~ /^(\d{8})\/(\w+\/)?stage3-(.*)-\d{8}.tar.(\S+) (\d+)$/
date = Date.parse('%s-%s-%s' % [$1[0..3], $1[4..5], $1[6..7]])
site.data['downloads'][arch]['stage3'] ||= {}
site.data['downloads'][arch]['stage3'][$3] = {
'name' => $3,
'date' => date,
'filename' => '%s/%sstage3-%s-%s.tar.%s' % [$1, $2, $3, $1, $4],
'subdir' => $2,
'size' => $5
}
end
end
end
end
end
end
|