RPM4 - perl module to access and manipulate RPM files
This module allow to use API functions from rpmlib, directly or trough perl objects.
Force rpmlib to re-read configuration files. If defined, $rpmrc is read. If $target is defined, rpmlib will read config for this target. $target has the form "CPU-VENDOR-OS".
readconfig(); # Reread default configuration readconfig(undef, "i386-mandrake-linux"); # Read configuration for i386
Set the rpmlib verbosity level. $level can be an integer (0 to 7) or a verbosity level name.
- EMERG (0) - ALERT (1) - CRIT (2) - ERR (3) - WARNING (4) - NOTICE (5) - INFO (6) - DEBUG (7)
Set a perl callback code for rpm logging/output system. When the callback is set, rpm lets your code print error/information messages. The parameter passed to the callback is a hash with log value: locode => the rpm log code (integer), priority => priority of the message (0 to 7), msg => the formated string message.
locode
priority
msg
To unset the callback function, passed an undef value as code reference.
Ex: setlogcallback( sub { my %log = @_; print "$log{priority}: $log{msg}\n"; });
Redirect all rpm message into this file. Data will be append to the end of the file, the file is created if it don't already exists. The old loging file is close.
To unset (and close) a pending loging file, passed an undef value.
Return an array about latest rpm log message information: - rpm log code, - rpm priority (0 to 7), - string message.
Send a message trougth the rpmlib logging system. - $codelevel is either an integer value between 0 and 7, or a level code string, see setverbosity(), - $msg is the message to send.
Some functions return an array of rpm transaction problem (RPM4::Db->transpb()), this function return an array of human readable string for each problem.
Returns a hash containing the tags known by rpmlib. The hash has the form TAGNAME = tagvalue >. Note that some tags are virtual and do not have any tag value, and that some tags are alias to already existing tags, so they have the same value.
TAGNAME =
Return the type value of a tag type. $tagtypename can be CHAR, INT8, INT16 INT32, STRING, ARRAY_STRING or I18NSTRING. This return value is usefull with RPM4::Header::addtag() function.
Returns the tag name for a given internal value.
tagName(1000); return "NAME".
See: tagValue.
Returns the internal tag value for $tagname.
$tagname
tagValue("NAME"); return 1000.
See: tagName.
Evaluate macros contained in $string, like rpm --eval.
$string
rpm --eval
expand("%_var") return "/var".
Define a macro into rpmlib. The macro is defined for the whole script. Ex: addmacro("_macro value"). Note that the macro name does have the prefix "%", to prevent rpm from evaluating it.
addmacro("_macro value")
Delete a macro from rpmlib. Exactly the reverse of addmacro().
Read a macro configuration file and load macros defined within. Unfortunately, the function returns nothing, even when file loading failed.
To reset macros loaded from file you have to re-read the rpm config file with readconfig.
Reset all macros defined with add_macro() functions.
This function does not reset macros loaded with loadmacrosfile().
Returns the operating system name of current rpm configuration. Rpmlib auto-detects the system name, but you can force rpm to use another system name with macros or using readconfig().
Returns the arch name of current rpm configuration. Rpmlib auto-detects the architecture, but you can force rpm to use another architecture with macros or by using readconfig().
Returns the BuildHost name of the current system, ie the value rpm will use to set BuilHost tag in built rpm.
Dump rpm configuration into file handle. Ex: dumprc(*STDOUT);
Dump rpm macros into file handle. Ex: dumpmacros(*STDOUT);
Resign a rpm using user settings. $passphrase is the key's gpg/pgp pass phrase.
$passphrase
Return 0 on success.
Compare two version and return 1 if left argument is highter, -1 if rigth argument is highter, 0 if equal. Ex: rpmvercmp("1.1mdk", "2.1mdk"); # return -1.
COmpare two rpm version in forms [epoch:]version[-release] and return 1 if left argument is highter, -1 if rigth argument is highter, 0 if equal. Ex: compare_evr("1:1-1mdk", "2-2mdk"); # return 1
Install a source rpm and return spec file path and its cookies. Returns undef if install is impossible.
see RPM4::Spec->new() for more information about cookies.
Create an empty rpm database located into %{_dbpath} (useally /var/lib/rpm). If set, rootdir is the root directory of system where rpm db should be create, if set, theses permissions will be applied to files, default is 0644.
Directory %{_dbpath} should exist.
Returns 0 on success.
Ex: rpmdbinit(); # Create rpm database on the system rpmdbinit("/chroot"); # Create rpm database for system located into /chroot.
Verify rpm database located into %{_dbpath} (useally /var/lib/rpm). If set, $rootdir is root directory of system to check.
Rebuild the rpm database located into %{_dbpath} (useally /var/lib/rpm). If set, $rootdir is the root directory of system.
Create a RPM4::Header::Dependencies object about rpmlib internals provides
rpm(8),
This aims at replacing part of the functionality provided by URPM.
To install RPM4, copy and paste the appropriate command in to your terminal.
cpanm
cpanm RPM4
CPAN shell
perl -MCPAN -e shell install RPM4
For more information on module installation, please visit the detailed CPAN module installation guide.