📄 0318-0321.html
字号:
<HTML>
<HEAD>
<TITLE>Maximum RPM (RPM):A Guide to the RPM Library API:EarthWeb Inc.-</TITLE>
<META NAME="ROBOTS" CONTENT="NOINDEX, NOFOLLOW">
<SCRIPT>
<!--
function displayWindow(url, width, height) {
var Win = window.open(url,"displayWindow",'width=' + width +
',height=' + height + ',resizable=1,scrollbars=yes');
}
//-->
</SCRIPT>
</HEAD>
-->
<!-- ISBN=0672311054 //-->
<!-- TITLE=Maximum RPM (RPM)//-->
<!-- AUTHOR=Edward Bailey//-->
<!-- PUBLISHER=Macmillan Computer Publishing//-->
<!-- IMPRINT=Sams//-->
<!-- CHAPTER=21 //-->
<!-- PAGES=0305-0336 //-->
<!-- UNASSIGNED1 //-->
<!-- UNASSIGNED2 //-->
<P><CENTER>
<a href="0314-0317.html">Previous</A> | <a href="../ewtoc.html">Table of Contents</A> | <a href="0322-0325.html">Next</A>
</CENTER></P>
<!-- END CODE //--><A NAME="PAGENUM-318"><P>Page 318</P></A>
<P>The function will be called at regular intervals during the installation, and will have two
parameters passed to it:
</P>
<UL>
<LI> amount—The number of bytes of the install that have been completed so far.
<LI> total—The total number of bytes that will be installed.
</UL>
<P>This function permits the creation of a dynamically updating progress meter during
package installation.
</P>
<H4>
21.2.8.4. rpmRemovePackage()—Remove Installed Package
</H4>
<P>This function removes the package at record number
offset in the RPM database specified
by db:
</P>
<!-- CODE //-->
<PRE>
#include <rpm/rpmlib.h>
int rpmRemovePackage(char * root,
rpmdb db,
unsigned int offset,
int flags);
</PRE>
<!-- END CODE //-->
<P>If root is specified, it is used as the path to a directory that will serve as the root directory
while the package is being removed.
</P>
<P>The flags parameter is used to control the package removal behavior. The flags that may
be passed are defined in rpmlib.h and are in the form
RPMUNINSTALLxxx , where xxx is the name of the flag.
</P>
<P>The following flags are currently defined:
</P>
<UL>
<LI>
RPMUNINSTALL_TEST—Perform all erase-time checks, but do not actually remove
the package.
<LI>
RPMUNINSTALL_NOSCRIPTS—Do not execute the package's erase-time scripts.
</UL>
<P>This function returns the following status values:</P>
<BLOCKQUOTE>
0—The package was removed successfully.<BR>
1—The package removal failed.<BR>
</BLOCKQUOTE>
<H4><A NAME="ch21_ 40">
21.2.9. Package and File Verification
</A></H4>
<P>The functions in this section perform the verification operations necessary to ensure that
the files comprising a package have not been modified since they were installed.
</P>
<P>Verification takes place on three distinct levels:
</P>
<UL>
<LI> On the
file-by-file level
<LI> On a package-wide level, through the use of the
%verifyscript verification script
<LI> On an interpackage level, through RPM's normal dependency processing
</UL>
<A NAME="PAGENUM-319"><P>Page 319</P></A>
<P>The first two types of verification are performed by functions described in this section.
The functions that implement dependency-related verification are covered in section 21.2.10.
</P>
<H4><A NAME="ch21_ 41">
21.2.9.1. rpmVerifyFile()—Verify File
</A></H4>
<P>This function verifies the filenumth file from the package whose header is
h:
</P>
<!-- CODE //-->
<PRE>
#include <rpm/rpmlib.h>
#include <rpm/header.h>
int rpmVerifyFile(char * root,
Header h,
int filenum,
int * result);
</PRE>
<!-- END CODE //-->
<P>If root is specified, it is used as the path to a directory that will serve as the root directory
while the file is being verified. The results of the file verification are returned in
result and consist of a number of flags. Each flag that is set indicates a verification failure.
</P>
<P>The flags are defined in rpmlib.h and are in the form
RPMVERIFY_xxx, where xxx is the name of the data that failed verification.
</P>
<P>This function returns 0 on success, and 1 on failure.
</P>
<H4><A NAME="ch21_ 42">
21.2.9.2. rpmVerifyScript()—Execute Package's
%verifyscript Verification Script
</A></H4>
<P>This function executes the %verifyscript verification script for the package whose header is
h. err must contain a valid file descriptor. If
rpmIsVerbose() returns true, the %verifyscript verification script will direct
all status messages to err:
</P>
<!-- CODE SNIP //-->
<PRE>
#include <rpm/rpmlib.h>
#include <rpm/header.h>
int rpmVerifyScript(char * root,
Header h,
int err);
</PRE>
<!-- END CODE SNIP //-->
<P>This function returns 0 on success, and 1 on failure.
</P>
<H4><A NAME="ch21_ 43">
21.2.10. Dependency-Related Operations
</A></H4>
<P>The functions in this section are used to perform the various dependency-related
operations supported by rpmlib.
</P>
<P>Dependency processing is entirely separate from normal package-based operations. The
package installation and removal functions do not perform any dependency processing themselves.
Therefore, dependency processing is somewhat different from other aspects of rpmlib's operation.
</P>
<A NAME="PAGENUM-320"><P>Page 320</P></A>
<P>Dependency processing centers around the
rpmDependencies data structure. The operations
that are to be performed against the RPM database (adding, removing, and upgrading
packages) are performed against this data structure, using the functions that are described in this
section. These functions simply populate the data structure according to the operation being
performed. They do not perform the actual operation on the package. This is an important point to
keep in mind.
</P>
<P>Once the data structure has been completely populated, a dependency check function is
called to determine if there are any dependency-related problems. The result is a structure of
dependency conflicts. This structure,
rpmDependencyConflict, is defined in rpmlib.h.
</P>
<P>Note that it is necessary to free both the conflicts structure and the
rpmDependencies structure when they are no longer needed. However,
free() should not be used—special functions
for this are provided and are discussed in this section.
</P>
<H4><A NAME="ch21_ 44">
21.2.10.1. rpmdepDependencies()—Create a New Dependency
Data Structure
</A></H4>
<P>This function returns an initialized
rpmDependencies structure. The dependency checking
to be done will be based on the RPM database specified in the
db parameter. If this parameter is NULL, the dependency checking will be done as if an empty RPM database were being used:
</P>
<!-- CODE SNIP //-->
<PRE>
#include <rpm/rpmlib.h>
rpmDependencies rpmdepDependencies(rpmdb db);
</PRE>
<!-- END CODE SNIP //-->
<H4><A NAME="ch21_ 45">
21.2.10.2. rpmdepAddPackage()—Add a Package Install to the
Dependency Data Structure
</A></H4>
<P>This function adds the installation of the package whose header is
h to the rpmDependencies data structure, rpmdep:
</P>
<!-- CODE //-->
<PRE>
#include <rpm/rpmlib.h>
#include <rpm/header.h>
void rpmdepAddPackage(rpmDependencies rpmdep,
Header h);
</PRE>
<!-- END CODE //-->
<H4><A NAME="ch21_ 46">
21.2.10.3. rpmdepUpgradePackage()—Add a Package Upgrade to
the Dependency Data Structure
</A></H4>
<P>This function adds the upgrading of the package whose header is
h to the rpmDependencies data structure, rpmdep. It is similar to
rpmdepAddPackage(), but older versions of the
package are removed:
</P>
<!-- CODE SNIP //-->
<PRE>
#include <rpm/rpmlib.h>
#include <rpm/header.h>
</PRE>
<!-- END CODE SNIP //--><A NAME="PAGENUM-321"><P>Page 321</P></A><!-- CODE SNIP //-->
<PRE>
void rpmdepUpgradePackage(rpmDependencies rpmdep,
Header h);
</PRE>
<!-- END CODE SNIP //-->
<H4>
21.2.10.4. rpmdepRemovePackage()—Add a Package Removal to
the Dependency Data Structure
</H4>
<P>This function adds the removal of the package whose RPM database offset is
dboffset to the rpmDependencies data structure,
rpmdep:
</P>
<!-- CODE SNIP //-->
<PRE>
#include <rpm/rpmlib.h>
void rpmdepRemovePackage(rpmDependencies rpmdep,
int dboffset);
</PRE>
<!-- END CODE SNIP //-->
<H4><A NAME="ch21_ 47">
21.2.10.5. rpmdepAvailablePackage()—Add an Available Package to
the Dependency Data Structure
</A></H4>
<P>This function adds the package whose header is
h to the rpmDependencies structure, rpmdep:
</P>
<!-- CODE //-->
<PRE>
#include <rpm/rpmlib.h>
#include <rpm/header.h>
void rpmdepAvailablePackage(rpmDependencies rpmdep,
Header h,
void * key);
</PRE>
<!-- END CODE //-->
<P>The key parameter can be anything that uniquely identifies the package being added. It will
be returned as part of the rpmDependencyConflict structure returned by
rpmdepCheck(), specifically in that structure's
suggestedPackage element.
</P>
<H4><A NAME="ch21_ 48">
21.2.10.6. rpmdepCheck()—Perform a Dependency Check
</A></H4>
<P>This function performs a dependency check on the
rpmDependencies structure rpmdep. It returns an array of size
numConflicts, pointed to by conflicts:
</P>
<!-- CODE //-->
<PRE>
#include <rpm/rpmlib.h>
int rpmdepCheck(rpmDependencies rpmdep,
struct rpmDependencyConflict ** conflicts,
int * numConflicts);
</PRE>
<!-- END CODE //-->
<P>This function returns 0 on success, and 1 on error.
</P>
<H4><A NAME="ch21_ 49">
21.2.10.7. rpmdepFreeConflicts()—Free Results of
rpmdepCheck()
</A></H4>
<P>This function frees the dependency conflict information of size
numConflicts that is pointed to by conflicts:
</P>
<!-- CODE //-->
<PRE>
#include <rpm/rpmlib.h>
void rpmdepFreeConflicts(struct rpmDependencyConflict * conflicts,
int numConflicts);
</PRE>
<P><CENTER>
<a href="0314-0317.html">Previous</A> | <a href="../ewtoc.html">Table of Contents</A> | <a href="0322-0325.html">Next</A>
</CENTER></P>
</td>
</tr>
</table>
<!-- begin footer information -->
</body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -