File: list_packages.rb

package info (click to toggle)
ruby-debian 0.3.12
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 488 kB
  • sloc: ruby: 2,704; fortran: 90; makefile: 44; cpp: 36
file content (38 lines) | stat: -rw-r--r-- 890 bytes parent folder | download | duplicates (8)
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
#!/usr/bin/ruby
# Copyright (c) 2001 Fumitoshi UKAI <ukai@debian.or.jp>
# GPL2

require 'debian'
require 'getoptlong'

file=''
top='/org/ftp.debian.org/ftp/dists/stable'
arch=Debian::Dpkg.installation_architecture

opts = GetoptLong.new(
		      ["--file", "-f", GetoptLong::REQUIRED_ARGUMENT],
		      ["--arch", "-a", GetoptLong::REQUIRED_ARGUMENT],
		      ["--top", "-t", GetoptLong::REQUIRED_ARGUMENT],
		      ["--help", "-h", GetoptLong::NO_ARGUMENT])
opts.each {|opt,val|
  case opt
  when "--file" then file = val
  when "--arch" then arch = val
  when "--top" then top = top
  else
    $stderr.puts "usage: $0 [-a arch] [-t top] [-f file]"
    exit 1
  end
}

packages = Debian::Packages.new
Debian::COMPONENT.collect {|c|
  f = file
  if file == ""
    f = "#{top}/#{c}/binary-#{arch}/Packages"
  end
  packages += Debian::Packages.new(f)
}
packages.each_package {|p|
  puts p
}