+++ /dev/null
-Revision history for Perl extension RPM.
-
-0.40 Fri May 10 01:09:13 PDT 2002
- -alpha thirteen
-
- RPM 3.0 line is no longer going to be supported. It's been long
- enough since the 4.0 line came out, I feel. All #ifdef'd code relating
- to 3.0 (and 4.0 line before about 4.0.2) has been removed. The code
- once again will compile standing on its own within the rpm CVS
- repository.
-
- Applied a patch to RPM/Database.xs from Gerald Teschl <gt@esi.ac.at>
- so that when a header for a package that exists multiple times in
- the db (such as kernel) is requested, the newest of the lot is
- returned.
-
- In a related area, the list of potential control-case packages in
- t/02_headers.t started with kernel, but if there were two such
- packages installed when the tests ran, several of them would fail.
- Now, rpm is the first choice.
-
- Applied a modified version of a patch from Anton Berezin
- <tobez@FreeBSD.org> to RPM/Header.xs that catches cases where at
- the start of key-iteration, the first run of headerNextIterator()
- might yield a null (unknown) header key (in rpmhdr_FIRSTKEY).
-
- Applied a patch to RPM/Database.pm to allow options to be passed to
- the new() method. Also added documentation for the new() method (!).
- Patch was from viktor@vs.nexus.hu.
-
- Applied a patch from Radu Greab <radu@netsoft.ro> that eliminated
- a couple of compiler warnings and freed a pointer at destructor-time
- that was previously overlooked (RPM/Header.xs and RPM/Error.xs).
-
- Removed all the calls to safemalloc and safefree, replaced them with
- the API-correct New (or Newz) and Safefree.
-
-0.32 Tue May 15 00:54:20 PDT 2001
- - alpha twelve
-
- Found and fixed a bug in RPM/Database.xs that was causing more of
- the "Attempt to free unreferenced scalar" messages. In the process,
- noticed that caching of values during iteration wasn't actually
- working as designed. The resulting fix should improve database look-ups
- fairly noticably.
-
- Two more places found (one in RPM/Header.xs, one in RPM/Database.xs)
- that were contributing to memory leakage.
-
- A lot of changes to RPM/Constants.xs in terms of reducing the number
- and length of string-compares made in constant look-ups. This is most
- noticable in the RPM* set of constants, where the breakdown is the
- most granular. On the main dev box (a P-1/233MHz) this sped up the
- full test suite by over 25%.
-
-0.31 Fri Apr 27 01:45:37 PDT 2001
- - alpha eleven
-
- Re-worked most of RPM/Constants.xs to accomodate the change from
- #define to enum values in 4.0.2. This will be released as an
- interim version, since Red Hat is shipping 7.1 with this version of
- rpm.
-
-0.30 Wed Mar 7 22:13:40 PST 2001
- - tenth alpha
-
- Much of the leakage of RPM::Header objects is now gone, due mostly to
- changing the prototype of rpmdb_FETCH to returning a SV* instead of
- a RPM::Header reference. The various class DESTROY methods seem to be
- getting called in the correct order, now.
-
- Caught a case in the RPM::Header class where attempting to reference
- an element of a non-existent tag would trigger auto-vivification on
- that key, which in turn was leading to some bad calls being made to
- the rpmlib routines.
-
- Re-did the av-assignment in rpmhdr_create. This should save on SV*
- creation, though it might not have been a leak. Still, this method
- is more efficient overall.
-
- Newer versions of rpm 4.0 tickled a bug in which a database offset
- value might get sent in without being initialized first. This was
- caught and fixed. Also related to the 3.0/4.0 rift, some variables
- only used for 3.0.X are now declared within #ifdef's to defeat 'unused'
- warnings.
-
- The current state of the module will be released to allow for use by
- other parties, without the wait for any ongoing development milestones
- on my part.
-
-0.292 Mon Nov 13 22:40:15 PST 2000
- - ninth alpha
-
- Some unused variables were found in several places.
-
- Moved away from the self-tie mechanism and instead handle the data
- opacity in a completely different fashion. This simplified some code,
- muddled some, but ultimately led to the removal of several #define
- macros, more unused variable removal, and (hopefully) more stable
- code.
-
- Addressed a problem in both RPM::Database and RPM::Header XS code
- wherein destructors were not getting called when objects were
- implicitly or explicitly freed.
-
- Added more tests to the test suite.
-
- Changed the names of some of the find_* routines in RPM::Database.
- See the manual page. The old names were confusing me, despite my
- direct familiarity with the code!
-
- The find_* functions in RPM::Database may now take a RPM::Header
- object as their argument, and will use the package's name for the
- searches.
-
- It's still leaking RPM::Header objects in the RPM::Database routines.
- The alternative is a nasty mix of "attempt to free unreferenced
- scalar" errors and core dumps.
-
-0.291 Fri Oct 13 01:45:18 PDT 2000
- - eighth alpha
-
- The flags that are created from the rpm version are now passed for
- 3.0.X, as well.
-
- A thread-safing bug was found and fixed in Header.xs. An unused
- variable was removed.
-
- Makefile.PL has some large-scale work, including the addition of a
- template spec file following the __DATA__ token, code to expand this
- file using the values that MakeMaker has derived for the package,
- generation of make rules to construct *.rpm and *.srpm files, and
- generation of "rpmrc" and "rpmmacro" files to use in invoking rpm
- (to force all operation into the local dir area).
-
-0.29 Wed Oct 4 22:29:56 PDT 2000
- - seventh alpha
-
- The only change of note in this release is compatibility with version
- 4.0 of RPM. Additionally, some flags to the C compiler to work with
- the gcc that is distributed with Red Hat Linux 7. This version has
- been tested on both 6.2 and 7 systems.
-
-0.28 Fri Aug 18 01:29:35 PDT 2000
- - sixth alpha
-
- Considerable additions made to the documentation in RPM::Constants, as
- well as a few corrections. The prototype of the constant() function
- was changed, as well.
-
- Several bugs were addressed in RPM::Header, most notably: Error returns
- now correctly return a value of "undef"; A blocking issue surrounding
- multiple RPM::Header objects from ftp:// sources is fixed; the mode
- with which files are opened was also changed to allow for reading off
- of STDIN. The error-return issue was also applied to RPM::Database.
-
- RPM::Header now has a source_name() accessor method that returns the
- file name (or URI) that the header was read from. This is null if the
- header came from the database.
-
-0.27 Tue Aug 8 00:02:22 PDT 2000
- - fifth alpha
-
- Added filenames() method to RPM::Header. This re-assembles the list of
- filenames from the components in the tags, BASENAMES, DIRNAMES and
- DIRINDEXES.
-
- Added scalar_tag() method to RPM::Header. This returns a 0/1 value
- based on whether the return value for a given flag is an array ref or
- scalar (respectively). Can be called with either a string or a number
- argument. Can be called as a static (class) method.
-
- Added RPM/Error.xs and integrated into the build. All the XS code for
- RPM::Error that was previously in RPM.xs has been moved here.
-
- Added export of %RPM to RPM::Database. If requested, this is a hash
- pre-tied to the RPM::Database package (and thus the rpm database). One
- may also request $RPM and get an object referencing a tied hash.
-
- The return values from fetches on header objects has been completely
- revised. Tags are now explicitly defined as scalar or list in nature.
- The scalar_tag() method above is a part of this. The return value from
- a scalar tag is now a plain scalar. There is no more need for $_->[0]
- on scalar returns. Lists are still returned as list references, and
- undef is still used to signify problems. Tests have been added to
- t/02_headers.t for this, and tests in t/01_database.t were updated to
- use the new syntax. This does not obsolete the RPM::Header::NVR method,
- as that is a much faster means of fetching those three items than a
- stock fetch of the three individual tags would be.
-
- More tags/values documented in RPM::Constants.
-
-0.26 Fri Jul 14 01:03:02 PDT 2000
- - fourth alpha
-
- Added NVR() method to RPM::Header for obvious reasons of convenience.
- Also added cmpver method, which calls into the rpmCompareVersion() API
- hook to compare two headers' version/release data with an internal
- algorithm that handles numerical and alpha content in the tags.
-
- Took out all remaining warn()'s and croak()'s, replacing them with
- rpm_error() calls. Most notable in the error-return cases of
- RPM::Database::init and ::rebuild.
-
- More thread-safing, in particular the heretofore-ignored RPM::Constants
- XS module.
-
- Added a sample script in utils, called rpmprune. It has a --help
- summary and a man page, see those for details.
-
-0.25 Mon Jun 5 00:54:59 PDT 2000
- - third alpha
-
- Fixes to the thread-safing code. When built against a 5.6.0 configured
- for threading, several problems were found. All (current) tests now
- pass on that configuration.
-
- Added a file, IMPORTANT.perl, to the distribution that explains the
- nature of a condition that can prevent the extension from working on
- any version of Perl not installed from an rpm.
-
- Still more trimming of tokens out of Constants.pm that are not of use
- by the interface being provided. Filled in a few more in terms of
- documentation.
-
- Found a case in RPM::Header that would cause core-dumps: Any tags found
- by the iterator that were not exported for the API by the rpm lib
- could cause a null pointer to be passed through to an entry point that
- was several lines past where I had normally checked for the null. This
- meant that source RPMs would almost certainly break, since the
- offending tags only showed up when I started testing against SRPMS.
- Now, the iterators skip over these internal tags. The normal FETCH
- method already tested for this, but the interators were sneaking past
- those tests.
-
- Added a method to the RPM::Header class, is_source(), that returns a
- true value (1) if the header is associated with a source RPM.
-
-0.2 Mon May 29 17:59:20 PDT 2000
- - second alpha
-
- Class for RPM::Error added. The code is in the RPM.xs file, but
- the docs and accessors are done in RPM/Error.pm.
-
- All sub-classes moved to RPM/.
-
- More documentation added, especially to RPM::Constants.
-
- RPM::Constants had about a dozen or so trimmed out.
-
- Found error in Database.xs where the FIRSTKEY/NEXTKEY pair would
- have returned string-ified references instead of package names,
- because of not taking the first array element. I really plan to
- change the RPM::Header::FETCH interface.
-
- Added two utility functions under the RPM::* space for getting O/S
- and architecture names.
-
- Put in the start of thread-safing the module. But this part of the
- API is still pretty black in the Lockheed Skunkworks sense of the
- word, so it isn't at all complete.
-
-0.1 Mon May 22 00:59:54 PDT 2000
- - first alpha release
-
- Classes for RPM::Header and RPM::Database are (more or less) done.
- RPM::Constants appears to have everything that is expected to be
- needed (i.e., any changes should result in shortening the list of
- exported symbols, rather than lengthening it). A basic top-level
- RPM namespace is present, but doesn't yet do anything useful. Some
- basic test scripts are in place, but more are (always) needed.
-
-0.01 Thu May 4 12:04:34 2000
- - original version; created by h2xs 1.19
+++ /dev/null
-I have found, through fairly extensive testing and bug reports, that if the
-Perl you try to use when building and using the Perl-RPM package was built to
-immediately link any database library, then the RPM code will be unable to
-open the rpm databases.
-
-This is due to the fact that Perl creates backwards-compatibility to the Perl 4
-dbmopen()/dbmclose() facility through linking of a DBM implementation into the
-base executable. Though I couldn't exactly determine why, even if the only
-such linkage is Berkeley DB (libdb.so, the same library used by rpm) this
-earlier linkage will cause calls to dbopen() made by rpm into db to fail.
-
-At this time, I don't have a solution for this problem, except to build Perl
-without any of those libraries linked in Perl itself. Note that this will NOT
-prevent you from building any of DB_File, GDBM_File, or NDBM_File (as installed
-software permits) as dynamic extensions. This is the way Perl is distributed
-on Red Hat Linux systems. No database libraries are natively linked, but both
-DB_File and GDBM_File are still available as normal.
-
-Building Perl in this fashion is not difficult, but not particularly easy,
-either. It is necessary to remove any of "-ldb", "-lgdbm" and/or "-lndbm"
-from the libraries that Perl selects for linking (these are usually listed
-immediately before the dyna-linking library, -ldl on my Linux machines). Once
-these are removed, they cause Configure to choose not to include DB_File or
-GDBM_File in the list of dynamic or static extensions. This is easier to
-remedy, since one can use variable substitution to add them back to the end of
-the list:
-
- $* DB_File GDBM_File
-
-Most likely, this disables the dbmopen/close functionality, though I haven't
-tested to see if it is still accessible. Most likely, you won't be using it,
-at least not with this particular extension.
-
-I apologize for this inconvenience, and hope to find a way around it in future
-versions of Perl. If you use Perl installations in RPM form (from rpm.org or
-from Red Hat), this shouldn't be a problem.
-
-Randy J. Ray <rjray@blackperl.com>
-Fri Jun 2 18:21:24 PDT 2000
-
+++ /dev/null
-ChangeLog Change history
-IMPORTANT.perl Notes regarding datbase-linkage issues in Perl
-MANIFEST This file
-Makefile.PL MakeMaker file
-README Overview
-RPM.h C header, declarations, etc.
-RPM.pm Perl code for top-level functionality
-RPM.xs C/XS code for top-level stuff
-RPM/Constants.pm Perl code for constants (export lists, etc.)
-RPM/Constants.xs C/XS code for constants
-RPM/Database.pm Perl code for database access
-RPM/Database.xs C/XS code for database
-RPM/Error.pm Perl code for the error package
-RPM/Error.xs C/XS code for the error package
-RPM/Header.pm Perl code for headers
-RPM/Header.xs C/XS code for headers
-typemap Type-mappings for xsubpp to manage headers and database
-t/00_load.t Test suite
-t/01_database.t
-t/02_headers.t
-t/03_errors.t
-t/04_utils.t
-utils/rpmprune Sample script
+++ /dev/null
-#!/bin/perl
-
-# $Id: Makefile.PL,v 1.29 2002/05/10 08:04:55 rjray Exp $
-
-use Config;
-use ExtUtils::MakeMaker;
-use Cwd 'cwd';
-
-$cwd = cwd;
-
-# Check for any "local" arguments to the command that creates the Makefile
-@ARGV = map { /^RPM_(\w+)=(.*)/ ? do { $opts{lc $1} = $2; (); } : $_ } @ARGV
- if @ARGV;
-
-%XS = qw(
- RPM.xs RPM.c
- RPM/Constants.xs RPM/Constants.c
- RPM/Database.xs RPM/Database.c
- RPM/Error.xs RPM/Error.c
- RPM/Header.xs RPM/Header.c
- );
-# RPM/Package.xs RPM/Package.c
-
-@OBJECT = values %XS;
-for (@OBJECT)
-{
- s/\.c\b/\$(OBJ_EXT)/g;
-}
-$OBJECT = join(' ', @OBJECT);
-
-%PM = map { ($from = $_) =~ s/xs$/pm/;
- ($from, "\$(INST_LIBDIR)/$from"); } (keys %XS);
-
-@SAMPLES = qw(utils/rpmprune);
-
-# This shouldn't be necessary, I don't think, but for now it is
-unlink 'RPM/typemap';
-symlink '../typemap', 'RPM/typemap';
-
-# Cruft that MakeMaker wouldn't inherently know about
-$CLEAN = join(' ', values %XS) . " $OBJECT";
-$CLEAN .= ' Perl-RPM.spec pod2html-* */pod2html-* *.html */*.html RPM/typemap';
-$CLEAN .= ' rpmrc rpmmacro Perl-RPM-*';
-
-$rpm_libs = '-lrpm -lrpmdb -lrpmio -lpopt';
-# Check for needed header files
-$rpm_libdir = '';
-unless ($opts{build})
-{
- # If RPM_BUILD was set, then this module is being built as a part of the
- # whole rpm kit. In that case, when the make is run the CFLAGS environment
- # variable will have all the paths we need.
- for (qw(/usr/include /usr/local/include /opt/include /opt/rpm/include))
- {
- next unless -d $_ and -d "$_/rpm";
- $rpm_libdir = "$_/rpm", last if (-d "$_/rpm" && -e "$_/rpm/rpmlib.h");
- }
- die "Header file 'rpmlib.h' not found. This is needed for compiling the XS
-code. If this is present, edit $0 and add the correct directory to the search
-list near this line. Stopped"
- unless $rpm_libdir;
-}
-
-WriteMakefile(
- NAME => 'RPM',
- DISTNAME => 'Perl-RPM',
- VERSION => '0.40',
- LIBS => $rpm_libs,
- DEFINE => $rpm_defines,
- PM => \%PM,
- XS => \%XS,
- EXE_FILES => [ @SAMPLES ],
- OBJECT => $OBJECT,
- INC => $rpm_libdir ? "-I. -I$rpm_libdir" : '-I.',
- DIR => [],
-# XSOPT => '-noversioncheck -nolinenumbers',
- XSOPT => '-noversioncheck',
- dist => { COMPRESS => 'gzip -9f' },
- clean => { FILES => $CLEAN }
- );
-
-exit;
-
-sub MY::c_o
-{
- package MY; # so that "SUPER" works right
-
- my $text = shift->SUPER::c_o(@_);
-
- $text =~ s/CCCMD.*$/$& -o \$*\$(OBJ_EXT)/gm;
-
- $text;
-}
-
-sub MY::tools_other
-{
- package MY;
-
- my $text = shift->SUPER::tools_other(@_);
-
- "$text\nECHO=\@echo\nRPM=rpm\n";
-}
-
-sub MY::post_constants
-{
- my $self = shift;
-
- "SPECFILE=$self->{DISTNAME}.spec";
-}
-
-sub MY::postamble
-{
- my $self = shift;
-
- my @text;
-
- #
- # Only create the support files and extra make targets when packaging
- # locally.
- #
- unless ($opts{build})
- {
- #
- # Generate the spec file from <DATA> with substitutions
- #
- print "Local build detected. Generating $self->{DISTNAME}.spec...\n";
- $self->{INSTALLDIR} = $Config{installsitearch}
- unless $self->{INSTALLDIR};
- $self->{RELEASE} = $opts{release} || 1 unless $self->{RELEASE};
- # Copy all the RPM_* args from the command-line (parsed earlier), but
- # don't overwrite any of MM's internal values
- $self->{uc $_} ||= $opts{$_} for (keys %opts);
- open(SPEC, "> $self->{DISTNAME}.spec");
- if ($?)
- {
- die "Error creating spec file: $!, stopped";
- }
- else
- {
- for (<DATA>)
- {
- s/(SPEC_(\w+))/$self->{$2}/eg;
- print SPEC $_;
- }
- close(SPEC);
- }
- print "Generating rpmrc...\n";
- open(RPMRC, "> rpmrc");
- if ($?)
- {
- die "Error creating rpmrc file: $!, stopped";
- }
- else
- {
- print RPMRC <<END_rpmrc;
-include: /usr/lib/rpm/rpmrc
-macrofiles: /usr/lib/rpm/macros:rpmmacro
-END_rpmrc
- close(RPMRC);
- }
- print "Generating rpmmacros...\n";
- open(MACRO, "> rpmmacro");
- if ($?)
- {
- die "Error creating macro file: $!, stopped";
- }
- else
- {
- chomp(my $rpm_ver = (reverse split(/ /, qx{rpm --version}))[0]);
- print MACRO <<END_macro;
-%_rpmfilename %%{NAME}-%%{VERSION}-%%{RELEASE}.%%{ARCH}.rpm
-%_builddir %{_topdir}
-%_sourcedir %{_topdir}
-%_specdir %{_topdir}
-%_srcrpmdir %{_topdir}
-%_rpmdir %{_topdir}
-%_topdir $cwd
-%rpm_version $rpm_ver
-END_macro
- close(MACRO);
- }
-
- # Create the rules that create RPM and SRPM files
- push(@text, qq{
-rpm: \$(SPECFILE) \$(DISTVNAME).tar\$(SUFFIX)
-\t\$(RPM) -bb --clean --rcfile rpmrc \$(SPECFILE)
-
-srpm: \$(SPECFILE) \$(DISTVNAME).tar\$(SUFFIX)
-\t\$(RPM) -bs --clean --rcfile rpmrc \$(SPECFILE)
-});
- }
-
- # Create per-object-file dependancy on RPM.h
- push(@text, ('',
- (map { "$_: RPM.h\n" } @OBJECT),
- ''));
-
- join("\n", @text);
-}
-
-__DATA__
-Summary: Perl bindings to the rpmlib API
-Name: SPEC_DISTNAME
-Version: SPEC_VERSION
-Release: SPEC_RELEASE
-Epoch: 1
-Vendor: Randy J. Ray
-Copyright: Artistic
-Group: Development/Languages
-Source: SPEC_DISTNAME-SPEC_VERSION.tar.gz
-Url: http://www.blackperl.com/SPEC_DISTNAME
-BuildRequires: perl >= 0:5.00503
-Requires: perl >= 0:5.00503
-Requires: rpm = %{rpm_version}
-Provides: SPEC_DISTNAME = SPEC_VERSION
-Provides: perl(RPM::Database) = %{rpm_version}
-Provides: perl(RPM::Header) = %{rpm_version}
-Obsoletes: rpm-perl
-BuildRoot: %{_tmppath}/%{name}-root
-
-%description
-Native Bindings to the RPM API for Perl 5.005 and later. Uses a combination
-of Perl and C/XS (compiled) code to provide access to the RPM database,
-headers of installed packages, and more.
-
-%prep
-%setup -q -n SPEC_DISTNAME-%{version}
-
-%build
-CFLAGS="$RPM_OPT_FLAGS" perl Makefile.PL
-
-%clean
-rm -rf $RPM_BUILD_ROOT
-
-%install
-rm -rf $RPM_BUILD_ROOT
-install_dir=SPEC_INSTALLDIR
-mkdir -p $RPM_BUILD_ROOT/$installdir
-make PREFIX=$RPM_BUILD_ROOT/usr install
-
-[ -x /usr/lib/rpm/brp-compress ] && /usr/lib/rpm/brp-compress
-
-find $RPM_BUILD_ROOT/usr -type f -print |
- sed "s@^$RPM_BUILD_ROOT@@g" |
- grep -v perllocal.pod |
- grep -v "\.packlist" > SPEC_DISTNAME-SPEC_VERSION-filelist
-if [ "$(cat SPEC_DISTNAME-SPEC_VERSION-filelist)X" = "X" ] ; then
- echo "ERROR: EMPTY FILE LIST"
- exit -1
-fi
-
-%files -f SPEC_DISTNAME-SPEC_VERSION-filelist
-%defattr(-,root,root)
-
-%changelog
-* Tue Oct 10 2000 Randy J. Ray <rjray@blackperl.com>
-- Turned into a meta-file that gets filled in by MakeMaker
-
-* Tue Oct 3 2000 Jeff Johnson <jbj@redhat.com>
-- update to 0.28.
-
-* Mon Oct 2 2000 root <root@redhat.com>
-- Spec file was autogenerated.
+++ /dev/null
-Perl-RPM - Native bindings to the RPM Package Manager API for Perl
-
-Version 0.32 (alpha twelve)
-
-
-WHAT IS IT
-
-The Perl-RPM package is an attempt to provide Perl-level access to the complete
-application programming interface that is a part of the RPM Package Manager
-(RPM). Rather than have scripts rely on executing RPM commands and parse the
-resultant output, this modules aims to provide Perl programmers the ability
-to do anything that would otherwise have been done in C or C++.
-
-The interface is being designed and laid out as a collection of classes, at
-least some of which are also available as tied-hash implementations.
-
-At this time, the interface only provides access to the database of installed
-packages, and header data retrieval for RPM and SRPM files not yet installed.
-Error management and the export of most defined constants, through RPM::Error
-and RPM::Constants respectively, is also available.
-
-
-BUILDING/INSTALLING
-
-This package is set up to configure and build like a typical Perl extension.
-To build:
-
- perl Makefile.PL
- make && make test
-
-If the RPM package passes all tests, then:
-
- make install
-
-You may need super-user access to install.
-
-
-PROBLEMS/BUG REPORTS
-
-Please send any reports of problems or bugs to rjray@blackperl.com.
-
-
-MAILING LIST
-
-There is now a mailing list for Perl-RPM. For details, see:
-
- https://listman.redhat.com/mailman/listinfo/perl-rpm-list
-
-
-CHANGES
-
-This is the twelfth release. For detailed changes, see the file ChangeLog.
-The main focus of this release is to address some lingering unreferenced-scalar
-warning messages. This is in preparation for moving the CVS repository to
-the one used for the rpm project itself.
-
-
-LICENSE
-
-This package is Copyright (C) 2000 by Randy J. Ray (rjray@blackperl.com). You
-may distribute this under the terms of Artistic License, as specified in the
-README file of Perl itself. Please see the file ARTISTIC in your distribution
-of Perl.
+++ /dev/null
-/*
- * $Id: RPM.h,v 1.19 2002/05/10 05:50:19 rjray Exp $
- *
- * Various C-specific decls/includes/etc. for the RPM linkage
- */
-
-#include "EXTERN.h"
-#include "perl.h"
-#include "XSUB.h"
-
-#ifndef H_RPM_XS_HDR
-#define H_RPM_XS_HDR
-
-#ifdef Stat
-# undef Stat
-#endif
-#ifdef Mkdir
-# undef Mkdir
-#endif
-#ifdef Fstat
-# undef Fstat
-#endif
-#ifdef Fflush
-# undef Fflush
-#endif
-#ifdef Fopen
-# undef Fopen
-#endif
-
-/* Borrowed from DB_File.xs */
-#ifndef pTHX
-# define pTHX
-# define pTHX_
-# define aTHX
-# define aTHX_
-# define dTHX dTHR
-#endif
-
-#ifndef newSVpvn
-# define newSVpvn(a,b) newSVpv(a,b)
-#endif
-
-#include <rpmcli.h>
-#include <rpmlib.h>
-
-/* Various flags. For now, one nybble for header and one for package. */
-#define RPM_HEADER_MASK 0x0f
-#define RPM_HEADER_READONLY 0x01
-#define RPM_HEADER_FROM_REF 0x02
-
-#define RPM_PACKAGE_MASK 0x0f00
-#define RPM_PACKAGE_READONLY 0x0100
-#define RPM_PACKAGE_NOREAD 0x0200
-
-/*
- Use this define for deriving the saved underlying struct, rather than coding
- it a dozen places.
-*/
-#define struct_from_object_ret(type, header, object, err_ret) \
- { \
- MAGIC* mg = mg_find((SV *)(object), '~'); \
- if (mg) \
- (header) = (type *)SvIV(mg->mg_obj); \
- else \
- return (err_ret); \
- }
-/* And a no-return version: */
-#define struct_from_object(type, header, object) \
- { \
- MAGIC* mg = mg_find((SV *)(object), '~'); \
- if (mg) \
- (header) = (type *)SvIV(mg->mg_obj); \
- else \
- (header) = Null(type *); \
- }
-
-/*
- * Perl complement: RPM::Database
- */
-
-/*
- This is the underlying struct that implements the interface to the RPM
- database.
-*/
-
-typedef struct {
- rpmdb dbp;
- int current_rec;
- int noffs;
- int offx;
- int* offsets;
- /* This HV will be used to cache key/value pairs to avoid re-computing */
- HV* storage;
-} RPM_Database;
-
-typedef HV* RPM__Database;
-
-
-/*
- * Perl complement: RPM::Header
- */
-
-/*
- This is the underlying struct that implements the interface to the RPM
- headers.
-*/
-
-typedef struct {
- Header hdr;
- /* These three tags will probably cover at least 80% of data requests */
- const char* name;
- const char* version;
- const char* release;
- /* These are set by rpmReadPackageHeader when applicable */
- int isSource; /* If this header is for a source RPM (SRPM) */
- int major; /* Major and minor rev numbers of package's format */
- int minor;
- /* This HV will be used to cache key/value pairs to avoid re-computing */
- HV* storage;
- /* Keep a per-header iterator for things like FIRSTKEY and NEXTKEY */
- HeaderIterator iterator;
- int read_only;
- /* Since we close the files after reading, store the filename here in case
- we have to re-open it later */
- char* source_name;
-} RPM_Header;
-
-typedef HV* RPM__Header;
-
-
-/*
- * Perl complement: RPM::Package
- */
-
-/*
- This is the underlying struct that implements the interface to the RPM
- packages. As above, we need the actual object to be a hash, so the struct
- will be stored as an SV on the same sort of special key as RPM__Database and
- RPM__Header use.
-*/
-
-typedef struct {
- /* The filepath, ftp path or URI that refers to the package */
- char* path;
- /* A weak ref to the header structure for the package, if it exists */
- RPM__Header header;
- /* The RPM signature (if present) is stored in the same struct as hdrs */
- Header signature;
- /* Should this be treated as a read-only source? */
- int readonly;
- /* The current notify/callback function associated with this package */
- CV* callback;
- /* Any data they want to have passed to the callback */
- SV* cb_data;
-} RPM_Package;
-
-typedef RPM_Package* RPM__Package;
-
-
-/*
- These represent the various interfaces that are allowed for use outside
- their native modules.
-*/
-/* RPM.xs: */
-extern int tag2num(pTHX_ const char *);
-extern const char* num2tag(pTHX_ int);
-
-/* RPM/Error.xs: */
-extern SV* rpm_errSV;
-extern void clear_errors(pTHX);
-extern SV* set_error_callback(pTHX_ SV *);
-extern void rpm_error(pTHX_ int, const char *);
-
-/* RPM/Header.xs: */
-extern const char* sv2key(pTHX_ SV *);
-extern RPM__Header rpmhdr_TIEHASH(pTHX_ char *, SV *, int);
-extern SV* rpmhdr_FETCH(pTHX_ RPM__Header, SV *, const char *, int, int);
-extern int rpmhdr_STORE(pTHX_ RPM__Header, SV *, SV *);
-extern int rpmhdr_DELETE(pTHX_ RPM__Header, SV *);
-extern bool rpmhdr_EXISTS(pTHX_ RPM__Header, SV *);
-extern unsigned int rpmhdr_size(pTHX_ RPM__Header);
-extern int rpmhdr_tagtype(pTHX_ RPM__Header, SV *);
-extern int rpmhdr_write(pTHX_ RPM__Header, SV *, int);
-extern int rpmhdr_is_source(pTHX_ RPM__Header);
-extern int rpmhdr_cmpver(pTHX_ RPM__Header, RPM__Header);
-extern int rpmhdr_scalar_tag(pTHX_ SV*, int);
-
-/* RPM/Database.xs: */
-extern RPM__Database rpmdb_TIEHASH(pTHX_ char *, SV *);
-extern SV* rpmdb_FETCH(pTHX_ RPM__Database, SV *);
-extern bool rpmdb_EXISTS(pTHX_ RPM__Database, SV *);
-
-/* RPM/Package.xs: */
-extern RPM__Package rpmpkg_new(pTHX_ char *, SV *, int);
-extern SV* rpmpkg_set_callback(pTHX_ RPM__Package, SV *);
-extern int rpmpkg_is_source(pTHX_ RPM__Package);
-extern int rpmpkg_cmpver_pkg(pTHX_ RPM__Package, RPM__Package);
-extern int rpmpkg_cmpver_hdr(pTHX_ RPM__Package, RPM__Header);
-
-#endif /* H_RPM_XS_HDR */
+++ /dev/null
-package RPM;
-
-use 5.005;
-use strict;
-use subs qw(bootstrap_Constants bootstrap_Header bootstrap_Database);
-use vars qw($VERSION @ISA @EXPORT @EXPORT_OK);
-
-require DynaLoader;
-require Exporter;
-
-@ISA = qw(Exporter DynaLoader);
-$VERSION = do { my @r=(q$Revision: 1.17 $=~/\d+/g); sprintf "%d."."%02d"x$#r,@r };
-
-@EXPORT = qw(rpm_osname rpm_archname);
-@EXPORT_OK = (@EXPORT, 'vercmp');
-
-bootstrap RPM;
-
-# These are stubs into the sub-module bootstraps, hacked into RPM.xs
-bootstrap_Constants();
-bootstrap_Header();
-bootstrap_Database();
-bootstrap_Error();
-#bootstrap_Package($VERSION);
-
-1;
-
-###############################################################################
-#
-# Sub Name: vercmp
-#
-# Description: Compare two sets of version/release values as though they
-# were from headers.
-#
-# Arguments: NAME IN/OUT TYPE DESCRIPTION
-# $verA in scalar First version component
-# $relA in scalar First release component
-# $verB in scalar Second version component
-# $relB in scalar Second release component
-#
-# Globals: None.
-#
-# Environment: None.
-#
-# Returns: -1, 0 or 1, as a comparison operator
-#
-###############################################################################
-sub vercmp
-{
- my ($verA, $relA, $verB, $relB) = @_;
-
- require RPM::Header unless $INC{'RPM/Header.pm'};
-
- my $headA = new RPM::Header;
- my $headB = new RPM::Header;
-
- $headA->{version} = $verA;
- $headA->{release} = $relA;
- $headB->{version} = $verB;
- $headB->{release} = $relB;
-
- $headA->cmpver($headB);
-}
-
-__END__
-
-=head1 NAME
-
-RPM - Perl interface to the API for the RPM Package Manager
-
-=head1 DESCRIPTION
-
-The B<Perl-RPM> package is an extension for natively linking the
-functionality of the B<RPM Package Manager> with the extension facility of
-Perl. The aim is to offer all the functionality made available via the C
-API in the form of Perl object classes.
-
-At present, the package-manipulation functionality is not yet implemented.
-The B<RPM::Database> and B<RPM::Header> packages do provide access to the
-information contained within the database of installed packages, and
-individual package headers, respectively. The B<RPM::Error> package is
-available, which provides support routines for signaling and catching
-errors. Additionally, there is the B<RPM::Constants> package which provides
-a number of values from the B<rpm> library, referred to by the same name used
-at the C level.
-
-=head1 UTILITY FUNCTIONS
-
-The following utility functions are exported by default from B<RPM>:
-
-=over
-
-=item rpm_osname
-
-Returns the text name of the O/S, as derived from the B<rpm> configuration
-files. This is the O/S token that B<rpm> will use to refer to the running
-system.
-
-=item rpm_archname
-
-As above, but returns the architecture string instead. Again, this may not
-directly match the running system, but rather is the value that B<rpm> is
-using. B<rpm> will use the lowest-matching architecture whenever possible,
-for maximum cross-platform compatibility.
-
-=back
-
-The following utility function may be explicitly requested via B<use> or
-B<import>:
-
-=over vercmp($verA, $relA, $verB, $relB)
-
-Allows RPM-style comparison of version/release pairs without having the full
-B<RPM::Header> objects in memory. This enables programs to compare versions
-without having to worry about how RPM handles the mixture of alphanumeric
-cases that are supported internally. The return value is -1, 0 or 1, as with
-any comparison operator. This is purposefully named differently from the
-B<cmpver> method in B<RPM::Header> so as to avoid confusion.
-
-=back
-
-=head1 DIAGNOSTICS
-
-When an error occurs in either the C-level B<rpm> library or internally
-within these libraries, it is made available via a special dual-nature
-variable B<$RPM::err>. When evaluated in a numeric context, it returns the
-integer code value of the error. When taken in a string context, it returns
-the text message associated with the error. This is intended to closely
-mimic the behavior of the special Perl variable "C<$!>".
-
-=head1 CAVEATS
-
-This is currently regarded as alpha-quality software. The interface is
-subject to change in future releases.
-
-=head1 SEE ALSO
-
-L<RPM::Constants>, L<RPM::Database>, L<RPM::Error>, L<RPM::Header>,
-L<perl>, L<rpm>
-
-=head1 AUTHOR
-
-Randy J. Ray <rjray@blackperl.com>
-
-=cut
+++ /dev/null
-#include "EXTERN.h"
-#include "perl.h"
-#include "XSUB.h"
-
-#include "RPM.h"
-
-static char * const rcsid = "$Id: RPM.xs,v 1.9 2000/11/10 08:49:57 rjray Exp $";
-
-extern XS(boot_RPM__Constants);
-extern XS(boot_RPM__Header);
-extern XS(boot_RPM__Database);
-extern XS(boot_RPM__Error);
-/*extern XS(boot_RPM__Package);*/
-
-static HV* tag2num_priv;
-static HV* num2tag_priv;
-
-static void setup_tag_mappings(pTHX)
-{
- const char* tag;
- int num;
- int idx;
- char str_num[8];
-
- tag2num_priv = perl_get_hv("RPM::tag2num", TRUE);
- num2tag_priv = perl_get_hv("RPM::num2tag", TRUE);
- for (idx = 0; idx < rpmTagTableSize; idx++)
- {
- /*
- For future reference: The offset of 7 used in referring to the
- (const char *) tag and its length is to discard the "RPMTAG_"
- prefix inherent in the tag names.
- */
- tag = rpmTagTable[idx].name;
- num = rpmTagTable[idx].val;
- hv_store(tag2num_priv, (char *)tag + 7, strlen(tag) - 7,
- newSViv(num), FALSE);
- Zero(str_num, 1, 8);
- snprintf(str_num, 8, "%d", num);
- hv_store(num2tag_priv, str_num, strlen(str_num),
- newSVpv((char *)tag + 7, strlen(tag) - 7), FALSE);
- }
-}
-
-int tag2num(pTHX_ const char* tag)
-{
- SV** svp;
-
- /* Get the #define value for the tag from the hash made at boot-up */
- svp = hv_fetch(tag2num_priv, (char *)tag, strlen(tag), FALSE);
- if (! (svp && SvOK(*svp) && SvIOK(*svp)))
- /* Later we may need to set some sort of error message */
- return 0;
-
- return (SvIV(*svp));
-}
-
-const char* num2tag(pTHX_ int num)
-{
- SV** svp;
- char str_num[8];
-
- Zero(str_num, 1, 8);
- snprintf(str_num, 8, "%d", num);
- svp = hv_fetch(num2tag_priv, str_num, strlen(str_num), FALSE);
- if (! (svp && SvPOK(*svp)))
- return Nullch;
-
- return (SvPV(*svp, PL_na));
-}
-
-char* rpm_rpm_osname(void)
-{
- char* os_name;
- int os_val;
-
- rpmGetOsInfo((const char **)&os_name, &os_val);
- return os_name;
-}
-
-char* rpm_rpm_archname(void)
-{
- char* arch_name;
- int arch_val;
-
- rpmGetArchInfo((const char **)&arch_name, &arch_val);
- return arch_name;
-}
-
-MODULE = RPM PACKAGE = RPM PREFIX = rpm_
-
-
-char*
-rpm_rpm_osname()
- PROTOTYPE:
-
-char*
-rpm_rpm_archname()
- PROTOTYPE:
-
-
-BOOT:
-{
- SV * config_loaded;
-
- config_loaded = perl_get_sv("RPM::__config_loaded", GV_ADD|GV_ADDMULTI);
- if (! (SvOK(config_loaded) && SvTRUE(config_loaded)))
- {
- rpmReadConfigFiles(NULL, NULL);
- sv_setiv(config_loaded, TRUE);
- }
-
- setup_tag_mappings(aTHX);
-
- newXS("RPM::bootstrap_Constants", boot_RPM__Constants, file);
- newXS("RPM::bootstrap_Header", boot_RPM__Header, file);
- newXS("RPM::bootstrap_Database", boot_RPM__Database, file);
- newXS("RPM::bootstrap_Error", boot_RPM__Error, file);
- /*newXS("RPM::bootstrap_Package", boot_RPM__Package, file);*/
-}
+++ /dev/null
-###############################################################################
-#
-# (c) Copyright @ 2000, Randy J. Ray <rjray@blackperl.com>
-# All Rights Reserved
-#
-###############################################################################
-#
-# $Id: Constants.pm,v 1.18 2001/04/27 09:05:21 rjray Exp $
-#
-# Description: Constants for the RPM package
-#
-# Functions: None-- constants are implemented as pseudo-functions
-#
-# Libraries: RPM (to force bootstrapping)
-#
-###############################################################################
-
-package RPM::Constants;
-
-use strict;
-use vars qw(@ISA @EXPORT_OK %EXPORT_TAGS $VERSION $AUTOLOAD);
-
-require Exporter;
-
-use RPM;
-
-@ISA = qw(Exporter);
-
-$VERSION = do { my @r=(q$Revision: 1.18 $=~/\d+/g); sprintf "%d."."%02d"x$#r,@r };
-
-@EXPORT_OK = qw(
- CHECKSIG_GPG
- CHECKSIG_MD5
- CHECKSIG_PGP
- INSTALL_HASH
- INSTALL_LABEL
- INSTALL_NODEPS
- INSTALL_NOORDER
- INSTALL_PERCENT
- INSTALL_UPGRADE
- QUERY_FOR_CONFIG
- QUERY_FOR_DOCS
- QUERY_FOR_DUMPFILES
- QUERY_FOR_LIST
- QUERY_FOR_STATE
- RPM_NULL_TYPE
- RPM_CHAR_TYPE
- RPM_INT8_TYPE
- RPM_INT16_TYPE
- RPM_INT32_TYPE
- RPM_STRING_TYPE
- RPM_BIN_TYPE
- RPM_STRING_ARRAY_TYPE
- RPM_I18NSTRING_TYPE
- RPMERR_BADARG
- RPMERR_BADDEV
- RPMERR_BADFILENAME
- RPMERR_BADMAGIC
- RPMERR_BADRELOCATE
- RPMERR_BADSIGTYPE
- RPMERR_BADSPEC
- RPMERR_CHOWN
- RPMERR_CPIO
- RPMERR_CREATE
- RPMERR_DBCORRUPT
- RPMERR_DBGETINDEX
- RPMERR_DBOPEN
- RPMERR_DBPUTINDEX
- RPMERR_EXEC
- RPMERR_FILECONFLICT
- RPMERR_FLOCK
- RPMERR_FORK
- RPMERR_GDBMOPEN
- RPMERR_GDBMREAD
- RPMERR_GDBMWRITE
- RPMERR_GZIP
- RPMERR_INTERNAL
- RPMERR_LDD
- RPMERR_MKDIR
- RPMERR_MTAB
- RPMERR_NEWPACKAGE
- RPMERR_NOCREATEDB
- RPMERR_NOGROUP
- RPMERR_NORELOCATE
- RPMERR_NOSPACE
- RPMERR_NOSPEC
- RPMERR_NOTSRPM
- RPMERR_NOUSER
- RPMERR_OLDDB
- RPMERR_OLDDBCORRUPT
- RPMERR_OLDDBMISSING
- RPMERR_OLDPACKAGE
- RPMERR_PKGINSTALLED
- RPMERR_READERROR
- RPMERR_RENAME
- RPMERR_RMDIR
- RPMERR_RPMRC
- RPMERR_SCRIPT
- RPMERR_SIGGEN
- RPMERR_STAT
- RPMERR_UNKNOWNARCH
- RPMERR_UNKNOWNOS
- RPMERR_UNLINK
- RPMERR_UNMATCHEDIF
- RPMFILE_CONFIG
- RPMFILE_DOC
- RPMFILE_DONOTUSE
- RPMFILE_GHOST
- RPMFILE_LICENSE
- RPMFILE_MISSINGOK
- RPMFILE_NOREPLACE
- RPMFILE_README
- RPMFILE_SPECFILE
- RPMFILE_STATE_NETSHARED
- RPMFILE_STATE_NORMAL
- RPMFILE_STATE_NOTINSTALLED
- RPMFILE_STATE_REPLACED
- RPMPROB_FILTER_DISKSPACE
- RPMPROB_FILTER_FORCERELOCATE
- RPMPROB_FILTER_IGNOREARCH
- RPMPROB_FILTER_IGNOREOS
- RPMPROB_FILTER_OLDPACKAGE
- RPMPROB_FILTER_REPLACENEWFILES
- RPMPROB_FILTER_REPLACEOLDFILES
- RPMPROB_FILTER_REPLACEPKG
- RPMSENSE_EQUAL
- RPMSENSE_GREATER
- RPMSENSE_LESS
- RPMSENSE_OBSOLETES
- RPMSENSE_PREREQ
- RPMSENSE_SENSEMASK
- RPMSENSE_TRIGGER
- RPMSENSE_TRIGGERIN
- RPMSENSE_TRIGGERPOSTUN
- RPMSENSE_TRIGGERUN
- RPMSIGTAG_GPG
- RPMSIGTAG_LEMD5_1
- RPMSIGTAG_LEMD5_2
- RPMSIGTAG_MD5
- RPMSIGTAG_PGP
- RPMSIGTAG_PGP5
- RPMSIGTAG_SIZE
- RPMSIG_BAD
- RPMSIG_NOKEY
- RPMSIG_NOTTRUSTED
- RPMSIG_OK
- RPMSIG_UNKNOWN
- RPMTAG_ARCH
- RPMTAG_ARCHIVESIZE
- RPMTAG_BASENAMES
- RPMTAG_BUILDARCHS
- RPMTAG_BUILDHOST
- RPMTAG_BUILDMACROS
- RPMTAG_BUILDROOT
- RPMTAG_BUILDTIME
- RPMTAG_CAPABILITY
- RPMTAG_CHANGELOGNAME
- RPMTAG_CHANGELOGTEXT
- RPMTAG_CHANGELOGTIME
- RPMTAG_CONFLICTFLAGS
- RPMTAG_CONFLICTNAME
- RPMTAG_CONFLICTVERSION
- RPMTAG_COPYRIGHT
- RPMTAG_COOKIE
- RPMTAG_DESCRIPTION
- RPMTAG_DIRINDEXES
- RPMTAG_DIRNAMES
- RPMTAG_DISTRIBUTION
- RPMTAG_EXCLUDEARCH
- RPMTAG_EXCLUDEOS
- RPMTAG_EXCLUSIVEARCH
- RPMTAG_EXCLUSIVEOS
- RPMTAG_FILEDEVICES
- RPMTAG_FILEFLAGS
- RPMTAG_FILEGROUPNAME
- RPMTAG_FILEINODES
- RPMTAG_FILELANGS
- RPMTAG_FILELINKTOS
- RPMTAG_FILEMD5S
- RPMTAG_FILEMODES
- RPMTAG_FILEMTIMES
- RPMTAG_FILERDEVS
- RPMTAG_FILESIZES
- RPMTAG_FILESTATES
- RPMTAG_FILEUSERNAME
- RPMTAG_FILEVERIFYFLAGS
- RPMTAG_GIF
- RPMTAG_GROUP
- RPMTAG_ICON
- RPMTAG_INSTALLTIME
- RPMTAG_INSTPREFIXES
- RPMTAG_LICENSE
- RPMTAG_NOPATCH
- RPMTAG_NOSOURCE
- RPMTAG_NAME
- RPMTAG_OBSOLETEFLAGS
- RPMTAG_OBSOLETENAME
- RPMTAG_OBSOLETEVERSION
- RPMTAG_OS
- RPMTAG_PACKAGER
- RPMTAG_PATCH
- RPMTAG_POSTIN
- RPMTAG_POSTINPROG
- RPMTAG_POSTUN
- RPMTAG_POSTUNPROG
- RPMTAG_PREFIXES
- RPMTAG_PREIN
- RPMTAG_PREINPROG
- RPMTAG_PREUN
- RPMTAG_PREUNPROG
- RPMTAG_PROVIDEFLAGS
- RPMTAG_PROVIDENAME
- RPMTAG_PROVIDEVERSION
- RPMTAG_RELEASE
- RPMTAG_REQUIREFLAGS
- RPMTAG_REQUIRENAME
- RPMTAG_REQUIREVERSION
- RPMTAG_RPMVERSION
- RPMTAG_SIZE
- RPMTAG_SOURCE
- RPMTAG_SOURCERPM
- RPMTAG_SUMMARY
- RPMTAG_TRIGGERCONDS
- RPMTAG_TRIGGERFLAGS
- RPMTAG_TRIGGERINDEX
- RPMTAG_TRIGGERNAME
- RPMTAG_TRIGGERSCRIPTPROG
- RPMTAG_TRIGGERSCRIPTS
- RPMTAG_TRIGGERVERSION
- RPMTAG_URL
- RPMTAG_VENDOR
- RPMTAG_VERIFYSCRIPT
- RPMTAG_VERIFYSCRIPTPROG
- RPMTAG_VERSION
- RPMTAG_XPM
- RPMTRANS_FLAG_ALLFILES
- RPMTRANS_FLAG_BUILD_PROBS
- RPMTRANS_FLAG_JUSTDB
- RPMTRANS_FLAG_KEEPOBSOLETE
- RPMTRANS_FLAG_NODOCS
- RPMTRANS_FLAG_NOSCRIPTS
- RPMTRANS_FLAG_NOTRIGGERS
- RPMTRANS_FLAG_TEST
- RPMVERIFY_ALL
- RPMVERIFY_FILESIZE
- RPMVERIFY_GROUP
- RPMVERIFY_LINKTO
- RPMVERIFY_LSTATFAIL
- RPMVERIFY_MD5
- RPMVERIFY_MODE
- RPMVERIFY_MTIME
- RPMVERIFY_NONE
- RPMVERIFY_RDEV
- RPMVERIFY_READFAIL
- RPMVERIFY_READLINKFAIL
- RPMVERIFY_USER
- UNINSTALL_ALLMATCHES
- UNINSTALL_NODEPS
- VERIFY_DEPS
- VERIFY_FILES
- VERIFY_MD5
- VERIFY_SCRIPT
- );
-
-#
-# To create the %EXPORT_TAGS table, we're going to create a temp hash with
-# the tags broken down into groupings. Then when the "known" groupings are
-# done, whatever is left can go in "misc"
-#
-my %groups = ();
-my %consts = map { $_, 1 } @EXPORT_OK;
-for my $group (qw(install query rpmerr rpmfile rpmlead rpmmess rpmprob_filter
- rpmsense rpmsigtag rpmsig rpmtag rpmtrans_flag
- rpmverify uninstall verify))
-{
- my $pat = qr/^$group/i;
- my $list = [];
-
- for (grep($_ =~ $pat, sort keys %consts))
- {
- push(@$list, $_);
- delete $consts{$_};
- }
-
- $groups{$group} = $list;
-}
-
-# Types didn't fit neatly into the above logic-loop
-$groups{rpmtype} = [];
-for (grep($_ =~ /^RPM_.*_TYPE/, sort keys %consts))
-{
- push(@{$groups{rpmtype}}, $_);
- delete $consts{$_};
-}
-
-# Pick up any stragglers
-$groups{misc} = [ sort keys %consts ];
-
-# Merge the install and uninstall groups
-push(@{$groups{install}}, @{$groups{uninstall}});
-delete $groups{uninstall};
-
-%EXPORT_TAGS = (
- all => [ @EXPORT_OK ],
- %groups
- );
-
-sub AUTOLOAD
-{
- my $constname;
- ($constname = $AUTOLOAD) =~ s/.*:://;
- die "& not defined" if $constname eq 'constant';
- my $val = constant($constname);
- if ($! != 0)
- {
- die "Your vendor has not defined RPM macro $constname";
- }
- no strict 'refs';
- *$AUTOLOAD = sub { $val };
- goto &$AUTOLOAD;
-}
-
-1;
-
-__END__
-
-=head1 NAME
-
-RPM::Constants - Groups of RPM-defined symbols
-
-=head1 SYNOPSIS
-
- use RPM::Constants qw(:rpmerr :rpmtype);
-
-=head1 DESCRIPTION
-
-This package is a collection of the constants defined by B<rpm> itself that
-may be of use to those developing with the B<RPM> Perl bindings.
-
-=head1 GROUPS
-
-For ease of use and uderstanding (at last count, the total number of
-constants was 232), the constants are broken up into several smaller groups:
-
-=head2 Header Tag Identifiers
-
-The following symbols may be imported via the tag B<:rpmtag>, and represent
-the various elements that may be present in a package header. When used to
-retrieve data from a header as a hash key, the C<RPMTAG_> portion should be
-omitted from the name. Use the full name only when referring to the constant.
-Note that each name is followed by either a C<$> or a C<@>. This signifies
-the return type of the data; a scalar or an array reference. In all cases, a
-failed operation is noted by a return value of C<undef>.
-
-The majority of the tags that return list references in fact refer to the
-ordered list of files present in the C<BASENAMES> tag. In these cases (such
-as C<MD5SUMS>), the value of the array at a given point may be null if it
-is not relevant. That is because the C<BASENAMES> array (and thus all other
-file-related lists) must accomodate the indices at which a directory name is
-specified for the sake of defining the directory. In such cases, values such
-as size or MD5 checksum have no direct relevance.
-
-=over
-
-=item RPMTAG_ARCH ($)
-
-Name of the architecture that the package was built for. If the package
-is architecture-independant, the value should read "noarch".
-
-=item RPMTAG_ARCHIVESIZE ($)
-
-Size of the archive portion of the file. B<RPM> stores the archive portion
-of a (non-source) package as a B<cpio> archive, which may also be compressed
-internally. Thus, this value is generally larger than the file size of the
-C<RPM> file itself.
-
-=item RPMTAG_BASENAMES (@)
-
-A list of the base (leaf) names of the files contained within the package.
-These are combined with the values from B<RPMTAG_DIRNAMES> using a mapping
-provided by B<RPMTAG_DIRINDEXES>.
-
-This is actually a very key tag within a header. Many of the list-returning
-tags documented further down maintain a one-to-one correlation with the
-elements in this array.
-
-=item RPMTAG_BUILDARCHS (@)
-
-Not entirely sure. Appears from source code examples to be a list of those
-architectures for which a package should be built. All examples from the set
-of SRPMs in Red Hat Linux 6.2 only use this tag when the only value is
-C<noarch>.
-
-=item RPMTAG_BUILDHOST ($)
-
-Name of the host the package was built on.
-
-=item RPMTAG_BUILDMACROS (@)
-
-This does not seem to be used in the library. It may be present for future
-expansion use.
-
-=item RPMTAG_BUILDROOT ($)
-
-Specifies the root at which the package is built.
-
-=item RPMTAG_BUILDTIME ($)
-
-The time/date when the package was created, expressed as a C<time()> value
-(seconds since the epoch).
-
-=item RPMTAG_CHANGELOGNAME (@)
-
-=item RPMTAG_CHANGELOGTEXT (@)
-
-=item RPMTAG_CHANGELOGTIME (@)
-
-These three items should be taken together. Each should have the same number
-of items, and the items at corresponding indices should be taken together.
-Taken this way, they provide a small-scale changelog for the package, detailing
-the name of the person making the entry, the text of the entry and the time
-of the entry, in the respective order given above.
-
-=item RPMTAG_CONFLICTFLAGS (@)
-
-=item RPMTAG_CONFLICTNAME (@)
-
-=item RPMTAG_CONFLICTVERSION (@)
-
-These three items are used in conjunction to specify packages and/or
-individual files which the package itself would conflict with. Of the three,
-only B<RPMTAG_CONFLICTNAME> is required to have data in all elements of
-the array. The other two will have the same number of elements, though some
-(or most) may be null. This is the same approach as is used to specify the
-elements that the package obsoletes, those the package provides and those
-the package requires (see L<"Three-Part Linkage"> below).
-
-=item RPMTAG_COPYRIGHT
-
-Maintained by RPM for backwards-compatibility with some older packages. It
-is the same as C<RPMTAG_LICENSE>.
-
-=item RPMTAG_COOKIE ($)
-
-A simple tag, a single text string, added at the time the RPM is created.
-Generally, it is created from the hostname on which the package is built
-and the UNIX C<time()> value at the time of packaging.
-
-=item RPMTAG_DESCRIPTION ($)
-
-A textual description of the package.
-
-=item RPMTAG_DIRINDEXES (@)
-
-This data should have a one-to-one correspondance with B<RPMTAG_BASENAMES>,
-above. Each item here is a numerical index into the list of directories named
-in B<RPMTAG_DIRNAMES> below. It indicates which of the directories is to be
-prepended to the corresponding base file name in order to create the full
-pathname.
-
-=item RPMTAG_DIRNAMES (@)
-
-This is a list of all directories into which the package would install files.
-This list is used with B<RPMTAG_BASENAMES> to create full paths, indexed by
-way of B<RPMTAG_DIRINDEXES> above.
-
-=item RPMTAG_DISTRIBUTION ($)
-
-A text label identifying the name given to the overall larger distribution
-the package itself is a part of.
-
-=item RPMTAG_EXCLUDEARCH (@)
-
-A list of architectures for which the package should not be built.
-
-=item RPMTAG_EXCLUDEOS (@)
-
-A list of operating systems for which the package should not be built.
-
-=item RPMTAG_EXCLUSIVEARCH (@)
-
-A list of architectures only for which the package should be built.
-
-=item RPMTAG_EXCLUSIVEOS (@)
-
-A list of operating systems only for which the package should be built.
-
-=item RPMTAG_FILEDEVICES (@)
-
-The integer device values (from the B<stat> system call) for each file in
-the package.
-
-=item RPMTAG_FILEFLAGS (@)
-
-A bit-field with zero or more of the flags defined below under the heading
-of I<rpmfile>. See the flags themselves for more detail.
-
-=item RPMTAG_FILEGROUPNAME (@)
-
-A string-array data field that contains the group ID (by name) that should
-be used for setting group ownership of the files contained in the package.
-There should be a one-to-one correspondance between this list and the list of
-files in C<RPMTAG_BASENAMES>. See also C<RPMTAG_USERNAME>.
-
-=item RPMTAG_FILEINODES (@)
-
-The C<inode> (from the B<stat> system call) that each file in
-the package had on the system on which the package was built.
-
-=item RPMTAG_FILELANGS (@)
-
-Used to specify language-specific files, which may then be marked for skipping
-based on the list of accepted languages at install-time.
-
-=item RPMTAG_FILELINKTOS (@)
-
-A list of names with exactly as many elements as there are filenames; each
-slot in this list is either empty, or (if not) gives the name of a file that
-the current filename should be made as a symbolic link to.
-
-=item RPMTAG_FILEMD5S (@)
-
-MD5 checksums for each file in the package.
-
-=item RPMTAG_FILEMODES (@)
-
-The file-modes as integer values, for each file in the package.
-
-=item RPMTAG_FILEMTIMES (@)
-
-The integer modification-time (from the B<stat> system call) for each file in
-the package.
-
-=item RPMTAG_FILERDEVS (@)
-
-The integer C<rdev> values (from the B<stat> system call) for each file in
-the package.
-
-=item RPMTAG_FILESIZES (@)
-
-The size (in bytes) of each file in the package.
-
-=item RPMTAG_FILESTATES (@)
-
-A list of file-state information for each file in the package. References
-the constants defined below under the heading of C<rpmfile_states>.
-
-=item RPMTAG_FILEUSERNAME (@)
-
-A string-array data field that contains the user ID (by name) that should
-be used for setting ownership of the files contained in the package. There
-should be a one-to-one correspondance between this list and the list of
-files in C<RPMTAG_BASENAMES>. See also C<RPMTAG_GROUPNAME>.
-
-=item RPMTAG_FILEVERIFYFLAGS (@)
-
-A list of flags (implemented as a bit-field within an integer) for each file
-in the archive, specifying what should be checked during the verification
-stage. See the B<RPMVERIFY_*> constants below.
-
-=item RPMTAG_GIF ($)
-
-Similar to B<RPMTAG_ICON> defined below, with the restriction that the file
-specified should in fact be a GIF image.
-
-=item RPMTAG_GROUP ($)
-
-A one-line text string that places the package within the overall hierarchy
-of packages, using a UNIX-style format of denoting level with forward-slash
-characters (C</>). Most packages will have at least two elements separated by
-one such slash, though more are possible (as is a top-level name).
-
-=item RPMTAG_ICON ($)
-
-Specifies a file within a source-RPM (SRPM) that should be treated as an icon
-(of either GIF or XPM format), for potential use by GUI-based RPM tools.
-See C<RPMTAG_XPM> below and C<RPMTAG_GIF> above.
-
-=item RPMTAG_INSTALLTIME ($)
-
-The time at which the package was installed on your system. Should only be
-present in header objects from the database, not from uninstalled packages.
-
-=item RPMTAG_INSTPREFIXES (@)
-
-Specifies one or more prefixes that are set to the environment variables,
-C<RPM_INSTALL_PREFIX{n}>, where C<{n}> is a number starting from zero. These
-are set before executing any of the scripts (pre- or post-install, or verify).
-
-=item RPMTAG_LICENSE ($)
-
-The license and/or restrictions under which the package is distributed.
-
-=item RPMTAG_NAME ($)
-
-The name of the package. This is the first part of a triple used to uniquely
-identify a given package. It is used in conjunction with B<RPMTAG_VERSION>
-and B<RPMTAG_RELEASE>, in that order.
-
-=item RPMTAG_NOPATCH (@)
-
-=item RPMTAG_NOSOURCE (@)
-
-These are used to list elements that should not be included in the resulting
-SRPM when it is built from a spec-file. The lists provided by the B<SOURCE>
-and B<PATCH> tags provide all elements as itemized in the spec-file. However,
-if either of these tags are also present, then some elements may not actually
-exist in the package. Both of these refer to entries in the corresponding
-list of names by numberical index (starting at 0).
-
-=item RPMTAG_OBSOLETEFLAGS (@)
-
-=item RPMTAG_OBSOLETENAME (@)
-
-=item RPMTAG_OBSOLETEVERSION (@)
-
-These three items are used in conjunction to specify packages and/or
-individual files which the package itself obsoletes. Of the three, only
-B<RPMTAG_OBSOLETENAME> is required to have data in all elements of the array.
-The other two will have the same number of elements, though some (or most)
-may be null. This is the same approach as is used to specify the elements
-that the package conflicts with, those the package provides and those the
-package requires (see L<"Three-Part Linkage"> below).
-
-=item RPMTAG_OS ($)
-
-The name of the O/S for which the package is intended.
-
-=item RPMTAG_PACKAGER ($)
-
-Name of the group/company/individual who built the package.
-
-=item RPMTAG_PATCH (@)
-
-A list of patch files (see L<patch>) that will be applied to the source tree
-when building the package from a source-RPM (SRPM). These files are part of
-the bundle in the SRPM. All patch files listed in the original spec are listed
-here, even if some were excluded by the B<NOPATCH> tag defined earlier.
-
-=item RPMTAG_POSTIN (@)
-
-Post-installation scripts, each entry in the list holds the text for a full
-script.
-
-=item RPMTAG_POSTINPROG (@)
-
-The program (and additional arguments) for executing post-installation scripts.
-The default is B</bin/sh> with no arguments. This is much like the C argv/argc
-pair, in that list subscript 0 represents the program itself while the
-remaining list items (if any) are arguments to the program.
-
-=item RPMTAG_POSTUN (@)
-
-Post-uninstallation scripts, again with one full script per array item.
-
-=item RPMTAG_POSTUNPROG (@)
-
-Specification of the program to run post-uninstallation scripts. See
-B<RPMTAG_POSTINPROG>.
-
-=item RPMTAG_PREFIXES (@)
-
-The list of directory prefixes under which files are (or will be) installed.
-This differs from the B<DIRNAMES> tag in that it is used to specify the parts
-of the filesystem affected. Thus, it is generally a shorter list and the
-elements are more basic (three directories under C</usr> in B<DIRNAMES> will
-only warrant a mention of C</usr> in this tag).
-
-=item RPMTAG_PREIN (@)
-
-=item RPMTAG_PREINPROG (@)
-
-=item RPMTAG_PREUN (@)
-
-=item RPMTAG_PREUNPROG (@)
-
-Specification of the scripts and commands to use in executing them, for
-pre-installation and pre-uninstallation. See the B<RPMTAG_POST*> set above.
-
-=item RPMTAG_PROVIDEFLAGS (@)
-
-=item RPMTAG_PROVIDENAME (@)
-
-=item RPMTAG_PROVIDEVERSION (@)
-
-These three items are used in conjunction to specify the specific files that
-the package itself provides to other packages as possible dependancies. Of the
-three, only B<RPMTAG_PROVIDENAME> is required to have data in all elements
-of the array. The other two will have the same number of elements, though
-some (or most) may be null. This three-part specification is also used to
-itemize dependancies and obsoletions (see L<"Three-Part Linkage">).
-
-=item RPMTAG_RELEASE ($)
-
-The release part of the identifying triple for a package. This is combined
-with the B<RPMTAG_NAME> and B<RPMTAG_VERSION> tags to create a unique
-identification for each package.
-
-=item RPMTAG_REQUIREFLAGS (@)
-
-=item RPMTAG_REQUIRENAME (@)
-
-=item RPMTAG_REQUIREVERSION (@)
-
-These three items are used in conjunction to specify packages and/or
-individual files on which the package itself depends. Of the three, only
-B<RPMTAG_REQUIRENAME> is required to have data in all elements of the array.
-The other two will have the same number of elements, though some (or most)
-may be null. This is the same approach as is used to specify the elements
-that the package provides and those the package obsoletes (see
-L<"Three-Part Linkage">).
-
-=item RPMTAG_RPMVERSION ($)
-
-The version of B<rpm> used when bundling the package.
-
-=item RPMTAG_SIZE ($)
-
-Total size of the package contents, the sum of individual file sizes.
-
-=item RPMTAG_SOURCE (@)
-
-A list of the source files that are present in the SRPM package. All files
-listed here will be placed in the relevant C<SOURCES> directory when building
-from this SRPM. All source files listed in the original spec are listed here,
-even if some were excluded by the B<NOSOURCE> tag defined earlier.
-
-=item RPMTAG_SOURCERPM ($)
-
-The source-RPM (SRPM) file used to build this package. If the file being
-queried is itself a source-RPM, this tag will be non-existent or null in
-value.
-
-=item RPMTAG_SUMMARY ($)
-
-A one line summary description of the package.
-
-=item RPMTAG_TRIGGERCONDS (@)
-
-=item RPMTAG_TRIGGERFLAGS (@)
-
-=item RPMTAG_TRIGGERINDEX (@)
-
-=item RPMTAG_TRIGGERNAME (@)
-
-=item RPMTAG_TRIGGERSCRIPTPROG (@)
-
-=item RPMTAG_TRIGGERSCRIPTS (@)
-
-=item RPMTAG_TRIGGERVERSION (@)
-
-These items are all taken together to manage the trigger functionality and
-mechanism of the RPM package. This is covered in greater depth in a later
-section (see L<"The Trigger Specifications">).
-
-=item RPMTAG_URL ($)
-
-A Uniform Resource Locator (generally a WWW page) for the vendor/individual
-or for the software project itself.
-
-=item RPMTAG_VENDOR ($)
-
-An alternate identifier for the company that created and provided the package.
-
-=item RPMTAG_VERIFYSCRIPT (@)
-
-Scripts to be run during the verification stage. As with other script-providing
-tags, each array element contains one full script.
-
-=item RPMTAG_VERIFYSCRIPTPROG (@)
-
-The program (and arguments) that is to be used in executing the verification
-scripts. If absent or empty, C</bin/sh> with no arguments is used.
-
-=item RPMTAG_VERSION ($)
-
-The package version, the second part (with B<RPMTAG_NAME> and
-B<RPMTAG_RELEASE>) of the triple used to uniquely identify packages.
-
-=item RPMTAG_XPM ($)
-
-The name of a file in the SRPM that may be used as an icon by a GUI-based
-tool. This differs from B<RPMTAG_ICON> above in that it implies that the file
-is specifically a XPM format image.
-
-=back
-
-=head2 Three-Part Linkage
-
-There are several groupings of tags that are used to specify a linkage of
-some sort, often external in nature. These triple-tags consist of a list of
-textual names, a list of corresponding versions and a list of flag fields.
-Of the three, only the list of names is required to have data in every
-element. The other two lists will have the same number of elements, however.
-The version values are only applied when the corresponding name refers to
-another RPM package.
-
-When a version is specified, the corresponding package may need to be
-logically equal to, less than (older than) or greater (newer) than the
-version as specified. This is signified in the corresponding flags field
-for the triple. The flags documented later (see L<"Dependancy Sense Flags">)
-can be used to determine the specific relationship.
-
-=head2 The Trigger Specifications
-
-The concept of trigger scripts was added into RPM from version 3.0 onwards.
-It provides a powerful and flexible (if delicate and tricky) mechanism by
-which packages may be sensitive to the installation, un-installation or
-upgrade of other packages. In C<RPM::Header> terms, triggers are managed
-through a combination of seven different header tags.
-
-Firstly, the tags C<RPMTAG_TRIGGERSCRIPTS> and C<RPMTAG_TRIGGERSCRIPTPROG>
-behave in the same fashion as similar tags for other script specifications.
-All the triggers are stored on the B<TRIGGERSCRIPTS> tag, with each script
-stored as one contiguous string. The B<TRIGGERSCRIPTPROG> array will specify
-the program (and optional additional arguments) if the program is anything
-other than C</bin/sh> (with no arguments).
-
-The C<RPMTAG_TRIGGERNAME> and C<RPMTAG_TRIGGERVERSION> lists are used to
-specify the packages that a given trigger is sensitive to. The name refers
-to the package name (as RPM knows it to be), while the version (if specified)
-further narrows the dependancy. The C<RPMTAG_TRIGGERCONDS> tag appears to be
-present for future use, but the C<RPMTAG_TRIGGERFLAGS> is used as similarly-
-named tags are for other script specifiers. In addition to the usual relative
-comparison flags, these will also have some trigger-specific flags that
-identify the trigger as being attached to an install, un-install or upgrade.
-See L<"Dependancy Sense Flags">.
-
-Lastly, the C<RPMTAG_TRIGGERINDEX> list is used to associate a given trigger
-entry (in the B<TRIGGERNAME> list) with a particular script from the
-B<TRIGGERSCRIPTS> list. This is to optimize storage, as the likelihood exists
-that a given script may be re-used for more than one trigger.
-
-The tags C<RPMTAG_TRIGGERNAME>, C<RPMTAG_TRIGGERVERSION>,
-C<RPMTAG_TRIGGERFLAGS> and C<RPMTAG_TRIGGERINDEX> must all have the same
-number of elements.
-
-=head2 Dependancy Sense Flags
-
-The following values may be imported via the tag B<:rpmsense>, and are
-used with the flags values from various triple-tag combinations, to establish
-the nature of the requirement relationship. In the paragraphs below, The C<*>
-refers to any of B<REQUIRE>, B<OBSOLETE>, B<PROVIDE> or B<CONFLICT>. The
-trigger-related flags have different uses than the rest of the B<:rpmsense>
-set, though they may also make use of the flags for version comparison.
-
-=over
-
-=item RPMSENSE_SENSEMASK
-
-This is a mask that, when applied to a value from B<RPMTAG_*FLAGS>,
-masks out all bits except for the following three values:
-
-=item RPMSENSE_EQUAL
-
-=item RPMSENSE_GREATER
-
-=item RPMSENSE_LESS
-
-These values are used to check the corresponding entries from
-B<RPMTAG_*NAME> and B<RPMTAG_*VERSION>, and specify whether
-the existing file should be of a version equal to, greater than or less than
-the version specified. More than one flag may be present.
-
-=item RPMSENSE_PREREQ
-
-The corresponding item from B<RPMTAG_*NAME> is a simple pre-requisite,
-generally without specific version checking.
-
-=item RPMSENSE_TRIGGER
-
-A mask value that will isolate the trigger flags below from any other data
-in the flag field.
-
-=item RPMSENSE_TRIGGERIN
-
-The corresponding trigger is an installation trigger.
-
-=item RPMSENSE_TRIGGERUN
-
-The corresponding trigger is an uninstallation trigger.
-
-=item RPMSENSE_TRIGGERPOSTUN
-
-The corresponding trigger is a post-uninstallation trigger.
-
-=back
-
-=head2 Header Data Types
-
-The following symbols may be imported via the tag B<:rpmtype>, and represent
-the different types of which the various header tags (described above) may
-return data:
-
-=over
-
-=item RPM_NULL_TYPE
-
-This is used internally by the C-level B<rpm> library.
-
-=item RPM_CHAR_TYPE
-
-This type represents single-character data.
-
-=item RPM_INT8_TYPE
-
-All items of this type are 8-bit integers.
-
-=item RPM_INT16_TYPE
-
-This type represents 16-bit integers.
-
-=item RPM_INT32_TYPE
-
-This type represents 32-bit integers.
-
-=item RPM_BIN_TYPE
-
-Data of this type represents a chunk of binary data without any further
-decoding or translation. It is stored as a string in Perl terms, and the
-C<length> keyword should return the size of the chunk.
-
-=item RPM_STRING_TYPE
-
-=item RPM_STRING_ARRAY_TYPE
-
-=item RPM_I18NSTRING_TYPE
-
-These data types represent strings of text. Each are stored and treated the
-same internally by Perl.
-
-=back
-
-=head2 Error Codes
-
-The following symbols may be imported via the tag B<:rpmerr>. They represent
-the set of pre-defined error conditions that the B<rpm> system anticipates
-as possibly occuring:
-
-=over
-
-=item RPMERR_BADARG
-
-This is the most common error type used within the Perl RPM bindings. It is
-used here to indicate bad or missing data in method calls.
-
-=item RPMERR_BADDEV
-
-Signaled when a file in the contents list is a bad or unknown device type.
-
-=item RPMERR_BADFILENAME
-
-This error signifies that RPM was unable to generate a filename, or that a
-filename that RPM tried to use led to an error.
-
-=item RPMERR_BADMAGIC
-
-Signaled whenever an attempt to read the lead-in of the header (the "file magic"
-information) fails. May be due either to bad data in that part, or an I/O
-failure in reading the data itself.
-
-=item RPMERR_BADRELOCATE
-
-An error with the relocation specifications in the spec file.
-
-=item RPMERR_BADSIGTYPE
-
-Signals that an older, obsoleted style of signature was detected.
-
-=item RPMERR_BADSPEC
-
-General errors in the parsing or processing of the spec file.
-
-=item RPMERR_CHOWN
-
-An error occured in using the B<chown> system call.
-
-=item RPMERR_CPIO
-
-Errors that may occur when using B<cpio> to either package or unpack the source.
-
-=item RPMERR_CREATE
-
-This is signaled when RPM cannot create a directory or file.
-
-=item RPMERR_DBCORRUPT
-
-Signaled for consistency errors found in the database.
-
-=item RPMERR_DBGETINDEX
-
-This error represents a failure to read a requested header record from the
-database.
-
-=item RPMERR_DBOPEN
-
-An error when opening some component of the database.
-
-=item RPMERR_DBPUTINDEX
-
-This error signals a failure to either store or remove a specified entry into
-(or from) the database.
-
-=item RPMERR_EXEC
-
-An error occured when executing a sub-command (such as B<pgp>).
-
-=item RPMERR_FILECONFLICT
-
-A file conflict (not otherwise caught or handled by B<rpm> itself) was detected.
-
-=item RPMERR_FLOCK
-
-A failure to obtain a lock on the database. When the RPM library opens the
-database it places an exclusive lock on it. As such, there cannot be two
-processes (or two B<RPM::Database> instances) accessing the database at one
-time.
-
-=item RPMERR_FORK
-
-An error occured when RPM tried to fork a child process.
-
-=item RPMERR_GDBMOPEN
-
-An error occured when trying to open a GDBM (GNU DBM) database.
-
-=item RPMERR_GDBMREAD
-
-An error occured when trying to read from a GDBM database.
-
-=item RPMERR_GDBMWRITE
-
-An error occured when trying to write to a GDBM database.
-
-=item RPMERR_GZIP
-
-An error occured with the B<gzip> program.
-
-=item RPMERR_INTERNAL
-
-This is used to signal internal errors from within the RPM library. Odds are,
-if your program sees this error, you should exit as cleanly and quickly as
-possible.
-
-=item RPMERR_LDD
-
-An error occurred with the B<ldd> program.
-
-=item RPMERR_MKDIR
-
-An error code was returned from the C<mkdir> system call.
-
-=item RPMERR_MTAB
-
-An error occured when trying to determine file system information from the
-system C<mtab> file.
-
-=item RPMERR_NEWPACKAGE
-
-An attempt was made to create a new package with a specification of an RPM
-version older (less) than 3.
-
-=item RPMERR_NOCREATEDB
-
-An attempt was made to create the database when one already exists.
-
-=item RPMERR_NOGROUP
-
-A group specified for file group-ownership was not found in the list of groups
-on the system. The group C<root> will be used instead.
-
-=item RPMERR_NORELOCATE
-
-An attempt was made to relocate a package that is not relocatable.
-
-=item RPMERR_NOSPACE
-
-An attempt to write a package file failed for lack of available disk space.
-
-=item RPMERR_NOSPEC
-
-Am unpack operation on a source RPM failed to produce a spec file.
-
-=item RPMERR_NOTSRPM
-
-An operation was requested that can only be performed on a source RPM, but the
-specified package was a binary (or C<noarch>) RPM.
-
-=item RPMERR_NOUSER
-
-A specified user (for file ownership) does not exist, and C<root> will be used
-in its place. See B<RPMERR_NOGROUP>.
-
-=item RPMERR_OLDDB
-
-An old-format database is present.
-
-=item RPMERR_OLDDBCORRUPT
-
-An old-format database being read (for conversion) was found to be corrupt.
-
-=item RPMERR_OLDDBMISSING
-
-A request to convert an old-format database found that there was no such
-database present.
-
-=item RPMERR_OLDPACKAGE
-
-An old-format package was detected.
-
-=item RPMERR_PKGINSTALLED
-
-A package requested for install is already installed on the system.
-
-=item RPMERR_READERROR
-
-An error occurred while reading data.
-
-=item RPMERR_RENAME
-
-An error occured while renaming a file.
-
-=item RPMERR_RMDIR
-
-An attempted removal of a directory failed.
-
-=item RPMERR_RPMRC
-
-A parsing or format error in an RC (options) file occurred.
-
-=item RPMERR_SCRIPT
-
-An error occurred while executing a script.
-
-=item RPMERR_SIGGEN
-
-Some type of error occurred when generating a signature on the package.
-
-=item RPMERR_STAT
-
-There was a failure of some sort on a C<stat> system call.
-
-=item RPMERR_UNKNOWNARCH
-
-A requested architecture is unknown to RPM.
-
-=item RPMERR_UNKNOWNOS
-
-A requested operating system is unknown to RPM.
-
-=item RPMERR_UNLINK
-
-An error occurred with the C<unlink> system call.
-
-=item RPMERR_UNMATCHEDIF
-
-An C<%else> or C<%endif> directive was seen in the spec file, for which there
-is no corresponding C<%if>.
-
-=back
-
-=head2 File-Verification Flags
-
-The values in the B<RPMTAG_FILEVERIFYFLAGS> list defined in the header-tags
-section earlier represent various combinations of the following values. These
-tags may be imported via B<:rpmverify>.
-
-=over
-
-=item RPMVERIFY_ALL
-
-A full mask that will isolate the valid flag-bits from the flag field.
-
-=item RPMVERIFY_NONE
-
-An empty mask that will not match any tested verification flags.
-
-=item RPMVERIFY_FILESIZE
-
-Test the file size against the value in the header.
-
-=item RPMVERIFY_GROUP
-
-Test the file group ID against the value it should have been set to.
-
-=item RPMVERIFY_LINKTO
-
-If the file was to be a symbolic link, check that it is set correctly.
-
-=item RPMVERIFY_MD5
-
-Check the MD5 checksum for the file.
-
-=item RPMVERIFY_MODE
-
-Verify the file mode against the value it was to be set to.
-
-=item RPMVERIFY_MTIME
-
-Check the file modification-time against that which it should have been set.
-
-=item RPMVERIFY_RDEV
-
-Check the device field of the inode, if relevant.
-
-=item RPMVERIFY_USER
-
-Check the user ID to which ownership was set.
-
-=back
-
-When the verification of a given file fails, the return value contains the
-relevant bits from the values above, corresponding to what test(s) failed.
-In addition, any of the following may be set to indicate a larger problem:
-
-=over
-
-=item RPMVERIFY_LSTATFAIL
-
-The attempt to read the inode information via C<lstat()> was not successful.
-This will guarantee that other bits in the return value are set, as well.
-
-=item RPMVERIFY_READFAIL
-
-The attempt to read the file or its data (for the sake of MD5, etc.) failed.
-
-=item RPMVERIFY_READLINKFAIL
-
-An attempt to do a C<readlink()> on the file, expected to be a symbolic link,
-failed.
-
-=back
-
-=head2 File Specification Flags
-
-The following tags may be imported via the B<:rpmfile> specifier. They are
-used to express various characteristics of files in the archive, based on the
-value from B<RPMTAG_FILEFLAGS> that corresponds to a given file.
-
-=over
-
-=item RPMFILE_CONFIG
-
-Not documented yet.
-
-=item RPMFILE_DOC
-
-Not documented yet.
-
-=item RPMFILE_DONOTUSE
-
-Not documented yet.
-
-=item RPMFILE_GHOST
-
-Not documented yet.
-
-=item RPMFILE_LICENSE
-
-Not documented yet.
-
-=item RPMFILE_MISSINGOK
-
-Not documented yet.
-
-=item RPMFILE_NOREPLACE
-
-Not documented yet.
-
-=item RPMFILE_README
-
-Not documented yet.
-
-=item RPMFILE_SPECFILE
-
-Not documented yet.
-
-=item RPMFILE_STATE_NETSHARED
-
-Not documented yet.
-
-=item RPMFILE_STATE_NORMAL
-
-Not documented yet.
-
-=item RPMFILE_STATE_NOTINSTALLED
-
-Not documented yet.
-
-=item RPMFILE_STATE_REPLACED
-
-Not documented yet.
-
-=back
-
-=head2 Not Yet Defined
-
-The following have not yet been categorized. They may, after further research
-and development, be found to be un-needed by this package.
-
-=over
-
-=item ADD_SIGNATURE
-
-Not documented yet.
-
-=item CHECKSIG_GPG
-
-Not documented yet.
-
-=item CHECKSIG_MD5
-
-Not documented yet.
-
-=item CHECKSIG_PGP
-
-Not documented yet.
-
-=item INSTALL_HASH
-
-Not documented yet.
-
-=item INSTALL_LABEL
-
-Not documented yet.
-
-=item INSTALL_NODEPS
-
-Not documented yet.
-
-=item INSTALL_NOORDER
-
-Not documented yet.
-
-=item INSTALL_PERCENT
-
-Not documented yet.
-
-=item INSTALL_UPGRADE
-
-Not documented yet.
-
-=item QUERY_FOR_CONFIG
-
-Not documented yet.
-
-=item QUERY_FOR_DOCS
-
-Not documented yet.
-
-=item QUERY_FOR_DUMPFILES
-
-Not documented yet.
-
-=item QUERY_FOR_LIST
-
-Not documented yet.
-
-=item QUERY_FOR_STATE
-
-Not documented yet.
-
-=item RPMPROB_FILTER_DISKSPACE
-
-Not documented yet.
-
-=item RPMPROB_FILTER_FORCERELOCATE
-
-Not documented yet.
-
-=item RPMPROB_FILTER_IGNOREARCH
-
-Not documented yet.
-
-=item RPMPROB_FILTER_IGNOREOS
-
-Not documented yet.
-
-=item RPMPROB_FILTER_OLDPACKAGE
-
-Not documented yet.
-
-=item RPMPROB_FILTER_REPLACENEWFILES
-
-Not documented yet.
-
-=item RPMPROB_FILTER_REPLACEOLDFILES
-
-Not documented yet.
-
-=item RPMPROB_FILTER_REPLACEPKG
-
-Not documented yet.
-
-=item RPMSIGTAG_GPG
-
-Not documented yet.
-
-=item RPMSIGTAG_LEMD5_1
-
-Not documented yet.
-
-=item RPMSIGTAG_LEMD5_2
-
-Not documented yet.
-
-=item RPMSIGTAG_MD5
-
-Not documented yet.
-
-=item RPMSIGTAG_PGP
-
-Not documented yet.
-
-=item RPMSIGTAG_PGP5
-
-Not documented yet.
-
-=item RPMSIGTAG_SIZE
-
-Not documented yet.
-
-=item RPMSIG_BAD
-
-Not documented yet.
-
-=item RPMSIG_NOKEY
-
-Not documented yet.
-
-=item RPMSIG_NOTTRUSTED
-
-Not documented yet.
-
-=item RPMSIG_OK
-
-Not documented yet.
-
-=item RPMSIG_UNKNOWN
-
-Not documented yet.
-
-=item RPMTRANS_FLAG_ALLFILES
-
-Not documented yet.
-
-=item RPMTRANS_FLAG_BUILD_PROBS
-
-Not documented yet.
-
-=item RPMTRANS_FLAG_JUSTDB
-
-Not documented yet.
-
-=item RPMTRANS_FLAG_KEEPOBSOLETE
-
-Not documented yet.
-
-=item RPMTRANS_FLAG_NODOCS
-
-Not documented yet.
-
-=item RPMTRANS_FLAG_NOSCRIPTS
-
-Not documented yet.
-
-=item RPMTRANS_FLAG_NOTRIGGERS
-
-Not documented yet.
-
-=item RPMTRANS_FLAG_TEST
-
-Not documented yet.
-
-=item UNINSTALL_ALLMATCHES
-
-Not documented yet.
-
-=item UNINSTALL_NODEPS
-
-Not documented yet.
-
-=item VERIFY_DEPS
-
-Not documented yet.
-
-=item VERIFY_FILES
-
-Not documented yet.
-
-=item VERIFY_MD5
-
-Not documented yet.
-
-=item VERIFY_SCRIPT
-
-Not documented yet.
-
-=back
-
-=head1 SEE ALSO
-
-L<RPM>, L<perl>, L<rpm>
-
-=head1 AUTHOR
-
-Randy J. Ray <rjray@blackperl.com>
-
-=cut
+++ /dev/null
-#include "EXTERN.h"
-#include "perl.h"
-#include "XSUB.h"
-
-#include "RPM.h"
-
-static char * const rcsid = "$Id: Constants.xs,v 1.12 2002/04/11 22:40:20 rjray Exp $";
-
-static int constant(pTHX_ char *name)
-{
- errno = 0;
-
- switch (*name)
- {
- case 'C':
- if (strnEQ(name, "CHECKSIG_", 9))
- {
- if (strEQ(name + 9, "GPG"))
- return CHECKSIG_GPG;
- if (strEQ(name + 9, "MD5"))
- return CHECKSIG_MD5;
- if (strEQ(name + 9, "PGP"))
- return CHECKSIG_PGP;
- }
- break;
- case 'I':
- if (strnEQ(name, "INSTALL_", 8))
- {
- if (strEQ(name + 8, "HASH"))
- return INSTALL_HASH;
- if (strEQ(name + 8, "LABEL"))
- return INSTALL_LABEL;
- if (strEQ(name + 8, "NODEPS"))
- return INSTALL_NODEPS;
- if (strEQ(name + 8, "NOORDER"))
- return INSTALL_NOORDER;
- if (strEQ(name + 8, "PERCENT"))
- return INSTALL_PERCENT;
- if (strEQ(name + 8, "UPGRADE"))
- return INSTALL_UPGRADE;
- }
- break;
- case 'Q':
- if (strnEQ(name, "QUERY_FOR_", 10))
- {
- if (strEQ(name + 10, "CONFIG"))
- return QUERY_FOR_CONFIG;
- if (strEQ(name + 10, "DOCS"))
- return QUERY_FOR_DOCS;
- if (strEQ(name + 10, "DUMPFILES"))
- return QUERY_FOR_DUMPFILES;
- if (strEQ(name + 10, "LIST"))
- return QUERY_FOR_LIST;
- if (strEQ(name + 10, "STATE"))
- return QUERY_FOR_STATE;
- }
- break;
- case 'R':
- /* THIS is the area that really needs progressive breaking down by
- minimal leading-string matching. */
- if (strnEQ(name, "RPM_MACHTABLE_", 14))
- {
- if (strEQ(name + 14, "BUILDARCH"))
- return RPM_MACHTABLE_BUILDARCH;
- if (strEQ(name + 14, "BUILDOS"))
- return RPM_MACHTABLE_BUILDOS;
- if (strEQ(name + 14, "COUNT"))
- return RPM_MACHTABLE_COUNT;
- if (strEQ(name + 14, "INSTARCH"))
- return RPM_MACHTABLE_INSTARCH;
- if (strEQ(name + 14, "INSTOS"))
- return RPM_MACHTABLE_INSTOS;
- }
- if (strnEQ(name, "RPM_", 4))
- {
- if (strEQ(name + 4, "NULL_TYPE"))
- return RPM_NULL_TYPE;
- if (strEQ(name + 4, "CHAR_TYPE"))
- return RPM_CHAR_TYPE;
- if (strEQ(name + 4, "INT8_TYPE"))
- return RPM_INT8_TYPE;
- if (strEQ(name + 4, "INT16_TYPE"))
- return RPM_INT16_TYPE;
- if (strEQ(name + 4, "INT32_TYPE"))
- return RPM_INT32_TYPE;
- if (strEQ(name + 4, "STRING_TYPE"))
- return RPM_STRING_TYPE;
- if (strEQ(name + 4, "BIN_TYPE"))
- return RPM_BIN_TYPE;
- if (strEQ(name + 4, "STRING_ARRAY_TYPE"))
- return RPM_STRING_ARRAY_TYPE;
- if (strEQ(name + 4, "I18NSTRING_TYPE"))
- return RPM_I18NSTRING_TYPE;
- }
- if (strnEQ(name, "RPMERR_", 7))
- {
- switch (*(name + 7))
- {
- case 'B':
- if (strEQ(name + 7, "BADARG"))
- return RPMERR_BADARG;
- if (strEQ(name + 7, "BADDEV"))
- return RPMERR_BADDEV;
- if (strEQ(name + 7, "BADFILENAME"))
- return RPMERR_BADFILENAME;
- if (strEQ(name + 7, "BADMAGIC"))
- return RPMERR_BADMAGIC;
- if (strEQ(name + 7, "BADRELOCATE"))
- return RPMERR_BADRELOCATE;
- if (strEQ(name + 7, "BADSIGTYPE"))
- return RPMERR_BADSIGTYPE;
- if (strEQ(name + 7, "BADSPEC"))
- return RPMERR_BADSPEC;
- break;
- case 'C':
- if (strEQ(name + 7, "CHOWN"))
- return RPMERR_CHOWN;
- if (strEQ(name + 7, "CPIO"))
- return RPMERR_CPIO;
- if (strEQ(name + 7, "CREATE"))
- return RPMERR_CREATE;
- break;
- case 'D':
- if (strEQ(name + 7, "DBCORRUPT"))
- return RPMERR_DBCORRUPT;
- if (strEQ(name + 7, "DBGETINDEX"))
- return RPMERR_DBGETINDEX;
- if (strEQ(name + 7, "DBOPEN"))
- return RPMERR_DBOPEN;
- if (strEQ(name + 7, "DBPUTINDEX"))
- return RPMERR_DBPUTINDEX;
- break;
- case 'E':
- if (strEQ(name + 7, "EXEC"))
- return RPMERR_EXEC;
- break;
- case 'F':
- if (strEQ(name + 7, "FILECONFLICT"))
- return RPMERR_FILECONFLICT;
- if (strEQ(name + 7, "FLOCK"))
- return RPMERR_FLOCK;
- if (strEQ(name + 7, "FORK"))
- return RPMERR_FORK;
- break;
- case 'G':
- if (strEQ(name + 7, "GDBMOPEN"))
- return RPMERR_GDBMOPEN;
- if (strEQ(name + 7, "GDBMREAD"))
- return RPMERR_GDBMREAD;
- if (strEQ(name + 7, "GDBMWRITE"))
- return RPMERR_GDBMWRITE;
- if (strEQ(name + 7, "GZIP"))
- return RPMERR_GZIP;
- break;
- case 'I':
- if (strEQ(name + 7, "INTERNAL"))
- return RPMERR_INTERNAL;
- break;
- case 'L':
- if (strEQ(name + 7, "LDD"))
- return RPMERR_LDD;
- break;
- case 'M':
- if (strEQ(name + 7, "MKDIR"))
- return RPMERR_MKDIR;
- if (strEQ(name + 7, "MTAB"))
- return RPMERR_MTAB;
- break;
- case 'N':
- if (strEQ(name + 7, "NEWPACKAGE"))
- return RPMERR_NEWPACKAGE;
- if (strEQ(name + 7, "NOCREATEDB"))
- return RPMERR_NOCREATEDB;
- if (strEQ(name + 7, "NOGROUP"))
- return RPMERR_NOGROUP;
- if (strEQ(name + 7, "NORELOCATE"))
- return RPMERR_NORELOCATE;
- if (strEQ(name + 7, "NOSPACE"))
- return RPMERR_NOSPACE;
- if (strEQ(name + 7, "NOSPEC"))
- return RPMERR_NOSPEC;
- if (strEQ(name + 7, "NOTSRPM"))
- return RPMERR_NOTSRPM;
- if (strEQ(name + 7, "NOUSER"))
- return RPMERR_NOUSER;
- break;
- case 'O':
- if (strEQ(name + 7, "OLDDB"))
- return RPMERR_OLDDB;
- if (strEQ(name + 7, "OLDDBCORRUPT"))
- return RPMERR_OLDDBCORRUPT;
- if (strEQ(name + 7, "OLDDBMISSING"))
- return RPMERR_OLDDBMISSING;
- if (strEQ(name + 7, "OLDPACKAGE"))
- return RPMERR_OLDPACKAGE;
- break;
- case 'P':
- if (strEQ(name + 7, "PKGINSTALLED"))
- return RPMERR_PKGINSTALLED;
- break;
- case 'R':
- if (strEQ(name + 7, "READ") || strEQ(name + 7, "READERROR"))
- return RPMERR_READ;
- if (strEQ(name + 7, "RENAME"))
- return RPMERR_RENAME;
- if (strEQ(name + 7, "RMDIR"))
- return RPMERR_RMDIR;
- if (strEQ(name + 7, "RPMRC"))
- return RPMERR_RPMRC;
- break;
- case 'S':
- if (strEQ(name + 7, "SCRIPT"))
- return RPMERR_SCRIPT;
- if (strEQ(name + 7, "SIGGEN"))
- return RPMERR_SIGGEN;
- if (strEQ(name + 7, "STAT"))
- return RPMERR_STAT;
- break;
- case 'U':
- if (strEQ(name + 7, "UNKNOWNARCH"))
- return RPMERR_UNKNOWNARCH;
- if (strEQ(name + 7, "UNKNOWNOS"))
- return RPMERR_UNKNOWNOS;
- if (strEQ(name + 7, "UNLINK"))
- return RPMERR_UNLINK;
- if (strEQ(name + 7, "UNMATCHEDIF"))
- return RPMERR_UNMATCHEDIF;
- break;
- default:
- break;
- }
- }
- if (strnEQ(name, "RPMFILE_", 8))
- {
- if (strEQ(name + 8, "CONFIG"))
- return RPMFILE_CONFIG;
- if (strEQ(name + 8, "DOC"))
- return RPMFILE_DOC;
- if (strEQ(name + 8, "DONOTUSE"))
- return RPMFILE_DONOTUSE;
- if (strEQ(name + 8, "GHOST"))
- return RPMFILE_GHOST;
- if (strEQ(name + 8, "LICENSE"))
- return RPMFILE_LICENSE;
- if (strEQ(name + 8, "MISSINGOK"))
- return RPMFILE_MISSINGOK;
- if (strEQ(name + 8, "NOREPLACE"))
- return RPMFILE_NOREPLACE;
- if (strEQ(name + 8, "README"))
- return RPMFILE_README;
- if (strEQ(name + 8, "SPECFILE"))
- return RPMFILE_SPECFILE;
- if (strEQ(name + 8, "STATE_NETSHARED"))
- return RPMFILE_STATE_NETSHARED;
- if (strEQ(name + 8, "STATE_NORMAL"))
- return RPMFILE_STATE_NORMAL;
- if (strEQ(name + 8, "STATE_NOTINSTALLED"))
- return RPMFILE_STATE_NOTINSTALLED;
- if (strEQ(name + 8, "STATE_REPLACED"))
- return RPMFILE_STATE_REPLACED;
- }
- if (strnEQ(name, "RPMPROB_FILTER_", 15))
- {
- if (strEQ(name + 15, "DISKSPACE"))
- return RPMPROB_FILTER_DISKSPACE;
- if (strEQ(name + 15, "FORCERELOCATE"))
- return RPMPROB_FILTER_FORCERELOCATE;
- if (strEQ(name + 15, "IGNOREARCH"))
- return RPMPROB_FILTER_IGNOREARCH;
- if (strEQ(name + 15, "IGNOREOS"))
- return RPMPROB_FILTER_IGNOREOS;
- if (strEQ(name + 15, "OLDPACKAGE"))
- return RPMPROB_FILTER_OLDPACKAGE;
- if (strEQ(name + 15, "REPLACENEWFILES"))
- return RPMPROB_FILTER_REPLACENEWFILES;
- if (strEQ(name + 15, "REPLACEOLDFILES"))
- return RPMPROB_FILTER_REPLACEOLDFILES;
- if (strEQ(name + 15, "REPLACEPKG"))
- return RPMPROB_FILTER_REPLACEPKG;
- }
- if (strnEQ(name, "RPMSENSE_", 9))
- {
- if (strEQ(name + 9, "EQUAL"))
- return RPMSENSE_EQUAL;
- if (strEQ(name + 9, "GREATER"))
- return RPMSENSE_GREATER;
- if (strEQ(name + 9, "LESS"))
- return RPMSENSE_LESS;
- if (strEQ(name + 9, "PREREQ"))
- return RPMSENSE_PREREQ;
- if (strEQ(name + 9, "SENSEMASK"))
- return RPMSENSE_SENSEMASK;
- if (strEQ(name + 9, "TRIGGER"))
- return RPMSENSE_TRIGGER;
- if (strEQ(name + 9, "TRIGGERIN"))
- return RPMSENSE_TRIGGERIN;
- if (strEQ(name + 9, "TRIGGERPOSTUN"))
- return RPMSENSE_TRIGGERPOSTUN;
- if (strEQ(name + 9, "TRIGGERUN"))
- return RPMSENSE_TRIGGERUN;
- }
- if (strnEQ(name, "RPMSIGTAG_", 10))
- {
- if (strEQ(name + 10, "GPG"))
- return RPMSIGTAG_GPG;
- if (strEQ(name + 10, "LEMD5_1"))
- return RPMSIGTAG_LEMD5_1;
- if (strEQ(name + 10, "LEMD5_2"))
- return RPMSIGTAG_LEMD5_2;
- if (strEQ(name + 10, "MD5"))
- return RPMSIGTAG_MD5;
- if (strEQ(name + 10, "PGP"))
- return RPMSIGTAG_PGP;
- if (strEQ(name + 10, "PGP5"))
- return RPMSIGTAG_PGP5;
- if (strEQ(name + 10, "SIZE"))
- return RPMSIGTAG_SIZE;
- }
- if (strnEQ(name, "RPMSIG_", 7))
- {
- if (strEQ(name + 7, "BAD"))
- return RPMSIG_BAD;
- if (strEQ(name + 7, "NOKEY"))
- return RPMSIG_NOKEY;
- if (strEQ(name + 7, "NOTTRUSTED"))
- return RPMSIG_NOTTRUSTED;
- if (strEQ(name + 7, "OK"))
- return RPMSIG_OK;
- if (strEQ(name + 7, "UNKNOWN"))
- return RPMSIG_UNKNOWN;
- }
- if (strnEQ(name, "RPMTAG_", 7))
- {
- switch (*(name + 7))
- {
- case 'A':
- if (strEQ(name + 7, "ARCH"))
- return RPMTAG_ARCH;
- if (strEQ(name + 7, "ARCHIVESIZE"))
- return RPMTAG_ARCHIVESIZE;
- break;
- case 'B':
- if (strEQ(name + 7, "BASENAMES"))
- return RPMTAG_BASENAMES;
- if (strEQ(name + 7, "BUILDARCHS"))
- return RPMTAG_BUILDARCHS;
- if (strEQ(name + 7, "BUILDHOST"))
- return RPMTAG_BUILDHOST;
- if (strEQ(name + 7, "BUILDMACROS"))
- return RPMTAG_BUILDMACROS;
- if (strEQ(name + 7, "BUILDROOT"))
- return RPMTAG_BUILDROOT;
- if (strEQ(name + 7, "BUILDTIME"))
- return RPMTAG_BUILDTIME;
- break;
- case 'C':
- if (strEQ(name + 7, "CHANGELOGNAME"))
- return RPMTAG_CHANGELOGNAME;
- if (strEQ(name + 7, "CHANGELOGTEXT"))
- return RPMTAG_CHANGELOGTEXT;
- if (strEQ(name + 7, "CHANGELOGTIME"))
- return RPMTAG_CHANGELOGTIME;
- if (strEQ(name + 7, "CONFLICTFLAGS"))
- return RPMTAG_CONFLICTFLAGS;
- if (strEQ(name + 7, "CONFLICTNAME"))
- return RPMTAG_CONFLICTNAME;
- if (strEQ(name + 7, "CONFLICTVERSION"))
- return RPMTAG_CONFLICTVERSION;
- if (strEQ(name + 7, "COPYRIGHT"))
- return RPMTAG_COPYRIGHT;
- if (strEQ(name + 7, "COOKIE"))
- return RPMTAG_COOKIE;
- break;
- case 'D':
- if (strEQ(name + 7, "DESCRIPTION"))
- return RPMTAG_DESCRIPTION;
- if (strEQ(name + 7, "DIRINDEXES"))
- return RPMTAG_DIRINDEXES;
- if (strEQ(name + 7, "DIRNAMES"))
- return RPMTAG_DIRNAMES;
- if (strEQ(name + 7, "DISTRIBUTION"))
- return RPMTAG_DISTRIBUTION;
- break;
- case 'E':
- if (strEQ(name + 7, "EXCLUDEARCH"))
- return RPMTAG_EXCLUDEARCH;
- if (strEQ(name + 7, "EXCLUDEOS"))
- return RPMTAG_EXCLUDEOS;
- if (strEQ(name + 7, "EXCLUSIVEARCH"))
- return RPMTAG_EXCLUSIVEARCH;
- if (strEQ(name + 7, "EXCLUSIVEOS"))
- return RPMTAG_EXCLUSIVEOS;
- break;
- case 'F':
- if (strEQ(name + 7, "FILEDEVICES"))
- return RPMTAG_FILEDEVICES;
- if (strEQ(name + 7, "FILEFLAGS"))
- return RPMTAG_FILEFLAGS;
- if (strEQ(name + 7, "FILEGROUPNAME"))
- return RPMTAG_FILEGROUPNAME;
- if (strEQ(name + 7, "FILEINODES"))
- return RPMTAG_FILEINODES;
- if (strEQ(name + 7, "FILELANGS"))
- return RPMTAG_FILELANGS;
- if (strEQ(name + 7, "FILELINKTOS"))
- return RPMTAG_FILELINKTOS;
- if (strEQ(name + 7, "FILEMD5S"))
- return RPMTAG_FILEMD5S;
- if (strEQ(name + 7, "FILEMODES"))
- return RPMTAG_FILEMODES;
- if (strEQ(name + 7, "FILEMTIMES"))
- return RPMTAG_FILEMTIMES;
- if (strEQ(name + 7, "FILERDEVS"))
- return RPMTAG_FILERDEVS;
- if (strEQ(name + 7, "FILESIZES"))
- return RPMTAG_FILESIZES;
- if (strEQ(name + 7, "FILESTATES"))
- return RPMTAG_FILESTATES;
- if (strEQ(name + 7, "FILEUSERNAME"))
- return RPMTAG_FILEUSERNAME;
- if (strEQ(name + 7, "FILEVERIFYFLAGS"))
- return RPMTAG_FILEVERIFYFLAGS;
- break;
- case 'G':
- if (strEQ(name + 7, "GIF"))
- return RPMTAG_GIF;
- if (strEQ(name + 7, "GROUP"))
- return RPMTAG_GROUP;
- break;
- case 'I':
- if (strEQ(name + 7, "ICON"))
- return RPMTAG_ICON;
- if (strEQ(name + 7, "INSTALLTIME"))
- return RPMTAG_INSTALLTIME;
- if (strEQ(name + 7, "INSTPREFIXES"))
- return RPMTAG_INSTPREFIXES;
- break;
- case 'L':
- if (strEQ(name + 7, "LICENSE"))
- return RPMTAG_LICENSE;
- break;
- case 'N':
- if (strEQ(name + 7, "NAME"))
- return RPMTAG_NAME;
- if (strEQ(name + 7, "NOPATCH"))
- return RPMTAG_NOPATCH;
- if (strEQ(name + 7, "NOSOURCE"))
- return RPMTAG_NOSOURCE;
- break;
- case 'O':
- if (strEQ(name + 7, "OBSOLETEFLAGS"))
- return RPMTAG_OBSOLETEFLAGS;
- if (strEQ(name + 7, "OBSOLETENAME"))
- return RPMTAG_OBSOLETENAME;
- if (strEQ(name + 7, "OBSOLETEVERSION"))
- return RPMTAG_OBSOLETEVERSION;
- if (strEQ(name + 7, "OS"))
- return RPMTAG_OS;
- break;
- case 'P':
- if (strEQ(name + 7, "PACKAGER"))
- return RPMTAG_PACKAGER;
- if (strEQ(name + 7, "PATCH"))
- return RPMTAG_PATCH;
- if (strEQ(name + 7, "POSTIN"))
- return RPMTAG_POSTIN;
- if (strEQ(name + 7, "POSTINPROG"))
- return RPMTAG_POSTINPROG;
- if (strEQ(name + 7, "POSTUN"))
- return RPMTAG_POSTUN;
- if (strEQ(name + 7, "POSTUNPROG"))
- return RPMTAG_POSTUNPROG;
- if (strEQ(name + 7, "PREFIXES"))
- return RPMTAG_PREFIXES;
- if (strEQ(name + 7, "PREIN"))
- return RPMTAG_PREIN;
- if (strEQ(name + 7, "PREINPROG"))
- return RPMTAG_PREINPROG;
- if (strEQ(name + 7, "PREUN"))
- return RPMTAG_PREUN;
- if (strEQ(name + 7, "PREUNPROG"))
- return RPMTAG_PREUNPROG;
- if (strEQ(name + 7, "PROVIDEFLAGS"))
- return RPMTAG_PROVIDEFLAGS;
- if (strEQ(name + 7, "PROVIDENAME"))
- return RPMTAG_PROVIDENAME;
- if (strEQ(name + 7, "PROVIDEVERSION"))
- return RPMTAG_PROVIDEVERSION;
- break;
- case 'R':
- if (strEQ(name + 7, "RELEASE"))
- return RPMTAG_RELEASE;
- if (strEQ(name + 7, "REQUIREFLAGS"))
- return RPMTAG_REQUIREFLAGS;
- if (strEQ(name + 7, "REQUIRENAME"))
- return RPMTAG_REQUIRENAME;
- if (strEQ(name + 7, "REQUIREVERSION"))
- return RPMTAG_REQUIREVERSION;
- if (strEQ(name + 7, "RPMVERSION"))
- return RPMTAG_RPMVERSION;
- break;
- case 'S':
- if (strEQ(name + 7, "SIZE"))
- return RPMTAG_SIZE;
- if (strEQ(name + 7, "SOURCE"))
- return RPMTAG_SOURCE;
- if (strEQ(name + 7, "SOURCERPM"))
- return RPMTAG_SOURCERPM;
- if (strEQ(name + 7, "SUMMARY"))
- return RPMTAG_SUMMARY;
- break;
- case 'T':
- if (strEQ(name + 7, "TRIGGERFLAGS"))
- return RPMTAG_TRIGGERFLAGS;
- if (strEQ(name + 7, "TRIGGERINDEX"))
- return RPMTAG_TRIGGERINDEX;
- if (strEQ(name + 7, "TRIGGERNAME"))
- return RPMTAG_TRIGGERNAME;
- if (strEQ(name + 7, "TRIGGERSCRIPTPROG"))
- return RPMTAG_TRIGGERSCRIPTPROG;
- if (strEQ(name + 7, "TRIGGERSCRIPTS"))
- return RPMTAG_TRIGGERSCRIPTS;
- if (strEQ(name + 7, "TRIGGERVERSION"))
- return RPMTAG_TRIGGERVERSION;
- break;
- case 'U':
- if (strEQ(name + 7, "URL"))
- return RPMTAG_URL;
- break;
- case 'V':
- if (strEQ(name + 7, "VENDOR"))
- return RPMTAG_VENDOR;
- if (strEQ(name + 7, "VERIFYSCRIPT"))
- return RPMTAG_VERIFYSCRIPT;
- if (strEQ(name + 7, "VERIFYSCRIPTPROG"))
- return RPMTAG_VERIFYSCRIPTPROG;
- if (strEQ(name + 7, "VERSION"))
- return RPMTAG_VERSION;
- break;
- case 'X':
- if (strEQ(name + 7, "XPM"))
- return RPMTAG_XPM;
- break;
- default:
- break;
- }
- }
- if (strnEQ(name, "RPMTRANS_FLAG_", 14))
- {
- if (strEQ(name + 14, "ALLFILES"))
- return RPMTRANS_FLAG_ALLFILES;
- if (strEQ(name + 14, "BUILD_PROBS"))
- return RPMTRANS_FLAG_BUILD_PROBS;
- if (strEQ(name + 14, "JUSTDB"))
- return RPMTRANS_FLAG_JUSTDB;
- if (strEQ(name + 14, "KEEPOBSOLETE"))
- return RPMTRANS_FLAG_KEEPOBSOLETE;
- if (strEQ(name + 14, "NODOCS"))
- return RPMTRANS_FLAG_NODOCS;
- if (strEQ(name + 14, "NOSCRIPTS"))
- return RPMTRANS_FLAG_NOSCRIPTS;
- if (strEQ(name + 14, "NOTRIGGERS"))
- return RPMTRANS_FLAG_NOTRIGGERS;
- if (strEQ(name + 14, "TEST"))
- return RPMTRANS_FLAG_TEST;
- }
- if (strnEQ(name, "RPMVAR_", 7))
- {
- if (strEQ(name + 7, "INCLUDE"))
- return RPMVAR_INCLUDE;
- if (strEQ(name + 7, "MACROFILES"))
- return RPMVAR_MACROFILES;
- if (strEQ(name + 7, "NUM"))
- return RPMVAR_NUM;
- if (strEQ(name + 7, "OPTFLAGS"))
- return RPMVAR_OPTFLAGS;
- if (strEQ(name + 7, "PROVIDES"))
- return RPMVAR_PROVIDES;
- }
- if (strnEQ(name, "RPMVERIFY_", 10))
- {
- if (strEQ(name + 10, "ALL"))
- return RPMVERIFY_ALL;
- if (strEQ(name + 10, "FILESIZE"))
- return RPMVERIFY_FILESIZE;
- if (strEQ(name + 10, "GROUP"))
- return RPMVERIFY_GROUP;
- if (strEQ(name + 10, "LINKTO"))
- return RPMVERIFY_LINKTO;
- if (strEQ(name + 10, "LSTATFAIL"))
- return RPMVERIFY_LSTATFAIL;
- if (strEQ(name + 10, "MD5"))
- return RPMVERIFY_MD5;
- if (strEQ(name + 10, "MODE"))
- return RPMVERIFY_MODE;
- if (strEQ(name + 10, "MTIME"))
- return RPMVERIFY_MTIME;
- if (strEQ(name + 10, "NONE"))
- return RPMVERIFY_NONE;
- if (strEQ(name + 10, "RDEV"))
- return RPMVERIFY_RDEV;
- if (strEQ(name + 10, "READFAIL"))
- return RPMVERIFY_READFAIL;
- if (strEQ(name + 10, "READLINKFAIL"))
- return RPMVERIFY_READLINKFAIL;
- if (strEQ(name + 10, "USER"))
- return RPMVERIFY_USER;
- }
- break;
- case 'U':
- if (strEQ(name, "UNINSTALL_ALLMATCHES"))
- return UNINSTALL_ALLMATCHES;
- if (strEQ(name, "UNINSTALL_NODEPS"))
- return UNINSTALL_NODEPS;
- break;
- case 'V':
- if (strnEQ(name, "VERIFY_", 7))
- {
- if (strEQ(name + 7, "DEPS"))
- return VERIFY_DEPS;
- if (strEQ(name + 7, "FILES"))
- return VERIFY_FILES;
- if (strEQ(name + 7, "MD5"))
- return VERIFY_MD5;
- if (strEQ(name + 7, "SCRIPT"))
- return VERIFY_SCRIPT;
- }
- break;
- default:
- break;
- }
- errno = EINVAL;
- return 0;
-}
-
-
-MODULE = RPM::Constants PACKAGE = RPM::Constants
-
-
-int
-constant(name)
- char* name;
- PROTOTYPE: $
- CODE:
- RETVAL = constant(aTHX_ name);
- OUTPUT:
- RETVAL
+++ /dev/null
-###############################################################################
-#
-# (c) Copyright @ 2000, Randy J. Ray <rjray@blackperl.com>
-# All Rights Reserved
-#
-###############################################################################
-#
-# $Id: Database.pm,v 1.18 2002/05/10 07:38:58 rjray Exp $
-#
-# Description: The RPM::Database class provides access to the RPM database
-# as a tied hash, whose keys are taken as the names of
-# packages installed and whose values are RPM::Header
-# objects.
-#
-# Functions: new
-# import
-#
-# Libraries: RPM
-# RPM::Header
-#
-# Global Consts: None.
-#
-# Environment: Just stuff from the RPM config.
-#
-###############################################################################
-
-package RPM::Database;
-
-require 5.005;
-
-use strict;
-use vars qw($VERSION %RPM $RPM);
-use subs qw(new import);
-
-require RPM;
-require RPM::Header;
-
-$VERSION = do { my @r=(q$Revision: 1.18 $=~/\d+/g); sprintf "%d."."%02d"x$#r,@r };
-
-1;
-
-sub new
-{
- my $class = shift;
- my $opts = shift;
- my %hash = ();
-
- # The presence of $opts when empty is hard on the XS TIEHASH method
- $opts ? tie(%hash, $class, $opts) : tie(%hash, $class);
-}
-
-###############################################################################
-#
-# Sub Name: import
-#
-# Description: This lies in wait to see if someone actually tries to
-# import from this package. If they do, check that it is
-# allowed and do it if it is.
-#
-# At present, only "%RPM" or "$RPM" is allowed. If that is
-# the requested export, then the hash is tied to the RPM
-# database (with no extra arguments) then exported to the
-# caller's namespace.
-#
-# Arguments: NAME IN/OUT TYPE DESCRIPTION
-# $class in scalar Name of this package
-# @args in list Requested exports
-#
-# Globals: None.
-#
-# Environment: None.
-#
-# Returns: void context
-#
-###############################################################################
-sub import
-{
- my ($class, @args) = @_;
-
- my $callpkg = caller(0);
-
- no strict 'refs';
-
- for my $arg (@args)
- {
- if ($arg eq '%RPM' and ! (tied %RPM))
- {
- tie %RPM, "RPM::Database";
- *{"${callpkg}::RPM"} = \%{"${class}::RPM"};
- }
- elsif ($arg eq '$RPM' and ! $RPM)
- {
- tie %RPM, "RPM::Database" unless (tied %RPM);
- $RPM = (tied %RPM);
- *{"${callpkg}::RPM"} = \${"${class}::RPM"};
- }
- else
- {
- warn "$class: Unknown export requested: $arg, ";
- return;
- }
- }
-}
-
-__END__
-
-=head1 NAME
-
-RPM::Database - Access to the RPM database of installed packages
-
-=head1 SYNOPSIS
-
- use RPM::Database;
-
- tie %RPM, "RPM::Database" or die "$RPM::err";
-
- for (sort keys %RPM)
- {
- ...
- }
-
-=head1 DESCRIPTION
-
-The B<RPM::Database> package provides access to the database of installed
-packages on a system. The database may be accessed as either a tied hash
-or as a blessed reference to a hash. The keys of the hash represent
-packages on the system. The order in which they are returned by any of
-C<keys>, C<each> or C<values>, is determined by the internal database
-ordering. Unlike the keys in B<RPM::Header> (see L<RPM::Header>), the
-keys here are in fact case-sensitive.
-
-The return value corresponding to each key is a reference to a
-B<RPM::Header> object. The header object is marked read-only, as the
-RPM database is not directly modifiable via this interface.
-
-There are also a number of class methods implemented, which are described in
-the next section.
-
-=head1 USAGE
-
-=head2 Creating an Object
-
-An object may be created one of two ways:
-
- tie %D, "RPM::Database";
-
- $dataref = new RPM::Database;
-
-The latter approach offers more direct access to the class methods, while
-also permitting the usual tied-hash operations such as fetching:
-
- $dataref->{package} # Such as "rpm" or "perl"
-
-=head2 Class Methods
-
-The following methods are available to objects of this class, in addition to
-the tied-hash suite of operations. If the object is a hash instead of a
-hash reference, it can be used to call these methods via:
-
- (tied %hash)->method_name(...)
-
-=over
-
-=item new
-
-Creates a tied hash using a lexically-scoped hash table, then returns a
-reference to it (the return value of the C<tie> operation). This reference
-prevents the hash table from going out of scope. If a hash-reference of
-options is passed to this constructor, they are passed along to the tie of the
-hash. If a single scalar argument is passed, it is assumed to be an alternate
-database root to be used in opening the RPM database. The hash-reference
-currently only supports a single key, C<root>, which serves the same
-purpose. The hash-reference approach leaves open the possibilty of future
-options being added.
-
-=item init
-
-This causes a complete initialization of the RPM database. It must be run
-with sufficient permissions to create/update the relevant files. It must
-also be called as a static method, to avoid having any file descriptors
-open on the database at the time.
-
-=item rebuild
-
-This rebuilds the database (same as "rpm --rebuilddb"). As with B<init>
-above, this requires adequate permissions and must be invoked as a static
-method.
-
-=item find_by_file(file)
-
-Returns a list of B<RPM::Header> objects that correspond to the package(s)
-claiming ownership of the file "file".
-
-=item find_by_group(group)
-
-Returns of a list of headers for all packages flagged as being in the
-group specified.
-
-=item find_what_provides(provides)
-
-Search as above, but based on which package(s) provide the functionality
-specified as "provides".
-
-=item find_what_requires(requires)
-
-Return a list of headers for the packages that directly depend on the
-specified package for installation and operation. The specified package should
-be just the name, no version or release information.
-
-=item find_what_conflicts(conflicts)
-
-List those packages that have conflicts based on the value of "conflicts".
-
-=item find_by_package(package)
-
-This performs the search by a specific package name. This is the API call
-used by the FETCH tied-hash method, but this differs in that if there is
-in fact more than one matching record, all are returned.
-
-=back
-
-Any of the C<find_*> routines can take an B<RPM::Header> object as an argument,
-in which case the package name will be retrieved and used for the argument. In
-some cases (such as C<find_by_file>), this is probably not what you want. But
-in other cases such as C<find_what_requires>, it may be exactly what you want.
-
-=head2 Importable Defaults
-
-Given that there may be only one concurrent process with the rpm database
-open, and given that such would lead to a lot of program code starting with
-the same sequence of use/tie or use/new, the following identifiers may be
-imported from the package:
-
-=over
-
-=item %RPM
-
-A hash pre-tied to the RPM::Database package (and thus the rpm database).
-
-=item $RPM
-
-A RPM::Database object, referencing a hash tied to the rpm database.
-
-=back
-
-=head1 DIAGNOSTICS
-
-Direct binding to the internal error-management of B<rpm> is still under
-development. At present, most operations generate their diagnostics to
-STDERR.
-
-=head1 CAVEATS
-
-This is currently regarded as alpha-quality software. The interface is
-subject to change in future releases.
-
-=head1 SEE ALSO
-
-L<RPM>, L<RPM::Header>, L<perl>, L<rpm>
-
-=head1 AUTHOR
-
-Randy J. Ray <rjray@blackperl.com>
-
-=cut
+++ /dev/null
-#include "EXTERN.h"
-#include "perl.h"
-#include "XSUB.h"
-
-#include <fcntl.h>
-#include "RPM.h"
-
-static char * const rcsid = "$Id: Database.xs,v 1.18 2002/05/10 05:53:48 rjray Exp $";
-
-/*
- rpmdb_TIEHASH
-
- This is the implementation of the tied-hash class constructor. The XS
- wrapper will verify that the value of class is correct, then massage the
- arguments as needed. The return value is expected to be either NULL or a
- valid RPM__Database value (which the XS wrapper will fix up).
-*/
-RPM__Database rpmdb_TIEHASH(pTHX_ char* class, SV* opts)
-{
- char* root = (char *)NULL;
- int mode = O_RDONLY;
- mode_t perms = 0;
- HV* opt_hash;
- SV* t_magic;
- SV** svp;
- RPM_Database* retvalp; /* For "private" */
- RPM__Database RETVAL;
-
- if (opts)
- {
- if (SvROK(opts) && (SvTYPE(opts) == SVt_PVHV))
- {
- /* This is a hash reference. We are concerned only with
- the key "root". "mode" and "perms" don't apply, as we are
- going to open the database as read-only. */
- opt_hash = (HV*)SvRV(opts);
-
- svp = hv_fetch(opt_hash, "root", 4, FALSE);
- if (svp && SvPOK(*svp))
- root = SvPV(*svp, PL_na);
- }
- else if (SvPOK(opts))
- {
- /* They passed a scalar, assumed to be the "root" */
- root = SvPV(opts, PL_na);
- }
- else
- {
- rpm_error(aTHX_ RPMERR_BADARG,
- "Wrong type for argument 2 to TIEHASH");
- return (Null(RPM__Database));
- }
- }
-
- /* With that all processed, attempt to open the actual RPM DB */
- /* The retvalp is used for the C-level rpmlib information on databases */
- Newz(0, retvalp, 1, RPM_Database);
- if (rpmdbOpen(root, &retvalp->dbp, mode, perms) != 0)
- /* rpm lib will have set the error already */
- return (Null(RPM__Database));
- else
- {
- retvalp->current_rec = 0;
- retvalp->noffs = retvalp->offx = 0;
- retvalp->offsets = (int *)NULL;
- }
-
- RETVAL = newHV();
- retvalp->storage = newHV();
- t_magic = newSViv((unsigned)retvalp);
-
- sv_magic((SV *)RETVAL, Nullsv, 'P', Nullch, 0);
- sv_magic((SV *)RETVAL, t_magic, '~', Nullch, 0);
- SvREFCNT_dec(t_magic);
-
- return RETVAL;
-}
-
-SV* rpmdb_FETCH(pTHX_ RPM__Database self, SV* key)
-{
- const char* name = NULL; /* For the actual name out of (SV *)key */
- int namelen; /* Arg for SvPV(..., len) */
- int offset; /* In case they pass an integer offset */
- Header hdr; /* For rpmdbGetRecord() calls */
- Header lasthdr; /* For searching latest rpm */
- rpmdbMatchIterator mi;
- SV** svp;
- SV* FETCH;
- RPM__Header FETCHp;
- RPM_Database* dbstruct; /* This is the struct used to hold C-level data */
-
- struct_from_object_ret(RPM_Database, dbstruct, self, FETCH);
- /* De-reference key, if it is a reference */
- if (SvROK(key))
- key = SvRV(key);
-
- /* For sake of flexibility (and because it's almost zero overhead),
- allow the request to be by name -or- by an offset number */
- if (SvPOK(key))
- {
- name = SvPV(key, namelen);
-
- /* Step 1: Check to see if this has already been requested and is
- thus cached on the hash itself */
- svp = hv_fetch(dbstruct->storage, (char *)name, namelen, FALSE);
- if (svp && SvROK(*svp))
- return newSVsv(*svp);
-
- offset = -1;
- lasthdr = NULL;
- mi = rpmdbInitIterator(dbstruct->dbp, RPMTAG_NAME, name, 0);
- while ((hdr = rpmdbNextIterator(mi)) != NULL)
- {
- /* There might be more than one match. Find the newest one. */
- if (lasthdr == NULL)
- {
- lasthdr = headerLink(hdr);
- offset = rpmdbGetIteratorOffset(mi);
- }
- else
- {
- if (rpmVersionCompare(hdr, lasthdr) == 1)
- {
- lasthdr = headerLink(hdr);
- offset = rpmdbGetIteratorOffset(mi);
- }
- }
- }
- rpmdbFreeIterator(mi);
- if (offset == -1)
- /* Some sort of error occured when reading the DB or the
- name was not found. */
- return &PL_sv_undef;
- }
- else if (SvIOK(key))
- {
- /* This is actually a lot easier than fetch-by-name, which is
- why I've thrown it in */
- offset = SvIV(key);
- }
- else
- {
- rpm_error(aTHX_ RPMERR_BADARG,
- "RPM::Database::FETCH: Second arg should be name or offset");
- return &PL_sv_undef;
- }
-
- mi = rpmdbInitIterator(dbstruct->dbp, RPMDBI_PACKAGES,
- &offset, sizeof(offset));
- hdr = rpmdbNextIterator(mi);
-
- if (hdr)
- {
- hdr = headerLink(hdr);
- FETCHp = rpmhdr_TIEHASH(aTHX_ "RPM::Header",
- sv_2mortal(newSViv((unsigned)hdr)),
- RPM_HEADER_FROM_REF | RPM_HEADER_READONLY);
- if (name == Null(const char *))
- name = SvPV(rpmhdr_FETCH(aTHX_ FETCHp,
- sv_2mortal(newSVpv("NAME", 4)),
- Null(const char *), 0, 0), namelen);
- FETCH = sv_bless(newRV_noinc((SV*)FETCHp),
- gv_stashpv("RPM::Header", TRUE));
- hv_store(dbstruct->storage, (char *)name, namelen, newSVsv(FETCH),
- FALSE);
- }
- rpmdbFreeIterator(mi);
-
- return FETCH;
-}
-
-bool rpmdb_EXISTS(pTHX_ RPM__Database self, SV* key)
-{
- SV* tmp;
-
- tmp = rpmdb_FETCH(aTHX_ self, key);
- return (tmp != &PL_sv_undef);
-}
-
-/*
- This is quite a bit easier than the FIRSTKEY/NEXTKEY combo for headers.
- In these cases, the transition is based on the last offset fetched, which
- we store on the struct part of self. We don't have to worry about an
- iterator struct.
-*/
-int rpmdb_FIRSTKEY(pTHX_ RPM__Database self, SV** key, SV** value)
-{
- RPM_Database* dbstruct;
-
- struct_from_object_ret(RPM_Database, dbstruct, self, 0);
- if (dbstruct->offsets == NULL || dbstruct->noffs <= 0)
- {
- rpmdbMatchIterator mi;
- Header h;
-
- if (dbstruct->offsets)
- free(dbstruct->offsets);
- dbstruct->offsets = NULL;
- dbstruct->noffs = 0;
- mi = rpmdbInitIterator(dbstruct->dbp, RPMDBI_PACKAGES, NULL, 0);
- while ((h = rpmdbNextIterator(mi)) != NULL)
- {
- dbstruct->noffs++;
- dbstruct->offsets =
- realloc(dbstruct->offsets,
- dbstruct->noffs * sizeof(dbstruct->offsets[0]));
- dbstruct->offsets[dbstruct->noffs-1] = rpmdbGetIteratorOffset(mi);
- }
- rpmdbFreeIterator(mi);
- }
-
- if (dbstruct->offsets == NULL || dbstruct->noffs <= 0)
- return 0;
-
- dbstruct->offx = 0;
- dbstruct->current_rec = dbstruct->offsets[dbstruct->offx++];
-
- *value = rpmdb_FETCH(aTHX_ self, newSViv(dbstruct->current_rec));
- *key = rpmhdr_FETCH(aTHX_ (RPM__Header)SvRV(*value), newSVpv("name", 4),
- Nullch, 0, 0);
-
- return 1;
-}
-
-int rpmdb_NEXTKEY(pTHX_ RPM__Database self, SV* key,
- SV** nextkey, SV** nextvalue)
-{
- RPM_Database* dbstruct;
-
- struct_from_object_ret(RPM_Database, dbstruct, self, 0);
-
- if (dbstruct->offsets == NULL || dbstruct->noffs <= 0)
- return 0;
- if (dbstruct->offx >= dbstruct->noffs)
- return 0;
-
- dbstruct->current_rec = dbstruct->offsets[dbstruct->offx++];
-
- *nextvalue = rpmdb_FETCH(aTHX_ self, newSViv(dbstruct->current_rec));
- *nextkey = rpmhdr_FETCH(aTHX_ (RPM__Header)SvRV(*nextvalue),
- newSVpv("name", 4), Nullch, 0, 0);
-
- return 1;
-}
-
-void rpmdb_DESTROY(pTHX_ RPM__Database self)
-{
- RPM_Database* dbstruct; /* This is the struct used to hold C-level data */
-
- struct_from_object(RPM_Database, dbstruct, self);
-
- rpmdbClose(dbstruct->dbp);
- if (dbstruct->offsets)
- Safefree(dbstruct->offsets);
-
- hv_undef(dbstruct->storage);
- Safefree(dbstruct);
- hv_undef(self);
-}
-
-int rpmdb_init(SV* class, const char* root, int perms)
-{
- return (1 - rpmdbInit(root, perms));
-}
-
-int rpmdb_rebuild(SV* class, const char* root)
-{
- return (1 - rpmdbRebuild(root));
-}
-
-/*
- This is a front-end to all the rpmdbFindBy*() set, including FindByPackage
- which differs from FETCH above in that if there is actually more than one
- match, all will be returned.
-*/
-AV* rpmdb_find_by_whatever(pTHX_ RPM__Database self, SV* string, int idx)
-{
- const char* str = NULL; /* For the actual string out of (SV *)string */
- RPM_Database* dbstruct; /* This is the struct used to hold C-level data */
- AV* return_val;
- int loop;
- SV* tmp_hdr;
- rpmdbMatchIterator mi;
-
- /* Any successful operation will store items on this */
- return_val = newAV();
-
- struct_from_object_ret(RPM_Database, dbstruct, self, return_val);
- if (sv_derived_from(string, "RPM::Header"))
- {
- SV* fetch_string = rpmhdr_FETCH(aTHX_ (RPM__Header)SvRV(string),
- sv_2mortal(newSVpvn("NAME", 4)),
- Nullch, 0, 0);
-
- str = SvPV(fetch_string, PL_na);
- }
- else
- {
- /* De-reference key, if it is a reference */
- if (SvROK(string))
- string = SvRV(string);
- /* Get the string */
- str = SvPV(string, PL_na);
- }
-
- mi = rpmdbInitIterator(dbstruct->dbp, idx, str, 0);
- if (mi)
- {
- av_extend(return_val, rpmdbGetIteratorCount(mi));
- loop = 0;
- while ((rpmdbNextIterator(mi)) != NULL)
- {
- idx = rpmdbGetIteratorOffset(mi);
- tmp_hdr = rpmdb_FETCH(aTHX_ self, sv_2mortal(newSViv(idx)));
- av_store(return_val, loop++, sv_2mortal(newSVsv(tmp_hdr)));
- }
- }
- rpmdbFreeIterator(mi);
-
- return return_val;
-}
-
-
-MODULE = RPM::Database PACKAGE = RPM::Database PREFIX = rpmdb_
-
-
-RPM::Database
-rpmdb_TIEHASH(class, opts=NULL)
- char* class;
- SV* opts;
- PROTOTYPE: $;$
- CODE:
- RETVAL = rpmdb_TIEHASH(aTHX_ class, opts);
- OUTPUT:
- RETVAL
-
-SV*
-rpmdb_FETCH(self, key)
- RPM::Database self;
- SV* key;
- PROTOTYPE: $$
- CODE:
- RETVAL = rpmdb_FETCH(aTHX_ self, key);
- OUTPUT:
- RETVAL
-
-int
-rpmdb_STORE(self=NULL, key=NULL, value=NULL)
- SV* self;
- SV* key;
- SV* value;
- PROTOTYPE: $$$
- CODE:
- {
- rpm_error(aTHX_ RPMERR_NOCREATEDB, "STORE: operation not permitted");
- RETVAL = 0;
- }
- OUTPUT:
- RETVAL
-
-SV*
-rpmdb_DELETE(self=NULL, key=NULL)
- SV* self;
- SV* key;
- PROTOTYPE: $$
- CODE:
- {
- rpm_error(aTHX_ RPMERR_NOCREATEDB, "DELETE: operation not permitted");
- RETVAL = Nullsv;
- }
- OUTPUT:
- RETVAL
-
-int
-rpmdb_CLEAR(self=NULL)
- SV* self;
- PROTOTYPE: $
- CODE:
- {
- rpm_error(aTHX_ RPMERR_NOCREATEDB, "CLEAR: operation not permitted");
- RETVAL = 0;
- }
- OUTPUT:
- RETVAL
-
-bool
-rpmdb_EXISTS(self, key)
- RPM::Database self;
- SV* key;
- PROTOTYPE: $$
- CODE:
- RETVAL = rpmdb_EXISTS(aTHX_ self, key);
- OUTPUT:
- RETVAL
-
-void
-rpmdb_FIRSTKEY(self)
- RPM::Database self;
- PROTOTYPE: $
- PPCODE:
- {
- SV* key;
- SV* value;
-
- if (! rpmdb_FIRSTKEY(aTHX_ self, &key, &value))
- {
- key = newSVsv(&PL_sv_undef);
- value = newSVsv(&PL_sv_undef);
- }
-
- EXTEND(SP, 2);
- PUSHs(sv_2mortal(value));
- PUSHs(sv_2mortal(newSVsv(key)));
- }
-
-void
-rpmdb_NEXTKEY(self, key=NULL)
- RPM::Database self;
- SV* key;
- PROTOTYPE: $;$
- PPCODE:
- {
- SV* nextkey;
- SV* nextvalue;
-
- if (! rpmdb_NEXTKEY(aTHX_ self, key, &nextkey, &nextvalue))
- {
- nextkey = newSVsv(&PL_sv_undef);
- nextvalue = newSVsv(&PL_sv_undef);
- }
-
- EXTEND(SP, 2);
- PUSHs(sv_2mortal(nextvalue));
- PUSHs(sv_2mortal(newSVsv(nextkey)));
- }
-
-void
-rpmdb_DESTROY(self)
- RPM::Database self;
- PROTOTYPE: $
- CODE:
- rpmdb_DESTROY(aTHX_ self);
-
-int
-rpmdb_init(class, root=NULL, perms=O_RDWR)
- SV* class;
- const char* root;
- int perms;
- PROTOTYPE: $;$$
- INIT:
- if (! (SvPOK(class) && strcmp(SvPV(class, PL_na), "RPM::Database")))
- {
- rpm_error(aTHX_ RPMERR_BADARG,
- "RPM::Database::init must be called as a static method");
- ST(0) = sv_2mortal(newSViv(0));
- XSRETURN(1);
- }
-
-int
-rpmdb_rebuild(class, root=NULL)
- SV* class;
- const char* root;
- PROTOTYPE: $;$
- INIT:
- if (! (SvPOK(class) && strcmp(SvPV(class, PL_na), "RPM::Database")))
- {
- rpm_error(aTHX_ RPMERR_BADARG,
- "RPM::Database::rebuild must be called as a static method");
- ST(0) = sv_2mortal(newSViv(0));
- XSRETURN(1);
- }
-
-void
-rpmdb_find_by_file(self, string)
- RPM::Database self;
- SV* string;
- PROTOTYPE: $$
- ALIAS:
- find_by_group = RPMTAG_GROUP
- find_what_provides = RPMTAG_PROVIDENAME
- find_what_requires = RPMTAG_REQUIRENAME
- find_what_conflicts = RPMTAG_CONFLICTNAME
- find_by_package = RPMTAG_NAME
- PPCODE:
- {
- AV* matches;
- int len, size;
-
- if (ix == 0) ix = RPMTAG_BASENAMES;
- matches = rpmdb_find_by_whatever(aTHX_ self, string, ix);
- if ((len = av_len(matches)) != -1)
- {
- /* We have (len+1) elements in the array to put onto the stack */
- size = len + 1;
- EXTEND(SP, size);
- while (len >= 0)
- {
- /* This being a stack and all, we put them in backwards */
- PUSHs(sv_2mortal(newSVsv(*av_fetch(matches, len, FALSE))));
- len--;
- }
- }
- else
- size = 0;
-
- XSRETURN(size);
- }
+++ /dev/null
-###############################################################################
-#
-# This file copyright (c) 2000 by Randy J. Ray, all rights reserved
-#
-# Copying and distribution are permitted under the terms of the Artistic
-# License as distributed with Perl versions 5.002 and later.
-#
-###############################################################################
-#
-# $Id: Error.pm,v 1.10 2001/04/27 09:05:21 rjray Exp $
-#
-# Description: Error-management support that cooperates with the primary
-# Perl/C error glue.
-#
-# Functions: None (all XS)
-#
-# Libraries: RPM
-#
-# Global Consts: None.
-#
-# Environment: None.
-#
-###############################################################################
-
-package RPM::Error;
-
-use 5.005;
-use strict;
-use vars qw(@ISA $VERSION @EXPORT @EXPORT_OK);
-
-require Exporter;
-require RPM;
-
-@ISA = qw(Exporter);
-
-$VERSION = do { my @r=(q$Revision: 1.10 $=~/\d+/g); sprintf "%d."."%02d"x$#r,@r };
-
-@EXPORT = qw(clear_errors set_error_callback rpm_error);
-@EXPORT_OK = @EXPORT;
-
-1;
-
-__END__
-
-=head1 NAME
-
-RPM::Error - Functions to supplement the internal error management of RPM
-
-=head1 SYNOPSIS
-
- use RPM::Error;
- use RPM::Constants ':rpmerr';
-
- set_error_callback(sub { ... });
-
- rpm_error(RPMERR_DBOPEN, "Error opening RPM DB: $!");
-
-=head1 DESCRIPTION
-
-The B<RPM::Error> package provides access to some functions that work with
-(but do not replace) the special C<$RPM::err> variable. These routines allow
-for reporting errors through the B<RPM> facility, clearing the error variable,
-and registering a callback function to be invoked whenever a new error is
-raised.
-
-None of these routines are required for normal use of the special variable
-C<$RPM::err> (see L<RPM>).
-
-=head1 USAGE
-
-The following routines are exported by B<RPM::Error>:
-
-=over
-
-=item rpm_error($code, $message)
-
-Report an error through the internal facility used by B<rpm>. By using this
-function, the special error variable is set up to have a dual-nature: When
-evaluated in a numeric context, it returns the numerical code C<$code>. When
-evaluated as a string, it will return C<$message>. The value of C<$code>
-should be (but is not required to be) one of the values exported from the
-B<RPM::Constants> package via the B<:rpmerr> tag. C<$message> may be any
-string value.
-
-=item clear_errors()
-
-Clears both the numeric and string values of C<$RPM::err>.
-
-=item $old_cb = set_error_callback($subr)
-
-Set a (new) callback to be invoked whenever a new error is flagged. Returns
-the old (existing) callback value if there was one, C<undef> otherwise.
-
-The parameter to this call should be either a subroutine reference or a
-closure. A subroutine name may be passed; if so, it should either be given
-a package qualification or exist in the C<main::> namespace. The routine,
-when invoked, will be passed the numeric code and the message string being
-raised as the error. Note that the callback may be invoked by internal error
-flagging in the core B<rpm> library, as well as by calls to B<rpm_error>
-above.
-
-Before any user-provided callback is invoked, the C<$RPM::err> variable is
-set. While accessing it in a callback would be redundant, users should not
-be concerned about interrupting other internal processes (in theory, that is).
-
-=back
-
-=head1 DIAGNOSTICS
-
-If the value passed to B<set_error_callback> is not valid, the current
-callback is set to a null value.
-
-=head1 CAVEATS
-
-The code value passed to B<rpm_error> is not checked against the list of
-valid constants before assignment.
-
-=head1 SEE ALSO
-
-L<RPM>, L<perl>, L<rpm>
-
-=head1 AUTHOR
-
-Randy J. Ray <rjray@blackperl.com>
-
-=cut
+++ /dev/null
-#include "EXTERN.h"
-#include "perl.h"
-#include "XSUB.h"
-
-#include "RPM.h"
-
-static char * const rcsid = "$Id: Error.xs,v 1.5 2002/05/10 07:38:21 rjray Exp $";
-
-static CV* err_callback;
-
-/*
- This was static, but it needs to be accessible from other modules, as well.
-*/
-SV* rpm_errSV;
-
-/*
- This is a callback routine that the bootstrapper will register with the RPM
- lib so as to catch any errors. (I hope)
-*/
-static void rpm_catch_errors(void)
-{
- /* Because rpmErrorSetCallback expects (void)fn(void), we have to declare
- our thread context here */
- dTHX;
- int error_code;
- const char* error_string;
-
- error_code = rpmErrorCode();
- error_string = rpmErrorString();
-
- /* Set the string part, first */
- sv_setsv(rpm_errSV, newSVpv((char*)error_string, strlen(error_string)));
- /* Set the IV part */
- sv_setiv(rpm_errSV, error_code);
- /* Doing that didn't erase the PV part, but it cleared the flag: */
- SvPOK_on(rpm_errSV);
-
- /* If there is a current callback, invoke it: */
- if (err_callback != Nullcv)
- {
- /* This is just standard boilerplate for calling perl from C */
- dSP;
- ENTER;
- SAVETMPS;
- PUSHMARK(sp);
- XPUSHs(sv_2mortal(newSViv(error_code)));
- XPUSHs(sv_2mortal(newSVpv((char*)error_string, strlen(error_string))));
- PUTBACK;
-
- /* The actual call */
- perl_call_sv((SV *)err_callback, G_DISCARD);
-
- /* More boilerplate */
- SPAGAIN;
- PUTBACK;
- FREETMPS;
- LEAVE;
- }
-
- return;
-}
-
-/* This is just to offer an easy way to clear both sides of $RPM::err */
-void clear_errors(pTHX)
-{
- sv_setsv(rpm_errSV, newSVpv("", 0));
- sv_setiv(rpm_errSV, 0);
- SvPOK_on(rpm_errSV);
-
- return;
-}
-
-SV* set_error_callback(pTHX_ SV* newcb)
-{
- SV* oldcb;
-
- oldcb = (err_callback) ? newRV((SV *)err_callback) : newSVsv(&PL_sv_undef);
-
- if (SvROK(newcb)) newcb = SvRV(newcb);
- if (SvTYPE(newcb) == SVt_PVCV)
- err_callback = (CV *)newcb;
- else if (SvPOK(newcb))
- {
- char* fn_name;
- char* sv_name;
-
- sv_name = SvPV(newcb, PL_na);
- if (! strstr(sv_name, "::"))
- {
- Newz(TRUE, fn_name, strlen(sv_name) + 7, char);
- strncat(fn_name, "main::", 6);
- strcat(fn_name + 6, sv_name);
- }
- else
- fn_name = sv_name;
-
- err_callback = perl_get_cv(fn_name, FALSE);
- }
- else
- {
- err_callback = Nullcv;
- }
-
- return oldcb;
-}
-
-void rpm_error(pTHX_ int code, const char* message)
-{
- rpmError(code, (char *)message);
-}
-
-
-MODULE = RPM::Error PACKAGE = RPM::Error
-
-
-SV*
-set_error_callback(newcb)
- SV* newcb;
- PROTOTYPE: $
- CODE:
- RETVAL = set_error_callback(aTHX_ newcb);
- OUTPUT:
- RETVAL
-
-void
-clear_errors()
- PROTOTYPE:
- CODE:
- clear_errors(aTHX);
-
-void
-rpm_error(code, message)
- int code;
- char* message;
- PROTOTYPE: $$
- CODE:
- rpm_error(aTHX_ code, message);
-
-
-BOOT:
-{
- rpm_errSV = perl_get_sv("RPM::err", GV_ADD|GV_ADDMULTI);
- rpmErrorSetCallback(rpm_catch_errors);
- err_callback = Nullcv;
-}
+++ /dev/null
-###############################################################################
-#
-# (c) Copyright @ 2000, Randy J. Ray <rjray@blackperl.com>
-# All Rights Reserved
-#
-###############################################################################
-#
-# $Id: Header.pm,v 1.20 2001/04/27 09:05:21 rjray Exp $
-#
-# Description: The RPM::Header class provides access to the RPM Header
-# structure as a tied hash, allowing direct access to the
-# tags in a header as keys, and the content of said tags
-# as the values.
-#
-# Functions: new
-# AUTOLOAD
-# filenames
-#
-# Libraries: None.
-#
-# Global Consts: None.
-#
-# Environment: Just stuff from the RPM config.
-#
-###############################################################################
-
-package RPM::Header;
-
-require 5.005;
-
-use strict;
-use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS $AUTOLOAD);
-use subs qw(new AUTOLOAD filenames);
-
-require Exporter;
-
-use RPM;
-use RPM::Error;
-use RPM::Constants ':rpmerr';
-
-$VERSION = do { my @r=(q$Revision: 1.20 $=~/\d+/g); sprintf "%d."."%02d"x$#r,@r };
-
-@ISA = qw(Exporter);
-@EXPORT = ();
-@EXPORT_OK = qw(RPM_HEADER_MASK RPM_HEADER_READONLY);
-%EXPORT_TAGS = (all => \@EXPORT_OK);
-
-1;
-
-sub AUTOLOAD
-{
- my $constname;
- ($constname = $AUTOLOAD) =~ s/.*:://;
- die "& not defined" if $constname eq 'constant';
- my $val = constant($constname);
- if ($! != 0)
- {
- die "Your vendor has not defined RPM macro $constname";
- }
- no strict 'refs';
- *$AUTOLOAD = sub { $val };
- goto &$AUTOLOAD;
-}
-
-sub new
-{
- my $class = shift;
- my %hash = ();
-
- tie %hash, $class, @_;
-}
-
-###############################################################################
-#
-# Sub Name: filenames
-#
-# Description: Glue together the contents of BASENAMES, DIRNAMES and
-# DIRINDEXES to create a single list of fully-qualified
-# filenames
-#
-# Arguments: NAME IN/OUT TYPE DESCRIPTION
-# $self in ref Object of this class
-#
-# Globals: None.
-#
-# Environment: None.
-#
-# Returns: Success: listref
-# Failure: undef
-#
-###############################################################################
-sub filenames
-{
- my $self = shift;
-
- # Each of these three fetches will have already triggered rpm_error, were
- # there any problems.
- my $base = $self->{BASENAMES} || return undef;
- my $dirs = $self->{DIRNAMES} || return undef;
- my $idxs = $self->{DIRINDEXES} || return undef;
-
- unless (@$base == @$idxs)
- {
- rpm_error(RPMERR_INTERNAL,
- "Mis-matched elements lists for BASENAMES and DIRINDEXES");
- return undef;
- }
-
- # The value from DIRNAMES already has the trailing separator
- [ map { "$dirs->[$idxs->[$_]]$base->[$_]" } (0 .. $#$base) ];
-}
-
-
-__END__
-
-=head1 NAME
-
-RPM::Header - Access to RPM package headers
-
-=head1 SYNOPSIS
-
- use RPM::Header;
-
- tie %hdr, "RPM::Header", "rpm-3.0.4-0.48.i386.rpm" or die "$RPM::err";
-
- for (sort keys %hdr)
- {
- ...
- }
-
-=head1 DESCRIPTION
-
-The B<RPM::Header> package permits access to the header of a package (external
-file or currently installed) as either a tied hash or a blessed hash reference.
-The tags that are present in the header are expressed as keys. Retrieving
-them via C<keys> or C<each> returns the tags in the order in which they
-appear in the header. Keys may be requested without regard for letter case,
-but they are always returned as all upper-case.
-
-The return value corresponding to each key is a list reference or scalar
-(or C<undef> if the key is not valid), depending on the data-type of the
-key. Each of the header tags are noted with one of C<$> or C<@> in the
-B<RPM::Constants> documentation. The C<defined> keyword should be used
-for testing success versus failure, as empty tags are possible. See the
-C<scalar_tag> test, below.
-
-This is a significant change from versions prior to 0.27, in which the
-return value was always a list reference. This new approach brings
-B<RPM::Header> more in line with other interfaces to B<rpm> header information.
-
-B<RPM::Header> objects are also the native return value from keys retrieved
-in the B<RPM::Database> class (see L<RPM::Database>). In these cases, the
-header data is marked read-only, and attempts to alter any of the keys will
-generate an error.
-
-There are also a number of class methods implemented, which are described in
-the next section.
-
-=head1 USAGE
-
-=head2 Creating an Object
-
-An object may be created one of two ways:
-
- tie %h, "RPM::Header", "filename";
-
- $href = new RPM::Header "filename";
-
-The latter approach offers more direct access to the class methods, while
-also permitting the usual tied-hash operations such as fetching:
-
- $href->{tag} # Such as "name" or "version"
-
-=head2 Class Methods
-
-The following methods are available to objects of this class, in addition to
-the tied-hash suite of operations. If the object is a hash instead of a
-hash reference, it can be used to call these methods via:
-
- (tied %hash)->method_name(...)
-
-=over
-
-=item filenames
-
-The B<RPM> system attempts to save space by splitting up the file paths into
-the leafs (stored by the tag C<BASENAMES>), the directories (stored under
-C<DIRNAMES>) and indexes into the list of directories (stored under
-C<DIRINDEXES>). As a convenience, this method re-assembles the list of
-filenames and returns it as a list reference. If an error occurs, C<undef>
-will be returned after C<rpm_error> has been called.
-
-=item is_source
-
-Returns true (1) or false (0), depending on whether the package the header
-object is derived from is a source RPM.
-
-=item size
-
-Return the size of the header, in bytes, within the disk file containing the
-associated package. The value is also returned for those headers within the
-database.
-
-=item scalar_tag(TAG)
-
-Returns a true/false value (1 or 0) based on whether the value returned by
-the specified tag is a scalar or an array reference. Useful in place of
-using C<ref> to test the fetched values. B<TAG> may be either a string (name)
-or a number (imported from the B<RPM::Constants> tag C<:rpmtag>). This
-method may be called as a class (static) method.
-
-=item tagtype(TAG)
-
-Given a tag I<TAG>, return the type as a numerical value. The valid types
-can be imported from the B<RPM::Constants> package via the import-tag
-":rpmtype", and are:
-
-=over
-
-=item RPM_NULL_TYPE
-
-Used internally by B<rpm>.
-
-=item RPM_BIN_TYPE
-
-The data returned is a single chunk of binary data. It has been converted to
-a single "string" in Perl terms, but may contain nulls within it. The
-B<length()> keyword should return the correct size for the chunk.
-
-=item RPM_CHAR_TYPE
-
-All items are single-character in nature. Note that since Perl does not
-distinguish single characters versus strings in the way that C does, these
-are stored as single-character strings. It is a tradeoff of efficiency over
-memory.
-
-=item RPM_INT8_TYPE
-
-All items are integers no larger than 8 bits wide.
-
-=item RPM_INT16_TYPE
-
-All items are integers no larger than 16 bits wide.
-
-=item RPM_INT32_TYPE
-
-All items are integers no larger than 32 bits wide.
-
-=item RPM_STRING_TYPE
-
-=item RPM_I18NSTRING_TYPE
-
-=item RPM_STRING_ARRAY_TYPE
-
-These three are functionally similar from the Perl perspective. Currently,
-B<RPM> does not export data in an I18N format, it will have been converted to
-an ordinary string before being handed to the caller (in this case, before
-the internal Perl/XS code receives it). The distinction between STRING and
-STRING_ARRAY types is only relevant internally. All of these are sequences of
-one or more text strings, returned in the same internal order as they are
-stored within the header.
-
-=back
-
-=item NVR
-
-The commonly-needed data triple of (B<name>, B<version>, B<release>) may be
-accessed more directly by means of this method. It returns the three values
-on the stack, saving the need for three separate fetches.
-
-=item cmpver(OTHER)
-
-Compare the version of the current header against that in the header
-referenced by C<$other>. The argument should be an object reference, not
-a tied-hash representation of a header. Returns -1, 0 or 1, based on the
-established behavior of other comparison operators (C<cmp> and C<E<lt>=E<gt>>);
--1 indicates that the calling object is considered less, or older, than the
-passed argument. A value of 1 indicates that the calling object is greater,
-or newer, than the argument. A value of 0 indicates that they are equal.
-
-=item source_name
-
-If the B<RPM::Header> object is created directly from a file, FTP source
-or HTTP source, then that source is kept for future reference and may be
-retrieved using this accessor. This will be an empty string if the header
-was retrieved from the RPM database, or was built in-memory from data.
-
-=back
-
-=head1 DIAGNOSTICS
-
-Direct binding to the internal error-management of B<rpm> is still under
-development. At present, most operations generate their diagnostics to
-STDERR.
-
-=head1 CAVEATS
-
-This is currently regarded as alpha-quality software. The interface is
-subject to change in future releases.
-
-=head1 SEE ALSO
-
-L<RPM>, L<RPM::Database>, L<RPM::Constants>, L<perl>, L<rpm>
-
-=head1 AUTHOR
-
-Randy J. Ray <rjray@blackperl.com>
-
-=cut
+++ /dev/null
-#include "EXTERN.h"
-#include "perl.h"
-#include "XSUB.h"
-
-#include "RPM.h"
-
-#ifndef RPMERR_READERROR
-# define RPMERR_READERROR RPMERR_READ
-#endif
-
-static char * const rcsid = "$Id: Header.xs,v 1.26 2002/05/10 07:37:08 rjray Exp $";
-static int scalar_tag(pTHX_ SV *, int);
-
-/*
- Use this define for deriving the saved Header struct, rather than coding
- it a dozen places.
-*/
-#define header_from_object_ret(header, object, err_ret) \
- { \
- MAGIC* mg = mg_find((SV *)(object), '~'); \
- if (mg) \
- (header) = (RPM_Header *)SvIV(mg->mg_obj); \
- else \
- return (err_ret); \
- }
-/* And a no-return version: */
-#define header_from_object(header, object) \
- { \
- MAGIC* mg = mg_find((SV *)(object), '~'); \
- if (mg) \
- (header) = (RPM_Header *)SvIV(mg->mg_obj); \
- else \
- (header) = Null(RPM_Header *); \
- }
-
-/* Any constants that are specific to the RPM::Header class will be exported
- from here, via this C-level constant() routine */
-static int constant(pTHX_ char *name)
-{
- errno = 0;
-
- if (strncmp((const char *)name, "RPM_HEADER_", 11))
- {
- errno = ENOENT;
- return 0;
- }
- else
- {
- name += 11;
- switch (*name)
- {
- case 'M':
- if (strEQ(name, "MASK"))
-#ifdef RPM_HEADER_MASK
- return RPM_HEADER_MASK;
-#endif
- case 'R':
- if (strEQ(name, "READONLY"))
-#ifdef RPM_HEADER_READONLY
- return RPM_HEADER_READONLY;
-#endif
- default:
- errno = EINVAL;
- return 0;
- }
- }
-}
-
-/* Some simple functions to manage key-to-SV* transactions, since these
- gets used frequently. */
-const char* sv2key(pTHX_ SV* key)
-{
- const char* new_key;
-
- /* De-reference key, if it is a reference */
- if (SvROK(key))
- key = SvRV(key);
- new_key = SvPV(key, PL_na);
-
- return new_key;
-}
-
-SV* key2sv(pTHX_ const char* key)
-{
- return (sv_2mortal(newSVpv((char *)key, PL_na)));
-}
-
-/* This creates a header data-field from the passed-in data */
-static SV* rpmhdr_create(pTHX_ const char* data, int type, int size,
- int scalar)
-{
- char urk[2];
- AV* new_list;
- SV* new_item;
- int idx;
-
- new_list = newAV();
-
- /*
- Bad enough to have to duplicate the loop for all the case branches, I
- can at least bitch out on two of them:
- */
- if (type == RPM_NULL_TYPE)
- {
- return newSVsv(&PL_sv_undef);
- }
- else if (type == RPM_BIN_TYPE)
- {
- /* This differs from other types in that here size is the length of
- the binary chunk itself */
- av_store(new_list, 0, newSVpv((char *)data, size));
- }
- else
- {
- /* There will be at least this many items: */
- av_extend(new_list, size);
-
- switch (type)
- {
- case RPM_CHAR_TYPE:
- {
- char* loop;
-
- for (loop = (char *)data, idx = 0; idx < size; idx++, loop++)
- {
- urk[0] = *data;
- urk[1] = '\0';
- sv_setpvn(*av_fetch(new_list, idx, TRUE), (char *)urk, 1);
- }
-
- break;
- }
- case RPM_INT8_TYPE:
- {
- I8* loop;
-
- for (loop = (I8 *)data, idx = 0; idx < size; idx++, loop++)
- {
- /* Note that the rpm lib also uses masks for INT8 */
- sv_setiv(*av_fetch(new_list, idx, TRUE),
- (I32)(*((I8 *)loop) & 0xff));
- }
-
- break;
- }
- case RPM_INT16_TYPE:
- {
- I16* loop;
-
- for (loop = (I16 *)data, idx = 0; idx < size; idx++, loop++)
- {
- /* Note that the rpm lib also uses masks for INT16 */
- sv_setiv(*av_fetch(new_list, idx, TRUE),
- (I32)(*((I16 *)loop) & 0xffff));
- }
-
- break;
- }
- case RPM_INT32_TYPE:
- {
- I32* loop;
-
- for (loop = (I32 *)data, idx = 0; idx < size; idx++, loop++)
- {
- sv_setiv(*av_fetch(new_list, idx, TRUE),
- (I32)*((I32 *)loop));
- }
-
- break;
- }
- case RPM_STRING_TYPE:
- case RPM_I18NSTRING_TYPE:
- case RPM_STRING_ARRAY_TYPE:
- {
- char** loop;
-
- /* Special case for exactly one RPM_STRING_TYPE */
- if (type == RPM_STRING_TYPE && size == 1)
- sv_setpv(*av_fetch(new_list, 0, TRUE), data);
- else
- {
- for (loop = (char **)data, idx = 0;
- idx < size;
- idx++, loop++)
- {
- sv_setpvn(*av_fetch(new_list, idx, TRUE),
- *loop, strlen(*loop));
- }
-
- /* Only for STRING_ARRAY_TYPE do we have to call free() */
- if (type == RPM_STRING_ARRAY_TYPE) Safefree(data);
- }
-
- break;
- }
- default:
- rpm_error(aTHX_ RPMERR_BADARG, "Unimplemented tag type");
- break;
- }
- }
-
- if (scalar)
- {
- new_item = newSVsv(*av_fetch(new_list, 0, FALSE));
- av_undef(new_list);
- }
- else
- new_item = newRV_noinc((SV *)new_list);
-
- return new_item;
-}
-
-/* These three are for reading the header data from external sources */
-static int new_from_fd_t(FD_t fd, RPM_Header* new_hdr)
-{
- if (rpmReadPackageHeader(fd, &new_hdr->hdr, &new_hdr->isSource,
- &new_hdr->major, &new_hdr->minor))
- {
- /* Some cases of this failing, rpmError was already called. But not
- all cases, unfortunately. So check the IV part of rpm_errSV */
- if (! SvIV(rpm_errSV))
- rpm_error(aTHX_ RPMERR_READERROR, "Error reading package header");
- return 0;
- }
-
- return 1;
-}
-
-static int new_from_fd(int fd, RPM_Header* new_hdr)
-{
- FD_t FD = fdDup(fd);
-
- return(new_from_fd_t(FD, new_hdr));
-}
-
-static int new_from_fname(pTHX_ const char* source, RPM_Header* new_hdr)
-{
- FD_t fd;
- int retval;
-
- if (! (fd = Fopen(source, "r")))
- {
- char errmsg[256];
-
- snprintf(errmsg, 256, "Unable to open file %s", source);
- rpm_error(aTHX_ RPMERR_BADFILENAME, errmsg);
- return 0;
- }
-
- if ((retval = new_from_fd_t(fd, new_hdr)))
- {
- Fclose(fd);
- New(0, new_hdr->source_name, strlen(source) + 1, char);
- strcpy(new_hdr->source_name, source);
- }
-
- return retval;
-}
-
-RPM__Header rpmhdr_TIEHASH(pTHX_ char* class, SV* source, int flags)
-{
- char* fname;
- int fname_len;
- RPM__Header RETVAL;
- RPM_Header* retvalp; /* Use this to store the actual C-level data */
- SV* t_magic;
-
- Newz(0, retvalp, 1, RPM_Header);
- RETVAL = Nullhv;
-
- if (! source)
- retvalp->hdr = headerNew();
- else if (! (flags & RPM_HEADER_FROM_REF))
- {
- /* If we aren't starting out with a pointer to a Header
- struct, figure out how to get there from here */
-
- /* If it is a string value, assume it to be a file name */
- if (SvPOK(source))
- {
- fname = SvPV(source, fname_len);
- if (! new_from_fname(aTHX_ fname, retvalp))
- {
- return RETVAL;
- }
- }
- else if (IoIFP(sv_2io(source)))
- {
- if (! new_from_fd(PerlIO_fileno(IoIFP(sv_2io(source))),
- retvalp))
- {
- return RETVAL;
- }
- }
- else
- {
- rpm_error(aTHX_ RPMERR_BADARG,
- "Argument 2 must be filename or GLOB");
- return RETVAL;
- }
- }
- else
- {
- retvalp->hdr = (Header)SvIV(source);
- /* We simply don't know these three settings at this point */
- retvalp->isSource = 0;
- retvalp->major = 0;
- retvalp->minor = 0;
- }
-
- /* These three are likely to be most of the data requests, anyway */
- headerNVR(retvalp->hdr,
- &retvalp->name, &retvalp->version, &retvalp->release);
- /* This defaults to false, but RPM::Database will set it true */
- retvalp->read_only = flags & RPM_HEADER_READONLY;
-
- retvalp->iterator = (HeaderIterator)NULL;
-
- retvalp->storage = newHV();
- RETVAL = newHV();
- t_magic = newSViv((unsigned)retvalp);
- /* With the actual HV*, store the type-keys for the three cached values: */
- hv_store(retvalp->storage,
- "NAME_t", 7, newSViv(RPM_STRING_TYPE), FALSE);
- hv_store(retvalp->storage,
- "VERSION_t", 10, newSViv(RPM_STRING_TYPE), FALSE);
- hv_store(retvalp->storage,
- "RELEASE_t", 10, newSViv(RPM_STRING_TYPE), FALSE);
-
- sv_magic((SV *)RETVAL, Nullsv, 'P', Nullch, 0);
- sv_magic((SV *)RETVAL, t_magic, '~', Nullch, 0);
- SvREFCNT_dec(t_magic);
-
- return RETVAL;
-}
-
-SV* rpmhdr_FETCH(pTHX_ RPM__Header self, SV* key,
- const char* data_in, int type_in, int size_in)
-{
- const char* name; /* For the actual name out of (SV *)key */
- int namelen; /* Arg for SvPV(..., len) */
- char* uc_name; /* UC'd version of name */
- RPM_Header* hdr; /* Pointer to C-level struct */
- SV** svp;
- SV* FETCH;
- int i, tag_by_num;
- char errmsg[256];
-
- FETCH = newSVsv(&PL_sv_undef);
-
- struct_from_object_ret(RPM_Header, hdr, self, FETCH);
-
- name = sv2key(aTHX_ key);
- if (! (name && (namelen = strlen(name))))
- return FETCH;
-
- New(0, uc_name, namelen+3, char);
- for (i = 0; i < namelen; i++)
- uc_name[i] = toUPPER(name[i]);
- uc_name[i] = '\0';
-
- /* Get the #define value for the tag from the hash made at boot */
- if (! (tag_by_num = tag2num(aTHX_ uc_name)))
- {
- snprintf(errmsg, 256, "RPM::Header::FETCH: unknown tag '%s'", uc_name);
- rpm_error(aTHX_ RPMERR_BADARG, errmsg);
- Safefree(uc_name);
- return FETCH;
- }
-
- /* Check the three keys that are cached directly on the struct itself: */
- if (! strcmp(uc_name, "NAME"))
- FETCH = newSVpv((char *)hdr->name, 0);
- else if (! strcmp(uc_name, "VERSION"))
- FETCH = newSVpv((char *)hdr->version, 0);
- else if (! strcmp(uc_name, "RELEASE"))
- FETCH = newSVpv((char *)hdr->release, 0);
- else
- {
- /* If it wasn't one of those three, then we have to explicitly fetch
- it, either from the store in cache or via the headerGetEntry call */
- svp = hv_fetch(hdr->storage, uc_name, namelen, FALSE);
- if (svp && SvOK(*svp))
- {
- FETCH = newSVsv(*svp);
- }
- else if (data_in)
- {
- /* In some cases (particarly the iterators) we could be called
- with the data already available, but not hashed just yet. */
- FETCH = rpmhdr_create(aTHX_ data_in, type_in, size_in,
- scalar_tag(aTHX_ Nullsv, tag_by_num));
-
- hv_store(hdr->storage, uc_name, namelen, FETCH, FALSE);
- hv_store(hdr->storage, strcat(uc_name, "_t"), (namelen + 2),
- newSViv(type_in), FALSE);
- }
- else
- {
- char* new_item_p;
- int new_item_type;
- int size;
-
- /* Pull the tag by the int value we now have */
- if (! headerGetEntry(hdr->hdr, tag_by_num,
- &new_item_type, (void **)&new_item_p, &size))
- {
- snprintf(errmsg, 256,
- "RPM::Header::FETCH: no tag '%s' in header", uc_name);
- rpm_error(aTHX_ RPMERR_BADARG, errmsg);
- Safefree(uc_name);
- return FETCH;
- }
- FETCH = rpmhdr_create(aTHX_ new_item_p, new_item_type, size,
- scalar_tag(aTHX_ Nullsv, tag_by_num));
-
- hv_store(hdr->storage, uc_name, namelen, FETCH, FALSE);
- hv_store(hdr->storage, strcat(uc_name, "_t"), (namelen + 2),
- newSViv(new_item_type), FALSE);
- /* For some reason, I don't seem to need this next line in the
- block above (the data_in branch) */
- FETCH = newSVsv(FETCH);
- }
- }
-
- Safefree(uc_name);
- return FETCH;
-}
-
-/*
- Store the data in "value" both in the header and in the hash associated
- with "self".
-*/
-int rpmhdr_STORE(pTHX_ RPM__Header self, SV* key, SV* value)
-{
- SV** svp;
- const char* name;
- char* uc_name;
- char errmsg[256];
- STRLEN namelen;
- int size, i, is_scalar;
- I32 num_ent, data_type;
- void* data;
- AV* a_value = Nullav;
- RPM_Header* hdr;
-
- struct_from_object_ret(RPM_Header, hdr, self, 0);
- if (hdr->read_only)
- return 0;
-
- name = sv2key(aTHX_ key);
- if (! (name && (namelen = strlen(name))))
- return 0;
-
- New(0, uc_name, namelen+3, char);
- for (i = 0; i < namelen; i++)
- uc_name[i] = toUPPER(name[i]);
- uc_name[i] = '\0';
-
- /* Get the numerical tag value for this name. If none exists, this means
- that there is no such tag, which is an error in this case */
- if (! (num_ent = tag2num(aTHX_ uc_name)))
- {
- snprintf(errmsg, 256, "RPM::Header::STORE: No such tag '%s'", uc_name);
- rpm_error(aTHX_ RPMERR_BADARG, errmsg);
- return 0;
- }
- is_scalar = scalar_tag(aTHX_ Nullsv, num_ent);
- if (SvROK(value))
- {
- /*
- This is complicated. We have to allow for straight-in AV*, or a
- single-pair HV* that provides the type indexing the data. Then
- we get to decide if the data part needs to be promoted to an AV*.
- */
- if (SvTYPE(SvRV(value)) == SVt_PVHV)
- {
- HE* iter;
- SV* key;
- SV* new_value;
- HV* hv_value = (HV *)SvRV(value);
-
- /* There should be exactly one key */
- if (hv_iterinit(hv_value) != 1)
- {
- snprintf(errmsg, 256,
- "RPM::Header::STORE: Hash reference passed in for "
- "tag '%s' has invalid content", uc_name);
- rpm_error(aTHX_ RPMERR_BADARG, errmsg);
- return 0;
- }
- iter = hv_iternext(hv_value);
- key = HeSVKEY(iter);
- new_value = HeVAL(iter);
- if (! (SvIOK(key) && (data_type = SvIV(key))))
- {
- snprintf(errmsg, 256,
- "RPM::Header::STORE: Hash reference key passed in "
- "for tag '%s' is invalid", uc_name);
- rpm_error(aTHX_ RPMERR_BADARG, errmsg);
- return 0;
- }
- /* Clear this for later sanity-check */
- value = Nullsv;
- /* Now let's look at new_value */
- if (SvROK(new_value))
- {
- if (SvTYPE(SvRV(new_value)) == SVt_PVAV)
- a_value = (AV *)SvRV(new_value);
- else
- /* Hope for the best... */
- value = SvRV(new_value);
- }
- else
- value = new_value;
- }
- else if (SvTYPE(SvRV(value)) == SVt_PVAV)
- {
- /*
- If they passed a straight-through AV*, de-ref it and mark type
- to be filled in later
- */
- a_value = (AV *)SvRV(value);
- /* A size of 0 means this is an attempt at autovivification... */
- if (av_len(a_value) == -1)
- /* ...which isn't allowed here. Nip it before it starts. */
- return 0;
- data_type = -1;
- value = Nullsv;
- }
- else
- {
- /* De-reference it and hope it passes muster as a scalar */
- value = SvRV(value);
- }
- }
-
- /* The only way value will still be set is if nothing else matched */
- if (value != Nullsv)
- {
- /*
- The case-block below is already set up to handle data in a manner
- transparent to the quantity or type. We can fake this with a_value
- and not worry again until actually storing on the hash table for
- self.
- */
- a_value = newAV();
- av_store(a_value, 0, value);
- /* Mark type for later setting */
- data_type = -1;
- }
- size = av_len(a_value) + 1;
-
- /*
- Setting/STORE-ing means do the following:
-
- 1. Confirm that data adheres to type (mostly check against int types)
- 2. Create the blob in **data (based on is_scalar)
- 3. Store to the header struct
- 4. Store the SV* on the hash
- */
-
- if (data_type == -1)
- {
- /* This will permanently concat "_t" to uc_name. But we'll craftily
- manipulate that later on with namelen. */
- svp = hv_fetch(hdr->storage, strcat(uc_name, "_t"), (namelen + 2),
- FALSE);
- if (! (svp && SvOK(*svp)))
- {
- /*
- If NAME_t does not exist, then this has not been fetched
- previously, and worse, we don't really know what the type is
- supposed to be. So we state in the docs that the default is
- RPM_STRING_TYPE.
- */
- data_type = RPM_STRING_TYPE;
- }
- else
- {
- data_type = SvIV(*svp);
- SvREFCNT_dec(*svp);
- }
- }
-
- if (data_type == RPM_INT8_TYPE ||
- data_type == RPM_INT16_TYPE ||
- data_type == RPM_INT32_TYPE)
- {
- /* Cycle over the array and verify that all elements are valid IVs */
- for (i = 0; i < size; i++)
- {
- svp = av_fetch(a_value, i, FALSE);
- if (! (SvOK(*svp) && SvIOK(*svp)))
- {
- rpm_error(aTHX_ RPMERR_BADARG,
- "RPM::Header::STORE: Non-integer value passed for "
- "integer-type tag");
- return 0;
- }
- }
- }
-
- /*
- This is more like the rpmhdr_create case block, where we have to
- discern based on data-type, so that the pointers are properly
- allocated and assigned.
- */
- switch (data_type)
- {
- case RPM_NULL_TYPE:
- size = 1;
- data = NULL;
- break;
- case RPM_BIN_TYPE:
- {
- char* data_p;
-
- svp = av_fetch(a_value, 0, FALSE);
- if (svp && SvPOK(*svp))
- data_p = SvPV(*svp, size);
- else
- {
- size = 0;
- data_p = Nullch;
- }
-
- data = (void *)data_p;
- break;
- }
- case RPM_CHAR_TYPE:
- {
- char* data_p;
- char* str_sv;
- STRLEN len;
-
- Newz(TRUE, data_p, size, char);
- for (i = 0; i < size; i++)
- {
- /* Having stored the chars in separate SVs wasn't the most
- efficient way, but it made the rest of things a lot
- cleaner. To be safe, only take the initial character from
- each SV. */
- svp = av_fetch(a_value, i, FALSE);
- if (svp && SvPOK(*svp))
- {
- str_sv = SvPV(*svp, len);
- data_p[i] = str_sv[0];
- }
- else
- data_p[i] = '\0';
- }
-
- data = (void *)data_p;
- break;
- }
- case RPM_INT8_TYPE:
- {
- I8** data_p;
-
- Newz(TRUE, data_p, size, I8*);
-
- for (i = 0; i < size; i++)
- {
- svp = av_fetch(a_value, i, FALSE);
- if (svp && SvIOK(*svp))
- *(data_p[i]) = (I8)SvIV(*svp);
- else
- *(data_p[i]) = (I8)0;
- }
-
- data = (void *)data_p;
- break;
- }
- case RPM_INT16_TYPE:
- {
- I16** data_p;
-
- Newz(TRUE, data_p, size, I16*);
-
- for (i = 0; i < size; i++)
- {
- svp = av_fetch(a_value, i, FALSE);
- if (svp && SvIOK(*svp))
- *(data_p[i]) = (I16)SvIV(*svp);
- else
- *(data_p[i]) = (I16)0;
- }
-
- data = (void *)data_p;
- break;
- }
- case RPM_INT32_TYPE:
- {
- I32** data_p;
-
- Newz(TRUE, data_p, size, I32*);
-
- for (i = 0; i < size; i++)
- {
- svp = av_fetch(a_value, i, FALSE);
- if (svp && SvIOK(*svp))
- *(data_p[i]) = SvIV(*svp);
- else
- *(data_p[i]) = 0;
- }
-
- data = (void *)data_p;
- break;
- }
- case RPM_STRING_TYPE:
- case RPM_I18NSTRING_TYPE:
- case RPM_STRING_ARRAY_TYPE:
- {
- char** data_p;
- char* str_sv;
- char* str_new;
- SV* cloned;
- STRLEN len;
-
- if (data_type == RPM_STRING_TYPE && size == 1)
- {
- /* Special case for exactly one RPM_STRING_TYPE */
- svp = av_fetch(a_value, 0, FALSE);
- if (svp)
- {
- if (SvPOK(*svp))
- cloned = *svp;
- else
- cloned = sv_mortalcopy(*svp);
- str_sv = SvPV(cloned, len);
- New(0, str_new, len+1, char);
- strncpy(str_new, str_sv, len + 1);
- }
- else
- str_new = Nullch;
-
- data = (void **)str_new;
- }
- else
- {
- Newz(TRUE, data_p, size, char*);
-
- for (i = 0; i < size; i++)
- {
- svp = av_fetch(a_value, i, FALSE);
- if (svp)
- {
- if (SvPOK(*svp))
- cloned = *svp;
- else
- cloned = sv_mortalcopy(*svp);
- str_sv = SvPV(*svp, len);
- New(0, str_new, len+1, char);
- strncpy(str_new, str_sv, len + 1);
- data_p[i] = str_new;
- }
- else
- data_p[i] = Nullch;
- }
-
- data = (void *)data_p;
- }
- break;
- }
- default:
- rpm_error(aTHX_ RPMERR_BADARG, "Unimplemented tag type");
- break;
- }
- /* That was fun. I always enjoy delving into the black magic of void *. */
-
- /* Remove any pre-existing tag */
- headerRemoveEntry(hdr->hdr, num_ent); /* Don't care if it fails? */
- /* Store the new data */
- headerAddEntry(hdr->hdr, num_ent, data_type, data, size);
- /* Store on the hash */
- hv_store(hdr->storage, uc_name, namelen,
- (is_scalar) ? newSVsv(value) : newRV_noinc((SV *)a_value),
- FALSE);
-
- return 1;
-}
-
-int rpmhdr_DELETE(pTHX_ RPM__Header self, SV* key)
-{
- const char* name; /* For the actual name out of (SV *)key */
- int namelen; /* Arg for SvPV(..., len) */
- char* uc_name; /* UC'd version of name */
- RPM_Header* hdr; /* Pointer to C-level struct */
- int retval, num, i;
-
- struct_from_object_ret(RPM_Header, hdr, self, 0);
- if (hdr->read_only)
- return 0;
-
- name = sv2key(aTHX_ key);
- if (! (name && (namelen = strlen(name))))
- return 0;
-
- New(0, uc_name, namelen+3, char);
- for (i = 0; i < namelen; i++)
- uc_name[i] = toUPPER(name[i]);
- uc_name[i] = '\0';
-
- /* Get the numerical tag value for this name. If none exists, this means
- that there is no such tag, which isn't really an error (so return 1). */
- if (! (num = tag2num(aTHX_ uc_name)))
- {
- retval = 1;
- }
- /*
- Deletion means three steps:
-
- 1. rpmlib-level deletion
- 2. Delete the key from self
- 3. Delete the KEY_t from self
- */
-
- /* First off, if there were no entries of this tag, no need to do 2 or 3 */
- else if (headerRemoveEntry(hdr->hdr, num))
- {
- retval = 1;
- }
- else
- {
- hv_delete(hdr->storage, uc_name, namelen, G_DISCARD);
- hv_delete(hdr->storage, strcat(uc_name, "_t"), namelen + 2, G_DISCARD);
- retval = 1;
- }
-
- Safefree(uc_name);
- return retval;
-}
-
-bool rpmhdr_EXISTS(pTHX_ RPM__Header self, SV* key)
-{
- const char* name;
- char* uc_name;
- int namelen, tag_by_num, i;
- RPM_Header* hdr;
-
- struct_from_object_ret(RPM_Header, hdr, self, 0);
- name = sv2key(aTHX_ key);
- if (! (name && (namelen = strlen(name))))
- return 0;
-
- /* Unlike FETCH, there will be no need for the KEY_t string */
- New(0, uc_name, namelen+1, char);
- for (i = 0; i < namelen; i++)
- uc_name[i] = toUPPER(name[i]);
- uc_name[i] = '\0';
-
- /* Get the #define value for the tag from the hash made at boot-up */
- tag_by_num = tag2num(aTHX_ uc_name);
- Safefree(uc_name);
- if (! tag_by_num)
- {
- char errmsg[256];
-
- snprintf(errmsg, 256,
- "RPM::Header::EXISTS: unknown (to rpm) tag %s", uc_name);
- rpm_error(aTHX_ RPMERR_BADARG, errmsg);
- Safefree(uc_name);
- return 0;
- }
-
- return (headerIsEntry(hdr->hdr, tag_by_num));
-}
-
-int rpmhdr_FIRSTKEY(pTHX_ RPM__Header self, SV** key, SV** value)
-{
- RPM_Header* hdr;
- int tag, type, size;
- char* ptr;
- const char* tagname;
-
- struct_from_object_ret(RPM_Header, hdr, self, 0);
- /* If there is an existing iterator attached to the struct, free it */
- if (hdr->iterator)
- headerFreeIterator(hdr->iterator);
-
- /* The init function returns the iterator that is used in later calls */
- if (! (hdr->iterator = headerInitIterator(hdr->hdr)))
- /* need some error message? */
- return 0;
-
- /* Run once to get started */
- headerNextIterator(hdr->iterator, Null(int *), Null(int *),
- Null(const void **), Null(int *));
- while (1)
- {
- /* Run it to get the header entry */
- if (! headerNextIterator(hdr->iterator, &tag, &type,
- (const void **)&ptr, &size))
- return 0;
-
- tagname = num2tag(aTHX_ tag);
- /* If the one we've just gotten is null, loop */
- if (tagname != Nullch)
- break;
- }
-
- *key = newSVpv((char *)tagname, strlen(tagname));
- *value = rpmhdr_FETCH(aTHX_ self, *key, ptr, type, size);
-
- return 1;
-}
-
-int rpmhdr_NEXTKEY(pTHX_ RPM__Header self, SV* key,
- SV** nextkey, SV** nextvalue)
-{
- RPM_Header* hdr;
- int tag, type, size;
- char* ptr;
- const char* tagname;
-
- struct_from_object_ret(RPM_Header, hdr, self, 0);
- /* If there is not an existing iterator, we can't continue */
- if (! hdr->iterator)
- return 0;
-
- /* Iterate here, since there are internal tags that may be present for
- which we don't want to expose to the user. */
- while (1)
- {
- /* Run it once, to get the next header entry */
- if (! headerNextIterator(hdr->iterator, &tag, &type,
- (const void **)&ptr, &size))
- /* Last tag. Inform perl that iteration is over. */
- return 0;
-
- tagname = num2tag(aTHX_ tag);
- /* This means that any time num2tag couldn't map it, we iterate */
- if (tagname != Nullch)
- break;
- }
-
- *nextkey = newSVpv((char *)tagname, strlen(tagname));
- *nextvalue = rpmhdr_FETCH(aTHX_ self, *nextkey, ptr, type, size);
-
- return 1;
-}
-
-void rpmhdr_DESTROY(pTHX_ RPM__Header self)
-{
- RPM_Header* hdr;
-
- struct_from_object(RPM_Header, hdr, self);
- if (! hdr) return;
-
- if (hdr->iterator)
- headerFreeIterator(hdr->iterator);
- if (hdr->hdr)
- headerFree(hdr->hdr);
-
- hv_undef(hdr->storage);
- if (hdr->source_name)
- Safefree(hdr->source_name);
- Safefree(hdr);
- hv_undef(self);
-}
-
-unsigned int rpmhdr_size(pTHX_ RPM__Header self)
-{
- RPM_Header* hdr;
-
- struct_from_object_ret(RPM_Header, hdr, self, 0);
-
- if (! hdr->hdr)
- return 0;
- else
- return(headerSizeof(hdr->hdr, HEADER_MAGIC_YES));
-}
-
-int rpmhdr_tagtype(pTHX_ RPM__Header self, SV* key)
-{
- STRLEN namelen;
- const char* name;
- char* uc_name;
- SV** svp;
- int i, retval;
- RPM_Header* hdr;
-
- struct_from_object_ret(RPM_Header, hdr, self, 0);
-
- name = sv2key(aTHX_ key);
- if (! (name && (namelen = strlen(name))))
- return RPM_NULL_TYPE;
-
- New(0, uc_name, namelen+3, char);
- for (i = 0; i < namelen; i++)
- uc_name[i] = toUPPER(name[i]);
- uc_name[i] = '\0';
- strcat(uc_name, "_t");
-
- retval = RPM_NULL_TYPE;
-
- svp = hv_fetch(hdr->storage, uc_name, strlen(uc_name), FALSE);
- if (svp && SvOK(*svp))
- {
- /* The base tag has already been fetched and thus we have a type */
- retval = SvIV(*svp);
- }
- else
- {
- /* We haven't had to fetch the tag itself yet. Until then, the special
- key that holds the type isn't available, either. */
-
- /* Do a plain fetch (that is, leave magic on) to populate the other */
- SV* sub_fetch = rpmhdr_FETCH(aTHX_ self, key, Nullch, 0, 0);
-
- if (sub_fetch)
- {
- svp = hv_fetch(hdr->storage, uc_name, strlen(uc_name), FALSE);
- if (svp && SvOK(*svp))
- {
- /* The base tag has now been fetched */
- retval = SvIV(*svp);
- }
- SvREFCNT_dec(*svp);
- SvREFCNT_dec(sub_fetch);
- }
- }
-
- Safefree(uc_name);
- return retval;
-}
-
-int rpmhdr_write(pTHX_ RPM__Header self, SV* gv_in, int magicp)
-{
- IO* io;
- PerlIO* fp;
- FD_t fd;
- RPM_Header* hdr;
- GV* gv;
- int written = 0;
-
- gv = (SvPOK(gv_in) && (SvTYPE(gv_in) == SVt_PVGV)) ?
- (GV *)SvRV(gv_in) : (GV *)gv_in;
- struct_from_object_ret(RPM_Header, hdr, self, 0);
-
- if (!gv || !(io = GvIO(gv)) || !(fp = IoIFP(io)))
- return written;
-
- fd = fdDup(PerlIO_fileno(fp));
- headerWrite(fd, hdr->hdr, magicp);
- Fclose(fd);
- written = headerSizeof(hdr->hdr, magicp);
-
- return written;
-}
-
-/* T/F test whether the header references a SRPM */
-int rpmhdr_is_source(pTHX_ RPM__Header self)
-{
- RPM_Header* hdr;
-
- struct_from_object_ret(RPM_Header, hdr, self, 0);
-
- if (! hdr->hdr)
- return 0;
- else
- return (hdr->isSource);
-}
-
-/*
- A classic-style comparison function for two headers, returns -1 if a < b,
- 1 if a > b, and 0 if a == b. In terms of version/release, that is.
-*/
-int rpmhdr_cmpver(pTHX_ RPM__Header self, RPM__Header other)
-{
- RPM_Header* one;
- RPM_Header* two;
-
- struct_from_object(RPM_Header, one, self);
- if (! one)
- {
- rpm_error(aTHX_ RPMERR_BADARG,
- "RPM::Header::rpmhdr_cmpver: Arg 1 has no header data");
- return 0;
- }
- struct_from_object(RPM_Header, two, other);
- if (! two)
- {
- rpm_error(aTHX_ RPMERR_BADARG,
- "RPM::Header::rpmhdr_cmpver: Arg 2 has no header data");
- return 0;
- }
-
- return rpmVersionCompare(one->hdr, two->hdr);
-}
-
-/*
- If the header object was read from a specific source (file, ftp, http), then
- a copy of that location was kept for future reference. Now reference it.
-*/
-char* rpmhdr_source_name(RPM__Header self)
-{
- RPM_Header* hdr;
-
- struct_from_object(RPM_Header, hdr, self);
-
- return hdr->source_name;
-}
-
-/*
- A matter-of-convenience function that tells whether the passed-in tag is
- one that returns a scalar (yields a true return value) or one that returns
- an array reference (yields a false value).
-*/
-static int scalar_tag(pTHX_ SV* self, int tag_value)
-{
- /* self is passed in as SV*, and unused, because this is a class method */
- switch (tag_value)
- {
- case RPMTAG_ARCH:
- case RPMTAG_ARCHIVESIZE:
- case RPMTAG_BUILDHOST:
- case RPMTAG_BUILDROOT:
- case RPMTAG_BUILDTIME:
- case RPMTAG_COOKIE:
- case RPMTAG_DESCRIPTION:
- case RPMTAG_DISTRIBUTION:
- case RPMTAG_EPOCH:
- case RPMTAG_EXCLUDEARCH:
- case RPMTAG_EXCLUDEOS:
- case RPMTAG_EXCLUSIVEARCH:
- case RPMTAG_EXCLUSIVEOS:
- case RPMTAG_GIF:
- case RPMTAG_GROUP:
- case RPMTAG_ICON:
- case RPMTAG_INSTALLTIME:
- case RPMTAG_LICENSE:
- case RPMTAG_NAME:
- case RPMTAG_OS:
- case RPMTAG_PACKAGER:
- case RPMTAG_RELEASE:
- case RPMTAG_RPMVERSION:
- case RPMTAG_SIZE:
- case RPMTAG_SOURCERPM:
- case RPMTAG_SUMMARY:
- case RPMTAG_URL:
- case RPMTAG_VENDOR:
- case RPMTAG_VERSION:
- case RPMTAG_XPM:
- return 1;
- /* not reached */
- break;
- default:
- return 0;
- /* not reached */
- break;
- }
- /* not reached */
-}
-
-
-MODULE = RPM::Header PACKAGE = RPM::Header PREFIX = rpmhdr_
-
-
-RPM::Header
-rpmhdr_TIEHASH(class, source=NULL, flags=0)
- char* class;
- SV* source;
- int flags;
- PROTOTYPE: $;$$
- CODE:
- RETVAL = rpmhdr_TIEHASH(aTHX_ class, source, flags);
- OUTPUT:
- RETVAL
-
-SV*
-rpmhdr_FETCH(self, key)
- RPM::Header self;
- SV* key;
- PROTOTYPE: $$
- CODE:
- RETVAL = rpmhdr_FETCH(aTHX_ self, key, Nullch, 0, 0);
- OUTPUT:
- RETVAL
-
-int
-rpmhdr_STORE(self, key, value)
- RPM::Header self;
- SV* key;
- SV* value;
- PROTOTYPE: $$$
- CODE:
- RETVAL = rpmhdr_STORE(aTHX_ self, key, value);
- OUTPUT:
- RETVAL
-
-int
-rpmhdr_DELETE(self, key)
- RPM::Header self;
- SV* key;
- PROTOTYPE: $$
- CODE:
- RETVAL = rpmhdr_DELETE(aTHX_ self, key);
- OUTPUT:
- RETVAL
-
-int
-rpmhdr_CLEAR(self=NULL)
- SV* self;
- PROTOTYPE: $
- CODE:
- {
- rpm_error(aTHX_ RPMERR_NOCREATEDB, "CLEAR: operation not permitted");
- RETVAL = 0;
- }
- OUTPUT:
- RETVAL
-
-bool
-rpmhdr_EXISTS(self, key)
- RPM::Header self;
- SV* key;
- PROTOTYPE: $$
- CODE:
- RETVAL = rpmhdr_EXISTS(aTHX_ self, key);
- OUTPUT:
- RETVAL
-
-void
-rpmhdr_FIRSTKEY(self)
- RPM::Header self;
- PROTOTYPE: $
- PPCODE:
- {
- SV* key;
- SV* value;
-
- if (! rpmhdr_FIRSTKEY(aTHX_ self, &key, &value))
- {
- key = newSVsv(&PL_sv_undef);
- value = newSVsv(&PL_sv_undef);
- }
-
- XPUSHs(sv_2mortal(newSVsv(value)));
- XPUSHs(sv_2mortal(newSVsv(key)));
- }
-
-void
-rpmhdr_NEXTKEY(self, key=NULL)
- RPM::Header self;
- SV* key;
- PROTOTYPE: $;$
- PPCODE:
- {
- SV* nextkey;
- SV* nextvalue;
-
- if (! rpmhdr_NEXTKEY(aTHX_ self, key, &nextkey, &nextvalue))
- {
- nextkey = newSVsv(&PL_sv_undef);
- nextvalue = newSVsv(&PL_sv_undef);
- }
-
- XPUSHs(sv_2mortal(newSVsv(nextvalue)));
- XPUSHs(sv_2mortal(newSVsv(nextkey)));
- }
-
-void
-rpmhdr_DESTROY(self)
- RPM::Header self;
- PROTOTYPE: $
- CODE:
- rpmhdr_DESTROY(aTHX_ self);
-
-unsigned int
-rpmhdr_size(self)
- RPM::Header self;
- PROTOTYPE: $
- CODE:
- RETVAL = rpmhdr_size(aTHX_ self);
- OUTPUT:
- RETVAL
-
-int
-rpmhdr_tagtype(self, key)
- RPM::Header self;
- SV* key;
- PROTOTYPE: $$
- CODE:
- RETVAL = rpmhdr_tagtype(aTHX_ self, key);
- OUTPUT:
- RETVAL
-
-int
-rpmhdr_write(self, gv, magicp=0)
- RPM::Header self;
- SV* gv;
- SV* magicp;
- PROTOTYPE: $$;$
- CODE:
- {
- int flag;
-
- if (magicp && SvIOK(magicp))
- flag = SvIV(magicp);
- else
- flag = HEADER_MAGIC_YES;
-
- RETVAL = rpmhdr_write(aTHX_ self, gv, flag);
- }
- OUTPUT:
- RETVAL
-
-int
-rpmhdr_is_source(self)
- RPM::Header self;
- PROTOTYPE: $
- CODE:
- RETVAL = rpmhdr_is_source(aTHX_ self);
- OUTPUT:
- RETVAL
-
-int
-rpmhdr_cmpver(self, other)
- RPM::Header self;
- RPM::Header other;
- PROTOTYPE: $$
- CODE:
- RETVAL = rpmhdr_cmpver(aTHX_ self, other);
- OUTPUT:
- RETVAL
-
-void
-rpmhdr_NVR(self)
- RPM::Header self;
- PROTOTYPE: $
- PPCODE:
- {
- RPM_Header* hdr;
-
- struct_from_object(RPM_Header, hdr, self);
-
- if (hdr->name)
- {
- XPUSHs(sv_2mortal(newSVpv((char *)hdr->name, 0)));
- XPUSHs(sv_2mortal(newSVpv((char *)hdr->version, 0)));
- XPUSHs(sv_2mortal(newSVpv((char *)hdr->release, 0)));
- }
- }
-
-int
-rpmhdr_scalar_tag(self, tag)
- SV* self;
- SV* tag;
- PROTOTYPE: $$
- CODE:
- int tag_value;
-
- if (SvPOK(tag))
- {
- const char* name;
- int i, namelen;
- char* uc_name;
-
- /*
- A matter of explanation:
-
- By doing this bit here, I can let the real scalar_tag take an
- integer argument directly. That means I can call it all over the
- place in here, without the overhead of the SV-to-int conversion
- below. Only use from outside of the XS code pays that penalty.
- */
- name = sv2key(aTHX_ tag);
- if (! (name && (namelen = strlen(name))))
- RETVAL = 0;
- else
- {
- New(0, uc_name, namelen+1, char);
- for (i = 0; i < namelen; i++)
- uc_name[i] = toUPPER(name[i]);
- uc_name[i] = '\0';
- if (! (tag_value = tag2num(aTHX_ uc_name)))
- {
- char errmsg[256];
-
- snprintf(errmsg, 256,
- "RPM::Header::scalar_tag: unknown tag %s", uc_name);
- rpm_error(aTHX_ RPMERR_BADARG, errmsg);
- Safefree(uc_name);
- RETVAL = 0;
- }
-
- RETVAL = scalar_tag(aTHX_ self, tag_value);
- }
- }
- else if (SvIOK(tag))
- {
- tag_value = SvIV(tag);
- RETVAL = scalar_tag(aTHX_ self, tag_value);
- }
- else
- {
- rpm_error(aTHX_ RPMERR_BADARG,
- "RPM::Header::scalar_tag: argument must be string or int");
- RETVAL = 0;
- }
- OUTPUT:
- RETVAL
-
-char*
-rpmhdr_source_name(self)
- RPM::Header self;
- PROTOTYPE: $
- CODE:
- RETVAL = rpmhdr_source_name(self);
- OUTPUT:
- RETVAL
-
-int
-constant(name)
- char* name;
- PROTOTYPE: $
- CODE:
- RETVAL = constant(aTHX_ name);
- OUTPUT:
- RETVAL
+++ /dev/null
-###############################################################################
-#
-# This file copyright (c) 2000 by Randy J. Ray, all rights reserved
-#
-# Copying and distribution are permitted under the terms of the Artistic
-# License as distributed with Perl versions 5.002 and later.
-#
-###############################################################################
-#
-# $Id: Package.pm,v 1.10 2001/04/27 09:05:21 rjray Exp $
-#
-# Description: Perl-level glue and such for the RPM::Package class, the
-# methods and accessors to package operations.
-#
-# Functions: AUTOLOAD
-#
-# Libraries: RPM
-#
-# Global Consts: $VERSION
-#
-# Environment: None.
-#
-###############################################################################
-
-package RPM::Package;
-
-use 5.005;
-use strict;
-use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS $AUTOLOAD);
-use subs qw(AUTOLOAD);
-
-require Exporter;
-
-use RPM;
-
-$VERSION = do { my @r=(q$Revision: 1.10 $=~/\d+/g); sprintf "%d."."%02d"x$#r,@r };
-
-@ISA = qw(Exporter);
-@EXPORT = ();
-@EXPORT_OK = qw(RPM_PACKAGE_MASK RPM_PACKAGE_NOREAD RPM_PACKAGE_READONLY);
-%EXPORT_TAGS = (all => \@EXPORT_OK);
-
-sub AUTOLOAD
-{
- my $constname;
- ($constname = $AUTOLOAD) =~ s/.*:://;
- die "& not defined" if $constname eq 'constant';
- my $val = constant($constname);
- if ($! != 0)
- {
- die "Your vendor has not defined RPM macro $constname";
- }
- no strict 'refs';
- *$AUTOLOAD = sub { $val };
- goto &$AUTOLOAD;
-}
-
-1;
-
-__END__
+++ /dev/null
-#include "EXTERN.h"
-#include "perl.h"
-#include "XSUB.h"
-
-#include "RPM.h"
-
-static char * const rcsid = "$Id: Package.xs,v 1.6 2001/03/08 06:12:32 rjray Exp $";
-
-/* Any constants that are specific to the RPM::Package class will be exported
- from here, via this C-level constant() routine */
-static int constant(pTHX_ char *name)
-{
- errno = 0;
-
- if (strncmp((const char *)name, "RPM_PACKAGE_", 12))
- {
- errno = ENOENT;
- return 0;
- }
- else
- {
- name += 12;
- switch (*name)
- {
- case 'M':
- if (strEQ(name, "MASK"))
-#ifdef RPM_PACKAGE_MASK
- return RPM_PACKAGE_MASK;
-#else
- goto not_found;
-#endif
- break;
- case 'N':
- if (strEQ(name, "NOREAD"))
-#ifdef RPM_PACKAGE_NOREAD
- return RPM_PACKAGE_NOREAD;
-#else
- goto not_found;
-#endif
- break;
- case 'R':
- if (strEQ(name, "READONLY"))
-#ifdef RPM_PACKAGE_READONLY
- return RPM_PACKAGE_READONLY;
-#else
- goto not_found;
-#endif
- break;
- default:
- errno = EINVAL;
- return 0;
- }
- }
-
- not_found:
- errno = EINVAL;
- return 0;
-}
-
-/* This is the class constructor for RPM::Package */
-RPM__Package rpmpkg_new(pTHX_ char* class, SV* source, int flags)
-{
- char* fname;
- int fname_len;
- RPM__Package retval;
- RPM__Header pkghdr;
-
- new_RPM__Package(retval);
- if (! retval) { return retval; }
-
- if (source && SvROK(source) && (SvTYPE(SvRV(source)) == SVt_PVHV))
- {
- /* This means a hashref of options was passed in for shortcuts' sake */
- SV** svp;
- HV* options = (HV *)SvRV(source);
-
- svp = hv_fetch(options, "source", 7, FALSE);
- if (SvOK(*svp))
- /* They specified a source in the hashref */
- source = sv_2mortal(*svp);
- else
- /* They, um, didn't */
- source = Nullsv;
-
- svp = hv_fetch(options, "callback", 9, FALSE);
- if (SvOK(*svp))
- rpmpkg_set_callback(retval, sv_2mortal(*svp));
-
- svp = hv_fetch(options, "flags", 6, FALSE);
- if (SvOK(*svp) && SvIOK(*svp))
- flags = SvIV(sv_2mortal(*svp));
- }
-
- if (source && SvOK(source))
- {
- /* Technically, at least one of these tests is a dupe, but necessary
- * since source may have been re-assigned above. */
- if (SvROK(source))
- source = SvRV(source);
- /* If it is a string value, assume it to be a file name */
- if (SvPOK(source))
- {
- fname = SvPV(source, fname_len);
- retval->path = safemalloc(fname_len + 1);
- strncpy(retval->path, fname, fname_len);
- retval->path[fname_len] = '\0';
- retval->header = rpmhdr_TIEHASH(aTHX_ Nullsv, source,
- (flags & RPM_HEADER_MASK));
- if (! retval->header)
- {
- if (retval->callback)
- SvREFCNT_dec((SV *)retval->callback);
- safefree(retval);
- return 0;
- }
- }
- else
- {
- rpm_error(aTHX_ RPMERR_BADARG,
- "Argument 2 must be a filename");
- if (retval->callback)
- SvREFCNT_dec((SV *)retval->callback);
- safefree(retval);
- return 0;
- }
- }
- else
- {
- /* Nothing valid in source means an empty object. Process flags. */
- if (flags & RPM_PACKAGE_READONLY)
- retval->readonly = 1;
- }
-
- return retval;
-}
-
-void rpmpkg_DESTROY(pTHX_ RPM__Package self)
-{
- /* Free/release the dynamic parts of the package structure */
- if (self->path)
- safefree(self->path);
- /* The Perl structures have their own clean-up methods that will kick in */
-
- return;
-}
-
-SV* rpmpkg_set_callback(pTHX_ RPM__Package self, SV* newcb)
-{
- SV* oldcb;
-
- oldcb = (self->callback) ?
- newRV((SV *)self->callback) : newSVsv(&PL_sv_undef);
-
- if (SvROK(newcb)) newcb = SvRV(newcb);
- if (SvTYPE(newcb) == SVt_PVCV)
- self->callback = (CV *)newcb;
- else if (SvPOK(newcb))
- {
- char* fn_name;
- char* sv_name;
-
- sv_name = SvPV(newcb, PL_na);
- if (! strstr(sv_name, "::"))
- {
- Newz(TRUE, fn_name, strlen(sv_name) + 7, char);
- strncat(fn_name, "main::", 6);
- strcat(fn_name + 6, sv_name);
- }
- else
- fn_name = sv_name;
-
- self->callback = perl_get_cv(fn_name, FALSE);
- }
- else
- {
- self->callback = Nullcv;
- }
-
- return oldcb;
-}
-
-int rpmpkg_install(pTHX_ RPM__Package self)
-{
-}
-
-int rpmpkg_uninstall(pTHX_ RPM__Package self)
-{
-}
-
-int rpmpkg_verify(pTHX_ RPM__Package self)
-{
-}
-
-SV* rpmpkg_size(pTHX_ RPM__Package self)
-{
- SV* size;
-
- if (self->header)
- size = rpmhdr_FETCH(self->header, newSVpv("SIZE", 5),
- /* These are internal params */ Nullch, 0, 0);
- else
- size = newSVsv(&PL_sv_undef);
-
- return size;
-}
-
-/* T/F test whether the package references a SRPM */
-int rpmpkg_is_source(pTHX_ RPM__Package self)
-{
- return (self->header) ? (rpmhdr_is_source(aTHX_ self->header)) : 0;
-}
-
-/*
- A classic-style comparison function for two packages, returns -1 if a < b,
- 1 if a > b, and 0 if a == b. In terms of version/release, that is.
-*/
-int rpmpkg_cmpver_pkg(pTHX_ RPM__Package self, RPM__Package other)
-{
- if (! ((self) && (self->header)))
- {
- rpm_error(aTHX_ RPMERR_BADARG,
- "RPM::Package::rpmpkg_cmpver: Arg 1 has no header data");
- return 0;
- }
- if (! ((other) && (other->header)))
- {
- rpm_error(aTHX_ RPMERR_BADARG,
- "RPM::Package::rpmpkg_cmpver: Arg 2 has no header data");
- return 0;
- }
-
- return rpmhdr_cmpver(aTHX_ self->header, other->header);
-}
-
-/*
- This is essentially a duplicate of the above, to provide an interface-
- polymorphic cmpver method to the user. This version takes a RPM::Header
- object as arg 2.
-*/
-int rpmpkg_cmpver_hdr(pTHX_ RPM__Package self, RPM__Header two)
-{
- if (! ((self) && (self->header)))
- {
- rpm_error(aTHX_ RPMERR_BADARG,
- "RPM::Package::rpmpkg_cmpver: Arg 1 has no header data");
- return 0;
- }
-
- return rpmhdr_cmpver(aTHX_ self->header, two);
-}
-
-/*
- * This is where we catch all callback-ish events for packages, and translate
- * them into a Perl-ized callback mechanism with (mostly) the same arguments
- * and argument structure.
- */
-static void* rpmpkg_callback_handler(const Header h,
- const rpmCallbackType what,
- const unsigned long amount,
- const unsigned long total,
- const void* pkg_key,
- void* data)
-{
- /* We couldn't declare the thread context in the prototype because we
- don't control the calling context of this function. */
- dTHX;
- RPM__Package self; /* This gets derived from "data" */
- SV* callback; /* So that we can more easily sanity-check it */
-
- /* This is simple, but I'm planning ahead in case it gets more complex */
- self = (RPM__Package)data;
- if (! (callback = (SV *)self->callback))
- return (void *)NULL;
-
- /* Set up the stack and the context */
- if (SvOK(callback) && (SvTYPE(callback) == SVt_PVCV))
- {
- dSP;
- ENTER;
- SAVETMPS;
- PUSHMARK(sp);
-
- /* Set up the args list */
- XPUSHs(sv_2mortal(sv_setref_pv(newSVsv(&PL_sv_undef), "RPM::Package",
- (void *)self)));
- XPUSHs(sv_2mortal(newSViv((I32)what)));
- XPUSHs(sv_2mortal(newSViv(amount)));
- XPUSHs(sv_2mortal(newSViv(total)));
- XPUSHs(sv_2mortal(newSVpv((char *)pkg_key, 0)));
- if (self->cb_data != Nullsv)
- XPUSHs(sv_2mortal(newSVsv(self->cb_data)));
-
- /* Make the call */
- perl_call_sv((SV *)self->callback, G_DISCARD);
-
- /* More boilerplate */
- SPAGAIN;
- PUTBACK;
- FREETMPS;
- LEAVE;
- }
-
- return (void *)NULL;
-}
-
-
-MODULE = RPM::Package PACKAGE = RPM::Package PREFIX = rpmpkg_
-
-
-RPM::Package
-rpmpkg_new(class, source=Nullsv, flags=0)
- char* class;
- SV* source;
- int flags;
- PROTOTYPE: $;$
- CODE:
- RETVAL = rpmpkg_new(aTHX_ class, source, flags);
- OUTPUT:
- RETVAL
-
-void
-rpmpkg_DESTROY(self)
- RPM::Package self;
- PROTOTYPE: $
- CODE:
- rpmpkg_DESTROY(aTHX_ self);
-
-SV*
-rpmpkg_set_callback(self, newcb)
- RPM::Package self;
- SV* newcb;
- PROTOTYPE: $$
- CODE:
- RETVAL = rpmpkg_set_callback(aTHX_ self, newcb);
- OUTPUT:
- RETVAL
-
-RPM::Header
-rpmpkg_header(self)
- RPM::Package self;
- PROTOTYPE: $
- CODE:
- RETVAL = self->header;
- OUTPUT:
- RETVAL
-
-int
-rpmpkg_install(self, ...)
- RPM::Package self;
- PROTOTYPE: $@
- CODE:
- RETVAL = rpmpkg_install(aTHX_ self);
- OUTPUT:
- RETVAL
-
-int
-rpmpkg_uninstall(self, ...)
- RPM::Package self;
- PROTOTYPE: $@
- CODE:
- RETVAL = rpmpkg_uninstall(aTHX_ self);
- OUTPUT:
- RETVAL
-
-int
-rpmpkg_verify(self, ...)
- RPM::Package self;
- PROTOTYPE: $@
- CODE:
- RETVAL = rpmpkg_verify(aTHX_ self);
- OUTPUT:
- RETVAL
-
-SV*
-rpmpkg_size(self)
- RPM::Package self;
- PROTOTYPE: $
- CODE:
- RETVAL = rpmpkg_size(aTHX_ self);
- OUTPUT:
- RETVAL
-
-int
-rpmpkg_is_source(self)
- RPM::Package self;
- PROTOTYPE: $
- CODE:
- RETVAL = rpmpkg_is_source(aTHX_ self);
- OUTPUT:
- RETVAL
-
-int
-rpmpkg_cmpver(self, other)
- RPM::Package self;
- SV* other;
- PROTOTYPE: $$
- PREINIT:
- RPM__Package pkg2;
- RPM__Header hdr2;
- CODE:
- {
- if (sv_derived_from(other, "RPM::Package"))
- {
- IV tmp = SvIV((SV*)SvRV(other));
- pkg2 = (RPM__Package)tmp;
-
- RETVAL = rpmpkg_cmpver_pkg(aTHX_ self, pkg2);
- }
- else if (sv_derived_from(other, "RPM::Header"))
- {
- hdr2 = (RPM__Header)SvRV(other);
-
- RETVAL = rpmpkg_cmpver_hdr(aTHX_ self, hdr2);
- }
- else
- {
- rpm_error(aTHX_ RPMERR_BADARG,
- "RPM::Package::cmpver: Arg 2 is not of a compatible "
- "type (should be either RPM::Header or RPM::Package");
- RETVAL = 0;
- }
- }
- OUTPUT:
- RETVAL
-
-int
-constant(name)
- char* name;
- PROTOTYPE: $
- CODE:
- RETVAL = constant(aTHX_ name);
- OUTPUT:
- RETVAL
+++ /dev/null
-###############################################################################
-#
-# This file copyright (c) 2000 by Randy J. Ray, all rights reserved
-#
-# Copying and distribution are permitted under the terms of the Artistic
-# License as distributed with Perl versions 5.002 and later.
-#
-###############################################################################
-#
-# $Id: Transaction.pm,v 1.8 2001/04/27 09:05:21 rjray Exp $
-#
-# Description: Perl-level glue and such for the RPM::Transaction class,
-# the methods and accessors to transaction operations.
-#
-# Functions:
-#
-# Libraries: RPM
-# RPM::Header
-# RPM::Package
-#
-# Global Consts:
-#
-# Environment:
-#
-###############################################################################
-
-package RPM::Package;
-
-use 5.005;
-use strict;
-use vars qw($VERSION);
-use subs qw();
-
-use RPM;
-use RPM::Header;
-use RPM::Package;
-
-$VERSION = do { my @r=(q$Revision: 1.8 $=~/\d+/g); sprintf "%d."."%02d"x$#r,@r };
-
-1;
-
-__END__
+++ /dev/null
-#include "EXTERN.h"
-#include "perl.h"
-#include "XSUB.h"
-
-#include "RPM.h"
-
-static char * const rcsid = "$Id: Transaction.xs,v 1.1 2000/08/06 08:57:09 rjray Exp $";
-
-/*
- Use this define for deriving the saved Transaction struct, rather
- than coding it a dozen places. Note that the hv_fetch call is the
- no-magic one defined in RPM.h
-*/
-#define trans_from_object_ret(s_ptr, trans, object, err_ret) \
- hv_fetch_nomg((s_ptr), (object), STRUCT_KEY, STRUCT_KEY_LEN, FALSE); \
- (trans) = ((s_ptr) && SvOK(*(s_ptr))) ? (RPM_Transaction *)SvIV(*(s_ptr)) : NULL; \
- if (! (trans)) \
- return (err_ret);
-/* And a no-return-value version: */
-#define trans_from_object(s_ptr, trans, object) \
- hv_fetch_nomg((s_ptr), (object), STRUCT_KEY, STRUCT_KEY_LEN, FALSE); \
- (trans) = ((s_ptr) && SvOK(*(s_ptr))) ? (RPM_Transaction *)SvIV(*(s_ptr)) : NULL;
-
-
-MODULE = RPM::Transaction PACKAGE = RPM::Transaction PREFIX = rpmtrans_
+++ /dev/null
-#!/usr/bin/perl
-
-# Verify that the individual modules will load
-
-@MODULES = qw(RPM RPM::Constants RPM::Database RPM::Header RPM::Error);
-
-printf "1..%d\n", scalar(@MODULES);
-
-$count = 0;
-for (@MODULES)
-{
- eval "use $_";
-
- printf "%sok %d\n", ($@) ? 'not ' : '', ++$count;
-}
-
-exit 0;
+++ /dev/null
-#!/usr/bin/perl
-
-use RPM::Database;
-
-print "1..18\n";
-$count = 1;
-
-#
-# Prior to starting up, we need to do some less-direct queries of the RPM
-# database, so that we have baseline data to test against.
-#
-@all_packs = `rpm -q -a --queryformat "\%{NAME}\\n"`;
-chomp(@all_packs);
-$all_packs{$_}++ for (@all_packs);
-
-#
-# With a full list of packages now known, find one to use for package existence
-# testing.
-#
-for (qw(kernel rpm inetd bash))
-{
- $test_pack = $_, last if (exists $all_packs{$_});
-}
-if ($test_pack)
-{
- @test_requires = `rpm -q --requires $test_pack`;
- chomp(@test_requires);
- @test_requires = map { (split(/ /, $_))[0] } grep(! m|^/|, @test_requires);
- @test_requires = grep(! /^rpmlib\(/, @test_requires);
- @test_required_by = `rpm -q --whatrequires $test_pack`;
- chomp(@test_required_by);
- @test_required_by = map { @p = split('-', $_);
- pop(@p); pop(@p);
- join('-', @p); } (@test_required_by);
-}
-else
-{
- die "Not enough testable data in your RPM database, stopped";
-}
-
-$skip_kernel = 1;
-if ($test_pack eq 'kernel')
-{
- $skip_kernel = 0;
- @kernel_matches =
- `rpm -qf /sbin/installkernel --queryformat "\%{NAME}\\n"`;
- chomp(@kernel_matches);
-}
-
-tie %DB, "RPM::Database" or print "not ";
-print "ok $count\n"; $count++;
-
-unless (tied %DB)
-{
- die "$RPM::err";
- exit -1;
-}
-
-# Start with the test package
-$rpm = $DB{$test_pack};
-print "not " unless (defined $rpm and ref $rpm);
-print "ok $count\n"; $count++;
-
-# Obviously, EXISTS should clear just fine
-print "not " unless (exists $DB{$test_pack});
-print "ok $count\n"; $count++;
-
-# Run over FIRSTKEY and NEXTKEY by iterating against a copy of %all_packs
-%tmp_packs = %all_packs;
-for (keys %DB) { delete $tmp_packs{$_} }
-print "not " if (keys %tmp_packs);
-print "ok $count\n"; $count++;
-
-# Verify that STORE, DELETE and CLEAR operations are blocked
-# STORE
-eval {
- $DB{foo_package} = 'baz';
- print "not " if (exists $DB{foo_package} and ($DB{foo_package} eq 'baz'));
-};
-print "ok $count\n"; $count++;
-
-# DELETE
-eval { delete $DB{foo_package} and print "not " };
-print "ok $count\n"; $count++;
-
-# CLEAR
-eval { %DB = () and print "not " };
-print "ok $count\n"; $count++;
-
-# Test the untying
-eval { untie %DB };
-print "not " if ($@);
-print "ok $count\n"; $count++;
-
-# That should cover the basic TIEHASH operands sufficiently.
-
-# No way to test init() or rebuilddb() !!!
-
-# All of the FindBy* suite behave basically the same way. For now, I only
-# have these few tests...
-
-# Test the non-tie approach
-$rpm = new RPM::Database;
-print "not " unless (defined $rpm and ref $rpm);
-print "ok $count\n"; $count++;
-
-# Ensure that the same test package is visible
-print "not " unless (exists $rpm->{$test_pack} and ref($rpm->{$test_pack}));
-print "ok $count\n"; $count++;
-
-# Run over FIRSTKEY and NEXTKEY for the direct ref interface
-%tmp_packs = %all_packs;
-for (keys %$rpm) { delete $tmp_packs{$_} }
-print "not " if (keys %tmp_packs);
-print "ok $count\n"; $count++;
-
-#
-# These two tests must be skipped if kernel is not an rpm package entry
-#
-if ($skip_kernel)
-{
- print "ok $count # Skipped: test data missing\n"; $count++;
- print "ok $count # Skipped: test data missing\n"; $count++;
-}
-else
-{
- @matches = $rpm->find_by_file('/sbin/installkernel');
- # There should be exactly one match:
- print "not " unless (@matches == @kernel_matches);
- print "ok $count\n"; $count++;
-
- $_ = $_->{name} for (@matches);
- print "not " unless (join(':', sort @matches) eq
- join(':', sort @kernel_matches));
- print "ok $count\n"; $count++;
-}
-
-# There may be more than one package that depends on $test_pack
-@matches = $rpm->find_what_requires($test_pack);
-%test = ();
-for (@matches) { $test{$_->{name}} = 1 }
-for (@test_required_by) { delete $test{$_} }
-print "not " if (keys %test);
-print "ok $count\n"; $count++;
-
-# Check now for finding those packages that $test_pack itself requires
-for $testp (@test_requires)
-{
- @matches = $rpm->find_what_requires($rpm->{$testp});
- print "not ", last unless (grep($_->{name} eq $test_pack, @matches));
-}
-print "ok $count\n"; $count++;
-
-# Test the find-by-group
-# First, check that the test pack is in the return list
-@matches = $rpm->find_by_group($rpm->{$test_pack}->{group});
-print "not " unless (grep($_->{name} eq $test_pack, @matches));
-print "ok $count\n"; $count++;
-
-# Check the list of matches against what RPM thinks
-@by_group = `rpm -q --group '$rpm->{$test_pack}->{group}'`;
-%test = ();
-for (@by_group)
-{
- @p = split '-';
- pop(@p); pop(@p);
- $_ = join('-', @p);
- $test{$_}++;
-}
-for (@matches)
-{
- delete $test{$_->{name}};
-}
-print "not " if ((! scalar(@by_group)) || (keys %test));
-print "ok $count\n"; $count++;
-
-# Try to fetch a bogus package
-$hdr = $rpm->{i_hope_no_one_makes_a_package_by_this_name};
-print "not " if $hdr;
-print "ok $count\n"; $count++;
-
-undef $rpm;
-
-exit 0;
+++ /dev/null
-#!/usr/bin/perl
-
-use RPM::Header;
-use RPM::Database;
-
-print "1..18\n";
-$count = 1;
-
-tie %DB, "RPM::Database" or die "$RPM::err";
-
-#
-# Find a package to use for package existence and data integrity testing.
-#
-for (qw(rpm kernel inetd bash))
-{
- $test_pack = $_, last if (exists $DB{$_});
-}
-if ($test_pack)
-{
- @test_files = `rpm -ql $test_pack`;
- chomp(@test_files);
- chomp($rpmstr = qx{rpm -q $test_pack});
-}
-else
-{
- die "Not enough testable data in your RPM database, stopped";
-}
-
-# Are we getting RPM::Header objects from the database?
-$hdr = $DB{$test_pack};
-print "not " unless (ref($hdr) and $hdr->isa('RPM::Header'));
-print "ok $count\n"; $count++;
-
-# Does this one match what rpm thinks?
-print "not "
- unless ($rpmstr eq join('-',
- map { $hdr->{$_} } qw(name version release)));
-print "ok $count\n"; $count++;
-
-# Headers store files as a list of basenames, dirnames, and pointers to a dir
-# for each file.
-$files = $hdr->{basenames};
-$dirs = $hdr->{dirnames};
-$indices = $hdr->{dirindexes};
-
-print "not " unless (@$files == @$indices);
-print "ok $count\n"; $count++;
-
-print "not " unless (@$files == @test_files);
-print "ok $count\n"; $count++;
-
-for $idx (0 .. $#test_files)
-{
- if ($test_files[$idx] ne
- sprintf("%s%s", $dirs->[$indices->[$idx]], $files->[$idx]))
- {
- print "not ";
- last;
- }
-}
-print "ok $count\n"; $count++;
-
-# Starting with 0.27, we have a method to do that for you
-$rpmlines = $hdr->filenames;
-print "not " unless ($rpmlines and (@$rpmlines == @test_files));
-print "ok $count\n"; $count++;
-
-for $idx (0 .. $#rpmlines)
-{
- if ($test_files[$idx] ne $rpmlines->[$idx])
- {
- print "not ";
- last;
- }
-}
-print "ok $count\n"; $count++;
-
-# Can't really test RPM::Header->size(), except to see that it works.
-print "not " if ($hdr->size <= 0);
-print "ok $count\n"; $count++;
-
-# Check tagtype()
-use RPM::Constants ':rpmtype';
-
-print "not " unless ($hdr->tagtype(q{size}) == RPM_INT32_TYPE);
-print "ok $count\n"; $count++;
-
-print "not " unless ($hdr->tagtype(q{dirnames}) == RPM_STRING_ARRAY_TYPE);
-print "ok $count\n"; $count++;
-
-# Test the NVR method
-print "not " unless ($rpmstr eq join('-', $hdr->NVR));
-print "ok $count\n"; $count++;
-
-# Some tests on empty RPM::Header objects
-$hdr = new RPM::Header;
-
-print "not " unless (defined $hdr and (ref($hdr) eq 'RPM::Header'));
-print "ok $count\n"; $count++;
-
-print "not " if (scalar($hdr->NVR));
-print "ok $count\n"; $count++;
-
-# And now the scalar_tag predicate:
-print "not " unless (RPM::Header->scalar_tag(q{size}));
-print "ok $count\n"; $count++;
-
-use RPM::Constants ':rpmtag';
-print "not " if (RPM::Header->scalar_tag(RPMTAG_DIRNAMES));
-print "ok $count\n"; $count++;
-
-use RPM::Constants ':rpmerr';
-print "not " unless ((! RPM::Header->scalar_tag(q{not_a_tag})) and
- ($RPM::err == RPMERR_BADARG));
-print "ok $count\n"; $count++;
-
-# Check all the keys to see that the scalar_tag flag matches the return value
-$hdr = $DB{$test_pack};
-while (($k, $v) = each %$hdr)
-{
- unless ((ref($v) and (! $hdr->scalar_tag($k))) or
- ((! ref($v)) and $hdr->scalar_tag($k)))
- {
- print "not ";
- last;
- }
-}
-print "ok $count\n"; $count++;
-untie %DB;
-
-# Test an attempt to open a non-existant RPM file
-$hdr = new RPM::Header "this_file_not_here.rpm";
-print "not " if $hdr;
-print "ok $count\n"; $count++;
-
-exit 0;
+++ /dev/null
-#!/usr/bin/perl
-
-# Test the error-reporting and management functions
-
-use RPM::Error;
-use RPM::Constants ':rpmerr';
-
-use vars qw($called $string $oldcb);
-
-select(STDOUT); $| = 1;
-
-print "1..11\n";
-
-# tests 1-2: basic set
-rpm_error(RPMERR_BADARG, "Bad argument passed");
-
-print 'not ' unless ($RPM::err == RPMERR_BADARG);
-print "ok 1\n";
-
-print 'not ' unless ($RPM::err eq 'Bad argument passed');
-print "ok 2\n";
-
-# tests 3-4: clearing the values
-clear_errors;
-
-print 'not ' if ($RPM::err);
-print "ok 3\n";
-
-print 'not ' if (length($RPM::err));
-print "ok 4\n";
-
-# tests 5-8: callbacks
-$called = 0;
-set_error_callback(sub { $called = 1 });
-rpm_error(RPMERR_BADSPEC, "Bad spec");
-
-print 'not ' unless ($called);
-print "ok 5\n";
-
-sub cb1 { $called = shift; $string = shift; }
-$called = 0; $string = '';
-set_error_callback('cb1');
-rpm_error(RPMERR_BADDEV, "baddev");
-
-print 'not ' unless ($called == $RPM::err);
-print "ok 6\n";
-
-print 'not ' unless (length($string) == 6);
-print "ok 7\n";
-
-sub cb2 { $called = 1 }
-set_error_callback(\&cb2);
-rpm_error(RPMERR_BADMAGIC, "badmagic");
-
-print 'not ' unless ($called == 1 and $RPM::err == RPMERR_BADMAGIC);
-print "ok 8\n";
-
-my $oldcb = set_error_callback(undef);
-$called = 0;
-rpm_error(RPMERR_BADDEV, "baddev");
-
-print 'not ' if ($called);
-print "ok 9\n";
-
-print 'not ' unless (ref $oldcb eq 'CODE');
-print "ok 10\n";
-
-set_error_callback($oldcb);
-$called = 0;
-rpm_error(RPMERR_BADMAGIC, "badmagic");
-
-print 'not ' unless ($called == 1 and $RPM::err == RPMERR_BADMAGIC);
-print "ok 11\n";
-
-exit 0;
+++ /dev/null
-#!/usr/bin/perl
-
-# Test the basic util functions
-
-use RPM;
-
-print "1..2\n";
-
-$arch = $os = '';
-
-open(PIPE, "rpm --showrc |");
-while (defined($line = <PIPE>))
-{
- chomp $line;
-
- $line =~ /^build arch\s*:\s*(\S+)\s*$/ and $arch = $1;
- $line =~ /^build os\s*:\s*(\S+)\s*$/ and $os = $1;
-}
-close(PIPE);
-
-print 'not ' unless ($arch eq rpm_archname);
-print "ok 1\n";
-
-print 'not ' unless ($os eq rpm_osname);
-print "ok 2\n";
-
-exit;
+++ /dev/null
-#!/usr/bin/perl
-
-use RPM::Database;
-
-$SIG{__WARN__} = sub { $@ = shift; };
-$SIG{__DIE__} = sub { $@ = shift; };
-
-print "1..0\n";
-
-exit;
+++ /dev/null
-# Treat this as -*- text -*-
-
-TYPEMAP
-
-const char * T_PTROBJ
-RPM::Database O_RPM_Tied
-RPM::Header O_RPM_Tied
-RPM::Package O_RPM_Blessed
-RPM::Transaction O_RPM_Blessed
-
-OUTPUT
-O_RPM_Tied
- if ($var)
- {
- $arg = sv_bless(sv_2mortal(newRV_noinc((SV*)$var)),
- gv_stashpv(\"${(my $ntt=$ntype)=~s/_/::/g;\$ntt}\",
- TRUE));
- }
- else
- {
- $arg = newSVsv(&PL_sv_undef);
- }
-
-O_RPM_Blessed
- if ($var)
- {
- sv_setref_pv($arg, \"${(my $ntt=$ntype)=~s/_/::/g;\$ntt}\",
- (void*)$var);
- }
- else
- {
- $arg = newSVsv(&PL_sv_undef);
- }
-
-INPUT
-O_RPM_Tied
- if (sv_isobject($arg) && (SvTYPE(SvRV($arg)) == SVt_PVHV))
- $var = (HV*)SvRV($arg);
- else
- {
- rpm_error(aTHX_ RPMERR_BADARG,
- \"${Package}::$func_name: not a blessed HV reference\");
- XSRETURN_UNDEF;
- }
-
-O_RPM_Blessed
- if (sv_derived_from($arg, \"${(my $ntt=$ntype)=~s/_/::/g;\$ntt}\"))
- {
- IV tmp = SvIV((SV*)SvRV($arg));
- $var = ($type) tmp;
- }
- else
- {
- rpm_error(aTHX_ RPMERR_BADARG,
- \"$var is not of type ${ntype}\");
- XSRETURN_UNDEF;
- }
\ No newline at end of file
+++ /dev/null
-#!/usr/bin/perl
-
-use strict;
-use vars qw($USAGE $VERSION $revision $cmd %opts $file $hdr $installed $ret);
-
-use Getopt::Long;
-use File::Basename qw(basename);
-
-use RPM::Database qw(%RPM);
-use RPM::Header;
-
-$cmd = basename $0;
-$revision = q$Revision: 1.1 $;
-$VERSION = sprintf("%d.%02d", $revision =~ /(\d+)\.(\d+)/);
-$USAGE = "USAGE:
- $cmd [ --newer ] [ --older ] [ --equal ] [ --uninst ]
- [ --invert ] file [ file ... ]
-
-Where:
-
---newer (--nonewer) Show (do not show) those files which are newer
---older (--noolder) Show (do not show) those that are older
---equal (--noequal) Show (do not show) those that match the database
---uninst (--nouninst) Show (do not show) those that are not in the database
-
---invert Invert the given selection logic
-
-The default is:
-
- --newer --noolder --noequal --uninst
-";
-
-$opts{newer} = 1;
-$opts{older} = 0;
-$opts{equal} = 0;
-$opts{uninst} = 1;
-GetOptions(\%opts, qw(help newer! older! equal! uninst! invert)) or
- die "$USAGE\nStopped";
-
-if ($opts{help})
-{
- print $USAGE;
- exit 0;
-}
-if ($opts{invert})
-{
- $opts{$_} = 1 - $opts{$_} for (qw(newer older equal uninst));
-}
-
-for $file (@ARGV)
-{
- $hdr = new RPM::Header $file;
- unless ($hdr)
- {
- warn "$file: $RPM::err\n";
- next;
- }
-
- $installed = $RPM{$hdr->{name}};
- unless ($installed)
- {
- # It isn't currently installed, so there is no conflict
- print "$file\n" if $opts{uninst};
- undef $hdr;
- next;
- }
-
- $ret = $hdr->cmpver($installed);
- print "$file\n" if ($ret < 0 and $opts{older});
- print "$file\n" if ($ret == 0 and $opts{equal});
- print "$file\n" if ($ret > 0 and $opts{newer});
- undef $hdr;
-}
-
-exit;
-
-__END__
-
-=head1 NAME
-
-rpmprune - Remove unneeded files from a list of RPM package files
-
-=head1 SYNOPSIS
-
-rpmprune [ --newer ] [ --older ] [ --equal ] [ --uninst ]
- [ --invert ] filelist ...
-
-=head1 DESCRIPTION
-
-The B<rpmprune> tool is a simple example of using some of the B<RPM> Perl
-bindings.
-
-With B<rpm> version 3 and newer, multiple files given on the command-line
-for an install, uninstall or update command are treated as a single
-I<transaction>. If any of the files in the set cannot be acted upon, the
-whole transaction must be rejected. This is inconvenient for casual package
-upgrades where a directory may have many B<rpm> files, some of which are
-already installed. A command of:
-
- rpm -Uhv *.rpm
-
-would fail, as one (or more) files in the set is already installed. This
-can lead to careless use of options such as C<--force>.
-
-In the simplest usage, this tool eases that situation by allowing:
-
- rpm -Uhv `rpmprune *.rpm`
-
-When the back-ticks are evaluated, B<rpmprune> has only echoed the names of
-those files that are either newer than their installed counterparts, or are
-not installed at all.
-
-=head1 OPTIONS
-
-For maximum flexibility, B<rpmprune> supports more options than anyone will
-realistically put to use:
-
-=over
-
-=item --help
-
-Print a summary of the options and general usage.
-
-=item --newer (--nonewer)
-
-If selected, all files that are newer than their installed counterparts
-will be echoed. Prefix with "no" to suppress the printing of these.
-
-=item --older (--noolder)
-
-If selected, all files that are older than their installed counterparts
-will be echoed. Prefix with "no" to suppress them, instead.
-
-=item --equal (--noequal)
-
-If selected, all files that are the same version as their installed
-counterparts will be echoed. Prefix with "no" to suppress them, instead.
-
-=item --uninst (--nouninst)
-
-If selected, all files that are for packages not currently installed on
-the system will be echoed. Prefix with "no" to suppress them, instead.
-
-=item --invert
-
-Invert the logic of all four of the previous selectors.
-
-=back
-
-Without any arguments, B<rpmprune> acts as if the following were the command
-line:
-
- rpmprune --newer --noolder --noequal --uninst ...
-
-The C<--invert> option is applied last, after all others have been processed.
-
-=head1 AUTHOR
-
-Randy J. Ray <rjray@blackperl.com>