Commit 384bb7f4 authored by Ryan Niebur's avatar Ryan Niebur

Imported Debian version 0.3.2

parents
#
# Makefile
#
SHELL = /bin/sh
RUBY = ruby
RM = rm
#### Start of system configuration section. ####
prefix = $(DESTDIR)/usr
bindir = $(prefix)/bin
libdir = $(prefix)/lib/ruby/$(shell $(RUBY) -rrbconfig -e 'puts Config::CONFIG["ruby_version"]')
mandir = $(DESTDIR)/usr/share/man
bins = $(wildcard bin/*)
libs = $(wildcard lib/*.rb)
libs_debian = $(wildcard lib/debian/*.rb)
man1 = $(wildcard man/*.1)
all:
clean:
@-(cd t; rm -f test.log)
distclean: clean
realclean: distclean
install:
@$(RUBY) -r ftools -e 'File::makedirs(*ARGV)' $(bindir)
@$(RUBY) -r ftools -e 'File::makedirs(*ARGV)' $(libdir)
@for b in $(bins); do \
$(RUBY) -r ftools -e 'File::install(ARGV[0], ARGV[1], 0755, true)' \
$$b $(bindir); \
done
@for rb in $(libs); do \
$(RUBY) -r ftools -e 'File::install(ARGV[0], ARGV[1], 0644, true)'\
$$rb $(libdir); \
done
@mkdir $(libdir)/debian/
@for rb in $(libs_debian); do \
$(RUBY) -r ftools -e 'File::install(ARGV[0], ARGV[1], 0644, true)'\
$$rb $(libdir)/debian; \
done
@mkdir -p $(mandir)/man1
@for m in $(man1); do \
$(RUBY) -r ftools -e 'File::install(ARGV[0], ARGV[1], 0644, true)' \
$$m $(mandir)/man1; \
done
test:
@(cd t; $(RUBY) testall.rb -o test.log)
dpkg-ruby - Ruby interface modules for dpkg
/usr/bin/dpkg.rb - dpkg like program (under development)
/usr/bin/dpkg-ruby - dpkg-awk clone
/usr/bin/dpkg-checkdeps.rb - check deb dependency problem
See also /usr/share/doc/dpkg-ruby/examples/
This program provides the following modules/class.
(old, to be rewritten)
Debian::Dpkg module
Dpkg.compare_versions(a,rel,b)
Dpkg.architecture
Dpkg.gnu_build_architecture
Dpkg.installation_architecture
Debian::DpkgDeb module
DpkgDeb.deb?(file)
DpkgDeb.control(file)
DpkgDeb.data(file)
DpkgDeb.load(file)
Debian::Deb class - for *.deb
.package -> aString
.source -> aString
.version -> aString
.provides -> array of aString
[field] -> aString
.unmet(aDebian::Packages) -> array of Debian::Dep::Unmet
Debian::Dsc class - for *.dsc
.package -> aString
.version -> aString
.binary -> array of aString
[field] -> aString
Debian::Archives class - parser of Packages,Sources
+ (aDebianArchives) -> aDebian::Archives
.each {|pkgname, d| block }
.each_key {|pkgname| block }
Debian::Sources < Debian::Archives - parser of Sources
Debian::Packages < Debian::Archives - parser of Packages
[pkgname] -> aDebianDeb
.provides(pkgname) -> array of aDebian::Deb
Debian::Status < Debian::Archives - parser of dpkg status
THANKS
akira yamada <akira@debian.org> - ruby coding style suggestions
$Id: README,v 1.7 2001/04/27 21:42:12 ukai Exp $
TODO
official release
performance tuning
slow!
more/better APIs
dpkg-deb APIs
conflicts checks
cleanup APIs
debian.rb -> debian/dpkg.rb ?
documentation
manual? info? RD?
useful samples
grep-dctrl.rb ?
remove /usr/bin/dpkg dependency
compare_versions
*architecture
remove ar,tar,gunzip dependency
gunzip -> libzlib-ruby
tar -> ??
test/test suites
-> more test
support old deb format?
$Id: TODO,v 1.11 2001/04/27 21:42:12 ukai Exp $
#!/usr/bin/ruby
#
# dpkg-checkdeps - utilities to check deb dependency
# Copyright (c) 2001 Fumitoshi UKAI <ukai@debian.or.jp>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# $Id: dpkg-checkdeps.rb,v 1.6 2001/05/15 18:16:26 ukai Exp $
#
require 'debian'
require 'getoptlong'
include Debian
opts = GetoptLong.new(["--to", "-t", GetoptLong::REQUIRED_ARGUMENT],
["--check", "-c", GetoptLong::NO_ARGUMENT],
["--from", "-f", GetoptLong::REQUIRED_ARGUMENT],
["--arch", "-a", GetoptLong::REQUIRED_ARGUMENT],
["--all", "-A", GetoptLong::NO_ARGUMENT],
["--verbose", "-v", GetoptLong::NO_ARGUMENT],
["--quiet", "-q", GetoptLong::NO_ARGUMENT],
["--help", "-h", GetoptLong::NO_ARGUMENT])
$quiet = false
$verbose = false
arch = Dpkg.installation_architecture
def usage
puts "Usage: #{$0} [opts] [{packagename|package}...]"
puts " #{$0} [--to <Packages>] --from <Packages> <packagename> ..."
puts " #{$0} [--to <Packages>] --from <Packages> -A"
puts " #{$0} [--to <Packages>] <packagefile>..."
puts " #{$0} [--to <Packages>] --check <packagename>"
end
$stdout.sync = true
to_packages = nil
from_packages = nil
check_inset = false
begin
opts.each {|opt, arg|
case opt
when "--to" then
if to_packages == nil
to_packages = Packages.new
end
arg.gsub!(/\$ARCH/,arch)
Dir[arg].each {|p|
print "* Loading target #{p}..." if $verbose
to_packages += Packages.new(p)
print "done\n" if $verbose
}
when "--from" then
if from_packages == nil
from_packages = Packages.new
end
arg.gsub!(/\$ARCH/,arch)
Dir[arg].each {|p|
print "* Loading source #{p}..." if $verbose
from_packages += Packages.new(p)
print "done\n" if $verbose
}
when "--arch" then
arch = arg
print "* Architecture: #{arch}\n" if $verbose
when "--all" then
if from_packages == nil
$stderr.puts "#{$0}: --all requires --from option"
raise GetoptLong::InvalidOption
end
from_packages.pkgnames {|p|
ARGV.push(p)
}
when "--check" then
check_inset = true
when "--verbose" then $verbose = true
when "--quiet" then $quiet = true
when "--help" then usage; exit 0
else raise GetoptLong::InvalidOption
end
}
rescue GetoptLong::InvalidOption
usage; exit 1
end
if to_packages == nil
print "* Loading target (dpkg status)..." if $verbose
to_packages = Status.new
print "done\n" if $verbose
end
if check_inset && from_packages == nil
from_packages = to_packages
end
check_packages = to_packages
check_debs = []
while arg = ARGV.shift
if from_packages == nil
deb = DpkgDeb.load(arg)
else
deb = from_packages[arg]
end
if deb == nil
$stderr.puts "E: Package: #{arg} not found"
exit 1
end
if deb['architecture'] != arch && deb['architecture'] != 'all'
next
end
check_debs.push(deb)
check_packages[deb.package] = deb
end
unmets = 0
mets = 0
num = 0
if check_inset
to_packages.each_package {|deb|
print "* Checking #{deb}\n" if $verbose
num += 1
safe = true
deb.deps('depends').each {|dep|
check_debs.each {|cdeb|
if dep.include?(cdeb) && ! dep.satisfy?(cdeb)
puts "E: #{deb} does not satisfy #{dep} against #{cdeb}"
unmets += 1
safe = false
end
}
}
if safe
mets += 1
end
}
else
check_debs.each {|deb|
print "* Checking #{deb}\n" if $verbose
num += 1
safe = true
deb.unmet(check_packages).each {|u|
puts u
unmets += 1
safe = false
}
if safe
mets += 1
end
}
end
puts "#{num} packages: #{unmets} unmet in #{num - mets} packages / #{mets} packages ok" unless $quiet
exit (unmets == 0 ? 0 : 1)
#!/usr/bin/ruby
#
# dpkg-ruby - ruby script to parse status,available and Packages,Sources
# dpkg-awk clone
# Copyright (c) 2001 Fumitoshi UKAI <ukai@debian.or.jp>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# $Id: dpkg-ruby,v 1.6 2001/04/20 19:07:00 ukai Exp $
#
require 'debian'
require 'getoptlong'
filename = Debian::Dpkg::STATUS_FILE
$debug = 0
sortfield = []
numfield = []
$rec_sep = ""
def usage
$stderr.puts "#{$0} [opts] 'field:regexp' .. -- 'output_field' .."
$stderr.puts " opts: [-f file] [-d nn] [-s sf] [-n nf] [-rs rs]"
end
opts = GetoptLong.new(
["--file", "-f", GetoptLong::REQUIRED_ARGUMENT],
["--debug", "-d", GetoptLong::OPTIONAL_ARGUMENT],
["--sort", "-s", GetoptLong::REQUIRED_ARGUMENT],
["--numeric_field", "-n", GetoptLong::REQUIRED_ARGUMENT],
["--rec_sep", "--rs", GetoptLong::REQUIRED_ARGUMENT],
["--help", "-h", GetoptLong::NO_ARGUMENT])
opts.ordering = GetoptLong::REQUIRE_ORDER
begin
opts.each {|opt, arg|
case opt
when "--file" then filename = arg
when "--debug" then
if arg
$debug = arg
else
$debug += 1
end
when "--sort" then
sortfield += arg.split(" ").collect{|a| a.split(",")}
sortfield.flatten!
when "--numeric_field" then
numfield += arg.split(" ").collect{|a| a.split(",")}
numfield.flatten!
when "--rec_sep" then
$rec_sep = arg
when "--help" then
usage; exit 0
else
opts.terminate
end
}
rescue GetoptLong::InvalidOption
usage; exit 1
end
field = {}
$outputfield = []
while arg = ARGV.shift
break if arg == "--"
unless /^([^:]+):(.*)/ =~ arg
$stderr.puts "E: invalid argument #{arg}"
exit 1
end
field[$1] = Regexp.new($2)
end
$outputfield = ARGV
da = Debian::Archives.load(filename)
def output(deb)
if $outputfield.empty?
deb.fields {|f|
puts "#{f.capitalize}: #{deb[f]}"
}
puts $rec_sep
elsif $outputfield[0] == '^'
deb.fields {|f|
unless $outputfield.find {|of| of.capitalize == f.capitalize }
puts "#{f.capitalize}: #{deb[f]}"
end
}
puts $rec_sep
else
$outputfield.each {|f|
puts "#{f.capitalize}: #{deb[f]}"
}
if $rec_sep != "" || $outputfield.length > 1
puts $rec_sep
end
end
end
mp = []
da.each_package {|d|
match = true
field.each {|f,re|
unless re =~ d[f]
match = false
break
end
}
if match
if sortfield.empty?
output(d)
else
mp.push(d)
end
end
}
unless sortfield.empty?
mp.sort{|a,b|
d = 0
sortfield.each{|sf|
if numfield.include?(sf)
d = a[sf].to_i <=> b[sf].to_i
else
d = a[sf] <=> b[sf]
end
if d != 0
break
end
}
d
}.each {|d|
output(d)
}
end
#!/usr/bin/ruby
#
# dpkg.rb - ruby script dpkg compatible interfaces
# Copyright (c) 2001 Fumitoshi UKAI <ukai@debian.or.jp>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# $Id: dpkg.rb,v 1.5 2001/04/22 16:39:29 ukai Exp $
#
require 'debian'
require 'getoptlong'
include Debian
opts = GetoptLong.new(
["--list", "-l", GetoptLong::NO_ARGUMENT],
["--status", "-s", GetoptLong::NO_ARGUMENT],
["--get-selections", GetoptLong::NO_ARGUMENT],
["--print-avail", GetoptLong::NO_ARGUMENT],
["--listfiles", "-L", GetoptLong::NO_ARGUMENT],
["--search", "-S", GetoptLong::NO_ARGUMENT],
["--help", "-h", GetoptLong::NO_ARGUMENT])
opts.ordering = GetoptLong::REQUIRE_ORDER
def usage
puts "Usage:"
puts " #{$0} --list [<package> ...]"
puts " #{$0} --status [<package> ...]"
puts " #{$0} --get-selections [<pattern> ...]"
puts " #{$0} --print-avail [<package> ...]"
puts " #{$0} --listfiles [<package> ...]"
puts " #{$0} --search [<pattern> ...]"
puts " #{$0} --help"
end
func = Proc.new {|args| $stderr.puts "#{$0}: need an action option"}
begin
opts.each {|opt, arg|
case opt
when "--list" then func = Proc.new {|args|
Dpkg.status(args).each_package {|deb|
puts [Deb::SELECTION_ID[deb.selection] +
Deb::STATUS_ID[deb.status] +
Deb::EFLAG_ID[deb.ok],
deb.package,
deb.version,
deb.description].join(" ")
}
}
when "--status" then func = Proc.new {|args|
Dpkg.status(args).each_package {|deb|
puts deb.info_s
}
}
when "--get-selections" then func = Proc.new {|args|
Dpkg.selections(args).each_package {|deb|
puts [deb.package, deb.selection].join("\t")
}
}
when "--print-avail" then func = Proc.new {|args|
Dpkg.avail(args).each_package {|deb|
puts deb.info_s
}
}
when "--listfiles" then func = Proc.new {|args|
Dpkg.listfiles(args).each {|dlist|
puts dlist
puts
}
}
when "--search" then func = Proc.new {|args|
Dpkg.search(args).each {|m|
puts "#{m[0]}: #{m[1]}"
}
}
when "--help" then usage; exit 0
else raise GetoptLong::InvalidOption
end
}
rescue GetoptLong::InvalidOption
usage; exit 1
end
func.call(ARGV)
dpkg-ruby (0.3.2) unstable; urgency=low
* man/dpkg-checkdeps. fix typo 'packges'
closes: Bug#351000
* man/dpkg-ruby.1. fix typos
closes: Bug#351001
* man/dpkg.rb.1. fix typo.
closes: Bug#351002
* rename programs without .rb suffixes
dpkg.rb is shipped as an example only.
closes: Bug#220934
* stop building ruby1.6 module
closes: Bug#366583
* lib/debian.rb: pkgs_re_escape()
fix package names with '+' characters cause errors
closes: Bug#366202
* lib/debian.rb: fix wrong instance variable usage
debian.rb:712: warning: instance variable @file not initialized
closes: Bug#272760
-- Fumitoshi UKAI <ukai@debian.or.jp> Fri, 12 May 2006 02:40:56 +0900
dpkg-ruby (0.3.1) unstable; urgency=low
* lib/debian.rb: preserve @info['Description']
* fix description. closes: Bug#192815
-- Fumitoshi UKAI <ukai@debian.or.jp> Wed, 11 Aug 2004 00:28:35 +0900
dpkg-ruby (0.3.0) unstable; urgency=low
* ruby1.8 transision
* multi packaged: libdpkg-ruby1.8 and libdpkg-ruby1.6
* lib/debian.rb: define Hash.values_at for ruby1.6
paren for args for ruby1.8
use .class instead of .type for ruby1.8
use Hash.values_at instead of Hash.indexes for ruby1.8
* lib/debian/ar.rb: paren for args for ruby1.8
* lib/debian/utils.rb: waitpid
redirect by using IO.reopen instead of assignment to $std*
paren for args for ruby1.8
* t: fix test program for both ruby1.6 and ruby1.8
-- Fumitoshi UKAI <ukai@debian.or.jp> Wed, 8 Oct 2003 02:10:23 +0900
dpkg-ruby (0.2.4) unstable; urgency=low
* Makefile: fix to use $(RUBY) instead of ruby
closes: Bug#209156
-- Fumitoshi UKAI <ukai@debian.or.jp> Mon, 8 Sep 2003 13:53:33 +0900
dpkg-ruby (0.2.3) unstable; urgency=low
* depends on ruby1.6
-- Fumitoshi UKAI <ukai@debian.or.jp> Mon, 8 Sep 2003 00:16:03 +0900
dpkg-ruby (0.2.2) unstable; urgency=low
* s/ControlError/FieldError/ closes: Bug#165622
-- Fumitoshi UKAI <ukai@debian.or.jp> Sat, 26 Oct 2002 03:15:06 +0900
dpkg-ruby (0.2.1) unstable; urgency=low
* fix for new ruby 1.6.6
-- Fumitoshi UKAI <ukai@debian.or.jp> Sun, 6 Jan 2002 23:42:50 +0900
dpkg-ruby (0.2) unstable; urgency=low
* (lib/debian.rb)
add Debian::Dep::Term#kind_of?
add Debian::Deb#deps(relation_field)
* (bin/dpkg-checkdeps.rb) add --check
* (man/dpkg-checkdeps.rb.1) add --check
-- Fumitoshi UKAI <ukai@debian.or.jp> Wed, 16 May 2001 02:41:46 +0900
dpkg-ruby (0.1.1) unstable; urgency=low
* fix typo in examples
-- Fumitoshi UKAI <ukai@debian.or.jp> Thu, 3 May 2001 00:11:16 +0900
dpkg-ruby (0.1) unstable; urgency=low
* Initial Release. closes: Bug#94378
-- Fumitoshi UKAI <ukai@debian.or.jp> Sun, 29 Apr 2001 01:59:19 +0900
dpkg-ruby (0.0.9.3) unstable; urgency=low
* Release Candidate 2
* (lib/debian.rb)
Deb.unmet takes relation fields parameter
* (bin/dpkg-checkdeps.rb)
fix --from wildcard
-- Fumitoshi UKAI <ukai@debian.or.jp> Sat, 28 Apr 2001 06:41:54 +0900
dpkg-ruby (0.0.9.2) unstable; urgency=low
* (bin/dpkg-checkdeps.rb)
support wildcard for --to and --from arguments
-- Fumitoshi UKAI <ukai@debian.or.jp> Sat, 28 Apr 2001 04:33:33 +0900
dpkg-ruby (0.0.9.1) unstable; urgency=low
* don't raise exception when E: duplicate package entry
* (bin/dpkg-checkdeps.rb)
- performance tuning
- change -a option for --arch
- -A option for --all
-- Fumitoshi UKAI <ukai@debian.or.jp> Sat, 28 Apr 2001 04:09:01 +0900
dpkg-ruby (0.0.9) unstable; urgency=low
* Release Candidate 1
* add dpkg-checkdeps.rb
* separate debian/utils.rb (gunzip, tar, [pipeline])
OK (130/130 tests 4563 asserts)
-- Fumitoshi UKAI <ukai@debian.or.jp> Sat, 28 Apr 2001 01:29:11 +0900
dpkg-ruby (0.0.8.1) unstable; urgency=HIGH
* missing install debian/ar.rb
-- Fumitoshi UKAI <ukai@debian.or.jp> Fri, 27 Apr 2001 12:33:45 +0900
dpkg-ruby (0.0.8) unstable; urgency=low
* add Debian::Ar
* Debian::DpkgDeb.{pipeline,gunzip,tar}
OK (132/132 tests 4564 asserts)
-- Fumitoshi UKAI <ukai@debian.or.jp> Fri, 27 Apr 2001 05:00:17 +0900
dpkg-ruby (0.0.7) unstable; urgency=low
* Debian::DpkgDeb.load
* Debian::Deb
- filename
- control,controlFile,controlData
- data,dataFile,dataData
- sys_tarfile
OK (129/129 tests 4512 asserts)
-- Fumitoshi UKAI <ukai@debian.or.jp> Tue, 24 Apr 2001 02:30:06 +0900
dpkg-ruby (0.0.6) unstable; urgency=low
* module Control -> Field
* SELECTION_ID, EFLAG_ID, STATUS_ID -> Debian::Deb
* fix dpkg.rb.1
-- Fumitoshi UKAI <ukai@debian.or.jp> Mon, 23 Apr 2001 01:43:45 +0900
dpkg-ruby (0.0.5) unstable; urgency=low
* (bin/{dpkg-ruby, dpkg.rb}): rescue GetoptLong::InvalidOption
* add/cleanup APIs
- Debian::Control.maintainer
- Debian::Archives.load
- Debian::Deb.*? - status, selection test
* add dpkg.rb.1
OK (117/117 tests 4472 asserts)
-- Fumitoshi UKAI <ukai@debian.or.jp> Sun, 22 Apr 2001 04:18:35 +0900
dpkg-ruby (0.0.4.1) unstable; urgency=HIGH
* fix broken /usr/bin/dpkg-ruby, /usr/bin/dpkg.rb
-- Fumitoshi UKAI <ukai@debian.or.jp> Sat, 21 Apr 2001 02:32:38 +0900
dpkg-ruby (0.0.4) unstable; urgency=low
* add several APIs
- Debian::Dpkg.{status,selections,avail,listfiles,search}
- Debian::Deb.files
- Debian::Archives.packages
- Debian::Status
* deleyed parse
- make test => OK (OK (98/98 tests 4436 asserts)
* add /usr/bin/dpkg.rb
-- Fumitoshi UKAI <ukai@debian.or.jp> Sat, 21 Apr 2001 01:51:38 +0900
dpkg-ruby (0.0.3) unstable; urgency=low
* add test suites using rubyunit
- make test => OK (87/87 tests 359 asserts)
* fix several bugs found with rubyunit
-- Fumitoshi UKAI <ukai@debian.or.jp> Fri, 20 Apr 2001 09:29:03 +0900
dpkg-ruby (0.0.2) unstable; urgency=low
* (lib/debian.rb)
- fix typo in Dpkg.*architecture()
- change Dpkg.info -> Dpkg.field