summaryrefslogtreecommitdiff
path: root/debian
blob: 96fe2252018224faf9bc2c33e15dc7076ee68688 (plain)
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#!/usr/bin/env ruby

require 'abbrev'

$map = [
  %w( buzz 1.1 ),
  %w( rex 1.2 ),
  %w( bo 1.3 ),
  %w( hamm 2.0 ),
  %w( slink 2.1 ),
  %w( potato 2.2 ),
  %w( woody 3.0 ),
  %w( sarge 3.1 ),
  %w( etch 4.0 ),
  %w( lenny 5.0 ),
  %w( squeeze 6.0 ),
  %w( wheezy 7 ),
  %w( jessie 8 ),
  %w( stretch 9 ),
  %w( buster 10 ),
  %w( bullseye 11 ),
  %w( sid unstable )
]

$stable = 9

def extras(keys)
  if keys.include?(($stable-2).to_s) then
    return ["oldoldstable"]
  elsif keys.include?(($stable-1).to_s) then
    return ["oldstable"]
  elsif keys.include?($stable.to_s) then
    return ["stable"]
  elsif keys.include?(($stable+1).to_s) then
    return ["testing"]
  else
    return []
  end
end

def find(elem)
  we = $map.map { |entry|
    entry + extras(entry)
  }

  ab = Abbrev.abbrev(we.flatten)
    
  s = we.select { |entry|
    entry.include?(ab[elem])
  }.first
  return nil if s.nil?
  return s - [elem]
end

if ARGV.length != 1 then
  $stderr.puts "No key provided"
  exit 2
end

key = ARGV.shift.strip.downcase

res = find(key)

if res.nil? then
  puts "No such key or ambiguous abbreviation"
  exit 1
end

puts "Debian \"#{key}\":"
tab = 8 + key.length + 2
res.each do |val|
  puts "#{" "*tab}\"#{val}\""
end