raptcache 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Changelog +47 -0
- data/MIT-LICENSE +21 -0
- data/README +19 -0
- data/lib/raptcache.rb +810 -0
- data/lib/raptcache/version.rb +10 -0
- data/setup.rb +1585 -0
- data/test/test_helper.rb +2 -0
- data/test/test_raptcache.rb +11 -0
- metadata +74 -0
data/Changelog
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
commit dc9430c54968dd5c0d9ec665f7d12c4fa0be142a
|
2
|
+
Author: Joel Bryan Juliano <jjuliano@clinic-it.com>
|
3
|
+
Date: Tue Dec 28 15:11:50 2010 +0800
|
4
|
+
|
5
|
+
Fix comments and documentations
|
6
|
+
|
7
|
+
commit 8e2c880131ea108695d6f8dd9e59cca0973c58ec
|
8
|
+
Author: Joel Bryan Juliano <jjuliano@clinic-it.com>
|
9
|
+
Date: Tue Dec 28 13:09:10 2010 +0800
|
10
|
+
|
11
|
+
Removed the yardoc documentations
|
12
|
+
|
13
|
+
commit 447bf1cb796f3601ba1809e09045f443d724dbee
|
14
|
+
Author: Joel Bryan Juliano <jjuliano@clinic-it.com>
|
15
|
+
Date: Tue Dec 28 12:29:02 2010 +0800
|
16
|
+
|
17
|
+
Added yardoc API documentation
|
18
|
+
|
19
|
+
commit 20174fe74c38d47dc7b5ae5d9d673e68ca085a2c
|
20
|
+
Author: Joel Bryan Juliano <jjuliano@clinic-it.com>
|
21
|
+
Date: Tue Dec 28 12:27:27 2010 +0800
|
22
|
+
|
23
|
+
bump to version 0.1.1
|
24
|
+
|
25
|
+
commit 914690cbaee71217f78deeb48a204ffe8c098bcc
|
26
|
+
Author: Joel Bryan Juliano <jjuliano@clinic-it.com>
|
27
|
+
Date: Tue Dec 28 11:55:44 2010 +0800
|
28
|
+
|
29
|
+
changed the version module name
|
30
|
+
|
31
|
+
commit f1655df0fd2b0fa0e7b313d6140814220f468654
|
32
|
+
Author: Joel Bryan Juliano <jjuliano@clinic-it.com>
|
33
|
+
Date: Mon Dec 27 19:52:32 2010 +0000
|
34
|
+
|
35
|
+
Added basic usage instructions
|
36
|
+
|
37
|
+
commit dcda2467fc9f4b51807ac94898f252454500ad7f
|
38
|
+
Author: Joel Bryan Juliano <jjuliano@clinic-it.com>
|
39
|
+
Date: Mon Dec 27 19:15:24 2010 +0000
|
40
|
+
|
41
|
+
Added github page as homepage in gemspec
|
42
|
+
|
43
|
+
commit 164d7524024ec1f7ccd9d308943b3d8790a61316
|
44
|
+
Author: Joel Bryan Juliano <jjuliano@clinic-it.com>
|
45
|
+
Date: Mon Dec 27 19:10:30 2010 +0000
|
46
|
+
|
47
|
+
Initial Commit
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2011 Joel Bryan Juliano <joelbryan.juliano@gmail.com>
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
README for Raptcache
|
2
|
+
==================
|
3
|
+
|
4
|
+
Raptcache is a gem providing a ruby interface to the apt-cache APT package
|
5
|
+
cache manipulator.
|
6
|
+
|
7
|
+
To install, type 'gem install raptcache'
|
8
|
+
|
9
|
+
Usage:
|
10
|
+
|
11
|
+
require 'raptcache'
|
12
|
+
|
13
|
+
packages = Array.new
|
14
|
+
packages.push('iagno')
|
15
|
+
packages.push('gnome-games')
|
16
|
+
|
17
|
+
aptcache = Raptcache.new
|
18
|
+
aptcache.rdepends(packages)
|
19
|
+
|
data/lib/raptcache.rb
ADDED
@@ -0,0 +1,810 @@
|
|
1
|
+
# = raptcache - A apt-cache gem for Ruby
|
2
|
+
#
|
3
|
+
# Homepage:: http://github.com/jjuliano/raptcache
|
4
|
+
# Author:: Joel Bryan Juliano
|
5
|
+
# Copyright:: (cc) 2011 Joel Bryan Juliano
|
6
|
+
# License:: MIT
|
7
|
+
#
|
8
|
+
# class Raptcache::Package.new( array, str, array)
|
9
|
+
|
10
|
+
require 'tempfile'
|
11
|
+
|
12
|
+
class Raptcache
|
13
|
+
#
|
14
|
+
# All accessors are boolean unless otherwise noted.
|
15
|
+
#
|
16
|
+
|
17
|
+
#
|
18
|
+
# Select the file to store the package cache.
|
19
|
+
# The package cache is the primary cache used by all operations.
|
20
|
+
# Configuration Item: Dir::Cache::pkgcache.
|
21
|
+
#
|
22
|
+
attr_accessor :pkg_cache
|
23
|
+
|
24
|
+
#
|
25
|
+
# Select the file to store the source cache. The source is used only
|
26
|
+
# by gencaches and it stores a parsed version of the package information
|
27
|
+
# from remote sources. When building the package cache the source
|
28
|
+
# cache is used to avoid reparsing all of the package files.
|
29
|
+
# Configuration Item: Dir::Cache::srcpkgcache.
|
30
|
+
#
|
31
|
+
attr_accessor :src_cache
|
32
|
+
|
33
|
+
#
|
34
|
+
# Quiet; produces output suitable for logging, omitting progress indicators.
|
35
|
+
# You can also use 'quiet=#' to set the quietness level, overriding the
|
36
|
+
# configuration file.
|
37
|
+
# Configuration Item: quiet.
|
38
|
+
#
|
39
|
+
attr_accessor :quiet
|
40
|
+
|
41
|
+
#
|
42
|
+
# Print only important dependencies; for use with unmet and depends.
|
43
|
+
# Causes only Depends and Pre-Depends relations to be printed.
|
44
|
+
# Configuration Item: APT::Cache::Important.
|
45
|
+
#
|
46
|
+
attr_accessor :important
|
47
|
+
|
48
|
+
#
|
49
|
+
# Per default the depends and rdepends print all dependencies.
|
50
|
+
# This can be twicked with these flags which will omit the specified
|
51
|
+
# dependency type.
|
52
|
+
# Configuration Item: APT::Cache::ShowDependencyType e.g.
|
53
|
+
# APT::Cache::ShowRecommends.
|
54
|
+
#
|
55
|
+
|
56
|
+
#
|
57
|
+
# Omit the pre dependencies for depends and rdepends.
|
58
|
+
#
|
59
|
+
attr_accessor :no_pre_depends
|
60
|
+
|
61
|
+
#
|
62
|
+
# Omit all dependencies for depends and rdepends.
|
63
|
+
#
|
64
|
+
attr_accessor :no_depends
|
65
|
+
|
66
|
+
#
|
67
|
+
# Omit the recommended dependencies for depends and rdepends.
|
68
|
+
#
|
69
|
+
attr_accessor :no_recommends
|
70
|
+
|
71
|
+
#
|
72
|
+
# Omit the suggested dependencies for depends and rdepends.
|
73
|
+
#
|
74
|
+
attr_accessor :no_suggests
|
75
|
+
|
76
|
+
#
|
77
|
+
# Omit the conflicting dependencies for depends and rdepends.
|
78
|
+
#
|
79
|
+
attr_accessor :no_conflicts
|
80
|
+
|
81
|
+
#
|
82
|
+
# Omit the breaking dependencies for depends and rdepends.
|
83
|
+
#
|
84
|
+
attr_accessor :no_breaks
|
85
|
+
|
86
|
+
#
|
87
|
+
# Omit the replaces dependencies for depends and rdepends.
|
88
|
+
#
|
89
|
+
attr_accessor :no_replaces
|
90
|
+
|
91
|
+
#
|
92
|
+
# Omit the enhances dependencies for depends and rdepends.
|
93
|
+
#
|
94
|
+
attr_accessor :no_enhances
|
95
|
+
|
96
|
+
#
|
97
|
+
# Print full package records when searching.
|
98
|
+
# Configuration Item: APT::Cache::ShowFull.
|
99
|
+
#
|
100
|
+
attr_accessor :full
|
101
|
+
|
102
|
+
#
|
103
|
+
# Print full records for all available versions. This is the default;
|
104
|
+
# to turn it off, use 'no_all_versions'. If 'no_all_versions' is specified,
|
105
|
+
# only the candidate version will displayed (the one which would be
|
106
|
+
# selected for installation). This option is only applicable to the
|
107
|
+
# show command.
|
108
|
+
# Configuration Item: APT::Cache::AllVersions.
|
109
|
+
#
|
110
|
+
attr_accessor :all_versions
|
111
|
+
|
112
|
+
#
|
113
|
+
# Perform automatic package cache regeneration, rather than use the cache
|
114
|
+
# as it is. This is the default; to turn it off, use 'no_generate'.
|
115
|
+
# Configuration Item: APT::Cache::Generate.
|
116
|
+
#
|
117
|
+
attr_accessor :generate
|
118
|
+
|
119
|
+
#
|
120
|
+
# Only search on the package names, not the long descriptions.
|
121
|
+
# Configuration Item: APT::Cache::NamesOnly.
|
122
|
+
#
|
123
|
+
attr_accessor :names_only
|
124
|
+
|
125
|
+
#
|
126
|
+
# Make pkgnames print all names, including virtual packages and missing
|
127
|
+
# dependencies.
|
128
|
+
# Configuration Item: APT::Cache::AllNames.
|
129
|
+
#
|
130
|
+
attr_accessor :all_names
|
131
|
+
|
132
|
+
#
|
133
|
+
# Make depends and rdepends recursive so that all packages mentioned
|
134
|
+
# are printed once.
|
135
|
+
# Configuration Item: APT::Cache::RecurseDepends.
|
136
|
+
#
|
137
|
+
attr_accessor :recurse
|
138
|
+
|
139
|
+
#
|
140
|
+
# Limit the output of depends and rdepends to packages which are
|
141
|
+
# currently installed.
|
142
|
+
# Configuration Item: APT::Cache::Installed.
|
143
|
+
#
|
144
|
+
attr_accessor :installed
|
145
|
+
|
146
|
+
#
|
147
|
+
# Show the program version.
|
148
|
+
#
|
149
|
+
attr_accessor :version
|
150
|
+
|
151
|
+
#
|
152
|
+
# Configuration File; Specify a configuration file to use.
|
153
|
+
# The program will read the default configuration file and then this
|
154
|
+
# configuration file. If configuration settings need to be set before
|
155
|
+
# the default configuration files are parsed specify a file with the
|
156
|
+
# APT_CONFIG environment variable. See apt.conf for syntax information.
|
157
|
+
#
|
158
|
+
attr_accessor :config_file
|
159
|
+
|
160
|
+
#
|
161
|
+
# Set a Configuration Option; This will set an arbitrary
|
162
|
+
# configuration option.
|
163
|
+
# The syntax is option = "Foo::Bar=bar"
|
164
|
+
#
|
165
|
+
attr_accessor :option
|
166
|
+
|
167
|
+
#
|
168
|
+
# Returns a new Raptcache Object
|
169
|
+
#
|
170
|
+
def initialize()
|
171
|
+
end
|
172
|
+
|
173
|
+
#
|
174
|
+
# add adds the named package index files to the package cache.
|
175
|
+
# This is for debugging only.
|
176
|
+
#
|
177
|
+
def add(files)
|
178
|
+
|
179
|
+
tmp = Tempfile.new('tmp')
|
180
|
+
files.collect! { |i| i + " " }
|
181
|
+
command = option_string() + "add " + files.to_s + " 2> " + tmp.path
|
182
|
+
success = system(command)
|
183
|
+
if success
|
184
|
+
begin
|
185
|
+
while (line = tmp.readline)
|
186
|
+
line.chomp
|
187
|
+
selected_string = line
|
188
|
+
end
|
189
|
+
rescue EOFError
|
190
|
+
tmp.close
|
191
|
+
end
|
192
|
+
return selected_string
|
193
|
+
else
|
194
|
+
tmp.close!
|
195
|
+
return success
|
196
|
+
end
|
197
|
+
|
198
|
+
end
|
199
|
+
|
200
|
+
#
|
201
|
+
# gencaches performs the same operation as apt-get check.
|
202
|
+
# It builds the source and package caches from the sources in
|
203
|
+
# sources.list and from /var/lib/dpkg/status.
|
204
|
+
# (require's root permission)
|
205
|
+
#
|
206
|
+
def gencaches
|
207
|
+
|
208
|
+
command = option_string() + "gencaches "
|
209
|
+
success = system(command)
|
210
|
+
return success
|
211
|
+
|
212
|
+
end
|
213
|
+
|
214
|
+
# showpkg displays information about the packages listed on the
|
215
|
+
# command line. Remaining arguments are package names.
|
216
|
+
# The available versions and reverse dependencies of each package listed
|
217
|
+
# are listed, as well as forward dependencies for each version.
|
218
|
+
# Forward (normal) dependencies are those packages upon which the package
|
219
|
+
# in question depends; reverse dependencies are those packages that depend
|
220
|
+
# upon the package in question. Thus, forward dependencies must be
|
221
|
+
# satisfied for a package, but reverse dependencies need not be.
|
222
|
+
# For instance, apt-cache showpkg libreadline2 would produce output
|
223
|
+
# similar to the following:
|
224
|
+
#
|
225
|
+
# Package: libreadline2
|
226
|
+
# Versions: 2.1-12(/var/state/apt/lists/foo_Packages),
|
227
|
+
# Reverse Depends:
|
228
|
+
# libreadlineg2,libreadline2
|
229
|
+
# libreadline2-altdev,libreadline2
|
230
|
+
# Dependencies:
|
231
|
+
# 2.1-12 - libc5 (2 5.4.0-0) ncurses3.0 (0 (null))
|
232
|
+
# Provides:
|
233
|
+
# 2.1-12 -
|
234
|
+
# Reverse Provides:
|
235
|
+
# Thus it may be seen that libreadline2, version 2.1-12, depends on
|
236
|
+
# libc5 and ncurses3.0 which must be installed for libreadline2 to work.
|
237
|
+
# In turn, libreadlineg2 and libreadline2-altdev depend on libreadline2.
|
238
|
+
# If libreadline2 is installed, libc5 and ncurses3.0 (and ldso) must also
|
239
|
+
# be installed; libreadlineg2 and libreadline2-altdev do not have to be
|
240
|
+
# installed. For the specific meaning of the remainder of the output it
|
241
|
+
# is best to consult the apt source code.
|
242
|
+
#
|
243
|
+
def showpkg(packages)
|
244
|
+
|
245
|
+
tmp = Tempfile.new('tmp')
|
246
|
+
packages.collect! { |i| i + " " }
|
247
|
+
command = option_string() + "showpkg " + packages.to_s + " 2> " + tmp.path
|
248
|
+
success = system(command)
|
249
|
+
if success
|
250
|
+
begin
|
251
|
+
while (line = tmp.readline)
|
252
|
+
line.chomp
|
253
|
+
selected_string = line
|
254
|
+
end
|
255
|
+
rescue EOFError
|
256
|
+
tmp.close
|
257
|
+
end
|
258
|
+
return selected_string
|
259
|
+
else
|
260
|
+
tmp.close!
|
261
|
+
return success
|
262
|
+
end
|
263
|
+
|
264
|
+
end
|
265
|
+
|
266
|
+
#
|
267
|
+
# stats displays some statistics about the cache. No further arguments are
|
268
|
+
# expected. Statistics reported are:
|
269
|
+
#
|
270
|
+
# * Total package names is the number of package names found in the cache.
|
271
|
+
#
|
272
|
+
# * Normal packages is the number of regular, ordinary package names;
|
273
|
+
# these are packages that bear a one-to-one correspondence between
|
274
|
+
# their names and the names used by other packages for them in
|
275
|
+
# dependencies. The majority of packages fall into this category.
|
276
|
+
#
|
277
|
+
# * Pure virtual packages is the number of packages that exist only as
|
278
|
+
# a virtual package name; that is, packages only "provide" the virtual
|
279
|
+
# package name, and no package actually uses the name. For instance,
|
280
|
+
# "mail-transport-agent" in the Debian GNU/Linux system is a pure
|
281
|
+
# virtual package; several packages provide "mail-transport-agent",
|
282
|
+
# but there is no package named "mail-transport-agent".
|
283
|
+
#
|
284
|
+
# * Single virtual packages is the number of packages with only one package
|
285
|
+
# providing a particular virtual package. For example, in the Debian
|
286
|
+
# GNU/Linux system, "X11-text-viewer" is a virtual package, but only
|
287
|
+
# one package, xless, provides "X11-text-viewer".
|
288
|
+
#
|
289
|
+
# * Mixed virtual packages is the number of packages that either provide
|
290
|
+
# a particular virtual package or have the virtual package name as the
|
291
|
+
# package name. For instance, in the Debian GNU/Linux system, "debconf"
|
292
|
+
# is both an actual package, and provided by the debconf-tiny package.
|
293
|
+
#
|
294
|
+
# * Missing is the number of package names that were referenced in a
|
295
|
+
# dependency but were not provided by any package. Missing packages may
|
296
|
+
# be an evidence if a full distribution is not accessed, or if a
|
297
|
+
# package (real or virtual) has been dropped from the distribution.
|
298
|
+
# Usually they are referenced from Conflicts or Breaks statements.
|
299
|
+
#
|
300
|
+
# * Total distinct versions is the number of package versions found in
|
301
|
+
# the cache; this value is therefore at least equal to the number of
|
302
|
+
# total package names. If more than one distribution (both "stable" and
|
303
|
+
# "unstable", for instance), is being accessed, this value can be
|
304
|
+
# considerably larger than the number of total package names.
|
305
|
+
#
|
306
|
+
# * Total dependencies is the number of dependency relationships claimed
|
307
|
+
# by all of the packages in the cache.
|
308
|
+
#
|
309
|
+
def stats
|
310
|
+
|
311
|
+
tmp = Tempfile.new('tmp')
|
312
|
+
command = option_string() + "stats " + " 2> " + tmp.path
|
313
|
+
success = system(command)
|
314
|
+
if success
|
315
|
+
begin
|
316
|
+
while (line = tmp.readline)
|
317
|
+
line.chomp
|
318
|
+
selected_string = line
|
319
|
+
end
|
320
|
+
rescue EOFError
|
321
|
+
tmp.close
|
322
|
+
end
|
323
|
+
return selected_string
|
324
|
+
else
|
325
|
+
tmp.close!
|
326
|
+
return success
|
327
|
+
end
|
328
|
+
|
329
|
+
end
|
330
|
+
|
331
|
+
#
|
332
|
+
# showsrc displays all the source package records that match the given
|
333
|
+
# package names. All versions are shown, as well as all records that
|
334
|
+
# declare the name to be a Binary.
|
335
|
+
#
|
336
|
+
def showsrc(packages)
|
337
|
+
|
338
|
+
tmp = Tempfile.new('tmp')
|
339
|
+
packages.collect! { |i| i + " " }
|
340
|
+
command = option_string() + "showsrc " + packages.to_s + " 2> " + tmp.path
|
341
|
+
success = system(command)
|
342
|
+
if success
|
343
|
+
begin
|
344
|
+
while (line = tmp.readline)
|
345
|
+
line.chomp
|
346
|
+
selected_string = line
|
347
|
+
end
|
348
|
+
rescue EOFError
|
349
|
+
tmp.close
|
350
|
+
end
|
351
|
+
return selected_string
|
352
|
+
else
|
353
|
+
tmp.close!
|
354
|
+
return success
|
355
|
+
end
|
356
|
+
|
357
|
+
end
|
358
|
+
|
359
|
+
#
|
360
|
+
# dump shows a short listing of every package in the cache.
|
361
|
+
# It is primarily for debugging.
|
362
|
+
#
|
363
|
+
def dump
|
364
|
+
|
365
|
+
tmp = Tempfile.new('tmp')
|
366
|
+
command = option_string() + "dump " + " 2> " + tmp.path
|
367
|
+
success = system(command)
|
368
|
+
if success
|
369
|
+
begin
|
370
|
+
while (line = tmp.readline)
|
371
|
+
line.chomp
|
372
|
+
selected_string = line
|
373
|
+
end
|
374
|
+
rescue EOFError
|
375
|
+
tmp.close
|
376
|
+
end
|
377
|
+
return selected_string
|
378
|
+
else
|
379
|
+
tmp.close!
|
380
|
+
return success
|
381
|
+
end
|
382
|
+
|
383
|
+
end
|
384
|
+
|
385
|
+
#
|
386
|
+
# dumpavail prints out an available list to stdout.
|
387
|
+
# This is suitable for use with dpkg and is used by
|
388
|
+
# the dselect method.
|
389
|
+
#
|
390
|
+
def dumpavail
|
391
|
+
|
392
|
+
tmp = Tempfile.new('tmp')
|
393
|
+
command = option_string() + "dumpavail " + " 2> " + tmp.path
|
394
|
+
success = system(command)
|
395
|
+
if success
|
396
|
+
begin
|
397
|
+
while (line = tmp.readline)
|
398
|
+
line.chomp
|
399
|
+
selected_string = line
|
400
|
+
end
|
401
|
+
rescue EOFError
|
402
|
+
tmp.close
|
403
|
+
end
|
404
|
+
return selected_string
|
405
|
+
else
|
406
|
+
tmp.close!
|
407
|
+
return success
|
408
|
+
end
|
409
|
+
|
410
|
+
end
|
411
|
+
|
412
|
+
#
|
413
|
+
# unmet displays a summary of all unmet dependencies in the package cache.
|
414
|
+
#
|
415
|
+
def unmet
|
416
|
+
|
417
|
+
tmp = Tempfile.new('tmp')
|
418
|
+
command = option_string() + "unmet " + " 2> " + tmp.path
|
419
|
+
success = system(command)
|
420
|
+
if success
|
421
|
+
begin
|
422
|
+
while (line = tmp.readline)
|
423
|
+
line.chomp
|
424
|
+
selected_string = line
|
425
|
+
end
|
426
|
+
rescue EOFError
|
427
|
+
tmp.close
|
428
|
+
end
|
429
|
+
return selected_string
|
430
|
+
else
|
431
|
+
tmp.close!
|
432
|
+
return success
|
433
|
+
end
|
434
|
+
|
435
|
+
end
|
436
|
+
|
437
|
+
#
|
438
|
+
# show performs a function similar to dpkg --print-avail;
|
439
|
+
# it displays the package records for the named packages.
|
440
|
+
#
|
441
|
+
def show(packages)
|
442
|
+
|
443
|
+
tmp = Tempfile.new('tmp')
|
444
|
+
packages.collect! { |i| i + " " }
|
445
|
+
command = option_string() + "show " + packages.to_s + " 2> " + tmp.path
|
446
|
+
success = system(command)
|
447
|
+
if success
|
448
|
+
begin
|
449
|
+
while (line = tmp.readline)
|
450
|
+
line.chomp
|
451
|
+
selected_string = line
|
452
|
+
end
|
453
|
+
rescue EOFError
|
454
|
+
tmp.close
|
455
|
+
end
|
456
|
+
return selected_string
|
457
|
+
else
|
458
|
+
tmp.close!
|
459
|
+
return success
|
460
|
+
end
|
461
|
+
|
462
|
+
end
|
463
|
+
|
464
|
+
#
|
465
|
+
# search performs a full text search on all available package lists
|
466
|
+
# for the POSIX regex pattern given, see regex. It searches the package
|
467
|
+
# names and the descriptions for an occurrence of the regular
|
468
|
+
# expression and prints out the package name and the short description,
|
469
|
+
# including virtual package names. If 'full' is given then output identical
|
470
|
+
# to show is produced for each matched package, and if 'names_only' is
|
471
|
+
# given then the long description is not searched, only the package name is.
|
472
|
+
#
|
473
|
+
# Separate arguments can be used to specify multiple search patterns
|
474
|
+
# that are and'ed together.
|
475
|
+
#
|
476
|
+
def search(regexp)
|
477
|
+
|
478
|
+
tmp = Tempfile.new('tmp')
|
479
|
+
regexp.collect! { |i| i + " " }
|
480
|
+
command = option_string() + "search " + regexp.to_s + " 2> " + tmp.path
|
481
|
+
success = system(command)
|
482
|
+
if success
|
483
|
+
begin
|
484
|
+
while (line = tmp.readline)
|
485
|
+
line.chomp
|
486
|
+
selected_string = line
|
487
|
+
end
|
488
|
+
rescue EOFError
|
489
|
+
tmp.close
|
490
|
+
end
|
491
|
+
return selected_string
|
492
|
+
else
|
493
|
+
tmp.close!
|
494
|
+
return success
|
495
|
+
end
|
496
|
+
|
497
|
+
end
|
498
|
+
|
499
|
+
|
500
|
+
#
|
501
|
+
# depends shows a listing of each dependency a package has and all the
|
502
|
+
# possible other packages that can fulfill that dependency.
|
503
|
+
#
|
504
|
+
def depends(packages)
|
505
|
+
|
506
|
+
tmp = Tempfile.new('tmp')
|
507
|
+
packages.collect! { |i| i + " " }
|
508
|
+
command = option_string() + "depends " + packages.to_s + " 2> " + tmp.path
|
509
|
+
success = system(command)
|
510
|
+
if success
|
511
|
+
begin
|
512
|
+
while (line = tmp.readline)
|
513
|
+
line.chomp
|
514
|
+
selected_string = line
|
515
|
+
end
|
516
|
+
rescue EOFError
|
517
|
+
tmp.close
|
518
|
+
end
|
519
|
+
return selected_string
|
520
|
+
else
|
521
|
+
tmp.close!
|
522
|
+
return success
|
523
|
+
end
|
524
|
+
|
525
|
+
end
|
526
|
+
|
527
|
+
#
|
528
|
+
# rdepends shows a listing of each reverse dependency a package has.
|
529
|
+
#
|
530
|
+
def rdepends(packages)
|
531
|
+
|
532
|
+
tmp = Tempfile.new('tmp')
|
533
|
+
packages.collect! { |i| i + " " }
|
534
|
+
command = option_string() + "rdepends " + packages.to_s + " 2> " + tmp.path
|
535
|
+
success = system(command)
|
536
|
+
if success
|
537
|
+
begin
|
538
|
+
while (line = tmp.readline)
|
539
|
+
line.chomp
|
540
|
+
selected_string = line
|
541
|
+
end
|
542
|
+
rescue EOFError
|
543
|
+
tmp.close
|
544
|
+
end
|
545
|
+
return selected_string
|
546
|
+
else
|
547
|
+
tmp.close!
|
548
|
+
return success
|
549
|
+
end
|
550
|
+
|
551
|
+
end
|
552
|
+
|
553
|
+
#
|
554
|
+
# This command prints the name of each package APT knows.
|
555
|
+
# The optional argument is a prefix match to filter the name list.
|
556
|
+
# The output is suitable for use in a shell tab complete function and the
|
557
|
+
# output is generated extremely quickly. This command is best used with
|
558
|
+
# the 'generate' option.
|
559
|
+
#
|
560
|
+
# Note that a package which APT knows of is not necessarily available
|
561
|
+
# to download, installable or installed, e.g. virtual packages are also
|
562
|
+
# listed in the generated list.
|
563
|
+
#
|
564
|
+
def pkgnames(prefix)
|
565
|
+
|
566
|
+
tmp = Tempfile.new('tmp')
|
567
|
+
prefix.collect! { |i| i + " " }
|
568
|
+
command = option_string() + "pkgnames " + prefix.to_s + " 2> " + tmp.path
|
569
|
+
success = system(command)
|
570
|
+
if success
|
571
|
+
begin
|
572
|
+
while (line = tmp.readline)
|
573
|
+
line.chomp
|
574
|
+
selected_string = line
|
575
|
+
end
|
576
|
+
rescue EOFError
|
577
|
+
tmp.close
|
578
|
+
end
|
579
|
+
return selected_string
|
580
|
+
else
|
581
|
+
tmp.close!
|
582
|
+
return success
|
583
|
+
end
|
584
|
+
|
585
|
+
end
|
586
|
+
|
587
|
+
#
|
588
|
+
# dotty takes a list of packages on the command line and generates output
|
589
|
+
# suitable for use by dotty from the GraphViz package. The result will be
|
590
|
+
# a set of nodes and edges representing the relationships between the
|
591
|
+
# packages. By default the given packages will trace out all dependent
|
592
|
+
# packages; this can produce a very large graph. To limit the output to
|
593
|
+
# only the packages listed on the command line, set
|
594
|
+
# the APT::Cache::GivenOnly option.
|
595
|
+
#
|
596
|
+
# The resulting nodes will have several shapes; normal packages are boxes,
|
597
|
+
# pure provides are triangles, mixed provides are diamonds,
|
598
|
+
# missing packages are hexagons. Orange boxes mean recursion was stopped
|
599
|
+
# [leaf packages], blue lines are pre-depends, green lines are conflicts.
|
600
|
+
#
|
601
|
+
def dotty(packages)
|
602
|
+
|
603
|
+
tmp = Tempfile.new('tmp')
|
604
|
+
packages.collect! { |i| i + " " }
|
605
|
+
command = option_string() + "dotty " + packages.to_s + " 2> " + tmp.path
|
606
|
+
success = system(command)
|
607
|
+
if success
|
608
|
+
begin
|
609
|
+
while (line = tmp.readline)
|
610
|
+
line.chomp
|
611
|
+
selected_string = line
|
612
|
+
end
|
613
|
+
rescue EOFError
|
614
|
+
tmp.close
|
615
|
+
end
|
616
|
+
return selected_string
|
617
|
+
else
|
618
|
+
tmp.close!
|
619
|
+
return success
|
620
|
+
end
|
621
|
+
|
622
|
+
end
|
623
|
+
|
624
|
+
#
|
625
|
+
# The same as dotty, only for xvcg from the VCG tool.
|
626
|
+
#
|
627
|
+
def xvcg(packages)
|
628
|
+
|
629
|
+
tmp = Tempfile.new('tmp')
|
630
|
+
packages.collect! { |i| i + " " }
|
631
|
+
command = option_string() + "xvcg " + packages.to_s + " 2> " + tmp.path
|
632
|
+
success = system(command)
|
633
|
+
if success
|
634
|
+
begin
|
635
|
+
while (line = tmp.readline)
|
636
|
+
line.chomp
|
637
|
+
selected_string = line
|
638
|
+
end
|
639
|
+
rescue EOFError
|
640
|
+
tmp.close
|
641
|
+
end
|
642
|
+
return selected_string
|
643
|
+
else
|
644
|
+
tmp.close!
|
645
|
+
return success
|
646
|
+
end
|
647
|
+
|
648
|
+
end
|
649
|
+
|
650
|
+
#
|
651
|
+
# policy is meant to help debug issues relating to the preferences file.
|
652
|
+
# With no arguments it will print out the priorities of each source.
|
653
|
+
# Otherwise it prints out detailed information about the priority
|
654
|
+
# selection of the named package.
|
655
|
+
#
|
656
|
+
def policy(packages)
|
657
|
+
|
658
|
+
tmp = Tempfile.new('tmp')
|
659
|
+
packages.collect! { |i| i + " " }
|
660
|
+
command = option_string() + "policy " + packages.to_s + " 2> " + tmp.path
|
661
|
+
success = system(command)
|
662
|
+
if success
|
663
|
+
begin
|
664
|
+
while (line = tmp.readline)
|
665
|
+
line.chomp
|
666
|
+
selected_string = line
|
667
|
+
end
|
668
|
+
rescue EOFError
|
669
|
+
tmp.close
|
670
|
+
end
|
671
|
+
return selected_string
|
672
|
+
else
|
673
|
+
tmp.close!
|
674
|
+
return success
|
675
|
+
end
|
676
|
+
|
677
|
+
end
|
678
|
+
|
679
|
+
#
|
680
|
+
# apt-cache's madison command attempts to mimic the output format and
|
681
|
+
# a subset of the functionality of the Debian archive management tool,
|
682
|
+
# madison. It displays available versions of a package in a tabular
|
683
|
+
# format. Unlike the original madison, it can only display information
|
684
|
+
# for the architecture for which APT has retrieved package lists
|
685
|
+
# (APT::Architecture).
|
686
|
+
#
|
687
|
+
def madison(packages)
|
688
|
+
|
689
|
+
tmp = Tempfile.new('tmp')
|
690
|
+
packages.collect! { |i| i + " " }
|
691
|
+
command = option_string() + "madison " + packages.to_s + " 2> " + tmp.path
|
692
|
+
success = system(command)
|
693
|
+
if success
|
694
|
+
begin
|
695
|
+
while (line = tmp.readline)
|
696
|
+
line.chomp
|
697
|
+
selected_string = line
|
698
|
+
end
|
699
|
+
rescue EOFError
|
700
|
+
tmp.close
|
701
|
+
end
|
702
|
+
return selected_string
|
703
|
+
else
|
704
|
+
tmp.close!
|
705
|
+
return success
|
706
|
+
end
|
707
|
+
|
708
|
+
end
|
709
|
+
|
710
|
+
private
|
711
|
+
|
712
|
+
def option_string()
|
713
|
+
ostring = "apt-cache "
|
714
|
+
|
715
|
+
if @option
|
716
|
+
ostring += "--option " + @option
|
717
|
+
end
|
718
|
+
|
719
|
+
if @config_file
|
720
|
+
ostring += "--config-file " + @config_file
|
721
|
+
end
|
722
|
+
|
723
|
+
if @version
|
724
|
+
ostring += "--version "
|
725
|
+
end
|
726
|
+
|
727
|
+
if @installed
|
728
|
+
ostring += "--installed "
|
729
|
+
end
|
730
|
+
|
731
|
+
if @recurse
|
732
|
+
ostring += "--recurse "
|
733
|
+
end
|
734
|
+
|
735
|
+
if @all_names
|
736
|
+
ostring += "--all-names "
|
737
|
+
end
|
738
|
+
|
739
|
+
if @names_only
|
740
|
+
ostring += "--names-only "
|
741
|
+
end
|
742
|
+
|
743
|
+
if @generate
|
744
|
+
ostring += "--generate "
|
745
|
+
end
|
746
|
+
|
747
|
+
if @all_versions
|
748
|
+
ostring += "--all-versions "
|
749
|
+
end
|
750
|
+
|
751
|
+
if @full
|
752
|
+
ostring += "--full "
|
753
|
+
end
|
754
|
+
|
755
|
+
if @no_pre_depends
|
756
|
+
ostring += "--no-pre-depends "
|
757
|
+
end
|
758
|
+
|
759
|
+
if @no_depends
|
760
|
+
ostring += "--no-depends "
|
761
|
+
end
|
762
|
+
|
763
|
+
if @no_recommends
|
764
|
+
ostring += "--no-recommends "
|
765
|
+
end
|
766
|
+
|
767
|
+
if @no_suggests
|
768
|
+
ostring += "--no-suggests "
|
769
|
+
end
|
770
|
+
|
771
|
+
if @no_conflicts
|
772
|
+
ostring += "--no-conflicts "
|
773
|
+
end
|
774
|
+
|
775
|
+
if @no_breaks
|
776
|
+
ostring += "--no-breaks "
|
777
|
+
end
|
778
|
+
|
779
|
+
if @no_replaces
|
780
|
+
ostring += "--no-replaces "
|
781
|
+
end
|
782
|
+
|
783
|
+
if @no_enhances
|
784
|
+
ostring += "--no-enhances "
|
785
|
+
end
|
786
|
+
|
787
|
+
if @important
|
788
|
+
ostring += "--important "
|
789
|
+
end
|
790
|
+
|
791
|
+
if @quiet
|
792
|
+
ostring += "--quiet " + @quiet
|
793
|
+
end
|
794
|
+
|
795
|
+
if @src_cache
|
796
|
+
ostring += "--src-cache " + @src_cache
|
797
|
+
end
|
798
|
+
|
799
|
+
if @pkg_cache
|
800
|
+
ostring += "--pkg-cache " + @pkg_cache
|
801
|
+
end
|
802
|
+
|
803
|
+
return ostring
|
804
|
+
|
805
|
+
end
|
806
|
+
end
|
807
|
+
|
808
|
+
|
809
|
+
#Dir[File.join(File.dirname(__FILE__), 'raptcache/**/*.rb')].sort.each { |lib| require lib }
|
810
|
+
|