#!/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 key = "stable" else key = ARGV.shift.strip.downcase end 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