libapt-pkg-perl/0000755000000000000000000000000012160072706010737 5ustar libapt-pkg-perl/Makefile.PL0000644000000000000000000000175312114053451012712 0ustar use ExtUtils::MakeMaker; my %changes = map /^([^:]*):\s+(.*)/, split /\n(?!\s)/, `dpkg-parsechangelog`; WriteMakefile( NAME => 'AptPkg', VERSION_FROM => 'AptPkg.pm', CC => 'c++', LD => 'c++', OBJECT => '$(O_FILES)', LIBS => ['-lapt-pkg'], XSOPT => '-C++', depend => { Makefile => 'AptPkg.pm debian/changelog' }, # for VERSION clean => { FILES => 't/cache/var/*.bin' . " $changes{Source}-$changes{Version}" . " $changes{Source}_$changes{Version}.*" . " $changes{Source}_$changes{Version}_*" }, ); sub MY::postamble { < libapt-pkg-perl is licensed under the terms of the GNU General Public License (GPL), version 3 or later, as published by the Free Software Foundation. See the file COPYING in the source, /usr/share/common-licenses/GPL, or for the terms of the latest version of the GNU General Public License. libapt-pkg-perl/debian/source/0000755000000000000000000000000012160072706013461 5ustar libapt-pkg-perl/debian/source/format0000644000000000000000000000001512114053451014663 0ustar 3.0 (native) libapt-pkg-perl/debian/compat0000644000000000000000000000000212114053451013352 0ustar 8 libapt-pkg-perl/debian/control0000644000000000000000000000126312114053451013561 0ustar Source: libapt-pkg-perl Section: perl Priority: optional Maintainer: Brendan O'Dea Build-Depends: perl (>= 5.8.0-6), debhelper (>= 8), libapt-pkg-dev (>= 0.6.40.1) Standards-Version: 3.9.2 Vcs-Git: git://anonscm.debian.org/users/bod/libapt-pkg-perl.git Vcs-Browser: http://anonscm.debian.org/gitweb/?p=users/bod/libapt-pkg-perl.git Package: libapt-pkg-perl Architecture: any Depends: ${misc:Depends}, ${perl:Depends}, ${shlibs:Depends} Description: Perl interface to libapt-pkg A Perl interface to APT's libapt-pkg which provides modules for configuration file/command line parsing, version comparison, inspection of the binary package cache and source package details. libapt-pkg-perl/debian/changelog0000644000000000000000000002104412231050156014026 0ustar libapt-pkg-perl (0.1.29build1) devel; urgency=low * Rebuild for Perl 5.18. -- Colin Watson Sun, 20 Oct 2013 22:51:42 +0100 libapt-pkg-perl (0.1.29) unstable; urgency=low * Update release years in debian/copyright. * Update Copyright to GPLv3. * Re-instate accidentally dropped Size and InstalledSize fields, and update test to ensure they exist. Thanks to Kevin Ryde for reporting the issue and for spelunking the git repository to find the problem change (closes: #712613). -- Brendan O'Dea Wed, 19 Jun 2013 00:31:45 +1000 libapt-pkg-perl (0.1.28) unstable; urgency=low * Whitespace cleanup. * More updates for multi-arch support: - Add is_multi_arch and native_arch methods to AptPkg::Cache. - Add FullName, ShortName and Arch fields to AptPkg::Cache::Package. - Change AptPkg::Cache::Iter to return FullName (including arch) rather than Name. - Update cache test to check for new fields. Thanks to Andrew Ayer for identifying the problem (closes: #707142). * Bump file versions. -- Brendan O'Dea Sat, 11 May 2013 00:25:16 +1000 libapt-pkg-perl (0.1.27) unstable; urgency=low * Update test files with to include multi-arch, translations and inline signed Release files. * Remove very obsolete, rarely updated README file. * Add support for translated descriptions (closes: #701899). -- Brendan O'Dea Fri, 01 Mar 2013 15:28:53 +1100 libapt-pkg-perl (0.1.26) unstable; urgency=low * Update MANIFEST. * Switch to non-deprecated pkgCacheFile::Open method. * Remove old CVS keywords. * Drop Architecture from pkgCache::PkgFileIterator as this field is no longer populated by debListParser::LoadReleaseInfo(). -- Brendan O'Dea Tue, 27 Mar 2012 22:41:35 +1100 libapt-pkg-perl (0.1.25) unstable; urgency=low * Update Vcs-Git and Vcs-Browser fields. * Update standards-version to 3.9.2: - switch to debhelper v8, adding debian/compat - use dh_prep rather than dh_clean -k - add ${misc:Depends} - add build-arch and build-indep targets - conditionally "make realclean" rather than supressing errors - use DESTDIR, rather than PREFIX in install rules - switch to "3.0 (Native)" source format * Apply patch from Kevin Lyda to fix a number of misspellings in the comments and documentation. -- Brendan O'Dea Mon, 03 Oct 2011 21:05:12 +1100 libapt-pkg-perl (0.1.24) unstable; urgency=low * Fix Vcs-Browser control field. * Create empty t/cache/etc/preferences.d directory to hush noisy test. -- Brendan O'Dea Tue, 04 Aug 2009 23:32:26 +1000 libapt-pkg-perl (0.1.23) unstable; urgency=low * Move repository to git://git.debian.org/users/bod/libapt-pkg-perl.git * Apply patch from Kevin Ryde to add Size/InstalledSize (closes: #522835). * Use pre-increment for iterator objects. -- Brendan O'Dea Fri, 17 Apr 2009 03:09:36 +1000 libapt-pkg-perl (0.1.22) unstable; urgency=low * Fix typo in AptPkg::Cache::Version DependsList docs (closes: #461553). -- Brendan O'Dea Wed, 06 Feb 2008 00:56:42 +1100 libapt-pkg-perl (0.1.21) unstable; urgency=low * Remove obsolete _iter method from AptPkg/hash.pm . * Use typemap for methods returning objects rather than calling sv_setref_pv() manually. * Tidy up parented<> class handling. * Implement pkgPolicy interface as AptPkg::Policy (closes: #243125). -- Brendan O'Dea Sun, 17 Jun 2007 21:57:35 +1000 libapt-pkg-perl (0.1.20) unstable; urgency=low * Use $(CURDIR) [make] rather than $(PWD) [sh] in debian/rules (closes: #365534). -- Brendan O'Dea Mon, 1 May 2006 23:34:08 +1000 libapt-pkg-perl (0.1.19) unstable; urgency=low * Ensure that parent objects persist for the life of the child. Thanks to Niko Tyni for identifying the problem (closes: #317058). -- Brendan O'Dea Sun, 30 Apr 2006 02:30:38 +1000 libapt-pkg-perl (0.1.18) unstable; urgency=low * Break reference loop in AptPkg::hash (closes: #323845). * Rebuild against current g++ and libapt-pkg-dev (closes: #335211, #336686, et al.). -- Brendan O'Dea Sun, 13 Nov 2005 18:36:24 +1100 libapt-pkg-perl (0.1.17) unstable; urgency=low * Re-build for apt 0.6.40.1. * Auto-load ::System and ::Version (closes: #316768). * typemap: require object instances, not classes (closes: #321303). -- Brendan O'Dea Mon, 8 Aug 2005 00:03:14 +1000 libapt-pkg-perl (0.1.16) unstable; urgency=low * Re-build for apt 0.6.39. -- Brendan O'Dea Tue, 2 Aug 2005 20:54:45 +1000 libapt-pkg-perl (0.1.15) unstable; urgency=low * Add SourcePkg to $cache->lookup docs. -- Brendan O'Dea Sat, 2 Jul 2005 00:48:47 +1000 libapt-pkg-perl (0.1.14) unstable; urgency=low * Build with apt 0.6. * Create new test Releases file. -- Brendan O'Dea Tue, 28 Jun 2005 20:19:22 +1000 libapt-pkg-perl (0.1.13) unstable; urgency=low * Fix ordering of dh_fixperms/dh_strip such that strip works. * Fix examples/apt-version argument parsing (closes: #276254). * Remove requirement for apt-pkg/deblistparser.h to allow for building on rpm-based systems. Allow for rpm in t/01_system.t . -- Brendan O'Dea Thu, 14 Oct 2004 11:36:07 +1000 libapt-pkg-perl (0.1.12-0.1) unstable; urgency=high * (NMU because I could not reach the maintainer) Removed perl dependency. This way, localization-config can be included on debian-installer netinst ISO without pulling all the perl stuff. (~100KB dependency instead of ~5MB). -- Konstantinos Margaritis Wed, 29 Sep 2004 11:11:05 +0300 libapt-pkg-perl (0.1.12) unstable; urgency=low * Use enumerated constants in a numeric context for SelectedState, CurrentState and InstState. Provide a string version for BuildDepends operators. Closes: #227642. -- Brendan O'Dea Sun, 20 Jun 2004 22:19:46 +1000 libapt-pkg-perl (0.1.11) unstable; urgency=low * AptPkg::Cache::PkgFile lookup method now correctly returns undef when passed a package name that has no available versions (closes: #186104). -- Brendan O'Dea Thu, 25 Sep 2003 01:11:45 +1000 libapt-pkg-perl (0.1.10) unstable; urgency=low * Fix typo in AptPkg::Version docs (closes: #196551). * Add "Priority" key to AptPkg::Cache::Version hashes. -- Brendan O'Dea Sat, 19 Jul 2003 13:59:39 +1000 libapt-pkg-perl (0.1.9) unstable; urgency=low * Fix SEGV using AptPkg::Source (closes: #193052). * Automagically use AptPkg::Config, AptPkg::System and initialise $_config and $_system where required. * Add tests for AptPkg::Source and auto-initialisation. -- Brendan O'Dea Mon, 9 Jun 2003 22:27:09 +1000 libapt-pkg-perl (0.1.8) unstable; urgency=low * Add version to libapt-pkg-dev build dependency. * Change section to "perl". -- Brendan O'Dea Sat, 10 May 2003 10:14:23 +1000 libapt-pkg-perl (0.1.7) unstable; urgency=low * Update BuildDepends parameters for apt 0.5.5 . * Rebuild for libapt-pkg 0.5.5 / c++ 3.2 (closes #192384). * Minor doc additions to AptPkg(3pm). -- Brendan O'Dea Sat, 10 May 2003 09:45:42 +1000 libapt-pkg-perl (0.1.6) unstable; urgency=low * Add source package handling (AptPkg::Source). -- Brendan O'Dea Mon, 5 Aug 2002 20:53:04 +1000 libapt-pkg-perl (0.1.5) unstable; urgency=low * Build against perl 5.8.0 . * Correct "ApkPkg" typo and document the AptPkg::Cache get, exists and keys methods (closes: #147963). -- Brendan O'Dea Mon, 29 Jul 2002 08:55:40 +1000 libapt-pkg-perl (0.1.4) unstable; urgency=low * Correct documentation (File attribute of AptPkg::Cache::VerFile). * Add examples/apt-{version,cache} scripts (closes: #128439). -- Brendan O'Dea Thu, 10 Jan 2002 19:06:47 +1100 libapt-pkg-perl (0.1.3) unstable; urgency=low * Fix typo in package description (closes: #128213). -- Brendan O'Dea Tue, 8 Jan 2002 16:21:29 +1100 libapt-pkg-perl (0.1.2) unstable; urgency=low * Include constants for pkgCache enumerations. * Add CompTypeDeb dependency attribute. * Provide numeric values for DepType, CompType and Flags. -- Brendan O'Dea Mon, 7 Jan 2002 19:57:54 +1100 libapt-pkg-perl (0.1.1) unstable; urgency=low * Initial Release. -- Brendan O'Dea Thu, 3 Jan 2002 23:43:08 +1100 Local variables: mode: debian-changelog End: libapt-pkg-perl/MANIFEST.SKIP0000644000000000000000000000000712114053451012625 0ustar ^.git/ libapt-pkg-perl/MANIFEST0000644000000000000000000000205712114101347012065 0ustar AptPkg.pm AptPkg.xs AptPkg/Cache.pm AptPkg/Config.pm AptPkg/Config.pod AptPkg/PkgRecords.pm AptPkg/Policy.pm AptPkg/Source.pm AptPkg/System.pm AptPkg/Version.pm AptPkg/hash.pm COPYING MANIFEST MANIFEST.SKIP Makefile.PL debian/changelog debian/compat debian/control debian/copyright debian/rules debian/source/format examples/apt-cache examples/apt-config examples/apt-version t/00_config.t t/01_system.t t/02_version.t t/03_cache.t t/04_source.t t/05_autoinit.t t/06_policy.t t/cache/etc/apt.conf t/cache/etc/preferences t/cache/etc/preferences.d/.emptydir t/cache/etc/sources.list t/cache/var/extended_states t/cache/var/lists/_test_dists_stable_InRelease t/cache/var/lists/_test_dists_stable_main_binary-i386_Packages t/cache/var/lists/_test_dists_stable_main_i18n_Translation-en t/cache/var/lists/_test_dists_stable_main_source_Sources t/cache/var/lists/_test_dists_testing_InRelease t/cache/var/lists/_test_dists_testing_main_binary-i386_Packages t/cache/var/lists/_test_dists_testing_main_i18n_Translation-en t/cache/var/status t/config.conf typemap utils.c utils.h libapt-pkg-perl/examples/0000755000000000000000000000000012160072706012555 5ustar libapt-pkg-perl/examples/apt-version0000755000000000000000000000356512114053451014756 0ustar #!/usr/bin/perl # # Example: demonstrate APT version methods # # Usage: apt-version compare VER1 VER2 # rel_compare REL1 REL2 # check_dep PKG OP DEP # upstream VER # use AptPkg::Config '$_config'; use AptPkg::System '$_system'; use AptPkg::Version; (my $self = $0) =~ s#.*/##; # initialise the global config object with the default values $_config->init; # determine the appropriate system type $_system = $_config->system; # fetch a versioning system my $vs = $_system->versioning; print '[System: ', $_system->label, '; Versioning type: ', $vs->label, "]\n"; sub describe { return 'earlier than' if $_[0] < 0; return 'later than' if $_[0] > 0; 'the same as'; } while ($_ = shift) { # compare VER1 VER2 /^comp(?:are)?$/ and do { die "Usage: $self compare VER1 VER2\n" if @ARGV < 2; my ($ver1, $ver2) = splice @ARGV, 0, 2; print "* package version `$ver1' is ", (describe $vs->compare($ver1, $ver2)), " `$ver2'\n"; next; }; # rel_compare REL1 REL2 /^rel(?:[_-]comp(?:are)?)?$/ and do { die "Usage: $self rel_compare REL1 REL2\n" if @ARGV < 2; my ($ver1, $ver2) = splice @ARGV, 0, 2; print "* release version `$ver1' is ", (describe $vs->rel_compare($ver1, $ver2)), " `$ver2'\n"; next; }; # check_dep PKG OP DEP /^check(?:[_-]dep)?$/ and do { die "Usage: $self check_dep PKG OP DEP\n" if @ARGV < 3; my ($pkg, $op, $dep) = splice @ARGV, 0, 3; my $r = $vs->check_dep($pkg, $op, $dep) ? 'satisfies' : 'does not satisfy'; print "* package version `$pkg' $r the dependency `($op $dep)'\n"; next; }; # upstream VER /^upstream$/ and do { die "Usage: $self upstream VER\n" if @ARGV < 1; my $ver = shift; print "* upstream component of package version `$ver' is `", $vs->upstream($ver), "'\n"; next; }; die "$self: unknown action `$_'\n"; } libapt-pkg-perl/examples/apt-cache0000755000000000000000000000604412143203460014326 0ustar #!/usr/bin/perl # # Example: demonstrate accessing the package cache # # Usage: apt-cache PACKAGE # use AptPkg::Config '$_config'; use AptPkg::System '$_system'; use AptPkg::Cache; (my $self = $0) =~ s#.*/##; # initialise the global config object with the default values and # setup the $_system object $_config->init; $_system = $_config->system; # suppress cache building messages $_config->{quiet} = 2; # set up the cache my $cache = AptPkg::Cache->new; my $policy = $cache->policy; die "Usage: $self PACKAGE ...\n" unless @ARGV; for my $pack (@ARGV) { my $p = $cache->{$pack}; unless ($p) { warn "$self: don't know anything about package `$pack'\n"; next; } print "Package: $pack\n"; for my $field (qw/Section SelectedState InstState CurrentState Flags/) { print "$field: $p->{$field}\n" if $p->{$field}; } print "CurrentVer: $p->{CurrentVer}{VerStr}\n" if $p->{CurrentVer}; if (my $c = $policy->candidate($p)) { print "CandidateVer: ", $c->{VerStr}, "\n"; } my $prio = $policy->priority($p); my $pin_ver; if ($prio and my $v = $policy->match($p)) { $pin_ver = $v->{VerStr}; } if (my $available = $p->{VersionList}) { print "VersionList:\n"; my $i = 0; for my $v (@$available) { print " [$i] $v->{VerStr}"; print " (prio $prio)" if $prio and $pin_ver eq $v->{VerStr}; print "\n"; for my $f (map $_->{File}, @{$v->{FileList}}) { printf " * %s (prio %d)\n", $f->{FileName}, $policy->priority($f); } for my $field (qw/MultiArch Arch Priority/) { print " $field: $v->{$field}\n" if $v->{$field}; } if (my $deps = $v->{DependsList}) { my $type = ''; my $delim = ''; for my $d (@$deps) { if ($d->{DepType} ne $type) { print "\n" if $type; $type = $d->{DepType}; print " $type: "; } else { print $delim; } $delim = ($d->{CompType} & AptPkg::Dep::Or) ? ' | ' : ', '; print $d->{TargetPkg}{ShortName}; print " ($d->{CompTypeDeb} $d->{TargetVer})" if $d->{TargetVer}; } print "\n"; } if (my $p = $v->{ProvidesList}) { print ' Provides: ', (join ', ', map $_->{Name}, @$p), "\n"; } $i++; } } if (my $revdeps = $p->{RevDependsList}) { print "RevDependsList:"; my $parent = ''; my $type = ''; for my $r (@$revdeps) { my $new_parent = "$r->{ParentPkg}{ShortName} $r->{ParentVer}{VerStr}"; unless ($new_parent eq $parent) { $parent = $new_parent; $type = ''; } if ($r->{DepType} ne $type) { printf "\n %-30s", $type ? '' : $parent; $type = $r->{DepType}; print " $type: "; } else { print ', '; } print $r->{TargetPkg}{ShortName}; print " ($r->{CompTypeDeb} $r->{TargetVer})" if $r->{TargetVer}; } print "\n"; } if (my $provides = $p->{ProvidesList}) { print 'ProvidesList: ', (join ', ', map "$_->{OwnerPkg}{ShortName} $_->{OwnerVer}{VerStr}", @$provides), "\n"; } print "\n"; } 1; libapt-pkg-perl/examples/apt-config0000755000000000000000000000323712143203451014531 0ustar #!/usr/bin/perl # # Example: apt-config in perl. See apt-config(8). # use AptPkg::Config '$_config'; (my $self = $0) =~ s#.*/##; # initialise the global config object with the default values $_config->init; # parse the command line @ARGV = $_config->parse_cmdline([ [ 'h', 'help', 'help' ], [ 'v', 'version', 'version' ], [ 'c', 'config-file', '', 'ConfigFile' ], [ 'o', 'option', '', 'ArbItem' ], ], @ARGV); if (my $v_opt = $_config->get_bool('version') or # --version $_config->get_bool('help') or # --help !@ARGV) # no args { # we don't have the PACKAGE/VERSION &c apt-config has... punt print "$self (using AptPkg $AptPkg::VERSION, built for ", "$_config->{APT::Architecture})\n"; print <dump; exit; } die "$self: invalid operation `$op'\n" unless $op eq 'shell'; while (@ARGV) { my $var = shift; my $cname = shift or die "$self: arguments not in pairs\n"; local $_; # check if the caller has requested a directory path in the old format $cname .= 'd' if $cname =~ m#/$#; $_ = $_config->get($cname) if $_config->exists($cname); next unless defined; if (m#[^\w@+,./:=-]#) { # quote s/'/'\\''/g; $_ = "'$_" unless s/^'//; $_ = "$_'" unless s/'$//; } print "$var=$_\n"; } libapt-pkg-perl/utils.h0000644000000000000000000000023512114053451012243 0ustar /* * Interface for utils.c */ #ifndef UTILS_H #define UTILS_H 1 char const *parse_avref(pTHX_ SV **p_avref, char const *fmt, ...); #endif /* UTILS_H */ libapt-pkg-perl/utils.c0000644000000000000000000000776212114053451012252 0ustar #define PERL_NO_GET_CONTEXT #include "EXTERN.h" #include "perl.h" #include #include "utils.h" /* * Parse an array reference in a similar manner to python's ParseTuple * * p_avref a pointer to an SV containing (hopefully) an AV reference * fmt a format string defining how to parse the elements of the * AV: * * s String (char const *). If followed by `#', the * s# length is placed into the argument following * (STRLEN *). * * z A variant of `s' in which permits the value to * z# be undefined (converted to NULL). * * h Short integer (short int *). * i Integer (int *). * l Long integer (long *). * c The first character of a string (char *). * f Floating point number (float *). * d Double precision floating point number (double *). * @ Array reference (AV **). * % Hash reference (HV **). * & Code reference (CV **). * | Optional elements follow. * * The return value is a string giving the first error encountered (if * any). */ char const *parse_avref(pTHX_ SV **p_avref, char const *fmt, ...) { va_list ap; char const *err = 0; AV *av; I32 len = 0; va_start(ap, fmt); if (p_avref && SvROK(*p_avref) && SvTYPE(SvRV(*p_avref)) == SVt_PVAV) { av = (AV *) SvRV(*p_avref); len = av_len(av) + 1; } else err = "array reference required"; I32 i = 0; int opt = 0; while (*fmt) { SV *v = 0; char type = *fmt++; if (!err) { if (i < len) { SV **tmp = av_fetch(av, i++, 0); if (tmp) v = *tmp; } else if (!opt) { err = "too few elements"; } } switch (type) { case 's': case 'z': { char const **s = va_arg(ap, char const **); STRLEN *l = &PL_na; if (*fmt == '#') { l = va_arg(ap, STRLEN *); fmt++; } *s = 0; *l = 0; if (v) { if (SvOK(v)) { if (SvPOK(v) || SvNIOK(v)) *s = SvPV(v, *l); else err = "invalid string"; } else if (type != 'z') err = "undefined element"; } } break; case 'h': { short *s = va_arg(ap, short *); *s = 0; if (v) { if (SvNIOK(v)) *s = (short) SvIV(v); else err = "short int expected"; } } break; case 'i': { int *i = va_arg(ap, int *); *i = 0; if (v) { if (SvNIOK(v)) *i = (int) SvIV(v); else err = "integer expected"; } } break; case 'l': { long *l = va_arg(ap, long *); *l = 0; if (v) { if (SvNIOK(v)) *l = (long) SvIV(v); else err = "long integer expected"; } } break; case 'c': { char *c = va_arg(ap, char *); *c = 0; if (v) { char const *s; STRLEN l; if ((SvPOK(v) || SvNIOK(v)) && (s = SvPV(v, l)) && l) *c = *s; } } break; case 'f': { float *f = va_arg(ap, float *); *f = 0; if (v) { if (SvNIOK(v)) *f = (float) SvNV(v); else err = "float expected"; } } break; case 'd': { double *d = va_arg(ap, double *); *d = 0; if (v) { if (SvNIOK(v)) *d = (double) SvNV(v); else err = "double expected"; } } break; case '@': { AV **a = va_arg(ap, AV **); *a = 0; if (v) { if (SvROK(v) && SvTYPE(SvRV(v)) == SVt_PVAV) *a = (AV *) SvRV(v); else err = "array ref expected"; } } break; case '%': { HV **h = va_arg(ap, HV **); *h = 0; if (v) { if (SvROK(v) && SvTYPE(SvRV(v)) == SVt_PVHV) *h = (HV *) SvRV(v); else err = "hash ref expected"; } } break; case '&': { CV **c = va_arg(ap, CV **); *c = 0; if (v) { if (SvROK(v) && SvTYPE(SvRV(v)) == SVt_PVCV) *c = (CV *) SvRV(v); else err = "code ref expected"; } } break; default: croak("parse_avref: invalid format character `%c'", type); } /* "|" = args following are optional */ if (*fmt == '|') { fmt++; opt++; } } if (!err && i < len) err = "extra elements"; va_end(ap); return err; } libapt-pkg-perl/t/0000755000000000000000000000000012160072706011202 5ustar libapt-pkg-perl/t/cache/0000755000000000000000000000000012160072706012245 5ustar libapt-pkg-perl/t/cache/etc/0000755000000000000000000000000012160072706013020 5ustar libapt-pkg-perl/t/cache/etc/preferences0000644000000000000000000000014411171650452015244 0ustar Package: * Pin: release a=testing Pin-Priority: 50 Package: b Pin: version 0.2* Pin-Priority: 1001 libapt-pkg-perl/t/cache/etc/sources.list0000644000000000000000000000012611171650452015400 0ustar deb file:/test stable main deb file:/test testing main deb-src file:/test stable main libapt-pkg-perl/t/cache/etc/apt.conf0000644000000000000000000000024112114070616014445 0ustar Dir "t/cache" { Etc "etc"; State "var" { status "status"; }; Cache "var"; }; APT::Architecture "i386"; Acquire::Languages { "en"; }; quiet 2; libapt-pkg-perl/t/cache/etc/preferences.d/0000755000000000000000000000000012160072706015543 5ustar libapt-pkg-perl/t/cache/etc/preferences.d/.emptydir0000644000000000000000000000000012114053451017362 0ustar libapt-pkg-perl/t/cache/var/0000755000000000000000000000000012160072706013035 5ustar libapt-pkg-perl/t/cache/var/lists/0000755000000000000000000000000012160072706014173 5ustar libapt-pkg-perl/t/cache/var/lists/_test_dists_stable_main_source_Sources0000644000000000000000000000127211171647667024104 0ustar Package: a Binary: a Version: 0.1 Priority: optional Section: test Maintainer: Brendan O'Dea Build-Depends: b (>= 0.2-42) [!hurd-i386] Architecture: i386 Standards-Version: 3.5.10 Format: 1.0 Directory: pool/main/a/a Files: 8202ae7d918948c192bdc0f183ab26ca 868 a_0.1.dsc a54a02be45314a8eea38058b9bbea7da 1409853 a_0.1.tar.gz Package: b Binary: b Version: 0.3-1 Priority: optional Section: main Maintainer: Brendan O'Dea Architecture: i386 Standards-Version: 3.5.10 Directory: pool/main/b/b Files: aaa191b444e844f254b83766d9fb833c 618 b_0.3-1.dsc 0d74bee86c2691899c94b2743deaf077 94791 b_0.3.orig.tar.gz 1ceb9ebf44ad63f65587e512b596520b 4424 b_0.3-1.diff.gz libapt-pkg-perl/t/cache/var/lists/_test_dists_stable_main_binary-i386_Packages0000644000000000000000000000124712114065165024635 0ustar Package: a Priority: optional Section: test Installed-Size: 300 Maintainer: Brendan O'Dea Architecture: i386 Version: 0.1 Depends: b (>= 0.2-3) Conflicts: foo Provides: bar Filename: pool/main/a/a/a_0.1_i386.deb Size: 30000 MD5sum: 0123456789abcdef0123456789abcdef Description: Test Package "a" Description-md5: 21262d43a904d77956fa318919f6a15c Package: b Priority: optional Section: test Installed-Size: 300 Maintainer: Brendan O'Dea Architecture: i386 Version: 0.3-1 Filename: pool/main/b/b/b_0.3-1_i386.deb Size: 30000 MD5sum: 0123456789abcdef0123456789abcdef Description: Test Package "b" Description-md5: d15627f448cd36d2193aafcd416de7eb libapt-pkg-perl/t/cache/var/lists/_test_dists_testing_InRelease0000644000000000000000000000242412114067372022132 0ustar -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Origin: Debian Label: Debian Suite: testing Version: 3.1 Architectures: i386 Component: main ea1cba338f00d54cf495ecf4ccfb7652 995 main/binary-i386/Packages 56551447be675cd8467072153a8b1c2c 462 main/i18n/Translation-en SHA1: 1ebf3c606abb5f1ae64f28a0a42ff2d53f1e74d4 995 main/binary-i386/Packages 4a24047acefde63a903f41f5a348d4b63f3aba8b 462 main/i18n/Translation-en -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.12 (GNU/Linux) iQIcBAEBAgAGBQJRMG7zAAoJEBx8Qe3r3btgSJUP/12p4Lg9xF1NMk6t+nYAmoxy 662adeFC8vxqluzphjhx7VGX7CUTsB4o/xsxyK9j7muIWZ1uV/Msq6qoJgrOFsqA vuee5RFNVlM7yccR78TbQJwNenqMRchBvCAen4AsQ6ar4TXejf7cFP2e1DR1duxp IC2plTiK/dF/PuhIvVtPcbpkusaehcu9f1kJEfaMRGlKtEaUJOUtJ/EkZLA6i6V/ K6UwwOQLS/1SBWvmel5fbt0AHF3VoDFBm6klDqTVcJSDbH1FHalMdEO8l1H11P1S UknpDq0Ozrkv1DTbh6oenj249J66CWi1T+fMA90aEhQOp5z9uzZdfyTFMgs8eFpE MXWbluliGNq62eS4et9R6hvyvkrJI+oFAQylpDNoOzjYfOcC9FT6kXSAdKDx2CYh PqJgEz33q6KdRVsVCC7jzXvducY/pL6pQhIwk39Wt9izahFVvelsMDyXnNboAsy5 Zm8bIGc9C8DUPCXSQcsadIc9yR0+fjQsj0CJPqO0j7sQYo0GQaWMOrvzt3ZZrtQI lCC6wpIktfd0LgAPfstKEYw7qeF17dHMKaxFUmTY5ENqchJzgAJcTUQZIagj3Lcb 8AzJ22ZPSj8OAs9xu8SfFQMW55qAfMbP/kjO6UJLzYDU5iZLIbbMyoXcOqkWU9Bq +yZBBMP2dndpWTA5/DJ+ =9HoO -----END PGP SIGNATURE----- libapt-pkg-perl/t/cache/var/lists/_test_dists_stable_main_i18n_Translation-en0000644000000000000000000000046412114065205024614 0ustar Package: a Description-md5: 21262d43a904d77956fa318919f6a15c Description-en: Test Package "a" This is a bogus package for the AptPkg::Cache test suite. Package: b Description-md5: d15627f448cd36d2193aafcd416de7eb Description-en: Test Package "b" This is a bogus package for the AptPkg::Cache test suite. libapt-pkg-perl/t/cache/var/lists/_test_dists_testing_main_binary-i386_Packages0000644000000000000000000000174312114065165025041 0ustar Package: a Priority: optional Section: test Installed-Size: 300 Maintainer: Brendan O'Dea Architecture: i386 Version: 0.5 Depends: b (>= 0.3-2) Conflicts: foo Provides: bar Filename: pool/main/a/a/a_0.5_i386.deb Size: 30000 MD5sum: 0123456789abcdef0123456789abcdef Description: Test Package "a" Description-md5: 21262d43a904d77956fa318919f6a15c Package: b Priority: optional Section: test Installed-Size: 300 Maintainer: Brendan O'Dea Architecture: i386 Version: 0.3-2 Filename: pool/main/b/b/b_0.3-2_i386.deb Size: 30000 MD5sum: 0123456789abcdef0123456789abcdef Description: Test Package "b" Description-md5: d15627f448cd36d2193aafcd416de7eb Package: c Priority: optional Section: test Installed-Size: 300 Maintainer: Brendan O'Dea Architecture: i386 Version: 0.2-1 Filename: pool/main/c/c/c_0.2-1_i386.deb Size: 30000 MD5sum: 0123456789abcdef0123456789abcdef Description: Test Package "c" Description-md5: 3786aae0160b7224cd23c3d6126fe037 libapt-pkg-perl/t/cache/var/lists/_test_dists_stable_InRelease0000644000000000000000000000264712114067344021735 0ustar -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Origin: Debian Label: Debian Suite: stable Version: 3.0 Architectures: i386 Component: main 08dc45ac51fe6992a4de6f65526217f7 679 main/binary-i386/Packages 14803085e92f2ad8dc7deabf5c79a443 308 main/i18n/Translation-en 969e3637c8147d6bb288cf12832200bc 698 main/source/Sources SHA1: e57c2e43e5d8bd51cf58d288b54507abb026a4ea 679 main/binary-i386/Packages c82b1dff73897e185ff27cdc47062efe0df1b12e 308 main/i18n/Translation-en 628cdf8615c970164d29bcf930cfdb8fc7e14dd2 698 main/source/Sources -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.12 (GNU/Linux) iQIcBAEBAgAGBQJRMG7hAAoJEBx8Qe3r3btg0osP/RyZRSDtuTuTtYG1VMvnmVzq zG5zf0kIVaQ8f0FTmUQIHdiSpvkKub9r4pReDKMZoxxl8DA4IWG3hiLUgcNwR5IM j9QE/twrBDZ/9nWUndN9VlgwlYs446lX9+6D8YfMWE2TJ6eAWdaYLgMof6jGzcZC K2ZfxaHUiq3cxKMPtYYVaK8Ew+Uua7TgVQyflnrid1ce1vqvEKLncyFARsn4G07/ 4guKnzW5q8zaZL8Hq/KE3k1kZtV8lp0Os79akRbod+PcVWtRkFEL4DBphpPy10KM LOgRgh3fDQ0B5oHN8Z0GuIy1dKCqGVEoWecNFGP/mxUROgvN+7IpWZ5psFGa3gy4 IShMi/hqj70pvoqy10z6Z6tUAxcv5Z566B65Wnb4gwZSc6WVfANs/g5Fjx+tURlO 08zSIsYGVswGZLj14Ucm455pSGtEvrFrFnsUj95XXUdw2pTPZ8Yav7tRI0Y7LDeJ uJ1Q2cXByCO90kuqn6j5NUpJUld6Ai5p2xnZQPD7C6J1cw22GOeG05F3WguEYNPd /xV5l+HmsaYXbpfPUWB69Id1ovAJUQB3mtIRtQBt81fZ/K13rXhT1lqBunn57gyY /sUQ5RWHc5DVU+yh+pvHiJdFaJ4I84gVfJgUohRDhdA++ieTqnmmrq92RKwoZS/r uyop5ZkZuP1Fj04Ce+u7 =ht74 -----END PGP SIGNATURE----- libapt-pkg-perl/t/cache/var/lists/_test_dists_testing_main_i18n_Translation-en0000644000000000000000000000071612114065205025017 0ustar Package: a Description-md5: 21262d43a904d77956fa318919f6a15c Description-en: Test Package "a" This is a bogus package for the AptPkg::Cache test suite. Package: b Description-md5: d15627f448cd36d2193aafcd416de7eb Description-en: Test Package "b" This is a bogus package for the AptPkg::Cache test suite. Package: c Description-md5: 3786aae0160b7224cd23c3d6126fe037 Description-en: Test Package "c" This is a bogus package for the AptPkg::Cache test suite. libapt-pkg-perl/t/cache/var/extended_states0000644000000000000000000000006112114057576016147 0ustar Package: b Architecture: i386 Auto-Installed: 0 libapt-pkg-perl/t/cache/var/status0000644000000000000000000000043012114061112014264 0ustar Package: b Status: install ok installed Priority: optional Section: test Installed-Size: 290 Maintainer: Brendan O'Dea Architecture: i386 Multi-Arch: foreign Version: 0.2-1 Description: Test Package "b" This is a bogus package for the AptPkg::Cache test suite. libapt-pkg-perl/t/06_policy.t0000644000000000000000000000323612114053451013172 0ustar #!/usr/bin/perl # AptPkg::Policy tests BEGIN { print "1..10\n" } use AptPkg::Config '$_config'; use AptPkg::System '$_system'; use AptPkg::Cache; use AptPkg::Policy; $_config->init; $_config->read_file('t/cache/etc/apt.conf'); $_system = $_config->system; print "ok 1\n"; my $cache = AptPkg::Cache->new; my $policy = $cache->policy; # policy created unless ($policy) { print "not ok 2\n"; exit; } # package "a" exists if (my $a = $cache->{a}) { print "ok 2\n"; # expect stable candidate my $c = $policy->candidate($a); print 'not ' unless $c and $c->{VerStr} eq '0.1'; print "ok 3\n"; # no package pin my $p = $policy->priority($a); print 'not ' unless $p == 0; print "ok 4\n"; # get archive priorities my %prio; for my $v (@{$a->{VersionList}}) { for my $f (map $_->{File}, @{$v->{FileList}}) { $prio{$1} = $policy->priority($f) if $f->{FileName} =~ /_dists_([^_]+)_main_/; } } # default prio print 'not ' unless $prio{stable} eq '500'; print "ok 5\n"; # pinned print 'not ' unless $prio{testing} eq '50'; print "ok 6\n"; } else { print "not ok 2 # package a missing\n"; print "ok $_ # skip\n" for 3..6; } if (my $b = $cache->{b}) { print "ok 7\n"; # expect pinned candidate my $c = $policy->candidate($b); print 'not ' unless $c and $c->{VerStr} eq '0.2-1'; print "ok 8\n"; my $p = $policy->priority($b); if ($p == 1001) { print "ok 9\n"; my $v = $policy->match($b); print 'not ' unless $v and $v->{VerStr} eq '0.2-1'; print "ok 10\n"; } else { print "not ok 9 # no pin on package b\n"; print "ok 10 # skip\n"; } } libapt-pkg-perl/t/00_config.t0000644000000000000000000000471012114053451013130 0ustar #!/usr/bin/perl # AptPkg::Config tests BEGIN { print "1..23\n" } use AptPkg::Config; # create my $c = AptPkg::Config->new; print "ok 1\n"; # set print 'not ' unless $c->set(a => 42) == 42; print "ok 2\n"; # get print 'not ' unless $c->get('a') == 42; print "ok 3\n"; # default print 'not ' unless $c->get('not there', 'default') eq 'default'; print "ok 4\n"; # get_file, get_dir $c->set(b => "/tmp/"); $c->set(b::c => "foo"); print 'not ' unless $c->get_file('b::c') eq '/tmp/foo'; print "ok 5\n"; print 'not ' unless $c->get_dir('b::c') eq '/tmp/foo/'; print "ok 6\n"; # using /f, /d suffix (FindAny) print 'not ' unless $c->get('b::c/f') eq '/tmp/foo'; print "ok 7\n"; print 'not ' unless $c->get('b::c/d') eq '/tmp/foo/'; print "ok 8\n"; # get_bool $c->set(c => 'false'); $c->set(d => 'yes'); print 'not ' if $c->get_bool('c'); print "ok 9\n"; print 'not ' unless $c->get_bool('d'); print "ok 10\n"; # exists print 'not ' unless $c->exists('c'); print "ok 11\n"; print 'not ' if $c->exists('not there'); print "ok 12\n"; # read_file { local $SIG{__WARN__} = sub { die @_ }; eval { $c->read_file('t/config.conf') }; } print 'not ' if $@; print "ok 13\n"; print 'not ' unless $c->get('e') eq 'e_val' and $c->get('e::f') eq 'f_val'; print "ok 14\n"; # parse_cmdline my @r = $c->parse_cmdline([ ['q', 'qtest', 'qtest', 'int_level'], ['r', 'rtest', 'rtest', 'int_level'], ['s', 'stest', 'stest', 'int_level'], ['t', 'ttest', 'ttest', 'has_arg'], ['o', 'otest', '', 'arb_item'], ], '-q', '-rr', '-s=3', '--ttest=t', '-ofoo=bar', 'cmd'); print 'not ' if $c->get('qtest') != 1 or $c->get('rtest') != 2 or $c->get('stest') != 3 or $c->get('ttest') ne 't' or $c->get('foo') ne 'bar' or "@r" ne 'cmd'; print "ok 15\n"; # XS methods print 'not ' unless $c->Find('a') == 42; print "ok 16\n"; # $_config, init $c = $AptPkg::Config::_config; print 'not ' unless $c->init; print "ok 17\n"; print 'not ' unless $c->get_dir('Dir::Etc') eq '/etc/apt/'; print "ok 18\n"; # hash access $c = AptPkg::Config->new; $c->{a} = 42; $c->{b} = 'foo'; print 'not ' unless $c->{a} == 42 and $c->{b} eq 'foo'; print "ok 19\n"; @r = keys %$c; print 'not ' unless "@r" eq 'a b'; print "ok 20\n"; @r = values %$c; print 'not ' unless "@r" eq '42 foo'; print "ok 21\n"; # explicit iterator @r = $c->keys; print 'not ' unless "@r" eq 'a b'; print "ok 22\n"; @r = (); for (my $i = $c->keys; my $k = $i->next; ) { push @r, $k } print 'not ' unless "@r" eq 'a b'; print "ok 23\n"; 1; libapt-pkg-perl/t/03_cache.t0000644000000000000000000001412612160067110012731 0ustar #!/usr/bin/perl # AptPkg::Cache tests BEGIN { print "1..66\n" } sub check_keys { my ($test, $thing, $expect) = @_; for my $key (keys %$expect) { print $thing->{$key} eq $expect->{$key} ? "ok $test\n" : "not ok $test # $thing->{$key} != $expect->{$key}\n"; $test++; } $test; } use AptPkg::Config '$_config'; use AptPkg::System '$_system'; use AptPkg::Cache; $_config->init; $_config->read_file('t/cache/etc/apt.conf'); $_system = $_config->system; print "ok 1\n"; my $cache = AptPkg::Cache->new; # cache created unless ($cache) { print "not ok 2\n"; exit; } my $verfile; # for ->packages test # package "b" exists if (my $b = $cache->{b}) { print "ok 2\n"; # check some string values check_keys 3, $b, { Name => 'b', FullName => 'b:i386', ShortName => 'b', Arch => 'i386', Section => 'test', SelectedState => 'Install', InstState => 'Ok', CurrentState => 'Installed', }; # expected current version print 'not ' unless $b->{CurrentVer}{VerStr} eq '0.2-1'; print "ok 11\n"; # installed and two new versions are available print 'not ' unless @{$b->{VersionList}} == 3; print "ok 12\n"; # newest version is first print 'not ' unless $b->{VersionList}[0]{VerStr} eq '0.3-2'; print "ok 13\n"; # stash verfile from stable version if (my $f = $b->{VersionList}[1]{FileList}) { $verfile = $f->[0]; } else { print 'not '; } print "ok 14\n"; # last is current version print 'not ' unless $b->{VersionList}[-1]{VerStr} eq '0.2-1'; print "ok 15\n"; # check rev depends my $r; if (@{$b->{RevDependsList}} == 2) { ($r) = grep { $_->{ParentPkg}{Name} eq 'a' and $_->{ParentVer}{VerStr} eq '0.1' } @{$b->{RevDependsList}}; } if ($r) { print "ok 16\n"; print 'not ' unless $r->{DepType} eq 'Depends'; print "ok 17\n"; print 'not ' unless $r->{TargetPkg}{Name} eq 'b'; print "ok 18\n"; print 'not ' unless $r->{CompType} eq '>='; print "ok 19\n"; print 'not ' unless $r->{TargetVer} eq '0.2-3'; print "ok 20\n"; } else { print "not ok 16 # no rev depends\n"; print "ok $_ # skip\n" for 17..20; } # check sizes from the newest version print 'not ' unless $b->{VersionList}[0]{Size} == 30000; print "ok 21\n"; print 'not ' unless $b->{VersionList}[0]{InstalledSize} == 300 * 1024; print "ok 22\n"; } else { print "not ok 2 # package b missing\n"; print "ok $_ # skip\n" for 3..22; } # package "a" exists if (my $a = $cache->{a}) { print "ok 23\n"; # check some string values check_keys 24, $a, { Name => 'a', Section => 'test', SelectedState => 'Unknown', InstState => 'Ok', CurrentState => 'NotInstalled', }; # expect two versions to be available print 'not ' unless @{$a->{VersionList}} == 2; print "ok 29\n"; # check version (stable version) print 'not ' unless $a->{VersionList}[1]{VerStr} eq '0.1'; print "ok 30\n"; # check provides print 'not ' unless @{$a->{VersionList}[1]{ProvidesList}} == 1; print "ok 31\n"; my $p = $a->{VersionList}[1]{ProvidesList}[0]; print 'not ' unless $p->{OwnerPkg}{Name} eq 'a'; print "ok 32\n"; print 'not ' unless $p->{OwnerVer}{VerStr} eq '0.1'; print "ok 33\n"; # check depends my $d = $a->{VersionList}[1]{DependsList}; my $depend; my $conflict; if ($d and @$d == 2) { for my $i (0, 1) { for ($d->[$i]{DepType}) { /^Depends$/ and $depend = $i; /^Conflicts$/ and $conflict = $i; } } } if (defined $depend and defined $conflict) { print "ok 34\n"; print 'not ' unless $d->[$depend]{TargetPkg}{Name} eq 'b'; print "ok 35\n"; print 'not ' unless $d->[$depend]{CompType} eq '>='; print "ok 36\n"; print 'not ' unless $d->[$depend]{TargetVer} eq '0.2-3'; print "ok 37\n"; print 'not ' unless $d->[$conflict]{TargetPkg}{Name} eq 'foo'; print "ok 38\n"; } else { print "not ok 34 # bad depends\n"; print "ok $_ # skip\n" for 35..38; } } else { print "not ok 21 # package a missing\n"; print "ok $_ # skip\n" for 22..38; } # test files my $f = $cache->files; my $status; my $packages; if ($f and @$f == 5) { for (my $i = 0; $i < @$f; $i++) { for ($f->[$i]{FileName}) { /\bstatus$/ and $status = $i; /stable_.*_Packages$/ and $packages = $i; } } } if (defined $status and defined $packages) { print "ok 39\n"; check_keys 40, $f->[$status], { FileName => 't/cache/var/status', IsOk => 1, Archive => 'now', IndexType => 'Debian dpkg status file', }; check_keys 44, $f->[$packages], { FileName => 't/cache/var/lists/_test_dists_stable_main_binary-i386_Packages', IsOk => 1, Origin => 'Debian', Label => 'Debian', Archive => 'stable', Version => '3.0', Component => 'main', IndexType => 'Debian Package Index', }; } else { print "not ok 39 # bad ->files\n"; print "ok $_ # skip\n" for 40..51; } if (my $p = $cache->packages) { # check by name if (my $a = $p->lookup('a')) { print "ok 52\n"; check_keys 53, $a, { Name => 'a', Section => 'test', VerStr => '0.5', Maintainer => 'Brendan O\'Dea ', FileName => 'pool/main/a/a/a_0.5_i386.deb', MD5Hash => '0123456789abcdef0123456789abcdef', ShortDesc => 'Test Package "a"', LongDesc => qq/Test Package "a"\n This is a bogus package for the AptPkg::Cache test suite./, }; } else { print "not ok 52 # lookup by name failed\n"; print "ok $_ # skip\n" for 53..60; } # check by verfile if ($verfile) { if (my $b = $p->lookup($verfile)) { print "ok 61\n"; check_keys 62, $b, { Name => 'b', Maintainer => 'Brendan O\'Dea ', FileName => 'pool/main/b/b/b_0.3-1_i386.deb', MD5Hash => '0123456789abcdef0123456789abcdef', ShortDesc => 'Test Package "b"', }; } else { print "not ok 61 # lookup by verfile failed\n"; print "ok $_ # skip\n" for 62..66; } } else { print "ok $_ # skip\n" for 61..66; } } else { print "not ok 52 # bad ->packages\n"; print "ok $_ # skip\n" for 53..66; } libapt-pkg-perl/t/02_version.t0000644000000000000000000000311312114053451013346 0ustar #!/usr/bin/perl # AptPkg::Version tests BEGIN { print "1..21\n" } use AptPkg::Config '$_config'; use AptPkg::System '$_system'; use AptPkg::Version; print 'not ' unless $_config->init and $_system = $_config->system; print "ok 1\n"; my $v = $_system->versioning; print 'not ' unless $v; print "ok 2\n"; print 'not ' unless $v->compare('1.0', '1.1') < 0; print "ok 3\n"; print 'not ' unless $v->compare('1.1', '1.0') > 0; print "ok 4\n"; print 'not ' unless $v->compare('1.1', '1.1') == 0; print "ok 5\n"; print 'not ' unless $v->compare('1.2-1', '1.2-2') < 0; print "ok 6\n"; print 'not ' unless $v->compare('1.2.3', '1.20.2') < 0; print "ok 7\n"; print 'not ' unless $v->compare('1.2.3', '1:1.0') < 0; print "ok 8\n"; print 'not ' unless $v->check_dep('1', '<<', '2'); print "ok 9\n"; print 'not ' unless $v->check_dep('1', '<=', '2'); print "ok 10\n"; print 'not ' unless $v->check_dep('2', '<=', '2'); print "ok 11\n"; print 'not ' unless $v->check_dep('1', '=', '1'); print "ok 12\n"; print 'not ' unless $v->check_dep('2', '>=', '2'); print "ok 13\n"; print 'not ' unless $v->check_dep('2', '>=', '1'); print "ok 14\n"; print 'not ' unless $v->check_dep('2', '>>', '1'); print "ok 15\n"; print 'not ' if $v->check_dep('1', '>>', '2'); print "ok 16\n"; print 'not ' if $v->check_dep('1', '>=', '2'); print "ok 17\n"; print 'not ' if $v->check_dep('1', '=', '2'); print "ok 18\n"; print 'not ' if $v->check_dep('2', '<=', '1'); print "ok 19\n"; print 'not ' if $v->check_dep('2', '<<', '1'); print "ok 20\n"; print 'not ' unless $v->upstream("1:6.12-3-1.2") eq '6.12-3'; print "ok 21\n"; 1; libapt-pkg-perl/t/04_source.t0000644000000000000000000000347412114334407013200 0ustar #!/usr/bin/perl # AptPkg::Source tests BEGIN { print "1..14\n" } use AptPkg::Config '$_config'; use AptPkg::Source; $_config->init; $_config->read_file('t/cache/etc/apt.conf'); $_config->{quiet} = 0; print "ok 1\n"; my $src = AptPkg::Source->new; # cache created unless ($src) { print "not ok 2\n"; exit; } sub check { my ($test, $t) = @_; print 'not ' unless $t; print "ok $test\n"; } # package "a" exists if (my $a = $src->{a}) { print "ok 2\n"; check 3, @$a == 1; $a = $a->[0]; check 4, $a->{Package} eq 'a'; check 5, $a->{Section} eq 'test'; check 6, $a->{Version} eq '0.1'; if ($a->{Binaries} and ref $a->{Binaries} eq 'ARRAY') { check 7, "@{$a->{Binaries}}" eq 'a'; } else { print "not ok 7 # no binaries\n"; } if ($a->{BuildDepends} and ref $a->{BuildDepends} eq 'HASH' and my $b = $a->{BuildDepends}{'Build-Depends'}) { check 8, $b->[0][0] eq 'b'; check 9, $b->[0][1] == AptPkg::Dep::GreaterEq; check 10, $b->[0][2] eq '0.2-42'; } else { print "not ok 8 # build depends\n"; print "ok $_ # skip\n" for 9..10; } if ($a->{Files} and ref $a->{Files} eq 'ARRAY') { if (my ($dsc) = grep $_->{Type} eq 'dsc', @{$a->{Files}}) { check 11, $dsc->{ArchiveURI} =~ m!pool/main/a/a/a_0\.1\.dsc$!; check 12, $dsc->{MD5Hash} eq '8202ae7d918948c192bdc0f183ab26ca'; } else { print "not ok 11 # no dsc\n"; print "ok 12 # skip\n"; } if (my ($tgz) = grep $_->{Type} eq 'tar', @{$a->{Files}}) { check 13, $tgz->{ArchiveURI} =~ m!pool/main/a/a/a_0\.1\.tar\.gz$!; check 14, $tgz->{MD5Hash} eq 'a54a02be45314a8eea38058b9bbea7da'; } else { print "not ok 13 # no tar\n"; print "ok 14 # skip\n"; } } } else { print "not ok 2 # source a missing\n"; print "ok $_ # skip\n" for 3..14; } libapt-pkg-perl/t/01_system.t0000644000000000000000000000074212114053451013211 0ustar #!/usr/bin/perl # AptPkg::System tests BEGIN { print "1..2\n" } use AptPkg::Config '$_config'; use AptPkg::System '$_system'; print 'not ' unless $_config->init and $_system = $_config->system; print "ok 1\n"; my $type; $type ||= 'dpkg' if -f '/etc/debian_version'; $type ||= 'rpm' if -f '/etc/redhat-release'; unless ($type) { print "# unknown system type, defaulting to dpkg\n"; $type = 'dpkg'; } print 'not ' unless $_system->label =~ /$type/; print "ok 2\n"; 1; libapt-pkg-perl/t/config.conf0000644000000000000000000000006511171647667013336 0ustar // test configuration file e "e_val" { f "f_val"; }; libapt-pkg-perl/t/05_autoinit.t0000644000000000000000000000063512143203451013525 0ustar #!/usr/bin/perl # AptPkg::Cache auto-init test BEGIN { print "1..3\n" } use AptPkg::Cache; if (my $cache = AptPkg::Cache->new) { print "ok 1\n"; if (my $apt = $cache->{apt}) { print "ok 2\n"; print 'not ' unless $apt->{Name} eq 'apt'; print "ok 3\n"; } else { print "not ok 2\n"; print "ok 3 # skip\n"; } } else { print "not ok 1\n"; print "ok $_ # skip\n" for 2..3; } libapt-pkg-perl/AptPkg.pm0000644000000000000000000001536212143321514012465 0ustar package AptPkg; require 5.005_62; use strict; use warnings; require DynaLoader; our @ISA = qw(DynaLoader); our $VERSION = 1.15; bootstrap AptPkg $VERSION; 1; __END__ =head1 NAME AptPkg - interface to libapt-pkg =head1 SYNOPSIS use AptPkg; =head1 DESCRIPTION The AptPkg module provides a low-level XS interface to libapt-pkg. Note that this interface is intended to be internal, and may change, see the AptPkg::Config, AptPkg::System, AptPkg::Version, AptPkg::Cache, Apt::Policy and AptPkg::Source classes for a higher level interface. =head2 AptPkg The AptPkg package provides the following functions: =over 4 =item _init_config(I) Initialise a Configuration object (pkgInitConfig). See the init method in AptPkg::Config. =item _init_system(I) Return a pointer to the system object (pkgInitSystem). See the system method in AptPkg::Config. =item _parse_cmdline(I, I, ...) Constructs a CommandLine instance, invokes the Parse method and returns the remaining arguments. See the parse_cmdline method in AptPkg::Config. =back =head2 AptPkg::_config The AptPkg::_config package wraps a Perl class around the Configuration class. It provides an instance of the global _config object, and exposes the following methods: Find, FindFile, FindDir, FindB, FindAny, Set, Exists, ExistsAny, Tree and Dump. The functions ReadConfigFile and ReadConfigDir are also provided within the package and may be used as methods. =head2 AptPkg::_config::item The AptPkg::_config::item package wraps a Perl class around the Configuration::Item class. The AptPkg::_config Tree method returns an instance of this class. Methods: Value, Tag, FullTag, Parent, Child and Next. =head2 AptPkg::System The AptPkg::System package wraps a Perl class around the pkgSystem class. It provides an instance of the global _system object, and exposes the following methods: Label, VS, Lock and UnLock. =head2 AptPkg::Version The AptPkg::Version package wraps a Perl class around the pkgVersioningSystem class. It exposes the following methods: Label, CmpVersion, CmpReleaseVer, CheckDep and UpstreamVersion. =head2 AptPkg::_cache The AptPkg::_cache package wraps a Perl class around the pkgCacheFile class. It exposes the following methods: Open, Close, FindPkg, PkgBegin, FileList, Packages, Policy, MultiArchCache and NativeArch. =head2 AptPkg::Cache::_package The AptPkg::Cache::_package package wraps a Perl class around the pkgCache::PkgIterator class. It exposes the following methods: Next, Name, FullName, Arch, Section, VersionList, CurrentVer, RevDependsList, ProvidesList, Index, SelectedState, InstState, CurrentState and Flags. =head2 AptPkg::Cache::_version The AptPkg::Cache::_version package wraps a Perl class around the pkgCache::VerIterator class. It exposes the following methods: VerStr, Section, MultiArch, Arch, ParentPkg, DescriptionList, TranslatedDescription, DependsList, ProvidesList, FileList, Index and Priority. =head2 AptPkg::Cache::_depends The AptPkg::Cache::_depends package wraps a Perl class around the pkgCache::DepIterator class. It exposes the following methods: TargetVer, TargetPkg, ParentVer, ParentPkg, Index, CompType and DepType. =head2 AptPkg::Cache::_provides The AptPkg::Cache::_provides package wraps a Perl class around the pkgCache::PrvIterator class. It exposes the following methods: Name, ProvideVersion, OwnerVer, OwnerPkg and Index. =head2 AptPkg::Cache::_description The AptPkg::Cache::_description package wraps a Perl class around the pkgCache::DescIterator class. It exposes the following methods: LanguageCode, md5 and FileList. =head2 AptPkg::Cache::_pkg_file The AptPkg::Cache::_pkg_file package wraps a Perl class around the pkgCache::PkgFileIterator class. It exposes the following methods: FileName, Archive, Component, Version, Origin, Label, Site, IndexType and Index. =head2 AptPkg::Cache::_ver_file The AptPkg::Cache::_ver_file package wraps a Perl class around the pkgCache::VerFileIterator class. It exposes the following methods: File, Index, Offset and Size. =head2 AptPkg::Cache::_desc_file The AptPkg::Cache::_desc_file package wraps a Perl class around the pkgCache::DescFileIterator class. It exposes the following methods: File =head2 AptPkg::Cache::_pkg_records The AptPkg::Cache::_pkg_records package wraps a Perl class around the pkgRecords class. It exposes the following methods: Lookup. =head2 AptPkg::_policy The AptPkg::_policy package wraps a Perl class around the pkgPolicy class. It exposes the following methods: GetPriority, GetMatch and GetCandidateVer. =head2 AptPkg::_source_list The AptPkg::_source_list package wraps a Perl class around the pkgSourceList class. Required as an argument to the AptPkg::_src_records constructor. =head2 AptPkg::_src_records The AptPkg::_src_records package wraps a Perl class around the pkgSrcRecords class. It exposes the following methods: Restart, Find. =head2 Constants The following B enumerations are included, used by attributes of AptPkg::Cache. =head3 pkgCache::Version::VerMultiArch C, C, C, C, C, C and C. =head3 pkgCache::Dep::DepType C, C, C, C, C, C and C. =head3 pkgCache::Dep::DepCompareOp C, C, C, C, C, C, C and C. =head3 pkgCache::State::VerPriority C, C, C, C and C. =head3 pkgCache::State::PkgSelectedState C, C, C, C and C. =head3 pkgCache::State::PkgInstState C, C, C and C. =head3 pkgCache::State::PkgCurrentState C, C, C, C, C and C. =head3 pkgCache::Flag::PkgFlags C, C and C. =head1 SEE ALSO AptPkg::Config(3pm), AptPkg::System(3pm), AptPkg::Version(3pm), AptPkg::Cache(3pm), AptPkg::Source(3pm). =head1 AUTHOR Brendan O'Dea =cut libapt-pkg-perl/AptPkg/0000755000000000000000000000000012160072706012125 5ustar libapt-pkg-perl/AptPkg/Cache.pm0000644000000000000000000003230512160063152013464 0ustar package AptPkg::Cache; require 5.005_62; use strict; use warnings; use AptPkg; use AptPkg::hash; require Exporter; our @ISA = qw(Exporter AptPkg::hash); our @EXPORT = (); our $VERSION = 1.25; sub new { my $class = shift; my $self = $class->SUPER::new; $self->_xs->Open(@_) ? $self : undef; } sub files { my $self = shift; my $files = $self->_priv->{files} ||= [ map AptPkg::Cache::PkgFile->new($_), $self->_xs->FileList ]; wantarray ? @$files : $files; } sub packages { my $self = shift; $self->_priv->{packages} ||= do { require AptPkg::PkgRecords; bless \$self->_xs->Packages, 'AptPkg::PkgRecords'; }; } sub policy { my $self = shift; $self->_priv->{policy} ||= do { require AptPkg::Policy; bless \$self->_xs->Policy, 'AptPkg::Policy'; }; } sub exists { shift->_xs->FindPkg(@_) } sub get { my $value = shift->exists(@_); $value ? AptPkg::Cache::Package->new($value) : undef; } sub is_multi_arch { shift->_xs->MultiArchCache() } sub native_arch { shift->_xs->NativeArch() } package AptPkg::Cache::Iter; sub new { my $class = shift; my $obj = shift; my $self = $obj->_xs->PkgBegin(@_); bless \$self, $class; } sub next { my $self = shift; my $obj = $$self or return; my $key = $obj->FullName; $obj->Next or $$self = undef; $key; } package AptPkg::Cache; # helper functions to convert XS iterators to tied hashes sub _make_class { my ($obj, $class) = @_; (my $method = (caller 1)[3]) =~ s/^.*:://; my $value = $obj->_xs->$method or return; $class->new($value); } sub _make_class_list { my ($obj, $class) = @_; (my $method = (caller 1)[3]) =~ s/^.*:://; my @values = $obj->_xs->$method or return; [ map $class->new($_), @values ]; } package AptPkg::Cache::Package; our @ISA = qw(AptPkg::hash::method); our @KEYS = qw( Name FullName ShortName Arch Section VersionList CurrentVer RevDependsList ProvidesList Index SelectedState InstState CurrentState Flags ); sub ShortName { # Same as Name for native, and FullName for non-native packages. shift->_xs->FullName(1); # Pretty=true } sub VersionList { AptPkg::Cache::_make_class_list shift, 'AptPkg::Cache::Version'; } sub CurrentVer { AptPkg::Cache::_make_class shift, 'AptPkg::Cache::Version'; } sub RevDependsList { AptPkg::Cache::_make_class_list shift, 'AptPkg::Cache::Depends'; } sub ProvidesList { AptPkg::Cache::_make_class_list shift, 'AptPkg::Cache::Provides'; } package AptPkg::Cache::Package::Iter; our @ISA = qw(AptPkg::hash::method::iter); package AptPkg::Cache::Version; our @ISA = qw(AptPkg::hash::method); our @KEYS = qw( VerStr Section Arch MultiArch ParentPkg DescriptionList TranslatedDescription DependsList ProvidesList FileList InstalledSize Size Index Priority ); sub ParentPkg { AptPkg::Cache::_make_class shift, 'AptPkg::Cache::Package'; } sub DescriptionList { AptPkg::Cache::_make_class_list shift, 'AptPkg::Cache::Description'; } sub TranslatedDescription { AptPkg::Cache::_make_class shift, 'AptPkg::Cache::Description'; } sub DependsList { AptPkg::Cache::_make_class_list shift, 'AptPkg::Cache::Depends'; } sub ProvidesList { AptPkg::Cache::_make_class_list shift, 'AptPkg::Cache::Provides'; } sub FileList { AptPkg::Cache::_make_class_list shift, 'AptPkg::Cache::VerFile'; } package AptPkg::Cache::Version::Iter; our @ISA = qw(AptPkg::hash::method::iter); package AptPkg::Cache::Depends; our @ISA = qw(AptPkg::hash::method); our @KEYS = qw( TargetVer TargetPkg ParentVer ParentPkg Index CompType CompTypeDeb DepType ); sub TargetPkg { AptPkg::Cache::_make_class shift, 'AptPkg::Cache::Package' } sub ParentVer { AptPkg::Cache::_make_class shift, 'AptPkg::Cache::Version' } sub ParentPkg { AptPkg::Cache::_make_class shift, 'AptPkg::Cache::Package' } package AptPkg::Cache::Depends::Iter; our @ISA = qw(AptPkg::hash::method::iter); package AptPkg::Cache::Provides; our @ISA = qw(AptPkg::hash::method); our @KEYS = qw(Name ProvideVersion OwnerVer OwnerPkg Index); sub OwnerVer { AptPkg::Cache::_make_class shift, 'AptPkg::Cache::Version' } sub OwnerPkg { AptPkg::Cache::_make_class shift, 'AptPkg::Cache::Package' } package AptPkg::Cache::Provides::Iter; our @ISA = qw(AptPkg::hash::method::iter); package AptPkg::Cache::Description; our @ISA = qw(AptPkg::hash::method); our @KEYS = qw(LanguageCode md5 FileList); sub FileList { AptPkg::Cache::_make_class shift, 'AptPkg::Cache::DescFile'; } package AptPkg::Cache::Description::Iter; our @ISA = qw(AptPkg::hash::method::iter); package AptPkg::Cache::PkgFile; package AptPkg::Cache::PkgFile; our @ISA = qw(AptPkg::hash::method); our @KEYS = qw( FileName Archive Component Version Origin Label Site Index IndexType IsOk ); package AptPkg::Cache::PkgFile::Iter; our @ISA = qw(AptPkg::hash::method::iter); package AptPkg::Cache::VerFile; our @ISA = qw(AptPkg::hash::method); our @KEYS = qw(File Index Offset Size); sub File { AptPkg::Cache::_make_class shift, 'AptPkg::Cache::PkgFile' } package AptPkg::Cache::VerFile::Iter; our @ISA = qw(AptPkg::hash::method::iter); package AptPkg::Cache::DescFile; our @ISA = qw(AptPkg::hash::method); our @KEYS = qw(File); sub File { AptPkg::Cache::_make_class shift, 'AptPkg::Cache::PkgFile' } package AptPkg::Cache::DescFile::Iter; our @ISA = qw(AptPkg::hash::method::iter); 1; __END__ =head1 NAME AptPkg::Cache - APT package cache interface =head1 SYNOPSIS use AptPkg::Cache; =head1 DESCRIPTION The AptPkg::Cache module provides an interface to B's package cache. =head2 AptPkg::Cache The AptPkg::Cache package implements the B pkgCacheFile class as a hash reference (inherits from AptPkg::hash). The hash keys are the names of packages in the cache, and the values are AptPkg::Cache::Package objects (which in turn appear as hash references, see below). =head3 Constructor =over 4 =item new([I]) Instantiation of the object uses configuration from the $AptPkg::Config::_config and $AptPkg::System::_system objects (automatically initialised if not done explicitly). The cache initialisation can be quite verbose--controlled by the value of $_config->{quiet}, which is set to "2" (quiet) if the $_config object is auto-initialised. The cache directory is locked if LOCK is true. It is important to note that the structure of the returned object contains self-referential elements, so some care must be taken if attempting to traverse it recursively. =back =head3 Methods =over 4 =item files Return a list of AptPkg::Cache::PkgFile objects describing the package files. =item packages Return an AptPkg::PkgRecords object which may be used to retrieve additional information about packages. =item get, exists, keys These methods are used to implement the hashref abstraction: $obj->get($pack) and $obj->{$pack} are equivalent. =item is_multi_arch Cache is multi-arch enabled. =item native_arch Native architecture. =back =head2 AptPkg::Cache::Package Implements the B pkgCache::PkgIterator class as a hash reference. =head3 Keys =over 4 =item Name =item Section =item Arch Package name, section and architecture. =item FullName Fully qualified name, including architecture. =item ShortName The shortest unambiguous package name: the same as C for native packages, and C for non-native. =item SelectedState =item InstState =item CurrentState Package state from the status file. SelectedState may be C, C, C, C or C. InstState may be C, C, C or C. CurrentState may be C, C, C, C, C or C. In a numeric context, SelectedState, InstState and CurrentState evaluate to an AptPkg::State:: constant. =item VersionList A reference to an array of AptPkg::Cache::Version objects describing available versions of the package. =item CurrentVer An AptPkg::Cache::Version object describing the currently installed version (if any) of the package. =item RevDependsList A reference to an array of AptPkg::Cache::Depends objects describing packages which depend upon the current package. =item ProvidesList For virtual packages, this is a reference to an array of AptPkg::Cache::Provides objects describing packages which provide the current package. =item Flags A comma separated list if flags: C, C or C. In a numeric context, evaluates to a combination of AptPkg::Flag:: constants. [Note: the only one of these you need worry about is C, which is set based on the package's header of the same name. C seems to be used internally by B, and C seems to only be set on the apt package.] =item Index Internal B unique reference for the package record. =back =head2 AptPkg::Cache::Version Implements the B pkgCache::VerIterator class as a hash reference. =head3 Keys =over 4 =item VerStr =item Section =item Arch The package version, section and architecture. =item MultiArch Multi-arch state: C, C, C, C, C, C or C. In a numeric context, evaluates to an AptPkg::Version:: constant. =item ParentPkg An AptPkg::Cache::Package objct describing the package providing this version. =item DescriptionList A list of AptCache::Cache::Description objects describing the files which descrie a package version. The list includes both Package files and Translation files, which contain translated Description fields. =item TranslatedDescription An AptCache::Cache::Description object for the current locale, which will generally be a Translation file. =item DependsList A reference to an array of AptPkg::Cache::Depends objects describing packages which the current package depends upon. =item ProvidesList A reference to an array of AptPkg::Cache::Provides objects describing virtual packages provided by this version. =item FileList A reference to an array of AptPkg::Cache::VerFile objects describing the packages files which include the current version. =item Size The F<.deb> file size, in bytes. =item InstalledSize The disk space used when installed, in bytes. =item Index Internal B unique reference for the version record. =item Priority Package priority: C, C, C, C or C. In a numeric context, evaluates to an AptPkg::VerPriority:: constant. =back =head2 AptPkg::Cache::Depends Implements the B pkgCache::DepIterator class as a hash reference. =head3 Keys =over 4 =item DepType Type of dependency: C, C, C, C, C, C or C. In a numeric context, evaluates to an AptPkg::Dep:: constant. =item ParentPkg =item ParentVer AptPkg::Cache::Package and AptPkg::Cache::Version objects describing the package declaring the dependency. =item TargetPkg AptPkg::Cache::Package object describing the depended package. =item TargetVer For versioned dependencies, TargetVer is a string giving the version of the target package required. =item CompType =item CompTypeDeb CompType gives a normalised comparison operator (>, >=, etc) describing the relationship to TargetVer ("" if none). CompTypeDeb returns Debian-style operators (>> rather than >). In a numeric context, both CompType and CompTypeDeb evaluate to an AptPkg::Dep:: constant. Alternative dependencies (Depends: a | b) are identified by all but the last having the AptPkg::Dep::Or bit set in the numeric representation of CompType (and CompTypeDeb). =item Index Internal B unique reference for the dependency record. =back =head2 AptPkg::Cache::Provides Implements the B pkgCache::PrvIterator class as a hash reference. =head3 Keys =over 4 =item Name Name of virtual package. =item OwnerPkg =item OwnerVer AptPkg::Cache::Package and AptPkg::Cache::Version objects describing the providing package. =item ProvideVersion Version of the virtual package. [Not currently supported by dpkg] =item Index Internal B unique reference for the provides record. =back =head2 AptPkg::Cache::VerFile Implements the B pkgCache::VerFileIterator class as a hash reference. =head3 Keys =over 4 =item File An AptPkg::Cache::PkgFile object describing the packages file. =item Offset =item Size The byte offset and length of the entry in the file. =item Index Internal B unique reference for the version file record. =back =head2 AptPkg::Cache::PkgFile Implements the B pkgCache::PkgFileIterator class as a hash reference. =head3 Keys =over 4 =item FileName Packages file path. =item IndexType File type: C, C. =item Archive =item Component =item Version =item Origin =item Label =item Site Fields from the Release file. =item IsOk True if the cache is in sync with this file. =item Index Internal B unique reference for the package file record. =back =head2 AptPkg::Cache::DescFile Implements the B pkgCache::DescFileIterator class as a hash reference. =head3 Keys =over 4 =item File An AptPkg::Cache::PkgFile object describing the packages file. =back =head1 SEE ALSO AptPkg::Config(3pm), AptPkg::System(3pm), AptPkg(3pm), AptPkg::hash(3pm), AptPkg::PkgRecords(3pm), AptPkg::Policy(3pm). =head1 AUTHOR Brendan O'Dea =cut libapt-pkg-perl/AptPkg/Source.pm0000644000000000000000000000711412143203451013720 0ustar package AptPkg::Source; require 5.005_62; use strict; use warnings; use AptPkg; use AptPkg::hash; require Exporter; our @ISA = qw(Exporter AptPkg::hash); our @EXPORT = (); our $VERSION = 1.4; sub new { my $class = shift; my $srclist = AptPkg::_source_list->new(@_); my $xs = AptPkg::_src_records->new($srclist); my $self = $class->SUPER::new($xs); $self->_priv->{srclist} = $srclist; $self; } sub exists { scalar shift->_xs->Find(@_) } sub find { my $self = shift; $self->_xs->Restart; return $self->_xs->Find(@_) unless wantarray; my @r; while (my %m = $self->_xs->Find(@_)) { push @r, \%m } @r; } sub get { my $self = shift; my @r = $self->find(@_); wantarray ? @r : [ @r ]; } 1; __END__ =head1 NAME AptPkg::Source - APT source package interface =head1 SYNOPSIS use AptPkg::Source; =head1 DESCRIPTION The AptPkg::Source module provides an interface to B's source package lists. =head2 AptPkg::Source The AptPkg::Source package implements the B pkgSrcRecords class as a hash reference (inherits from AptPkg::hash). The hash is keyed on source or binary package name and the value is an array reference of the details of matching source packages. Note that there is no iterator class, so it is not possible to get a list of all keys (with keys or each). =head3 Constructor =over 4 =item new([I]) Instantiation of the object uses configuration from the $AptPkg::Config::_config object (automatically initialised if not done explicitly). If no I is specified, then the value of Dir::Etc::sourcelist from the configuration object is used (generally /etc/apt/sources.list). =back =head3 Methods =over 4 =item find(I, [I]) In a list context, return a list of source package details for the given I, which may either be a source package name, or the name of one of the binaries provided (unless I is provided and true). In a scalar context, the source package name of the first entry is returned. =item get, exists These methods are used to implement the hashref abstraction: $obj->get($pack) and $obj->{$pack} are equivalent. The get method has the same semantics as find, but returns an array reference in a scalar context. =back The list returned by the find (and get) methods consists of hashes which describe each available source package (in order of discovery from the deb-src files described in sources.list). Each hash contains the following entries: =over 4 =item Package =item Version =item Maintainer =item Section Strings giving the source package name, version, maintainer and section. =item Binaries A list of binary package names from the package. =item BuildDepends A hash describing the build dependencies of the package. Possible keys are: =over 4 C, C, C, C. =back The values are a list of dependencies/conflicts with each item being a list containing the package name followed optionally by an operator and version number. Operator values evaluate to a comparison string* (>, >=, etc) or one of the AptPkg::Dep:: constants in a numeric context (see L). *Note that this is a normalised, rather than Debian-style (>> vs >) string. =item Files A list of files making up the source package, each described by a hash containing the keys: =over 4 C, C, C, C. =back =back =head1 SEE ALSO AptPkg::Config(3pm), AptPkg::Cache(3pm), AptPkg(3pm), AptPkg::hash(3pm). =head1 AUTHOR Brendan O'Dea =cut libapt-pkg-perl/AptPkg/Version.pm0000644000000000000000000000433612114053451014111 0ustar package AptPkg::Version; require 5.005_62; use strict; use warnings; use AptPkg; use Carp; require Exporter; our @ISA = qw(Exporter); our @EXPORT_OK = qw(); our @EXPORT = (); our $VERSION = 1.7; sub label { shift->Label(@_) } sub compare { shift->CmpVersion(@_) } sub rel_compare { shift->CmpReleaseVer(@_) } sub upstream { shift->UpstreamVersion(@_) } { my %DEB_RELATION = ( '<<' => AptPkg::Dep::Less, '<=' => AptPkg::Dep::LessEq, '=' => AptPkg::Dep::Equals, '>=' => AptPkg::Dep::GreaterEq, '>>' => AptPkg::Dep::Greater, # deprecated '<' => AptPkg::Dep::LessEq, '>' => AptPkg::Dep::GreaterEq, ); sub check_dep { my $self = shift; my ($pkg, $op_str, $dep) = @_; my $op = $DEB_RELATION{$op_str} || croak "invalid relation for check_dep `$op_str'"; $self->CheckDep($pkg, $op, $dep); } } 1; __END__ =head1 NAME AptPkg::Version - APT package versioning class =head1 SYNOPSIS use AptPkg::Version; =head1 DESCRIPTION The AptPkg::Version module provides an interface to B's package version handling. =head2 AptPkg::Version The AptPkg::Version package implements the B pkgVersioningSystem class. An instance of the AptPkg::Version class may be fetched using the C method from an AptPkg::System object. The following methods are implemented: =over 4 =item label Return the description of the versioning system, for example: Standard .deb for Debian systems. =item compare(I, I) Compare package version I with I, returning a negative value if I is an earlier version than I, zero if the same or a positive value if I is later. =item rel_compare(I, I) Compare distribution release numbers. =item check_dep(I, I, I) Check that the package version I satisfies the relation I to the dependency version I. The relation I is specified in the Debian syntax regardless of the versioning system: << strictly earlier <= earlier or equal = exactly equal >= later or equal >> strictly later =item upstream(I) Return the upstream component of the given version string. =back =head1 SEE ALSO AptPkg::Config(3pm), AptPkg::System(3pm), AptPkg(3pm). =head1 AUTHOR Brendan O'Dea =cut libapt-pkg-perl/AptPkg/PkgRecords.pm0000644000000000000000000000430112143173613014524 0ustar package AptPkg::PkgRecords; require 5.005_62; use strict; use warnings; use AptPkg; our $VERSION = 1.2; sub lookup { my ($self, $pack) = @_; my $xs = $$self; my %extra; unless (ref $pack) { my $p = do { my $_p = $xs->cache->FindPkg($pack) or return; AptPkg::Cache::Package->new($_p); }; my $v = ($p->{VersionList} || [])->[0] or return; $pack = ($v->{FileList} || [])->[0] or return; $extra{$_} = $v->{$_} for qw/Section VerStr/; # Get translated ShortDesc and LongDesc if (my $t = $v->{TranslatedDescription}) { if (my %e = $xs->Lookup($t->{FileList}->_xs)) { $extra{$_} = $e{$_} for grep /^(Long|Sort)Desc$/, keys %e;; } } } my %r = $xs->Lookup($pack->_xs) or return; $r{$_} = $extra{$_} for keys %extra; wantarray ? %r : \%r; } 1; __END__ =head1 NAME AptPkg::PkgRecords - APT package description class =head1 SYNOPSIS use AptPkg::PkgRecords; =head1 DESCRIPTION The AptPkg::PkgRecords module provides an interface to the parsed contents of package files. =head2 AptPkg::PkgRecords The AptPkg::PkgRecords package Implements the B pkgRecords class. An instance of the AptPkg::PkgRecords class may be fetched using the C method from an AptPkg::Cache object. =head3 Methods =over 4 =item lookup(I) Return a hash (or hash reference, depending on context) for the given package. I may either be an AptPkg::Cache::VerFile object, an AptPkg::Cache::DescFile object or a package name. The hash contains the following keys: =over 4 C, C, C, C, C, C and C. =back with values taken from the packages or translation file. Note that C is generally not useful for AptPkg::Cache::VerFile objects, which refer to the Packages file, as these no longer contain the full description (now in the Translation files). If I is a package name, these additional values are set: =over 4 C
and C. =back and the following values are overriden with the translated versions: =over 4 C and C. =back =back =head1 SEE ALSO AptPkg::Cache(3pm), AptPkg(3pm). =head1 AUTHOR Brendan O'Dea =cut libapt-pkg-perl/AptPkg/hash.pm0000644000000000000000000001010512143203451013375 0ustar package AptPkg::hash; require 5.005_62; use strict; use warnings; use Scalar::Util 'weaken'; our $VERSION = 1.6; sub new { my ($class, $xs) = @_; my $self = \my %h; my $priv = {}; unless ($xs) { my $xs_prefix = ''; (my $xs_class = $class) =~ s/(.*::)// and $xs_prefix = $1; $xs_class =~ s/([A-Z])/_\l$1/g; $xs = "$xs_prefix$xs_class"->new; } { no strict; no warnings; local *keys = *{"$class\::KEYS"}; $priv->{$_}++ for @keys; } tie %h => __PACKAGE__, $self, $xs, $priv; bless $self, $class; } sub _self { (tied %{$_[0]})->[0] } sub _xs { (tied %{$_[0]})->[1] } sub _priv { (tied %{$_[0]})->[2] } sub keys { my $self = shift; (my $iter_class = $self) =~ s/=.*/::Iter/; my $iter = $iter_class->new($self, @_); return $iter unless wantarray; my @keys; while (my $key = $iter->next) { push @keys, $key } @keys; } sub TIEHASH { my $class = shift; my $self = [@_]; weaken $self->[0]; # prevent reference loop bless $self, $class; } sub FETCH { shift->[0]->get(@_) } sub STORE { shift->[0]->set(@_) } sub EXISTS { shift->[0]->exists(@_) } sub FIRSTKEY { ($_[0][3] = $_[0][0]->keys) ? $_[0][3]->next : undef } sub NEXTKEY { $_[0][3] ? $_[0][3]->next : undef } package AptPkg::hash::method; our @ISA = qw(AptPkg::hash); sub get { my ($self, $key) = @_; my $keys = $self->_priv; return unless exists $keys->{$key}; # try object first, then XS $self->_self->can($key) ? $self->_self->$key : $self->_xs->$key; } *exists = \&get; package AptPkg::hash::method::iter; sub new { my ($class, $obj) = @_; my $keys = $obj->_priv; keys %$keys; # reset iterator bless \$obj, $class; } sub next { my $self = shift; my $obj = $$self; my $keys = $obj->_priv; while (my $key = each %$keys) { return $key if $obj->exists($key); } undef; } 1; __END__ =head1 NAME AptPkg::hash - a helper class for implementing tied hashes =head1 SYNOPSIS use AptPkg::hash; =head1 DESCRIPTION The AptPkg::hash class provides hash-like access for objects which have an underlying XS implementation. Such objects need to add AptPkg::hash to @ISA, provide get, set and exists methods, and an iterator class. =head2 AptPkg::hash =over 4 =item new([I]) Create a object as a tied hash. The object is implemented as a hash reference blessed into the class, which in turn is tied to AptPkg::hash. This means that both $obj->method() and $obj->{key} valid, the latter invoking get/set (through FETCH/STORE). The tie associates an array reference with the hash, which initially contains a reference to the hash, the XS object and an anon hash which may be used by subclasses to store state information. If no XS object is passed, one is created via new in the XS class. The name of that class is constructed from the class name, by lower-casing the last component and prefixing it with an underscore (eg. AptPkg::Config becomes AptPkg::_config). If the module contains a @KEYS array, then the private hash will be populated with those entries as keys (see the description below of the AptPkg::hash::method class). =item _self, _xs, _priv Accessors which may be used in subclass methods to fetch the three array elements associated with the hash reference. =item keys(I) In a scalar context, creates and returns a new iterator object (the class name with the suffix ::Iter appended). The XS object, the private hash and any arguments are passed to the constructor. In an array context, the iterator is used to generate a list of keys which are then returned. The iterator class must implement a next method, which returns the current key and advances to the next. =back =head2 AptPkg::hash::method The AptPkg::hash::method class extends AptPkg::hash, providing a simple way to map a fixed set of keys (defined by the @KEYS array) into method calls on either the object, or the internal XS object. Classes inheriting from AptPkg::hash::method should provide an iterator class which inherits from AptPkg::hash::method::iter. =head1 AUTHOR Brendan O'Dea =cut libapt-pkg-perl/AptPkg/Config.pod0000644000000000000000000001161112114053451014031 0ustar # # This is not in Config.pm as MakeMaker can't be convinced to build a # manpage matching /setup|config/i # =head1 NAME AptPkg::Config - APT configuration interface =head1 SYNOPSIS use AptPkg::Config; =head1 DESCRIPTION The AptPkg::Config module provides an interface to B's configuration mechanism. Provides a configuration file and command line parser for a tree-oriented configuration environment. =head2 AptPkg::Config The AptPkg::Config package implements the B Configuration class. A global instance of the libapt-pkg _config instance is provided as $AptPkg::Config::_config, and may be imported. The following methods are implemented: =over 4 =item get(I, [I]) Fetch the value of I from the configuration object, returning undef if not found (or I if given). If the key ends in ::, an array of values is returned in an array context, or a string containing the values separated by spaces in a scalar context. A trailing /f, /d, /b or /i causes file, directory, boolean or integer interpretation (the underlying XS call is FindAny). =item get_file(I, [I]), get_dir(I, [I]) Variants of get which prepend the directory value from the parent key. The get_dir method additionally appends a `/'. For example, given the configuration file: foo "/some/dir/" { bar "value"; } then: $conf->get("foo::bar") # "value" $conf->get_file("foo::bar") # "/some/dir/value" $conf->get_dir("foo::bar") # "/some/dir/value/" =item get_bool(I, [I]) Another get varient, which returns true (1) if the value contains any of: 1 yes true with on enable otherwise false (''). =item set(I, I) Set configuration entry I to I. Returns I. Note that empty parent entries may be created for Is containing ::. =item exists(I) Test if I exists in the configuration. =item dump Principally for debugging, output the contents of the configuration object to stderr. =item read_file(I, [I, [I]]) Load the contents of I into the object. The format of the file is described in apt.conf(5). If the I argument is true, then the file is parsed as a BIND-style config. That is: foo "bar" { baz "quux"; } is interpreted as if it were: foo::bar { baz "quux"; } The I argument may be used to restrict the number of nested include directives processed. =item read_dir(I, [I, [I]]) Load configuration from all files in I. =item init Initialise the configuration object with some default values for the libapt-pkg library and reads the default configuration file /etc/apt/apt.conf (or as given by the environment variable APT_CONFIG) if it exists. =item system Return the AptPkg::System object appropriate for this system. =item parse_cmdline(I, [I, ...]) Parse the arguments given by Is based on the contents of I and returns the list of remaining arguments. Note, the function does not return if there are errors processing the args. Use eval to trap such errors. I is a reference to an array containing a set argument definition arrays. The elements of each definition define: the short argument character, the long argument string, the configuration key and the optional argument type (defaults to Boolean). Valid argument types are defined by the strings: HasArg takes an argument value (-f foo) IntLevel defines an integer value (-q -q, -qq, -q2, -q=2) Boolean true/false (-d, -d=true, -d=yes, --no-d, -d=false, etc) InvBoolean same as Boolean but false with no specified sense (-d) ConfigFile load the specified configuration file ArbItem arbitrary configuration string of the form key=value The configuration key in the last two cases is ignored, and for the rest gives the key into which the value is placed. Single case equivalents also work (has_arg == HasArg). Example: @files = $conf->parse_cmndline([ [ 'h', 'help', 'help' ], [ 'v', 'version', 'version' ], [ 'c', 'config-file', '', ConfigFile ], [ 'o', 'option', '', ArbItem ], ], @ARGV); =back The module uses AptPkg::hash to provide a hash-like access to the object, so that $conf->{key} is equivalent to using the get/set methods. Additionally inherits the constructor (new) and keys methods from that module. Methods of the internal XS object (AptPkg::_config) such as Find may also be used. See AptPkg. =head2 AptPkg::Config::Iter Iterator object for AptPkg::Config which is returned by the keys method. =over 4 =item new(I, [I]) Constructor, which is invoked by the keys method. I, if given determines the subset of the tree to walk (may be given as an argument to keys). =item next Returns the current key and advances to the next. =back =head1 SEE ALSO AptPkg::System(3pm), AptPkg(3pm), AptPkg::hash(3pm). =head1 AUTHOR Brendan O'Dea =cut libapt-pkg-perl/AptPkg/Config.pm0000644000000000000000000000357112114053451013671 0ustar package AptPkg::Config; require 5.005_62; use strict; use warnings; use AptPkg; use AptPkg::hash; use Carp; require Exporter; our @ISA = qw(Exporter AptPkg::hash); our @EXPORT_OK = qw($_config); our @EXPORT = (); our $VERSION = 1.7; our $_config = __PACKAGE__->new($AptPkg::_config::_config); sub get { my $xs = shift->_xs; return $xs->FindAny(@_) unless @_ and $_[0] =~ /(.+)::$/; # special case where name ends with :: my $tree = $xs->Tree($1); return unless $tree and $tree = $tree->Child; my @r; while ($tree) { my $v = $tree->Value; push @r, $v if defined $v; $tree = $tree->Next; } wantarray ? @r : "@r"; # what *should* this return in a scalar context? } sub get_file { shift->_xs->FindFile(@_) } sub get_dir { shift->_xs->FindDir(@_) } sub get_bool { shift->_xs->FindB(@_) } sub set { shift->_xs->Set(@_) } sub exists { shift->_xs->ExistsAny(@_) } sub dump { shift->_xs->Dump(@_) } sub read_file { shift->_xs->ReadConfigFile(@_) } sub read_dir { shift->_xs->ReadConfigDir(@_) } sub init { AptPkg::_init_config shift->_xs; } sub system { require AptPkg::System; AptPkg::_init_system shift->_xs; } sub parse_cmdline { AptPkg::_parse_cmdline shift->_xs, @_; } sub AUTOLOAD { (my $method = our $AUTOLOAD) =~ s/.*:://; return if $method eq 'DESTROY'; my $self = shift; my $xs = $self->_xs; my $sub = $xs->can($method); croak "method `$method' not implemented" unless $sub; unshift @_, $xs; goto &$sub; } package AptPkg::Config::Iter; sub new { my $class = shift; my $obj = shift; my $self = $obj->_xs->Tree(@_); bless \$self, $class; } sub next { my $self = shift; my $tree = $$self or return; my $key = $tree->FullTag; $$self = $tree->Child || $tree->Next; until ($$self) { last unless $tree = $tree->Parent; $$self = $tree->Next; } $key; } 1; libapt-pkg-perl/AptPkg/System.pm0000644000000000000000000000275212114053451013750 0ustar package AptPkg::System; require 5.005_62; use strict; use warnings; use AptPkg; require Exporter; our @ISA = qw(Exporter); our @EXPORT_OK = qw($_system); our @EXPORT = (); our $VERSION = 1.4; our $_system; sub label { shift->Label(@_) } sub lock { shift->Lock(@_) } sub unlock { shift->UnLock(@_) } sub versioning { require AptPkg::Version; shift->VS(@_) } 1; __END__ =head1 NAME AptPkg::System - APT system abstraction class =head1 SYNOPSIS use AptPkg::System; =head1 DESCRIPTION The AptPkg::System module provides an interface to B's system abstraction mechanism. =head2 AptPkg::System The AptPkg::System package implements the B pkgSystem class. An instance of the AptPkg::System class appropriate for the particular back-end packaging system (deb, rpm, etc.) may be fetched using the system method from AptPkg::Config. A global instance of the libapt-pkg _system instance is provided as $AptPkg::System::_system, and may be imported. The following methods are implemented: =over 4 =item label Return the description of the packaging system, for example: Debian dpkg interface for Debian systems. =item lock Lock the packaging system. =item unlock(I) Unlock the packaging system, ignoring errors if I is non-zero. =item versioning Return an instance of the AptPkg::Version class for this system. =back =head1 SEE ALSO AptPkg::Config(3pm), AptPkg::Version(3pm), AptPkg(3pm). =head1 AUTHOR Brendan O'Dea =cut libapt-pkg-perl/AptPkg/Policy.pm0000644000000000000000000000262312114053451013720 0ustar package AptPkg::Policy; require 5.005_62; use strict; use warnings; use AptPkg; our $VERSION = 1.1; sub priority { my ($self, $arg) = @_; my $xs = $$self; $xs->GetPriority($arg->_xs); } sub match { my ($self, $pkg) = @_; my $xs = $$self; my $ver = $xs->GetMatch($pkg->_xs) or return; AptPkg::Cache::Version->new($ver); } sub candidate { my ($self, $pkg) = @_; my $xs = $$self; my $ver = $xs->GetCandidateVer($pkg->_xs) or return; AptPkg::Cache::Version->new($ver); } 1; __END__ =head1 NAME AptPkg::Policy - APT package version policy class =head1 SYNOPSIS use AptPkg::Policy; =head1 DESCRIPTION The AptPkg::Policy module provides an interface to B's package version policy. =head2 AptPkg::Policy The AptPkg::Policy package implements the B pkgPolicy class. An instance of the AptPkg::Policy class may be fetched using the C method from an AptPkg::Cache object. The following methods are implemented: =over 4 =item priority(I|I) Return the pin priority for the given I (AptPkg::Cache::Package) or I (AptPkg::Cache::PkgFile) object. =item match(I) Find the pinned version of I. Returns an AptPkg::Cache::Version object. =item candidate(I) Returns the installation candidate version for I. =back =head1 SEE ALSO AptPkg::Cache(3pm), AptPkg(3pm). =head1 AUTHOR Brendan O'Dea =cut libapt-pkg-perl/typemap0000644000000000000000000001326612114343520012343 0ustar TYPEMAP off_t T_UV string T_STRING Configuration * T_CONFIG Configuration_Item * T_CONFIG_ITEM Configuration_Item const * T_CONFIG_ITEM pkgSystem * T_PKG_SYSTEM pkgVersioningSystem * T_PKG_VER_SYSTEM pkgCacheFile * T_PKG_CACHE_FILE pkgCache_PkgIterator_p * T_PKG_CACHE_PKG_ITERATOR pkgCache_VerIterator_p * T_PKG_CACHE_VER_ITERATOR pkgCache_DepIterator_p * T_PKG_CACHE_DEP_ITERATOR pkgCache_PrvIterator_p * T_PKG_CACHE_PRV_ITERATOR pkgCache_DescIterator_p * T_PKG_CACHE_DESC_ITERATOR pkgCache_PkgFileIterator_p * T_PKG_CACHE_PKG_FILE_ITERATOR pkgCache_VerFileIterator_p * T_PKG_CACHE_VER_FILE_ITERATOR pkgCache_DescFileIterator_p * T_PKG_CACHE_DESC_FILE_ITERATOR pkgRecords_p * T_PKG_RECORDS pkgPolicy_p * T_PKG_POLICY pkgSourceList * T_PKG_SOURCE_LIST pkgSrcRecords * T_PKG_SRC_RECORDS OUTPUT T_STRING if ($var.length()) sv_setpv($arg, $var.c_str()); else $arg = &PL_sv_undef; T_CONFIG sv_setref_pv($arg, "AptPkg::_config", (void *) $var); T_CONFIG_ITEM if ($var) sv_setref_pv($arg, "AptPkg::Config::_item", (void *) $var); else $arg = &PL_sv_undef; T_PKG_SYSTEM sv_setref_pv($arg, "AptPkg::System", (void *) $var); T_PKG_VER_SYSTEM sv_setref_pv($arg, "AptPkg::Version", (void *) $var); T_PKG_CACHE_FILE sv_setref_pv($arg, "AptPkg::_cache", (void *) $var); T_PKG_CACHE_PKG_ITERATOR sv_setref_pv($arg, "AptPkg::Cache::_package", (void *) $var); T_PKG_CACHE_DEP_ITERATOR sv_setref_pv($arg, "AptPkg::Cache::_depends", (void *) $var); T_PKG_CACHE_VER_ITERATOR sv_setref_pv($arg, "AptPkg::Cache::_version", (void *) $var); T_PKG_CACHE_PRV_ITERATOR sv_setref_pv($arg, "AptPkg::Cache::_provides", (void *) $var); T_PKG_CACHE_DESC_ITERATOR sv_setref_pv($arg, "AptPkg::Cache::_description", (void *) $var); T_PKG_CACHE_PKG_FILE_ITERATOR sv_setref_pv($arg, "AptPkg::Cache::_pkg_file", (void *) $var); T_PKG_CACHE_VER_FILE_ITERATOR sv_setref_pv($arg, "AptPkg::Cache::_ver_file", (void *) $var); T_PKG_CACHE_DESC_FILE_ITERATOR sv_setref_pv($arg, "AptPkg::Cache::_desc_file", (void *) $var); T_PKG_RECORDS sv_setref_pv($arg, "AptPkg::_pkg_records", (void *) $var); T_PKG_POLICY sv_setref_pv($arg, "AptPkg::_policy", (void *) $var); T_PKG_SOURCE_LIST sv_setref_pv($arg, "AptPkg::_source_list", (void *) $var); T_PKG_SRC_RECORDS sv_setref_pv($arg, "AptPkg::_src_records", (void *) $var); INPUT T_STRING $var = (char *) SvPV_nolen($arg); T_CONFIG if (SvROK($arg) && sv_derived_from($arg, \"AptPkg::_config\")) $var = ($type) SvIV((SV *) SvRV($arg)); else croak(\"$var is not of type AptPkg::_config\"); T_CONFIG_ITEM if (SvROK($arg) && sv_derived_from($arg, \"AptPkg::Config::_item\")) $var = ($type) SvIV((SV *) SvRV($arg)); else croak(\"$var is not of type AptPkg::Config::_item\"); T_PKG_SYSTEM if (SvROK($arg) && sv_derived_from($arg, \"AptPkg::System\")) $var = ($type) SvIV((SV *) SvRV($arg)); else croak(\"$var is not of type AptPkg::System\"); T_PKG_VER_SYSTEM if (SvROK($arg) && sv_derived_from($arg, \"AptPkg::Version\")) $var = ($type) SvIV((SV *) SvRV($arg)); else croak(\"$var is not of type AptPkg::Version\"); T_PKG_CACHE_FILE if (SvROK($arg) && sv_derived_from($arg, \"AptPkg::_cache\")) $var = ($type) SvIV((SV *) SvRV($arg)); else croak(\"$var is not of type AptPkg::_cache\"); T_PKG_CACHE_PKG_ITERATOR if (SvROK($arg) && sv_derived_from($arg, \"AptPkg::Cache::_package\")) $var = ($type) SvIV((SV *) SvRV($arg)); else croak(\"$var is not of type AptPkg::Cache::_package\"); T_PKG_CACHE_DEP_ITERATOR if (SvROK($arg) && sv_derived_from($arg, \"AptPkg::Cache::_depends\")) $var = ($type) SvIV((SV *) SvRV($arg)); else croak(\"$var is not of type AptPkg::Cache::_depends\"); T_PKG_CACHE_VER_ITERATOR if (SvROK($arg) && sv_derived_from($arg, \"AptPkg::Cache::_version\")) $var = ($type) SvIV((SV *) SvRV($arg)); else croak(\"$var is not of type AptPkg::Cache::_version\"); T_PKG_CACHE_PRV_ITERATOR if (SvROK($arg) && sv_derived_from($arg, \"AptPkg::Cache::_provides\")) $var = ($type) SvIV((SV *) SvRV($arg)); else croak(\"$var is not of type AptPkg::Cache::_provides\"); T_PKG_CACHE_DESC_ITERATOR if (SvROK($arg) && sv_derived_from($arg, \"AptPkg::Cache::_description\")) $var = ($type) SvIV((SV *) SvRV($arg)); else croak(\"$var is not of type AptPkg::Cache::_description\"); T_PKG_CACHE_PKG_FILE_ITERATOR if (SvROK($arg) && sv_derived_from($arg, \"AptPkg::Cache::_pkg_file\")) $var = ($type) SvIV((SV *) SvRV($arg)); else croak(\"$var is not of type AptPkg::Cache::_pkg_file\"); T_PKG_CACHE_VER_FILE_ITERATOR if (SvROK($arg) && sv_derived_from($arg, \"AptPkg::Cache::_ver_file\")) $var = ($type) SvIV((SV *) SvRV($arg)); else croak(\"$var is not of type AptPkg::Cache::_ver_file\"); T_PKG_CACHE_DESC_FILE_ITERATOR if (SvROK($arg) && sv_derived_from($arg, \"AptPkg::Cache::_desc_file\")) $var = ($type) SvIV((SV *) SvRV($arg)); else croak(\"$var is not of type AptPkg::Cache::_desc_file\"); T_PKG_RECORDS if (SvROK($arg) && sv_derived_from($arg, \"AptPkg::_pkg_records\")) $var = ($type) SvIV((SV *) SvRV($arg)); else croak(\"$var is not of type AptPkg::_pkg_records\"); T_PKG_POLICY if (SvROK($arg) && sv_derived_from($arg, \"AptPkg::_policy\")) $var = ($type) SvIV((SV *) SvRV($arg)); else croak(\"$var is not of type AptPkg::_policy\"); T_PKG_SOURCE_LIST if (SvROK($arg) && sv_derived_from($arg, \"AptPkg::_source_list\")) $var = ($type) SvIV((SV *) SvRV($arg)); else croak(\"$var is not of type AptPkg::_src_list\"); T_PKG_SRC_RECORDS if (SvROK($arg) && sv_derived_from($arg, \"AptPkg::_src_records\")) $var = ($type) SvIV((SV *) SvRV($arg)); else croak(\"$var is not of type AptPkg::_src_records\"); libapt-pkg-perl/COPYING0000644000000000000000000010451312160062152011770 0ustar GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007 Copyright (C) 2007 Free Software Foundation, Inc. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The GNU General Public License is a free, copyleft license for software and other kinds of works. The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users. We, the Free Software Foundation, use the GNU General Public License for most of our software; it applies also to any other work released this way by its authors. You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things. To protect your rights, we need to prevent others from denying you these rights or asking you to surrender the rights. Therefore, you have certain responsibilities if you distribute copies of the software, or if you modify it: responsibilities to respect the freedom of others. For example, if you distribute copies of such a program, whether gratis or for a fee, you must pass on to the recipients the same freedoms that you received. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. Developers that use the GNU GPL protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License giving you legal permission to copy, distribute and/or modify it. For the developers' and authors' protection, the GPL clearly explains that there is no warranty for this free software. For both users' and authors' sake, the GPL requires that modified versions be marked as changed, so that their problems will not be attributed erroneously to authors of previous versions. Some devices are designed to deny users access to install or run modified versions of the software inside them, although the manufacturer can do so. This is fundamentally incompatible with the aim of protecting users' freedom to change the software. The systematic pattern of such abuse occurs in the area of products for individuals to use, which is precisely where it is most unacceptable. Therefore, we have designed this version of the GPL to prohibit the practice for those products. If such problems arise substantially in other domains, we stand ready to extend this provision to those domains in future versions of the GPL, as needed to protect the freedom of users. Finally, every program is threatened constantly by software patents. States should not allow patents to restrict development and use of software on general-purpose computers, but in those that do, we wish to avoid the special danger that patents applied to a free program could make it effectively proprietary. To prevent this, the GPL assures that patents cannot be used to render the program non-free. The precise terms and conditions for copying, distribution and modification follow. TERMS AND CONDITIONS 0. Definitions. "This License" refers to version 3 of the GNU General Public License. "Copyright" also means copyright-like laws that apply to other kinds of works, such as semiconductor masks. "The Program" refers to any copyrightable work licensed under this License. Each licensee is addressed as "you". "Licensees" and "recipients" may be individuals or organizations. To "modify" a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a "modified version" of the earlier work or a work "based on" the earlier work. A "covered work" means either the unmodified Program or a work based on the Program. To "propagate" a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well. To "convey" a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying. An interactive user interface displays "Appropriate Legal Notices" to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion. 1. Source Code. The "source code" for a work means the preferred form of the work for making modifications to it. "Object code" means any non-source form of a work. A "Standard Interface" means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language. The "System Libraries" of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A "Major Component", in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it. The "Corresponding Source" for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those subprograms and other parts of the work. The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source. The Corresponding Source for a work in source code form is that same work. 2. Basic Permissions. All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law. You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you. Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary. 3. Protecting Users' Legal Rights From Anti-Circumvention Law. No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures. When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures. 4. Conveying Verbatim Copies. You may convey verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program. You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee. 5. Conveying Modified Source Versions. You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions: a) The work must carry prominent notices stating that you modified it, and giving a relevant date. b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to "keep intact all notices". c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it. d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so. A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an "aggregate" if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate. 6. Conveying Non-Source Forms. You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways: a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange. b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge. c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b. d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements. e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d. A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work. A "User Product" is either (1) a "consumer product", which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, "normally used" refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product. "Installation Information" for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made. If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM). The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network. Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying. 7. Additional Terms. "Additional permissions" are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions. When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission. Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms: a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or d) Limiting the use for publicity purposes of names of licensors or authors of the material; or e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors. All other non-permissive additional terms are considered "further restrictions" within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying. If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms. Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way. 8. Termination. You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11). However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation. Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice. Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10. 9. Acceptance Not Required for Having Copies. You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so. 10. Automatic Licensing of Downstream Recipients. Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License. An "entity transaction" is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts. You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it. 11. Patents. A "contributor" is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's "contributor version". A contributor's "essential patent claims" are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, "control" includes the right to grant patent sublicenses in a manner consistent with the requirements of this License. Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version. In the following three paragraphs, a "patent license" is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To "grant" such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party. If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent license to downstream recipients. "Knowingly relying" means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid. If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it. A patent license is "discriminatory" if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007. Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law. 12. No Surrender of Others' Freedom. If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program. 13. Use with the GNU Affero General Public License. Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU Affero General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the special requirements of the GNU Affero General Public License, section 13, concerning interaction through a network will apply to the combination as such. 14. Revised Versions of this License. The Free Software Foundation may publish revised and/or new versions of the GNU General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies that a certain numbered version of the GNU General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU General Public License, you may choose any version ever published by the Free Software Foundation. If the Program specifies that a proxy can decide which future versions of the GNU General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program. Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version. 15. Disclaimer of Warranty. THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 16. Limitation of Liability. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 17. Interpretation of Sections 15 and 16. If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) 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 3 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, see . Also add information on how to contact you by electronic and paper mail. If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode: Copyright (C) This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, your program's commands might be different; for a GUI interface, you would use an "about box". You should also get your employer (if you work as a programmer) or school, if any, to sign a "copyright disclaimer" for the program, if necessary. For more information on this, and how to apply and follow the GNU GPL, see . The GNU General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. But first, please read . libapt-pkg-perl/AptPkg.xs0000644000000000000000000010042212143203460012472 0ustar /* * perl interface to libapt-pkg */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define PERL_NO_GET_CONTEXT #include "EXTERN.h" #include "perl.h" #include "XSUB.h" #include "utils.h" /* XS has grief with colons */ #define Configuration_Item Configuration::Item #define pkgSrcRecords_Parser pkgSrcRecords::Parser /* ensure parent SV persists for the life of the child */ template class parented { public: SV *parent; T *obj; private: bool copy; void init(SV *p, T *o, bool c) { dTHX; parent = SvREFCNT_inc(p); obj = o; copy = c; }; public: parented(SV *p, T *o, bool c = false) { init(p, o, c); }; parented(SV *p, T &o) { init(p, new T(o), true); }; ~parented() { dTHX; SvREFCNT_dec(parent); if (copy) delete obj; }; }; #define THIS_sv ST(0) #define THAT_sv ST(1) #define pkgRecords_p parented #define pkgPolicy_p parented #define pkgCache_PkgIterator_p parented #define pkgCache_VerIterator_p parented #define pkgCache_DepIterator_p parented #define pkgCache_PrvIterator_p parented #define pkgCache_DescIterator_p parented #define pkgCache_VerFileIterator_p parented #define pkgCache_PkgFileIterator_p parented #define pkgCache_DescFileIterator_p parented /* handle warnings/errors */ static void handle_errors(int fatal) { while (!_error->empty()) { string msg; if (_error->PopMessage(msg) && fatal) croak("%s\n", msg.c_str()); else warn("%s\n", msg.c_str()); } } /* convert strings to CommandLine::Flags */ static int cmdline_flag(char const *f) { if (strEQ(f, "HasArg") || strEQ(f, "has_arg")) return CommandLine::HasArg; if (strEQ(f, "IntLevel") || strEQ(f, "int_level")) return CommandLine::IntLevel; if (strEQ(f, "Boolean") || strEQ(f, "boolean")) return CommandLine::Boolean; if (strEQ(f, "InvBoolean") || strEQ(f, "inv_boolean")) return CommandLine::InvBoolean; if (strEQ(f, "ConfigFile") || strEQ(f, "config_file")) return CommandLine::ConfigFile; if (strEQ(f, "ArbItem") || strEQ(f, "arb_item")) return CommandLine::ArbItem; warn("unrecognised command line option type `%s'", f); return 0; } /* automagically do _config and _system initialisation if required */ static int init_done = 0; #define INIT_CONFIG 1 #define INIT_SYSTEM 2 static void auto_init(pTHX_ int required) { if (!(init_done & INIT_CONFIG)) { load_module(PERL_LOADMOD_NOIMPORT, newSVpvn("AptPkg::Config", 14), 0); eval_pv("$AptPkg::Config::_config->init;" "$AptPkg::Config::_config->{quiet} = 2;", 1); } if ((required & INIT_SYSTEM) && !(init_done & INIT_SYSTEM)) { load_module(PERL_LOADMOD_NOIMPORT, newSVpvn("AptPkg::System", 14), 0); eval_pv("$AptPkg::System::_system = $AptPkg::Config::_config->system;", 1); } } /* assigning to the $AptPkg::System::_system needs to magically modify the global _system (ick) */ static int _system_set(pTHX_ SV *sv, MAGIC *mg) { if (SvROK(sv) && sv_derived_from(sv, "AptPkg::System")) { init_done |= INIT_SYSTEM; _system = (pkgSystem *) SvIV((SV *) SvRV(sv)); } else croak("can't set _system to a value not of type AptPkg::System"); return 1; } static MGVTBL _system_magic = { 0, _system_set, 0, 0, 0 }; /* for AptPkg::Dep, AptPkg::State and AptPkg::Flag constants */ XS(XS_AptPkg__constant) { dXSARGS; ST(0) = newSViv(CvXSUBANY(cv).any_iv); sv_2mortal(ST(0)); XSRETURN(1); } #define CONSTANT(_sub_, _enum_) \ do { \ CV *cv = newXS(_sub_, XS_AptPkg__constant, file); \ CvXSUBANY(cv).any_iv = _enum_; \ } while (0) MODULE = AptPkg PACKAGE = AptPkg PROTOTYPES: DISABLE bool _init_config(conf) Configuration *conf CODE: if (conf == _config) init_done |= INIT_CONFIG; if (!(RETVAL = pkgInitConfig(*conf))) handle_errors(0); OUTPUT: RETVAL pkgSystem * _init_system(conf) Configuration *conf CODE: pkgSystem *sys = 0; if (!pkgInitSystem(*conf, sys)) handle_errors(0); RETVAL = sys; OUTPUT: RETVAL void _parse_cmdline(conf, args, ...) Configuration *conf SV *args PPCODE: if (!(SvROK(args) && SvTYPE(SvRV(args)) == SVt_PVAV)) croak("AptPkg::_parse_cmdline: array reference required"); AV *av = (AV *) SvRV(args); I32 len = av_len(av) + 1; if (len && items > 2) { CommandLine::Args *a = new CommandLine::Args[len + 1]; I32 j = 0; for (I32 i = 0; i < len; i++) { char const *type = 0; char const *e; if ((e = parse_avref(aTHX_ av_fetch(av, i, 0), "czs|s", &a[j].ShortOpt, &a[j].LongOpt, &a[j].ConfName, &type))) warn("AptPkg::_parse_cmdline: invalid array %d (%s)", i, e); else a[j++].Flags = type ? cmdline_flag(type) : 0; } a[j].ShortOpt = 0; a[j].LongOpt = 0; CommandLine cmd(a, conf); int argc = items - 1; char const **argv = new char const*[argc]; j = 0; argv[j++] = PL_origfilename; for (I32 i = 2; i < items; i++) argv[j++] = SvPV_nolen(ST(i)); if (cmd.Parse(argc, argv)) for (I32 i = 0; cmd.FileList[i]; i++) XPUSHs(sv_2mortal(newSVpv(cmd.FileList[i], 0))); delete [] a; delete [] argv; handle_errors(1); } MODULE = AptPkg PACKAGE = AptPkg::_config BOOT: /* make global available */ sv_setref_pv(get_sv("AptPkg::_config::_config", 1), "AptPkg::_config", (void *) _config); Configuration * Configuration::new() void Configuration::DESTROY() INIT: if (THIS == _config) XSRETURN_EMPTY; string Configuration::Find(name, default_value = 0) char *name char *default_value string Configuration::FindFile(name, default_value = 0) char *name char *default_value string Configuration::FindDir(name, default_value = 0) char *name char *default_value bool Configuration::FindB(name, default_value = 0) char *name int default_value string Configuration::FindAny(name, default_value = 0) char *name char *default_value string Configuration::Set(name, value) char *name string value CODE: THIS->Set(name, value); RETVAL = value; OUTPUT: RETVAL bool Configuration::Exists(name) char *name bool Configuration::ExistsAny(name) char *name Configuration_Item const * Configuration::Tree(name = 0) char *name void Configuration::Dump() bool ReadConfigFile(config, file, as_sectional = false, depth = 0) Configuration *config string file bool as_sectional int depth C_ARGS: *config, file, as_sectional, depth POSTCALL: handle_errors(0); bool ReadConfigDir(config, dir, as_sectional = false, depth = 0) Configuration *config string dir bool as_sectional int depth C_ARGS: *config, dir, as_sectional, depth POSTCALL: handle_errors(0); MODULE = AptPkg PACKAGE = AptPkg::Config::_item string Configuration_Item::Value() CODE: RETVAL = THIS->Value; OUTPUT: RETVAL string Configuration_Item::Tag() CODE: RETVAL = THIS->Tag; OUTPUT: RETVAL string Configuration_Item::FullTag(stop = 0) Configuration_Item const *stop Configuration_Item const * Configuration_Item::Parent() CODE: RETVAL = THIS->Parent; OUTPUT: RETVAL Configuration_Item const * Configuration_Item::Child() CODE: RETVAL = THIS->Child; OUTPUT: RETVAL Configuration_Item const * Configuration_Item::Next() CODE: RETVAL = THIS->Next; OUTPUT: RETVAL MODULE = AptPkg PACKAGE = AptPkg::System BOOT: { /* make global available */ SV *sv = sv_setref_pv(get_sv("AptPkg::System::_system", 1), "AptPkg::System", (void *) _system); /* and make it magical, so that setting the value of $_system modifies the underlying _system global */ sv_magic(sv, 0, '~', 0, 0); mg_find(sv, '~')->mg_virtual = &_system_magic; SvMAGICAL_on(sv); } char * pkgSystem::Label() CODE: RETVAL = (char *) THIS->Label; OUTPUT: RETVAL pkgVersioningSystem * pkgSystem::VS() CODE: RETVAL = THIS->VS; OUTPUT: RETVAL bool pkgSystem::Lock() POSTCALL: handle_errors(0); bool pkgSystem::UnLock(NoErrors = false) bool NoErrors POSTCALL: handle_errors(0); MODULE = AptPkg PACKAGE = AptPkg::Version char * pkgVersioningSystem::Label() CODE: RETVAL = (char *) THIS->Label; OUTPUT: RETVAL int pkgVersioningSystem::CmpVersion(a, b) char *a char *b int pkgVersioningSystem::CmpReleaseVer(a, b) char *a char *b bool pkgVersioningSystem::CheckDep(pkg, op, dep) char *pkg unsigned op char *dep string pkgVersioningSystem::UpstreamVersion(str) char *str MODULE = AptPkg PACKAGE = AptPkg::_cache pkgCacheFile * pkgCacheFile::new() PREINIT: auto_init(aTHX_ INIT_CONFIG|INIT_SYSTEM); void pkgCacheFile::DESTROY() bool pkgCacheFile::Open(lock = false) bool lock PREINIT: OpTextProgress progress(*_config); C_ARGS: &progress, lock POSTCALL: handle_errors(0); void pkgCacheFile::Close() pkgCache_PkgIterator_p * pkgCacheFile::FindPkg(name) string name CODE: pkgCache *cache = *THIS; pkgCache::PkgIterator p = cache->FindPkg(name); if (p.end()) XSRETURN_UNDEF; RETVAL = new pkgCache_PkgIterator_p(THIS_sv, p); OUTPUT: RETVAL pkgCache_PkgIterator_p * pkgCacheFile::PkgBegin() CODE: pkgCache *cache = *THIS; pkgCache::PkgIterator p = cache->PkgBegin(); if (p.end()) XSRETURN_UNDEF; RETVAL = new pkgCache_PkgIterator_p(THIS_sv, p); OUTPUT: RETVAL SV * pkgCacheFile::FileList() PPCODE: pkgCache *cache = *THIS; for (pkgCache::PkgFileIterator i = cache->FileBegin(); !i.end(); ++i) { pkgCache_PkgFileIterator_p *f = new pkgCache_PkgFileIterator_p(THIS_sv, i); SV *file = sv_newmortal(); sv_setref_pv(file, "AptPkg::Cache::_pkg_file", (void *) f); XPUSHs(file); } pkgRecords_p * pkgCacheFile::Packages() CODE: pkgRecords *p = new pkgRecords(*THIS); RETVAL = new pkgRecords_p(THIS_sv, p, true); OUTPUT: RETVAL pkgPolicy_p * pkgCacheFile::Policy() CODE: pkgPolicy *p = THIS->Policy; if (!p) XSRETURN_UNDEF; RETVAL = new pkgPolicy_p(THIS_sv, p); OUTPUT: RETVAL bool pkgCacheFile::MultiArchCache() CODE: pkgCache *cache = *THIS; RETVAL = cache->MultiArchCache(); OUTPUT: RETVAL char * pkgCacheFile::NativeArch() CODE: pkgCache *cache = *THIS; RETVAL = (char *) cache->NativeArch(); OUTPUT: RETVAL MODULE = AptPkg PACKAGE = AptPkg::Cache::_package void pkgCache_PkgIterator_p::DESTROY() int pkgCache_PkgIterator_p::Next() CODE: (*THIS->obj)++; RETVAL = !THIS->obj->end(); OUTPUT: RETVAL char * pkgCache_PkgIterator_p::Name() CODE: RETVAL = (char *) THIS->obj->Name(); OUTPUT: RETVAL string pkgCache_PkgIterator_p::FullName(Pretty = false) bool Pretty CODE: RETVAL = THIS->obj->FullName(Pretty); OUTPUT: RETVAL char * pkgCache_PkgIterator_p::Arch() CODE: RETVAL = (char *) THIS->obj->Arch(); OUTPUT: RETVAL char * pkgCache_PkgIterator_p::Section() CODE: RETVAL = (char *) THIS->obj->Section(); OUTPUT: RETVAL SV * pkgCache_PkgIterator_p::VersionList() PPCODE: for (pkgCache::VerIterator i = THIS->obj->VersionList(); !i.end(); ++i) { pkgCache_VerIterator_p *v = new pkgCache_VerIterator_p(THIS_sv, i); SV *ver = sv_newmortal(); sv_setref_pv(ver, "AptPkg::Cache::_version", (void *) v); XPUSHs(ver); } pkgCache_VerIterator_p * pkgCache_PkgIterator_p::CurrentVer() CODE: if (!(*THIS->obj)->CurrentVer) XSRETURN_UNDEF; pkgCache::VerIterator i = THIS->obj->CurrentVer(); RETVAL = new pkgCache_VerIterator_p(THIS_sv, i); OUTPUT: RETVAL SV * pkgCache_PkgIterator_p::RevDependsList() PPCODE: for (pkgCache::DepIterator i = THIS->obj->RevDependsList(); !i.end(); ++i) { pkgCache_DepIterator_p *d = new pkgCache_DepIterator_p(THIS_sv, i); SV *dep = sv_newmortal(); sv_setref_pv(dep, "AptPkg::Cache::_depends", (void *) d); XPUSHs(dep); } SV * pkgCache_PkgIterator_p::ProvidesList() PPCODE: for (pkgCache::PrvIterator i = THIS->obj->ProvidesList(); !i.end(); ++i) { pkgCache_PrvIterator_p *p = new pkgCache_PrvIterator_p(THIS_sv, i); SV *prv = sv_newmortal(); sv_setref_pv(prv, "AptPkg::Cache::_provides", (void *) p); XPUSHs(prv); } unsigned long pkgCache_PkgIterator_p::Index() CODE: RETVAL = THIS->obj->Index(); OUTPUT: RETVAL SV * pkgCache_PkgIterator_p::SelectedState() PREINIT: char const *rv; CODE: switch ((*THIS->obj)->SelectedState) { case pkgCache::State::Unknown: rv = "Unknown"; break; case pkgCache::State::Install: rv = "Install"; break; case pkgCache::State::Hold: rv = "Hold"; break; case pkgCache::State::DeInstall: rv = "DeInstall"; break; case pkgCache::State::Purge: rv = "Purge"; break; default: XSRETURN_UNDEF; } RETVAL = newSViv((*THIS->obj)->SelectedState); sv_setpv(RETVAL, rv); SvIOK_on(RETVAL); OUTPUT: RETVAL SV * pkgCache_PkgIterator_p::InstState() PREINIT: char const *rv; CODE: switch ((*THIS->obj)->InstState) { case pkgCache::State::Ok: rv = "Ok"; break; case pkgCache::State::ReInstReq: rv = "ReInstReq"; break; case pkgCache::State::HoldInst: rv = "HoldInst"; break; case pkgCache::State::HoldReInstReq: rv = "HoldReInstReq"; break; default: XSRETURN_UNDEF; } RETVAL = newSViv((*THIS->obj)->InstState); sv_setpv(RETVAL, rv); SvIOK_on(RETVAL); OUTPUT: RETVAL SV * pkgCache_PkgIterator_p::CurrentState() PREINIT: char const *rv; CODE: switch ((*THIS->obj)->CurrentState) { case pkgCache::State::NotInstalled: rv = "NotInstalled"; break; case pkgCache::State::UnPacked: rv = "UnPacked"; break; case pkgCache::State::HalfConfigured: rv = "HalfConfigured"; break; case pkgCache::State::HalfInstalled: rv = "HalfInstalled"; break; case pkgCache::State::ConfigFiles: rv = "ConfigFiles"; break; case pkgCache::State::Installed: rv = "Installed"; break; default: XSRETURN_UNDEF; } RETVAL = newSViv((*THIS->obj)->CurrentState); sv_setpv(RETVAL, rv); SvIOK_on(RETVAL); OUTPUT: RETVAL SV * pkgCache_PkgIterator_p::Flags() CODE: string flags = ""; if ((*THIS->obj)->Flags & pkgCache::Flag::Auto) flags += "Auto"; if ((*THIS->obj)->Flags & pkgCache::Flag::Essential) { if (flags.size()) flags += ","; flags += "Essential"; } if ((*THIS->obj)->Flags & pkgCache::Flag::Important) { if (flags.size()) flags += ","; flags += "Important"; } RETVAL = newSViv((*THIS->obj)->Flags); sv_setpv(RETVAL, (char *) flags.c_str()); SvIOK_on(RETVAL); OUTPUT: RETVAL MODULE = AptPkg PACKAGE = AptPkg::Cache::_version void pkgCache_VerIterator_p::DESTROY() char * pkgCache_VerIterator_p::VerStr() CODE: RETVAL = (char *) THIS->obj->VerStr(); OUTPUT: RETVAL char * pkgCache_VerIterator_p::Section() CODE: RETVAL = (char *) THIS->obj->Section(); OUTPUT: RETVAL char * pkgCache_VerIterator_p::Arch() CODE: RETVAL = (char *) THIS->obj->Arch(); OUTPUT: RETVAL SV * pkgCache_VerIterator_p::MultiArch() PREINIT: char const *rv; CODE: switch ((*THIS->obj)->MultiArch) { case pkgCache::Version::None: rv = "None"; break; case pkgCache::Version::All: rv = "All"; break; case pkgCache::Version::Foreign: rv = "Foreign"; break; case pkgCache::Version::Same: rv = "Same"; break; case pkgCache::Version::Allowed: rv = "Allowed"; break; case pkgCache::Version::AllForeign: rv = "AllForeign"; break; case pkgCache::Version::AllAllowed: rv = "AllAllowed"; break; default: XSRETURN_UNDEF; } RETVAL = newSViv((*THIS->obj)->MultiArch); sv_setpv(RETVAL, rv); SvIOK_on(RETVAL); OUTPUT: RETVAL pkgCache_PkgIterator_p * pkgCache_VerIterator_p::ParentPkg() CODE: pkgCache::PkgIterator i = THIS->obj->ParentPkg(); RETVAL = new pkgCache_PkgIterator_p(THIS_sv, i); OUTPUT: RETVAL SV * pkgCache_VerIterator_p::DescriptionList() PPCODE: for (pkgCache::DescIterator i = THIS->obj->DescriptionList(); !i.end(); ++i) { pkgCache_DescIterator_p *d = new pkgCache_DescIterator_p(THIS_sv, i); SV *dep = sv_newmortal(); sv_setref_pv(dep, "AptPkg::Cache::_description", (void *) d); XPUSHs(dep); } pkgCache_DescIterator_p * pkgCache_VerIterator_p::TranslatedDescription() CODE: pkgCache::DescIterator i = THIS->obj->TranslatedDescription(); RETVAL = new pkgCache_DescIterator_p(THIS_sv, i); OUTPUT: RETVAL SV * pkgCache_VerIterator_p::DependsList() PPCODE: for (pkgCache::DepIterator i = THIS->obj->DependsList(); !i.end(); ++i) { pkgCache_DepIterator_p *d = new pkgCache_DepIterator_p(THIS_sv, i); SV *dep = sv_newmortal(); sv_setref_pv(dep, "AptPkg::Cache::_depends", (void *) d); XPUSHs(dep); } SV * pkgCache_VerIterator_p::ProvidesList() PPCODE: for (pkgCache::PrvIterator i = THIS->obj->ProvidesList(); !i.end(); ++i) { pkgCache_PrvIterator_p *p = new pkgCache_PrvIterator_p(THIS_sv, i); SV *prv = sv_newmortal(); sv_setref_pv(prv, "AptPkg::Cache::_provides", (void *) p); XPUSHs(prv); } SV * pkgCache_VerIterator_p::FileList() PPCODE: for (pkgCache::VerFileIterator i = THIS->obj->FileList(); !i.end(); ++i) { pkgCache_VerFileIterator_p *f = new pkgCache_VerFileIterator_p(THIS_sv, i); SV *file = sv_newmortal(); sv_setref_pv(file, "AptPkg::Cache::_ver_file", (void *) f); XPUSHs(file); } unsigned long pkgCache_VerIterator_p::InstalledSize() CODE: RETVAL = (*THIS->obj)->InstalledSize; OUTPUT: RETVAL unsigned long pkgCache_VerIterator_p::Size() CODE: RETVAL = (*THIS->obj)->Size; OUTPUT: RETVAL unsigned long pkgCache_VerIterator_p::Index() CODE: RETVAL = THIS->obj->Index(); OUTPUT: RETVAL SV * pkgCache_VerIterator_p::Priority() CODE: char const *p = THIS->obj->PriorityType(); RETVAL = newSViv((*THIS->obj)->Priority); sv_setpv(RETVAL, (char *) p); SvIOK_on(RETVAL); OUTPUT: RETVAL MODULE = AptPkg PACKAGE = AptPkg::Cache::_depends void pkgCache_DepIterator_p::DESTROY() char * pkgCache_DepIterator_p::TargetVer() CODE: RETVAL = (char *) THIS->obj->TargetVer(); OUTPUT: RETVAL pkgCache_PkgIterator_p * pkgCache_DepIterator_p::TargetPkg() CODE: pkgCache::PkgIterator i = THIS->obj->TargetPkg(); RETVAL = new pkgCache_PkgIterator_p(THIS_sv, i); OUTPUT: RETVAL pkgCache_VerIterator_p * pkgCache_DepIterator_p::ParentVer() CODE: pkgCache::VerIterator i = THIS->obj->ParentVer(); RETVAL = new pkgCache_VerIterator_p(THIS_sv, i); OUTPUT: RETVAL pkgCache_PkgIterator_p * pkgCache_DepIterator_p::ParentPkg() CODE: pkgCache::PkgIterator i = THIS->obj->ParentPkg(); RETVAL = new pkgCache_PkgIterator_p(THIS_sv, i); OUTPUT: RETVAL unsigned long pkgCache_DepIterator_p::Index() CODE: RETVAL = THIS->obj->Index(); OUTPUT: RETVAL SV * pkgCache_DepIterator_p::CompType() CODE: RETVAL = newSViv((*THIS->obj)->CompareOp); sv_setpv(RETVAL, (char *) THIS->obj->CompType()); SvIOK_on(RETVAL); OUTPUT: RETVAL SV * pkgCache_DepIterator_p::CompTypeDeb() CODE: RETVAL = newSViv((*THIS->obj)->CompareOp); sv_setpv(RETVAL, (char *) THIS->obj->Cache()->CompTypeDeb((*THIS->obj)->CompareOp)); SvIOK_on(RETVAL); OUTPUT: RETVAL SV * pkgCache_DepIterator_p::DepType() CODE: RETVAL = newSViv((*THIS->obj)->Type); sv_setpv(RETVAL, (char *) THIS->obj->DepType()); SvIOK_on(RETVAL); OUTPUT: RETVAL MODULE = AptPkg PACKAGE = AptPkg::Cache::_provides void pkgCache_PrvIterator_p::DESTROY() char * pkgCache_PrvIterator_p::Name() CODE: RETVAL = (char *) THIS->obj->Name(); OUTPUT: RETVAL char * pkgCache_PrvIterator_p::ProvideVersion() CODE: RETVAL = (char *) THIS->obj->ProvideVersion(); OUTPUT: RETVAL pkgCache_VerIterator_p * pkgCache_PrvIterator_p::OwnerVer() CODE: pkgCache::VerIterator i = THIS->obj->OwnerVer(); RETVAL = new pkgCache_VerIterator_p(THIS_sv, i); OUTPUT: RETVAL pkgCache_PkgIterator_p * pkgCache_PrvIterator_p::OwnerPkg() CODE: pkgCache::PkgIterator i = THIS->obj->OwnerPkg(); RETVAL = new pkgCache_PkgIterator_p(THIS_sv, i); OUTPUT: RETVAL unsigned long pkgCache_PrvIterator_p::Index() CODE: RETVAL = THIS->obj->Index(); OUTPUT: RETVAL MODULE = AptPkg PACKAGE = AptPkg::Cache::_description void pkgCache_DescIterator_p::DESTROY() char * pkgCache_DescIterator_p::LanguageCode() CODE: RETVAL = (char *) THIS->obj->LanguageCode(); OUTPUT: RETVAL char * pkgCache_DescIterator_p::md5() CODE: RETVAL = (char *) THIS->obj->md5(); OUTPUT: RETVAL pkgCache_DescFileIterator_p * pkgCache_DescIterator_p::FileList() CODE: pkgCache::DescFileIterator i = THIS->obj->FileList(); RETVAL = new pkgCache_DescFileIterator_p(THIS_sv, i); OUTPUT: RETVAL MODULE = AptPkg PACKAGE = AptPkg::Cache::_pkg_file void pkgCache_PkgFileIterator_p::DESTROY() char * pkgCache_PkgFileIterator_p::FileName() CODE: RETVAL = (char *) THIS->obj->FileName(); OUTPUT: RETVAL char * pkgCache_PkgFileIterator_p::Archive() CODE: RETVAL = (char *) THIS->obj->Archive(); OUTPUT: RETVAL char * pkgCache_PkgFileIterator_p::Component() CODE: RETVAL = (char *) THIS->obj->Component(); OUTPUT: RETVAL char * pkgCache_PkgFileIterator_p::Version() CODE: RETVAL = (char *) THIS->obj->Version(); OUTPUT: RETVAL char * pkgCache_PkgFileIterator_p::Origin() CODE: RETVAL = (char *) THIS->obj->Origin(); OUTPUT: RETVAL char * pkgCache_PkgFileIterator_p::Label() CODE: RETVAL = (char *) THIS->obj->Label(); OUTPUT: RETVAL char * pkgCache_PkgFileIterator_p::Site() CODE: RETVAL = (char *) THIS->obj->Site(); OUTPUT: RETVAL char * pkgCache_PkgFileIterator_p::IndexType() CODE: RETVAL = (char *) THIS->obj->IndexType(); OUTPUT: RETVAL unsigned long pkgCache_PkgFileIterator_p::Index() CODE: RETVAL = THIS->obj->Index(); OUTPUT: RETVAL bool pkgCache_PkgFileIterator_p::IsOk() CODE: RETVAL = (char *) THIS->obj->IsOk(); OUTPUT: RETVAL MODULE = AptPkg PACKAGE = AptPkg::Cache::_ver_file void pkgCache_VerFileIterator_p::DESTROY() pkgCache_PkgFileIterator_p * pkgCache_VerFileIterator_p::File() CODE: pkgCache::PkgFileIterator i = THIS->obj->File(); RETVAL = new pkgCache_PkgFileIterator_p(THIS_sv, i); OUTPUT: RETVAL unsigned long pkgCache_VerFileIterator_p::Index() CODE: RETVAL = THIS->obj->Index(); OUTPUT: RETVAL off_t pkgCache_VerFileIterator_p::Offset() CODE: RETVAL = (*THIS->obj)->Offset; OUTPUT: RETVAL unsigned short pkgCache_VerFileIterator_p::Size() CODE: RETVAL = (*THIS->obj)->Size; OUTPUT: RETVAL MODULE = AptPkg PACKAGE = AptPkg::Cache::_desc_file void pkgCache_DescFileIterator_p::DESTROY() pkgCache_PkgFileIterator_p * pkgCache_DescFileIterator_p::File() CODE: pkgCache::PkgFileIterator i = THIS->obj->File(); RETVAL = new pkgCache_PkgFileIterator_p(THIS_sv, i); OUTPUT: RETVAL MODULE = AptPkg PACKAGE = AptPkg::_pkg_records void pkgRecords_p::DESTROY() SV * pkgRecords_p::cache() PPCODE: XPUSHs(sv_mortalcopy(THIS->parent)); #define PUSH_PAIR(_pack_, _name_) \ do { \ string v; \ if ((v = _pack_._name_()).size()) \ { \ EXTEND(SP, 2); \ PUSHs(sv_2mortal(newSVpvn(#_name_, sizeof(#_name_)-1))); \ PUSHs(sv_2mortal(newSVpvn(v.c_str(), v.size()))); \ } \ } while (0) SV * pkgRecords_p::Lookup(arg) SV *arg PPCODE: pkgCache_VerFileIterator_p *pack = 0; pkgCache_DescFileIterator_p *desc = 0; if (SvROK(arg)) if (sv_derived_from(arg, "AptPkg::Cache::_ver_file")) pack = (pkgCache_VerFileIterator_p *) SvIV((SV *) SvRV(arg)); else if (sv_derived_from(arg, "AptPkg::Cache::_desc_file")) desc = (pkgCache_DescFileIterator_p *) SvIV((SV *) SvRV(arg)); if (pack) { pkgRecords::Parser &p = THIS->obj->Lookup(*pack->obj); PUSH_PAIR(p, FileName); PUSH_PAIR(p, MD5Hash); PUSH_PAIR(p, SourcePkg); PUSH_PAIR(p, Maintainer); PUSH_PAIR(p, ShortDesc); PUSH_PAIR(p, LongDesc); PUSH_PAIR(p, Name); } else if (desc) { pkgRecords::Parser &p = THIS->obj->Lookup(*desc->obj); PUSH_PAIR(p, ShortDesc); PUSH_PAIR(p, LongDesc); PUSH_PAIR(p, Name); } else croak("arg is not of type AptPkg::Cache::_ver_file" " or AptPkg::Cache::_desc_file"); MODULE = AptPkg PACKAGE = AptPkg::_policy void pkgPolicy_p::DESTROY() short pkgPolicy_p::GetPriority(arg) SV *arg CODE: pkgCache_PkgFileIterator_p *f = 0; pkgCache_PkgIterator_p *p = 0; if (SvROK(arg)) if (sv_derived_from(arg, "AptPkg::Cache::_pkg_file")) f = (pkgCache_PkgFileIterator_p *) SvIV((SV *) SvRV(arg)); else if (sv_derived_from(arg, "AptPkg::Cache::_package")) p = (pkgCache_PkgIterator_p *) SvIV((SV *) SvRV(arg)); if (f) RETVAL = THIS->obj->GetPriority(*f->obj); else if (p) RETVAL = THIS->obj->GetPriority(*p->obj); else croak("arg is not of type AptPkg::Cache::_pkg_file" " or AptPkg::Cache::_package"); OUTPUT: RETVAL pkgCache_VerIterator_p * pkgPolicy_p::GetMatch(pkgCache_PkgIterator_p *p) CODE: pkgCache::VerIterator v = THIS->obj->GetMatch(*p->obj); if (v.end()) XSRETURN_UNDEF; RETVAL = new pkgCache_VerIterator_p(THAT_sv, v); OUTPUT: RETVAL pkgCache_VerIterator_p * pkgPolicy_p::GetCandidateVer(pkgCache_PkgIterator_p *p) CODE: pkgCache::VerIterator v = THIS->obj->GetCandidateVer(*p->obj); if (v.end()) XSRETURN_UNDEF; RETVAL = new pkgCache_VerIterator_p(THAT_sv, v); OUTPUT: RETVAL MODULE = AptPkg PACKAGE = AptPkg::_source_list pkgSourceList * pkgSourceList::new(list = 0) char *list PREINIT: auto_init(aTHX_ INIT_CONFIG); C_ARGS: POSTCALL: if (list) RETVAL->Read(list); else RETVAL->ReadMainList(); handle_errors(0); void pkgSourceList::DESTROY() MODULE = AptPkg PACKAGE = AptPkg::_src_records pkgSrcRecords * pkgSrcRecords::new(sources) pkgSourceList *sources C_ARGS: *sources POSTCALL: handle_errors(0); void pkgSrcRecords::DESTROY() void pkgSrcRecords::Restart() SV * pkgSrcRecords::Find(src, src_only = false) char *src bool src_only PPCODE: pkgSrcRecords::Parser *parser = THIS->Find(src, src_only); if (!parser) XSRETURN_EMPTY; if (GIMME_V != G_ARRAY) { XPUSHs(sv_2mortal(newSVpv(parser->Package().c_str(), 0))); XSRETURN(1); } { pkgSrcRecords::Parser &p = *parser; PUSH_PAIR(p, Package); PUSH_PAIR(p, Version); PUSH_PAIR(p, Maintainer); PUSH_PAIR(p, Section); } char const **b = parser->Binaries(); if (b && *b) { AV *av = newAV(); while (*b) av_push(av, newSVpv(*b++, 0)); SV *a = sv_newmortal(); SvUPGRADE(a, SVt_RV); SvRV(a) = (SV *) av; SvROK_on(a); EXTEND(SP, 2); PUSHs(sv_2mortal(newSVpv("Binaries", 0))); PUSHs(a); } vector bd; if (parser->BuildDepends(bd, false)) { HV *hv = newHV(); for (vector::const_iterator b = bd.begin(); b != bd.end(); ++b) { char const *key = parser->BuildDepType(b->Type); STRLEN klen = strlen(key); AV *dep_list; if (SV **e = hv_fetch(hv, key, klen, 0)) { dep_list = (AV *) SvRV(*e); } else { SV *s = newSV(0); SvUPGRADE(s, SVt_RV); SvRV(s) = (SV *) (dep_list = newAV()); SvROK_on(s); hv_store(hv, key, klen, s, 0); } AV *dep = newAV(); av_push(dep, newSVpvn(b->Package.c_str(), b->Package.size())); if (b->Op || !b->Version.empty()) { SV *o = newSViv(b->Op); sv_setpv(o, pkgCache::CompType(b->Op)); SvIOK_on(o); av_push(dep, o); } if (!b->Version.empty()) av_push(dep, newSVpvn(b->Version.c_str(), b->Version.size())); SV *d = newSV(0); SvUPGRADE(d, SVt_RV); SvRV(d) = (SV *) dep; SvROK_on(d); av_push(dep_list, d); } SV *s = sv_newmortal(); SvUPGRADE(s, SVt_RV); SvRV(s) = (SV *) hv; SvROK_on(s); EXTEND(SP, 2); PUSHs(sv_2mortal(newSVpv("BuildDepends", 0))); PUSHs(s); } vector files; if (parser->Files(files)) { AV *av = newAV(); for (vector::const_iterator f = files.begin(); f != files.end(); ++f) { HV *hv = newHV(); hv_store(hv, "MD5Hash", 7, newSVpvn(f->MD5Hash.c_str(), f->MD5Hash.size()), 0); hv_store(hv, "Size", 4, newSVuv(f->Size), 0); hv_store(hv, "ArchiveURI", 10, newSVpv(parser->Index().ArchiveURI(f->Path).c_str(), 0), 0); hv_store(hv, "Type", 4, newSVpvn(f->Type.c_str(), f->Type.size()), 0); SV *h = newSV(0); SvUPGRADE(h, SVt_RV); SvRV(h) = (SV *) hv; SvROK_on(h); av_push(av, h); } SV *s = sv_newmortal(); SvUPGRADE(s, SVt_RV); SvRV(s) = (SV *) av; SvROK_on(s); EXTEND(SP, 4); PUSHs(sv_2mortal(newSVpv("Files", 0))); PUSHs(s); } MODULE = AptPkg PACKAGE = AptPkg BOOT: { /* constants */ /* pkgCache::Version::VerMultiArch */ CONSTANT("AptPkg::Version::None", pkgCache::Version::None); CONSTANT("AptPkg::Version::All", pkgCache::Version::All); CONSTANT("AptPkg::Version::Foreign", pkgCache::Version::Foreign); CONSTANT("AptPkg::Version::Same", pkgCache::Version::Same); CONSTANT("AptPkg::Version::Allowed", pkgCache::Version::Allowed); CONSTANT("AptPkg::Version::AllForeign", pkgCache::Version::AllForeign); CONSTANT("AptPkg::Version::AllAllowed", pkgCache::Version::AllAllowed); /* pkgCache::Dep::DepType */ CONSTANT("AptPkg::Dep::Depends", pkgCache::Dep::Depends); CONSTANT("AptPkg::Dep::PreDepends", pkgCache::Dep::PreDepends); CONSTANT("AptPkg::Dep::Suggests", pkgCache::Dep::Suggests); CONSTANT("AptPkg::Dep::Recommends", pkgCache::Dep::Recommends); CONSTANT("AptPkg::Dep::Conflicts", pkgCache::Dep::Conflicts); CONSTANT("AptPkg::Dep::Replaces", pkgCache::Dep::Replaces); CONSTANT("AptPkg::Dep::Obsoletes", pkgCache::Dep::Obsoletes); /* pkgCache::Dep::DepCompareOp */ CONSTANT("AptPkg::Dep::Or", pkgCache::Dep::Or); CONSTANT("AptPkg::Dep::NoOp", pkgCache::Dep::NoOp); CONSTANT("AptPkg::Dep::LessEq", pkgCache::Dep::LessEq); CONSTANT("AptPkg::Dep::GreaterEq", pkgCache::Dep::GreaterEq); CONSTANT("AptPkg::Dep::Less", pkgCache::Dep::Less); CONSTANT("AptPkg::Dep::Greater", pkgCache::Dep::Greater); CONSTANT("AptPkg::Dep::Equals", pkgCache::Dep::Equals); CONSTANT("AptPkg::Dep::NotEquals", pkgCache::Dep::NotEquals); /* pkgCache::State::VerPriority */ CONSTANT("AptPkg::State::Important", pkgCache::State::Important); CONSTANT("AptPkg::State::Required", pkgCache::State::Required); CONSTANT("AptPkg::State::Standard", pkgCache::State::Standard); CONSTANT("AptPkg::State::Optional", pkgCache::State::Optional); CONSTANT("AptPkg::State::Extra", pkgCache::State::Extra); /* pkgCache::State::PkgSelectedState */ CONSTANT("AptPkg::State::Unknown", pkgCache::State::Unknown); CONSTANT("AptPkg::State::Install", pkgCache::State::Install); CONSTANT("AptPkg::State::Hold", pkgCache::State::Hold); CONSTANT("AptPkg::State::DeInstall", pkgCache::State::DeInstall); CONSTANT("AptPkg::State::Purge", pkgCache::State::Purge); /* pkgCache::State::PkgInstState */ CONSTANT("AptPkg::State::Ok", pkgCache::State::Ok); CONSTANT("AptPkg::State::ReInstReq", pkgCache::State::ReInstReq); CONSTANT("AptPkg::State::HoldInst", pkgCache::State::HoldInst); CONSTANT("AptPkg::State::HoldReInstReq",pkgCache::State::HoldReInstReq); /* pkgCache::State::PkgCurrentState */ CONSTANT("AptPkg::State::NotInstalled", pkgCache::State::NotInstalled); CONSTANT("AptPkg::State::UnPacked", pkgCache::State::UnPacked); CONSTANT("AptPkg::State::HalfConfigured", pkgCache::State::HalfConfigured); CONSTANT("AptPkg::State::HalfInstalled",pkgCache::State::HalfInstalled); CONSTANT("AptPkg::State::ConfigFiles", pkgCache::State::ConfigFiles); CONSTANT("AptPkg::State::Installed", pkgCache::State::Installed); /* pkgCache::Flag::PkgFlags */ CONSTANT("AptPkg::Flag::Auto", pkgCache::Flag::Auto); CONSTANT("AptPkg::Flag::Essential", pkgCache::Flag::Essential); CONSTANT("AptPkg::Flag::Important", pkgCache::Flag::Important); }