📄 0314-0317.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="0310-0313.html">Previous</A> | <a href="../ewtoc.html">Table of Contents</A> | <a href="0318-0321.html">Next</A>
</CENTER></P>
<A NAME="PAGENUM-314"><P>Page 314</P></A>
<H4><A NAME="ch21_ 32">
21.2.7.3. rpmdbFindByGroup()—Search RPM Database by Group
</A></H4>
<P>This function searches the RPM database specified by
db for the packages that are members of the group specified by
group. It returns matching records in matches:
</P>
<!-- CODE //-->
<PRE>
#include <rpm/rpmlib.h>
#include <rpm/dbindex.h>
int rpmdbFindByGroup(rpmdb db,
char * group,
dbiIndexSet * matches);
</PRE>
<!-- END CODE //-->
<P>This function returns the following status values:</P>
<BLOCKQUOTE>
-1—An error occurred while reading a database record.<BR>
0—The search completed normally.<BR>
1—The search term was not found.<BR>
</BLOCKQUOTE>
<H4><A NAME="ch21_ 33">
21.2.7.4. rpmdbFindPackage()—Search RPM Database by Package
</A></H4>
<P>This function searches the RPM database specified by
db for the packages with the package name (not label) specified by
name. It returns matching records in matches:
</P>
<!-- CODE //-->
<PRE>
#include <rpm/rpmlib.h>
#include <rpm/dbindex.h>
int rpmdbFindPackage(rpmdb db,
char * name,
dbiIndexSet * matches);
</PRE>
<!-- END CODE //-->
<P>This function returns the following status values:
</P>
<BLOCKQUOTE>
-1—An error occurred while reading a database record.<BR>
0—The search completed normally.<BR>
1—The search term was not found.<BR>
</BLOCKQUOTE>
<H4><A NAME="ch21_ 34">
21.2.7.5. rpmdbFindByProvides()—Search RPM Database by Provides
</A></H4>
<P>This function searches the RPM database specified by
db for the packages that make available the provides information specified by
provides. It returns matching records in matches:
</P>
<!-- CODE //-->
<PRE>
#include <rpm/rpmlib.h>
#include <rpm/dbindex.h>
int rpmdbFindByProvides(rpmdb db,
char * provides,
dbiIndexSet * matches);
</PRE>
<!-- END CODE //--><A NAME="PAGENUM-315"><P>Page 315</P></A>
<P>This function returns the following status values:</P>
<BLOCKQUOTE>
-1—An error occurred while reading a database record.<BR>
0—The search completed normally.<BR>
1—The search term was not found.<BR>
</BLOCKQUOTE>
<H4>
21.2.7.6. rpmdbFindByRequiredBy()—Search RPM Database by Requires
</H4>
<P>This function searches the RPM database specified by
db for the packages that need the requires information specified by
requires. It returns matching records in matches:
</P>
<!-- CODE //-->
<PRE>
#include <rpm/rpmlib.h>
#include <rpm/dbindex.h>
int rpmdbFindByRequiredBy(rpmdb db,
char * requires,
dbiIndexSet * matches);
</PRE>
<!-- END CODE //-->
<P>This function returns the following status values:
</P>
<BLOCKQUOTE>
-1—An error occurred while reading a database record.<BR>
0—The search completed normally.<BR>
1—The search term was not found.<BR>
</BLOCKQUOTE>
<H4><A NAME="ch21_ 35">
21.2.7.7. rpmdbFindByConflicts()—Search RPM Database by Conflicts
</A></H4>
<P>This function searches the RPM database specified by
db for the packages that conflict with the conflicts information specified by
conflicts. It returns matching records in matches:
</P>
<!-- CODE //-->
<PRE>
#include <rpm/rpmlib.h>
#include <rpm/dbindex.h>
int rpmdbFindByConflicts(rpmdb db,
char * conflicts,
dbiIndexSet * matches);
</PRE>
<!-- END CODE //-->
<P>This function returns the following status values:
</P>
<BLOCKQUOTE>
-1—An error occurred while reading a database record.<BR>
0—The search completed normally.<BR>
1—The search term was not found.<BR>
</BLOCKQUOTE>
<H4><A NAME="ch21_ 36">
21.2.8. Package Manipulation
</A></H4>
<P>The functions described in this section perform the operations most RPM users are
familiar with. Functions that install and erase packages are here, along with a few related,
lower-level support functions.
</P>
<A NAME="PAGENUM-316"><P>Page 316</P></A>
<H4><A NAME="ch21_ 37">
21.2.8.1. rpmInstallSourcePackage()—Install Source Package File
</A></H4>
<P>This function installs the source package file specified by
fd:
</P>
<!-- CODE //-->
<PRE>
#include <rpm/rpmlib.h>
int rpmInstallSourcePackage(char * root,
int fd,
char ** specFile,
rpmNotifyFunction notify,
char * labelFormat);
</PRE>
<!-- END CODE //-->
<P>If root is not NULL, it is prepended to the variables
RPMVAR_SOURCEDIR and RPMVAR_SPECDIR prior to the actual installation. If
specFile is not NULL, the complete path and filename of the
just-installed spec file are returned.
</P>
<P>The notify parameter is used to specify a progress-tracking function that will be called
during the installation. See section 21.2.8.3 for more information on this parameter.
</P>
<P>The labelFormat parameter can be used to specify how the package label should be
formatted. It is used when printing the package label (once the package install is ready to proceed).
If labelFormat is NULL, the package label is not printed.
</P>
<P>This function returns the following status values:
<BLOCKQUOTE>
0—The source package was installed successfully.<BR>
1—The source package file contained incorrect magic numbers.<BR>
2—Another type of error occurred.<BR>
</BLOCKQUOTE>
<H4><A NAME="ch21_ 38">
21.2.8.2. rpmInstallPackage()—Install Binary Package File
</A></H4>
<P>This function installs the binary package specified by
fd:
</P>
<!-- CODE //-->
<PRE>
#include <rpm/rpmlib.h>
int rpmInstallPackage(char * rootdir,
rpmdb db,
int fd,
char * prefix,
int flags,
rpmNotifyFunction notify,
char * labelFormat,
char * netsharedPath);
</PRE>
<!-- END CODE //-->
<P>If a path is specified in rootdir, the package will be installed with that path acting as the
root directory. If a path is specified in prefix, it will be used as the prefix for relocatable
packages. The RPM database specified by db is updated to reflect the newly installed package.
</P>
<P>The flags parameter is used to control the installation behavior. The flags are defined in
rpmlib.h and take the form RPMINSTALL_xxx, where
xxx is the name of the flag.
</P>
<A NAME="PAGENUM-317"><P>Page 317</P></A>
<P>The following flags are currently defined:
</P>
<UL>
<LI>
RPMINSTALL_REPLACEPKG—Install the package even if it is already installed.
<LI>
RPMINSTALL_REPLACEFILES—Install the package even if it will replace files owned
by another package.
<LI>
RPMINSTALL_TEST—Perform all install-time checks, but do not actually install
the package.
<LI>
RPMINSTALL_UPGRADE—Install the package, and remove all older versions of
the package.
<LI>
RPMINSTALL_UPGRADETOOLD—Install the package, even if the package is an older
version of an already-installed package.
<LI>
RPMINSTALL_NODOCS—Do not install the package's documentation files.
<LI>
RPMINSTALL_NOSCRIPTS—Do not execute the package's install- and erase-time (in
the case of an upgrade) scripts.
<LI>
RPMINSTALL_NOARCH—Do not perform architecture-compatibility tests.
<LI>
RPMINSTALL_NOOS—Do not perform operating system_compatibility tests.
</UL>
<P>The notify parameter is used to specify a progress-tracking_function that will be called
during the installation. See section 21.2.8.3 for more information on this parameter.
</P>
<P>The labelFormat parameter can be used to specify how the package label should be
formatted. This information is used when printing the package label once the package install is ready
to proceed. If labelFormat is NULL, the package label is not printed.
</P>
<P>The netsharedPath parameter is used to specify that part of the local filesystem that is
shared with other systems. If there is more than one path that is shared, the paths should be
separated with a colon.
</P>
<P>This function returns the following status values:</P>
<BLOCKQUOTE>
0—The binary package was installed successfully.<BR>
1—The binary package file contained incorrect magic numbers.<BR>
2—Another type of error occurred.<BR>
</BLOCKQUOTE>
<H4><A NAME="ch21_ 39">
21.2.8.3. rpmNotifyFunction()—Track Package Installation Progress
</A></H4>
<P>A function can be passed to
rpmInstallSourcePackage or rpmInstallPackage via the
notify parameter:
</P>
<!-- CODE //-->
<PRE>
#include <rpm/rpmlib.h>
typedef void (*rpmNotifyFunction)(const unsigned long amount,
const unsigned long total);
</PRE>
<P><CENTER>
<a href="0310-0313.html">Previous</A> | <a href="../ewtoc.html">Table of Contents</A> | <a href="0318-0321.html">Next</A>
</CENTER></P>
</td>
</tr>
</table>
<!-- begin footer information -->
</body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -