logo
Free, unlimited AI code reviews that run on commit
git-lrc git-lrc GitHub Install Now We'd appreciate a star git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt

Debian::AptContents - parse/search through apt-file's Contents files

Author

       Damyan Ivanov <dmn@debian.org>
       gregor herrmann <gregoa@debian.org>

Constructor

       new Constructs new instance of the class. Expects at least "cache_dir" option.

Fields

       cache_dir
           (mandatory) Directory where the object stores its cache.

       homedir
           Legacy option to specify the cache directory.

       dist
           Used  for filtering on the "distributon" part of the repository paths listed in sources.list. Default
           is empty, meaning no filtering.

       contents_files
           Arrayref of Contents file names. Default is to let apt-file find them.

       cache_file
           Path to the file with cached parsed information from all Contents files.  Default  is  Contents.cache
           under "cache_dir".

       cache
           Filled by "read_cache". Used by "find_file_packages" and (obviously) "store_cache"

       verbose
           Verbosity level. 0 means silent, the bigger the more the jabber. Default is 1.

Name

       Debian::AptContents - parse/search through apt-file's Contents files

Object Methods

       warning
           Used internally. Given a verbosity level and a message, prints the message to STDERR if the verbosity
           level is greater than or equal of the value of "verbose".

       get_contents_files
           Reads  sources.list,  gives  the  repository  paths to "repo_source_to_contents_paths" and returns an
           arrayref of file names of Contents files.

       read_cache
           Reads the cached parsed Contents files. If there are Contents files with more recent mtime than  that
           of  the  cache  (or  if  there  is  no  cache  at  all), parses all Contents and stores the cache via
           "store_cache" for later invocation.

       store_cache
           Writes the contents of the parsed "cache" to the "cache_file".

           Storable is used to stream the data. Along with the information from Contents files, a time stamp  is
           stored.

       find_file_packages
           Returns a list of packages where the given file was found.

           Contents files store the package section together with package name. That is stripped.

           Returns an empty list of the file is not found in any package.

       find_perl_module_package( $module, $version )
           Given Perl module name (e.g. Foo::Bar), returns a Debian::Dependency object representing the required
           Debian  package  and  version.  If  the module is only in perl core, a suitable dependency on perl is
           returned.

           For dual-lived modules, which are in perl and in a separate package, only the latter is returned,  as
           the perl package has versioned Provides for them.

Synopsis

           my $c = Debian::AptContents->new( { cache_dir => '~/.cache/dh-make-perl' } );
           my @pkgs = $c->find_file_packages('/usr/bin/foo');
           my $dep = $c->find_perl_module_package('Foo::Bar');

Todo

       This needs to really work not only for Perl modules.

       A module specific to Perl modules is needed by dh-make-perl, but it can subclass Debian::AptContents,
       which needs to become more generic.

See Also