Class: Raptcache
- Inherits:
-
Object
- Object
- Raptcache
- Defined in:
- lib/raptcache.rb
Instance Attribute Summary collapse
-
#all_names ⇒ Object
Make pkgnames print all names, including virtual packages and missing dependencies.
-
#all_versions ⇒ Object
Print full records for all available versions.
-
#config_file ⇒ Object
Configuration File; Specify a configuration file to use.
-
#full ⇒ Object
Print full package records when searching.
-
#generate ⇒ Object
Perform automatic package cache regeneration, rather than use the cache as it is.
-
#important ⇒ Object
Print only important dependencies; for use with unmet and depends.
-
#installed ⇒ Object
Limit the output of depends and rdepends to packages which are currently installed.
-
#names_only ⇒ Object
Only search on the package names, not the long descriptions.
-
#no_breaks ⇒ Object
Omit the breaking dependencies for depends and rdepends.
-
#no_conflicts ⇒ Object
Omit the conflicting dependencies for depends and rdepends.
-
#no_depends ⇒ Object
Omit all dependencies for depends and rdepends.
-
#no_enhances ⇒ Object
Omit the enhances dependencies for depends and rdepends.
-
#no_pre_depends ⇒ Object
Omit the pre dependencies for depends and rdepends.
-
#no_recommends ⇒ Object
Omit the recommended dependencies for depends and rdepends.
-
#no_replaces ⇒ Object
Omit the replaces dependencies for depends and rdepends.
-
#no_suggests ⇒ Object
Omit the suggested dependencies for depends and rdepends.
-
#option ⇒ Object
Set a Configuration Option; This will set an arbitrary configuration option.
-
#pkg_cache ⇒ Object
Select the file to store the package cache.
-
#quiet ⇒ Object
Quiet; produces output suitable for logging, omitting progress indicators.
-
#recurse ⇒ Object
Make depends and rdepends recursive so that all packages mentioned are printed once.
-
#src_cache ⇒ Object
Select the file to store the source cache.
-
#version ⇒ Object
Show the program version.
Instance Method Summary collapse
-
#add(files) ⇒ Object
add adds the named package index files to the package cache.
-
#depends(packages) ⇒ Object
depends shows a listing of each dependency a package has and all the possible other packages that can fulfill that dependency.
-
#dotty(packages) ⇒ Object
dotty takes a list of packages on the command line and generates output suitable for use by dotty from the GraphViz package.
-
#dump ⇒ Object
dump shows a short listing of every package in the cache.
-
#dumpavail ⇒ Object
dumpavail prints out an available list to stdout.
-
#gencaches ⇒ Object
gencaches performs the same operation as apt-get check.
-
#initialize ⇒ Raptcache
constructor
Returns a new Raptcache Object.
-
#madison(packages) ⇒ Object
apt-cache’s madison command attempts to mimic the output format and a subset of the functionality of the Debian archive management tool, madison.
-
#pkgnames(prefix) ⇒ Object
This command prints the name of each package APT knows.
-
#policy(packages) ⇒ Object
policy is meant to help debug issues relating to the preferences file.
-
#rdepends(packages) ⇒ Object
rdepends shows a listing of each reverse dependency a package has.
-
#search(regexp) ⇒ Object
search performs a full text search on all available package lists for the POSIX regex pattern given, see regex.
-
#show(packages) ⇒ Object
show performs a function similar to dpkg –print-avail; it displays the package records for the named packages.
-
#showpkg(packages) ⇒ Object
showpkg displays information about the packages listed on the command line.
-
#showsrc(packages) ⇒ Object
showsrc displays all the source package records that match the given package names.
-
#stats ⇒ Object
stats displays some statistics about the cache.
-
#unmet ⇒ Object
unmet displays a summary of all unmet dependencies in the package cache.
-
#xvcg(packages) ⇒ Object
The same as dotty, only for xvcg from the VCG tool.
Constructor Details
#initialize ⇒ Raptcache
Returns a new Raptcache Object
170 171 |
# File 'lib/raptcache.rb', line 170 def initialize() end |
Instance Attribute Details
#all_names ⇒ Object
Make pkgnames print all names, including virtual packages and missing dependencies. Configuration Item: APT::Cache::AllNames.
130 131 132 |
# File 'lib/raptcache.rb', line 130 def all_names @all_names end |
#all_versions ⇒ Object
Print full records for all available versions. This is the default; to turn it off, use ‘no_all_versions’. If ‘no_all_versions’ is specified, only the candidate version will displayed (the one which would be selected for installation). This option is only applicable to the show command. Configuration Item: APT::Cache::AllVersions.
110 111 112 |
# File 'lib/raptcache.rb', line 110 def all_versions @all_versions end |
#config_file ⇒ Object
Configuration File; Specify a configuration file to use. The program will read the default configuration file and then this configuration file. If configuration settings need to be set before the default configuration files are parsed specify a file with the APT_CONFIG environment variable. See apt.conf for syntax information.
158 159 160 |
# File 'lib/raptcache.rb', line 158 def config_file @config_file end |
#full ⇒ Object
Print full package records when searching. Configuration Item: APT::Cache::ShowFull.
100 101 102 |
# File 'lib/raptcache.rb', line 100 def full @full end |
#generate ⇒ Object
Perform automatic package cache regeneration, rather than use the cache as it is. This is the default; to turn it off, use ‘no_generate’. Configuration Item: APT::Cache::Generate.
117 118 119 |
# File 'lib/raptcache.rb', line 117 def generate @generate end |
#important ⇒ Object
Print only important dependencies; for use with unmet and depends. Causes only Depends and Pre-Depends relations to be printed. Configuration Item: APT::Cache::Important.
46 47 48 |
# File 'lib/raptcache.rb', line 46 def important @important end |
#installed ⇒ Object
Limit the output of depends and rdepends to packages which are currently installed. Configuration Item: APT::Cache::Installed.
144 145 146 |
# File 'lib/raptcache.rb', line 144 def installed @installed end |
#names_only ⇒ Object
Only search on the package names, not the long descriptions. Configuration Item: APT::Cache::NamesOnly.
123 124 125 |
# File 'lib/raptcache.rb', line 123 def names_only @names_only end |
#no_breaks ⇒ Object
Omit the breaking dependencies for depends and rdepends.
84 85 86 |
# File 'lib/raptcache.rb', line 84 def no_breaks @no_breaks end |
#no_conflicts ⇒ Object
Omit the conflicting dependencies for depends and rdepends.
79 80 81 |
# File 'lib/raptcache.rb', line 79 def no_conflicts @no_conflicts end |
#no_depends ⇒ Object
Omit all dependencies for depends and rdepends.
64 65 66 |
# File 'lib/raptcache.rb', line 64 def no_depends @no_depends end |
#no_enhances ⇒ Object
Omit the enhances dependencies for depends and rdepends.
94 95 96 |
# File 'lib/raptcache.rb', line 94 def no_enhances @no_enhances end |
#no_pre_depends ⇒ Object
Omit the pre dependencies for depends and rdepends.
59 60 61 |
# File 'lib/raptcache.rb', line 59 def no_pre_depends @no_pre_depends end |
#no_recommends ⇒ Object
Omit the recommended dependencies for depends and rdepends.
69 70 71 |
# File 'lib/raptcache.rb', line 69 def no_recommends @no_recommends end |
#no_replaces ⇒ Object
Omit the replaces dependencies for depends and rdepends.
89 90 91 |
# File 'lib/raptcache.rb', line 89 def no_replaces @no_replaces end |
#no_suggests ⇒ Object
Omit the suggested dependencies for depends and rdepends.
74 75 76 |
# File 'lib/raptcache.rb', line 74 def no_suggests @no_suggests end |
#option ⇒ Object
Set a Configuration Option; This will set an arbitrary configuration option. The syntax is option = “Foo::Bar=bar”
165 166 167 |
# File 'lib/raptcache.rb', line 165 def option @option end |
#pkg_cache ⇒ Object
Select the file to store the package cache. The package cache is the primary cache used by all operations. Configuration Item: Dir::Cache::pkgcache.
22 23 24 |
# File 'lib/raptcache.rb', line 22 def pkg_cache @pkg_cache end |
#quiet ⇒ Object
Quiet; produces output suitable for logging, omitting progress indicators. You can also use ‘quiet=#’ to set the quietness level, overriding the configuration file. Configuration Item: quiet.
39 40 41 |
# File 'lib/raptcache.rb', line 39 def quiet @quiet end |
#recurse ⇒ Object
Make depends and rdepends recursive so that all packages mentioned are printed once. Configuration Item: APT::Cache::RecurseDepends.
137 138 139 |
# File 'lib/raptcache.rb', line 137 def recurse @recurse end |
#src_cache ⇒ Object
Select the file to store the source cache. The source is used only by gencaches and it stores a parsed version of the package information from remote sources. When building the package cache the source cache is used to avoid reparsing all of the package files. Configuration Item: Dir::Cache::srcpkgcache.
31 32 33 |
# File 'lib/raptcache.rb', line 31 def src_cache @src_cache end |
#version ⇒ Object
Show the program version.
149 150 151 |
# File 'lib/raptcache.rb', line 149 def version @version end |
Instance Method Details
#add(files) ⇒ Object
add adds the named package index files to the package cache. This is for debugging only.
177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 |
# File 'lib/raptcache.rb', line 177 def add(files) tmp = Tempfile.new('tmp') files.collect! { |i| i + " " } command = option_string() + "add " + files.to_s + " 2> " + tmp.path success = system(command) if success begin while (line = tmp.readline) line.chomp selected_string = line end rescue EOFError tmp.close end return selected_string else tmp.close! return success end end |
#depends(packages) ⇒ Object
depends shows a listing of each dependency a package has and all the possible other packages that can fulfill that dependency.
504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 |
# File 'lib/raptcache.rb', line 504 def depends(packages) tmp = Tempfile.new('tmp') packages.collect! { |i| i + " " } command = option_string() + "depends " + packages.to_s + " 2> " + tmp.path success = system(command) if success begin while (line = tmp.readline) line.chomp selected_string = line end rescue EOFError tmp.close end return selected_string else tmp.close! return success end end |
#dotty(packages) ⇒ Object
dotty takes a list of packages on the command line and generates output suitable for use by dotty from the GraphViz package. The result will be a set of nodes and edges representing the relationships between the packages. By default the given packages will trace out all dependent packages; this can produce a very large graph. To limit the output to only the packages listed on the command line, set the APT::Cache::GivenOnly option.
The resulting nodes will have several shapes; normal packages are boxes, pure provides are triangles, mixed provides are diamonds, missing packages are hexagons. Orange boxes mean recursion was stopped [leaf packages], blue lines are pre-depends, green lines are conflicts.
601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 |
# File 'lib/raptcache.rb', line 601 def dotty(packages) tmp = Tempfile.new('tmp') packages.collect! { |i| i + " " } command = option_string() + "dotty " + packages.to_s + " 2> " + tmp.path success = system(command) if success begin while (line = tmp.readline) line.chomp selected_string = line end rescue EOFError tmp.close end return selected_string else tmp.close! return success end end |
#dump ⇒ Object
dump shows a short listing of every package in the cache. It is primarily for debugging.
363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 |
# File 'lib/raptcache.rb', line 363 def dump tmp = Tempfile.new('tmp') command = option_string() + "dump " + " 2> " + tmp.path success = system(command) if success begin while (line = tmp.readline) line.chomp selected_string = line end rescue EOFError tmp.close end return selected_string else tmp.close! return success end end |
#dumpavail ⇒ Object
dumpavail prints out an available list to stdout. This is suitable for use with dpkg and is used by the dselect method.
390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 |
# File 'lib/raptcache.rb', line 390 def dumpavail tmp = Tempfile.new('tmp') command = option_string() + "dumpavail " + " 2> " + tmp.path success = system(command) if success begin while (line = tmp.readline) line.chomp selected_string = line end rescue EOFError tmp.close end return selected_string else tmp.close! return success end end |
#gencaches ⇒ Object
gencaches performs the same operation as apt-get check. It builds the source and package caches from the sources in sources.list and from /var/lib/dpkg/status. (require’s root permission)
206 207 208 209 210 211 212 |
# File 'lib/raptcache.rb', line 206 def gencaches command = option_string() + "gencaches " success = system(command) return success end |
#madison(packages) ⇒ Object
apt-cache’s madison command attempts to mimic the output format and a subset of the functionality of the Debian archive management tool, madison. It displays available versions of a package in a tabular format. Unlike the original madison, it can only display information for the architecture for which APT has retrieved package lists (APT::Architecture).
687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 |
# File 'lib/raptcache.rb', line 687 def madison(packages) tmp = Tempfile.new('tmp') packages.collect! { |i| i + " " } command = option_string() + "madison " + packages.to_s + " 2> " + tmp.path success = system(command) if success begin while (line = tmp.readline) line.chomp selected_string = line end rescue EOFError tmp.close end return selected_string else tmp.close! return success end end |
#pkgnames(prefix) ⇒ Object
This command prints the name of each package APT knows. The optional argument is a prefix match to filter the name list. The output is suitable for use in a shell tab complete function and the output is generated extremely quickly. This command is best used with the ‘generate’ option.
Note that a package which APT knows of is not necessarily available to download, installable or installed, e.g. virtual packages are also listed in the generated list.
564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 |
# File 'lib/raptcache.rb', line 564 def pkgnames(prefix) tmp = Tempfile.new('tmp') prefix.collect! { |i| i + " " } command = option_string() + "pkgnames " + prefix.to_s + " 2> " + tmp.path success = system(command) if success begin while (line = tmp.readline) line.chomp selected_string = line end rescue EOFError tmp.close end return selected_string else tmp.close! return success end end |
#policy(packages) ⇒ Object
policy is meant to help debug issues relating to the preferences file. With no arguments it will print out the priorities of each source. Otherwise it prints out detailed information about the priority selection of the named package.
656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 |
# File 'lib/raptcache.rb', line 656 def policy(packages) tmp = Tempfile.new('tmp') packages.collect! { |i| i + " " } command = option_string() + "policy " + packages.to_s + " 2> " + tmp.path success = system(command) if success begin while (line = tmp.readline) line.chomp selected_string = line end rescue EOFError tmp.close end return selected_string else tmp.close! return success end end |
#rdepends(packages) ⇒ Object
rdepends shows a listing of each reverse dependency a package has.
530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 |
# File 'lib/raptcache.rb', line 530 def rdepends(packages) tmp = Tempfile.new('tmp') packages.collect! { |i| i + " " } command = option_string() + "rdepends " + packages.to_s + " 2> " + tmp.path success = system(command) if success begin while (line = tmp.readline) line.chomp selected_string = line end rescue EOFError tmp.close end return selected_string else tmp.close! return success end end |
#search(regexp) ⇒ Object
search performs a full text search on all available package lists for the POSIX regex pattern given, see regex. It searches the package names and the descriptions for an occurrence of the regular expression and prints out the package name and the short description, including virtual package names. If ‘full’ is given then output identical to show is produced for each matched package, and if ‘names_only’ is given then the long description is not searched, only the package name is.
Separate arguments can be used to specify multiple search patterns that are and’ed together.
476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 |
# File 'lib/raptcache.rb', line 476 def search(regexp) tmp = Tempfile.new('tmp') regexp.collect! { |i| i + " " } command = option_string() + "search " + regexp.to_s + " 2> " + tmp.path success = system(command) if success begin while (line = tmp.readline) line.chomp selected_string = line end rescue EOFError tmp.close end return selected_string else tmp.close! return success end end |
#show(packages) ⇒ Object
show performs a function similar to dpkg –print-avail; it displays the package records for the named packages.
441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 |
# File 'lib/raptcache.rb', line 441 def show(packages) tmp = Tempfile.new('tmp') packages.collect! { |i| i + " " } command = option_string() + "show " + packages.to_s + " 2> " + tmp.path success = system(command) if success begin while (line = tmp.readline) line.chomp selected_string = line end rescue EOFError tmp.close end return selected_string else tmp.close! return success end end |
#showpkg(packages) ⇒ Object
showpkg displays information about the packages listed on the command line. Remaining arguments are package names. The available versions and reverse dependencies of each package listed are listed, as well as forward dependencies for each version. Forward (normal) dependencies are those packages upon which the package in question depends; reverse dependencies are those packages that depend upon the package in question. Thus, forward dependencies must be satisfied for a package, but reverse dependencies need not be. For instance, apt-cache showpkg libreadline2 would produce output similar to the following:
Package: libreadline2
Versions: 2.1-12(/var/state/apt/lists/foo_Packages),
Reverse Depends:
libreadlineg2,libreadline2
libreadline2-altdev,libreadline2
Dependencies:
2.1-12 - libc5 (2 5.4.0-0) ncurses3.0 (0 (null))
Provides:
2.1-12 -
Reverse Provides:
Thus it may be seen that libreadline2, version 2.1-12, depends on libc5 and ncurses3.0 which must be installed for libreadline2 to work. In turn, libreadlineg2 and libreadline2-altdev depend on libreadline2. If libreadline2 is installed, libc5 and ncurses3.0 (and ldso) must also be installed; libreadlineg2 and libreadline2-altdev do not have to be installed. For the specific meaning of the remainder of the output it is best to consult the apt source code.
243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 |
# File 'lib/raptcache.rb', line 243 def showpkg(packages) tmp = Tempfile.new('tmp') packages.collect! { |i| i + " " } command = option_string() + "showpkg " + packages.to_s + " 2> " + tmp.path success = system(command) if success begin while (line = tmp.readline) line.chomp selected_string = line end rescue EOFError tmp.close end return selected_string else tmp.close! return success end end |
#showsrc(packages) ⇒ Object
showsrc displays all the source package records that match the given package names. All versions are shown, as well as all records that declare the name to be a Binary.
336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 |
# File 'lib/raptcache.rb', line 336 def showsrc(packages) tmp = Tempfile.new('tmp') packages.collect! { |i| i + " " } command = option_string() + "showsrc " + packages.to_s + " 2> " + tmp.path success = system(command) if success begin while (line = tmp.readline) line.chomp selected_string = line end rescue EOFError tmp.close end return selected_string else tmp.close! return success end end |
#stats ⇒ Object
stats displays some statistics about the cache. No further arguments are expected. Statistics reported are:
-
Total package names is the number of package names found in the cache.
-
Normal packages is the number of regular, ordinary package names; these are packages that bear a one-to-one correspondence between their names and the names used by other packages for them in dependencies. The majority of packages fall into this category.
-
Pure virtual packages is the number of packages that exist only as a virtual package name; that is, packages only “provide” the virtual package name, and no package actually uses the name. For instance, “mail-transport-agent” in the Debian GNU/Linux system is a pure virtual package; several packages provide “mail-transport-agent”, but there is no package named “mail-transport-agent”.
-
Single virtual packages is the number of packages with only one package providing a particular virtual package. For example, in the Debian GNU/Linux system, “X11-text-viewer” is a virtual package, but only one package, xless, provides “X11-text-viewer”.
-
Mixed virtual packages is the number of packages that either provide a particular virtual package or have the virtual package name as the package name. For instance, in the Debian GNU/Linux system, “debconf” is both an actual package, and provided by the debconf-tiny package.
-
Missing is the number of package names that were referenced in a dependency but were not provided by any package. Missing packages may be an evidence if a full distribution is not accessed, or if a package (real or virtual) has been dropped from the distribution. Usually they are referenced from Conflicts or Breaks statements.
-
Total distinct versions is the number of package versions found in the cache; this value is therefore at least equal to the number of total package names. If more than one distribution (both “stable” and “unstable”, for instance), is being accessed, this value can be considerably larger than the number of total package names.
-
Total dependencies is the number of dependency relationships claimed by all of the packages in the cache.
309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 |
# File 'lib/raptcache.rb', line 309 def stats tmp = Tempfile.new('tmp') command = option_string() + "stats " + " 2> " + tmp.path success = system(command) if success begin while (line = tmp.readline) line.chomp selected_string = line end rescue EOFError tmp.close end return selected_string else tmp.close! return success end end |
#unmet ⇒ Object
unmet displays a summary of all unmet dependencies in the package cache.
415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 |
# File 'lib/raptcache.rb', line 415 def unmet tmp = Tempfile.new('tmp') command = option_string() + "unmet " + " 2> " + tmp.path success = system(command) if success begin while (line = tmp.readline) line.chomp selected_string = line end rescue EOFError tmp.close end return selected_string else tmp.close! return success end end |
#xvcg(packages) ⇒ Object
The same as dotty, only for xvcg from the VCG tool.
627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 |
# File 'lib/raptcache.rb', line 627 def xvcg(packages) tmp = Tempfile.new('tmp') packages.collect! { |i| i + " " } command = option_string() + "xvcg " + packages.to_s + " 2> " + tmp.path success = system(command) if success begin while (line = tmp.readline) line.chomp selected_string = line end rescue EOFError tmp.close end return selected_string else tmp.close! return success end end |