ruby-debian 0.3.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (56) hide show
  1. data/Makefile +47 -0
  2. data/README +55 -0
  3. data/TODO +29 -0
  4. data/bin/dpkg-checkdeps +163 -0
  5. data/bin/dpkg-ruby +148 -0
  6. data/debian/changelog +310 -0
  7. data/debian/compat +1 -0
  8. data/debian/control +56 -0
  9. data/debian/copyright +26 -0
  10. data/debian/dirs +2 -0
  11. data/debian/manpages +0 -0
  12. data/debian/ruby-debian.docs +3 -0
  13. data/debian/ruby-debian.examples +1 -0
  14. data/debian/ruby-debian.manpages +2 -0
  15. data/debian/rules +15 -0
  16. data/debian/source/format +1 -0
  17. data/examples/ONE_LINER +39 -0
  18. data/examples/dpkg.rb +95 -0
  19. data/examples/list_packages.rb +38 -0
  20. data/examples/unmet_packages.rb +39 -0
  21. data/ext/debian_version/Version.cpp +43 -0
  22. data/ext/debian_version/extconf.rb +7 -0
  23. data/lib/debian.rb +1063 -0
  24. data/lib/debian/ar.rb +159 -0
  25. data/lib/debian/utils.rb +111 -0
  26. data/man/dpkg-checkdeps.1 +102 -0
  27. data/man/dpkg-ruby.1 +99 -0
  28. data/t/d/available +492 -0
  29. data/t/d/non-US_sid_Sources +32 -0
  30. data/t/d/non-US_sid_i386_Packages +50 -0
  31. data/t/d/sid_Sources +287 -0
  32. data/t/d/sid_i386_Packages +456 -0
  33. data/t/d/status +324 -0
  34. data/t/d/w3m-ssl_0.2.1-1.f +24 -0
  35. data/t/d/w3m-ssl_0.2.1-2.dsc +12 -0
  36. data/t/d/w3m-ssl_0.2.1-2.f +24 -0
  37. data/t/d/w3m_0.2.1-1.dsc +12 -0
  38. data/t/d/w3m_0.2.1-1.f +21 -0
  39. data/t/d/w3m_0.2.1-2.dsc +12 -0
  40. data/t/d/w3m_0.2.1-2.f +21 -0
  41. data/t/d/w3m_met_list +83 -0
  42. data/t/testall.rb +50 -0
  43. data/t/testar.rb +59 -0
  44. data/t/testarchives.rb +277 -0
  45. data/t/testdeb.rb +239 -0
  46. data/t/testdep.rb +70 -0
  47. data/t/testdepterm.rb +140 -0
  48. data/t/testdepunmet.rb +71 -0
  49. data/t/testdpkg.rb +197 -0
  50. data/t/testdpkgdeb.rb +83 -0
  51. data/t/testdsc.rb +49 -0
  52. data/t/testfield.rb +155 -0
  53. data/t/testpackages.rb +138 -0
  54. data/t/testsources.rb +44 -0
  55. data/t/teststatus.rb +38 -0
  56. metadata +133 -0
@@ -0,0 +1,159 @@
1
+ #
2
+ # ar.rb - ar(1) ruby interface (for debian.rb)
3
+ # Copyright (c) 2001 Fumitoshi UKAI <ukai@debian.or.jp>
4
+ #
5
+ # This program is free software; you can redistribute it and/or modify
6
+ # it under the terms of the GNU General Public License as published by
7
+ # the Free Software Foundation; either version 2 of the License, or
8
+ # (at your option) any later version.
9
+ #
10
+ # This program is distributed in the hope that it will be useful,
11
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ # GNU General Public License for more details.
14
+ #
15
+ # You should have received a copy of the GNU General Public License
16
+ # along with this program; if not, write to the Free Software
17
+ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18
+ #
19
+ # $Id: ar.rb,v 1.3 2003/10/07 17:07:02 ukai Exp $
20
+ #
21
+
22
+ # struct ar_hdr
23
+ # {
24
+ # char ar_name[16]; /* Member file name, sometimes / terminated. */
25
+ # char ar_date[12]; /* File date, decimal seconds since Epoch. */
26
+ # char ar_uid[6], ar_gid[6]; /* User and group IDs, in ASCII decimal. */
27
+ # char ar_mode[8]; /* File mode, in ASCII octal. */
28
+ # char ar_size[10]; /* File size, in ASCII decimal. */
29
+ # char ar_fmag[2]; /* Always contains ARFMAG. */
30
+ # };
31
+
32
+ module Debian
33
+ class ArError < StandardError; end
34
+ class Ar
35
+ ARMAG = "!<arch>\n"
36
+ SARMAG = 8
37
+ ARFMAG = "`\n"
38
+ AR_HDR_SIZE = (16+12+6+6+8+10+2)
39
+ class ArFile
40
+ class Stat
41
+ def initialize(time,uid,gid,mode,size,dev)
42
+ @time, @uid, @gid, @mode, @size, @dev = time,uid,gid,mode,size,dev
43
+ end
44
+ def <=>(s) @time <=> s.atime; end
45
+ def atime; @time; end
46
+ def blksize; 0; end
47
+ def blockdev?; false; end
48
+ def blocks; 0; end
49
+ def chardev?; false; end
50
+ def ctime; @time; end
51
+ def dev; @dev; end
52
+ def directory?; false; end
53
+ def executable?; false; end
54
+ def executable_real?; false; end
55
+ def file?; true; end
56
+ def ftype; 'file'; end
57
+ def gid; @gid; end
58
+ def grpowned?; false; end
59
+ def ino; @dev; end
60
+ def mode; @mode; end
61
+ def mtime; @time; end
62
+ def nlink; 1; end
63
+ def owned?; false; end
64
+ def pipe?; false; end
65
+ def rdev; @dev; end
66
+ def readable?; true; end
67
+ def readable_real?; true; end
68
+ def setgid?; false; end
69
+ def setuid?; false; end
70
+ def size; @size; end
71
+ def size?; @size == 0 ? nil : @size; end
72
+ def socket?; false; end
73
+ def sticky?; false; end
74
+ def symlink?; false; end
75
+ def uid; @uid; end
76
+ def writable?; false; end
77
+ def writable_real?; false; end
78
+ def zero?; @size == 0; end
79
+ end
80
+
81
+ def initialize(fp,name,date,uid,gid,mode,size,pos)
82
+ @fp,@name = fp,name
83
+ @stat = Stat.new(date,uid,gid,mode,size,pos)
84
+ @size = size
85
+ @pos = pos
86
+ @cur = 0
87
+ end
88
+ attr_reader :name, :size, :pos, :cur, :stat
89
+
90
+ def read(size = -1)
91
+ if size < 0
92
+ size = @size - @cur
93
+ end
94
+ if @cur + size > @size
95
+ size = @size - @cur
96
+ end
97
+ @fp.seek(@pos + @cur, IO::SEEK_SET)
98
+ r = @fp.read(size)
99
+ @cur += r.size
100
+ return r
101
+ end
102
+
103
+ def eof?; @cur == @size; end
104
+ def rewind; @cur = 0; end
105
+ end
106
+
107
+ def initialize(file)
108
+ @fp = File.open(file)
109
+ magic = @fp.gets
110
+ unless magic == ARMAG
111
+ raise ArError, "archive broken: #{file}"
112
+ end
113
+ @ofs = []
114
+ end
115
+
116
+ def close
117
+ @fp.close
118
+ end
119
+
120
+ def list
121
+ @fp.seek(SARMAG, IO::SEEK_SET)
122
+ while ! @fp.eof?
123
+ hdr = @fp.read(AR_HDR_SIZE)
124
+ name,date,uid,gid,mode,size,fmag = hdr.unpack('a16a12a6a6a8a10a2')
125
+ unless fmag == ARFMAG
126
+ raise ArError, "invalid archive field magic #{fmag} @ #{@fp.pos} [#{hdr}]"
127
+ end
128
+ name.strip!
129
+ size = size.to_i
130
+ @ofs.push(ArFile.new(@fp,
131
+ name,Time.at(date.to_i), uid.to_i, gid.to_i,
132
+ mode.oct, size, @fp.pos))
133
+ # puts "hdr=[#{hdr}] pos=#{@fp.pos}, size=#{size} #{(size + 1)&~1}"
134
+ @fp.seek((size + 1)&~1, IO::SEEK_CUR)
135
+ end
136
+ @ofs
137
+ end
138
+ def each_file
139
+ if @ofs.empty?; list; end
140
+ @ofs.each {|file|
141
+ yield file.name, file
142
+ }
143
+ end
144
+
145
+ def open(name)
146
+ if @ofs.empty?; list; end
147
+ @ofs.each {|file|
148
+ if file.name == name
149
+ if block_given?
150
+ return yield(file)
151
+ else
152
+ return file
153
+ end
154
+ end
155
+ }
156
+ end
157
+ end
158
+
159
+ end
@@ -0,0 +1,111 @@
1
+ #
2
+ # utils.rb - ruby utilities interface for debian.rb (gunzip, tar, ..)
3
+ # Copyright (c) 2001 Fumitoshi UKAI <ukai@debian.or.jp>
4
+ #
5
+ # This program is free software; you can redistribute it and/or modify
6
+ # it under the terms of the GNU General Public License as published by
7
+ # the Free Software Foundation; either version 2 of the License, or
8
+ # (at your option) any later version.
9
+ #
10
+ # This program is distributed in the hope that it will be useful,
11
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ # GNU General Public License for more details.
14
+ #
15
+ # You should have received a copy of the GNU General Public License
16
+ # along with this program; if not, write to the Free Software
17
+ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18
+ #
19
+ # $Id: utils.rb,v 1.2 2003/10/07 17:07:02 ukai Exp $
20
+ #
21
+
22
+ module Debian
23
+ module Utils
24
+ GUNZIP = '/bin/gunzip'
25
+ TAR = '/bin/tar'
26
+ TAR_EXTRACT = '-x'
27
+ TAR_LIST = '-t'
28
+
29
+ def Utils.pipeline(io,progs,stderr = false)
30
+ Signal.trap('CHLD', 'IGNORE')
31
+ # wr0 -> rd0 [gunzip] wr -> rd
32
+ rd,wr = IO.pipe
33
+ rde,wre = IO.pipe
34
+ pid = fork
35
+ if pid
36
+ # parent
37
+ wr.close
38
+ wre.close
39
+ if block_given?
40
+ return yield(rd, rde)
41
+ else
42
+ return rd, rde
43
+ end
44
+ else
45
+ # child
46
+ rd.close
47
+ rd0, wr0 = IO.pipe
48
+ pid2 = fork
49
+ if pid2
50
+ # gunzip
51
+ wr0.close
52
+ STDOUT.reopen(wr)
53
+ STDERR.reopen(wre) if stderr
54
+ STDIN.reopen(rd0)
55
+ ENV["LANG"] = "C"
56
+ ENV["LC_ALL"] = "C"
57
+ exec(*progs)
58
+ # XXX: waitpid(pid2?)
59
+ else
60
+ rd0.close
61
+ while ! io.eof?
62
+ wr0.write(io.read(4096))
63
+ end
64
+ exit 0
65
+ end
66
+ end
67
+ Process.waitpid(pid, 0)
68
+ Process.wait
69
+ end
70
+
71
+ def gunzip(io)
72
+ Utils.pipeline(io, [GUNZIP]) {|fp,fpe|
73
+ fpe.close
74
+ if block_given?
75
+ return yield(fp)
76
+ else
77
+ return fp
78
+ end
79
+ }
80
+ end
81
+ def tar(io,op,*pat)
82
+ progs = [TAR, op, '--wildcards', '-f', '-']
83
+ if pat[0]
84
+ progs += ['--to-stdout', *pat]
85
+ end
86
+ Utils.pipeline(io,progs,op == "-t") {|fp,fpe|
87
+ if op == "-t"
88
+ pid = fork
89
+ if pid
90
+ # parent
91
+ else
92
+ while !fpe.eof? && str = fpe.readline
93
+ unless str.match(/^\/bin\/tar: Record size = [0-9]+ blocks$/)
94
+ STDERR.puts str
95
+ end
96
+ end
97
+ exit
98
+ end
99
+ end
100
+ fpe.close
101
+ if block_given?
102
+ return yield(fp)
103
+ else
104
+ return fp
105
+ end
106
+ }
107
+ end
108
+
109
+ module_function :gunzip, :tar
110
+ end
111
+ end
@@ -0,0 +1,102 @@
1
+ .TH DPKG-CHECKDEPS.RB 1 "Debian Utilities" "DEBIAN" \" -*- nroff -*-
2
+ .SH NAME
3
+ dpkg-checkdeps.rb \- Utility to check deb dependency
4
+ .SH SYNOPSIS
5
+ \fBdpkg-checkdeps.rb\fP [\fIopts\fP] \fIdebfile\fP ...
6
+ .br
7
+ \fBdpkg-checkdeps.rb\fP [\fIopts\fP] \fB\-\-from\fP \fIpackages\fP \fIpkgname\fP...
8
+ .br
9
+ \fBdpkg-checkdeps.rb\fP [\fIopts\fP] \fB\-\-from\fP \fB\-\-all\fP
10
+ .br
11
+ \fBdpkg-checkdeps.rb\fP [\fIopts\fP] \fB\-\-check\fP \fIpkgname\fP...
12
+ .br
13
+ \fIopts\fP: \fB\-\-to\fP \fIpackages\fP
14
+ \fB\-\-arch\fP \fIarch\fP
15
+ \fB\-\-verbose\fP
16
+ \fB\-q\fP
17
+ .br
18
+ .SH DESCRIPTION
19
+ .I dpkg-checkdeps.rb
20
+ checks deb dependency problems when specified deb packages are
21
+ installed in the target packages list.
22
+ .SH OPTIONS
23
+ .TP
24
+ .PD 0
25
+ .BI \-t " packages-file"
26
+ .TP
27
+ .BI \-\-to " packages-file"
28
+ .PD
29
+ Specify target \fIpackages-file\fP. If this option is used multiple times,
30
+ packages lists are appended. If no \fB-t\fP option specified,
31
+ default is current installed packages list, that is, /var/lib/dpkg/status.
32
+ .TP
33
+ .PD 0
34
+ .BI \-f " packages-file"
35
+ .TP
36
+ .BI \-\-from " packages-file"
37
+ .PD
38
+ Specify source \fIpackages-file\fP. If this option is used multiple times,
39
+ packages lists are appended. If you use this option, you can select packages
40
+ by \fIpackage-name\fP, or all of them by \fB\-\-all\fP option.
41
+ .TP
42
+ .PD 0
43
+ .B \-A
44
+ .TP
45
+ .B \-\-all
46
+ .PD
47
+ Select all packages in source \fIpackages-file\fP. You must use this option
48
+ with \fB\-\-from\fP option.
49
+ .TP
50
+ .PD 0
51
+ .BI \-a " arch"
52
+ .TP
53
+ .BI \-\-arch " arch"
54
+ .PD
55
+ Specify acceptable \fIarch\fP in \fIpackages-file\fP. Default is
56
+ installation_architecture of dpkg.
57
+ .TP
58
+ .PD 0
59
+ .B \-c
60
+ .TP
61
+ .B \-\-check
62
+ .PD
63
+ Check selected packages are satisfied by all packages in target
64
+ \fIpackages\fP.
65
+ .TP
66
+ .PD 0
67
+ .B \-v
68
+ .TP
69
+ .B \-\-verbose
70
+ .PD
71
+ Verbose mode
72
+ .TP
73
+ .PD 0
74
+ .BI \-h
75
+ .TP
76
+ .BI \-\-help
77
+ .PD
78
+ Display some help.
79
+ .SH EXAMPLES
80
+
81
+ % dpkg-checkdeps.rb \-\-arch alpha \
82
+ \-\-to '*/binary-$ARCH/Packages' \
83
+ \-\-from ../proposed-updates/Packages' \-\-all
84
+
85
+ % dpkg-checkdeps.rb \-\-to '*/binary-$ARCH/Packages' \-\-check libc6
86
+
87
+ .SH BUGS
88
+
89
+ There are probably tons of bugs in this program.
90
+
91
+ This checks only depends, recommends and suggests, doesn't check
92
+ pre-depends and conflicts, yet.
93
+
94
+ This program comes with no warranties. If running this program
95
+ causes fire and brimstone to rain down upon the earth, you will be
96
+ on our own.
97
+
98
+ .SH AUTHOR
99
+ Fumitoshi UKAI <ukai@debian.or.jp>.
100
+
101
+
102
+
@@ -0,0 +1,99 @@
1
+ .TH DPKG-RUBY 1 "Debian Utilities" "DEBIAN" \" -*- nroff -*-
2
+ .SH NAME
3
+ dpkg-ruby \- Utility to read a dpkg style db file, dpkg-awk clone
4
+ .SH SYNOPSIS
5
+ \fBdpkg-ruby\fP [\fB(\-f|\-\-file) \fIfilename\fP] [\fB(\-d|\-\-debug) \fI##\fP] [\fB(\-s|\-\-sort) \fIlist\fP] [\fB(\-n|\-\-numeric) \fIlist\fP] [\fB(\-rs|\-\-rec_sep) \fI??\fP] '\fI<fieldname>:<regex>\fP' ... \-\- \fI<out_fieldname>\fP ..
6
+ .br
7
+ .SH DESCRIPTION
8
+ .I dpkg-ruby
9
+ Parses a dpkg status file(or other similarly formated file) and
10
+ outputs the resulting records. It can use regex on the field
11
+ values to limit the returned records, and it can also be told
12
+ which fields to output. As another option, it can sort the
13
+ matched fields.
14
+ .SH OPTIONS
15
+
16
+ .TP
17
+ .PD 0
18
+ .BI \-f " filename"
19
+ .TP
20
+ .BI \-\-file " filename"
21
+ .PD
22
+ The file to parse. The default is /var/lib/dpkg/status.
23
+ .TP
24
+ .PD 0
25
+ .BI \-d " [#]"
26
+ .TP
27
+ .BI \-\-debug " [#]"
28
+ .PD
29
+ Each time this is specified, it increased the debug level.
30
+ .TP
31
+ .PD 0
32
+ .BI \-s " field(s)"
33
+ .TP
34
+ .BI \-\-sort " field(s)"
35
+ .PD
36
+ A space or comma separated list of fields to sort on.
37
+ .TP
38
+ .PD 0
39
+ .BI \-n " field(s)"
40
+ .TP
41
+ .BI \-\-numeric " field(s)"
42
+ .PD
43
+ A space or comma separated list of fields that should be
44
+ interpreted as numeric in value.
45
+ .TP
46
+ .PD 0
47
+ .BI \-rs " ??"
48
+ .TP
49
+ .BI \-\-rec_sep " ??"
50
+ .PD
51
+ Output this string at the end of each output paragraph.
52
+ .\" .TP
53
+ .\" .PD 0
54
+ .\" .I -of ??
55
+ .\" .TP
56
+ .\" .I --outform ??
57
+ .\" .PD
58
+ .\" Specify the outform that dpkg-ruby should use. Current
59
+ .\" formats are normal(the old, tried and true style), and
60
+ .\" xml.
61
+ .TP
62
+ .PD 0
63
+ .B \-h
64
+ .TP
65
+ .B \-\-help
66
+ .PD
67
+ Display some help.
68
+ .TP
69
+ .I fieldname
70
+ The fields from the file, that are matched with the regex given.
71
+ The \fIfieldname\fPs are case insensitive.
72
+ .TP
73
+ .I out_fieldname
74
+ The fields from the file, that are outputted for each record.
75
+ If the first field listed is begins with
76
+ .IR ^ ,
77
+ then the list that follows are fields
78
+ .I NOT
79
+ to be outputted.
80
+ .SH BUGS
81
+
82
+ Be warned that the author has only a shallow understanding of the
83
+ dpkg packaging system, so there are probably tons of bugs in this
84
+ program.
85
+
86
+ This program comes with no warranties. If running this program
87
+ causes fire and brimstone to rain down upon the earth, you will be
88
+ on our own.
89
+
90
+ This program accesses the dpkg database directly in places, querying
91
+ for data that cannot be gotten via dpkg.
92
+
93
+ .SH AUTHOR
94
+ Fumitoshi UKAI <ukai@debian.or.jp>.
95
+ This manual page are based on (or almost copy from :) dpkg-awk(1) manual
96
+ written by Adam Heath <doogie@debian.org>
97
+
98
+
99
+