-->

Previous | Table of Contents | Next

Page 318

The function will be called at regular intervals during the installation, and will have two parameters passed to it:

This function permits the creation of a dynamically updating progress meter during package installation.

21.2.8.4. rpmRemovePackage()—Remove Installed Package

This function removes the package at record number offset in the RPM database specified by db:


#include   <rpm/rpmlib.h>



int   rpmRemovePackage(char * root,

                        rpmdb db,

                           unsigned int offset,

                         int flags);

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.

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.

The following flags are currently defined:

This function returns the following status values:

0—The package was removed successfully.
1—The package removal failed.

21.2.9. Package and File Verification

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.

Verification takes place on three distinct levels:

Page 319

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.

21.2.9.1. rpmVerifyFile()—Verify File

This function verifies the filenumth file from the package whose header is h:


#include <rpm/rpmlib.h>

#include <rpm/header.h>



int rpmVerifyFile(char * root,

                  Header h,

                   int filenum,

                    int * result);

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.

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.

This function returns 0 on success, and 1 on failure.

21.2.9.2. rpmVerifyScript()—Execute Package's %verifyscript Verification Script

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:


#include  <rpm/rpmlib.h>

#include  <rpm/header.h>



int rpmVerifyScript(char * root,

                    Header h,

                     int err);

This function returns 0 on success, and 1 on failure.

21.2.10. Dependency-Related Operations

The functions in this section are used to perform the various dependency-related operations supported by rpmlib.

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.

Page 320

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.

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.

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.

21.2.10.1. rpmdepDependencies()—Create a New Dependency Data Structure

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:


#include   <rpm/rpmlib.h>



rpmDependencies   rpmdepDependencies(rpmdb db);



21.2.10.2. rpmdepAddPackage()—Add a Package Install to the Dependency Data Structure

This function adds the installation of the package whose header is h to the rpmDependencies data structure, rpmdep:


#include  <rpm/rpmlib.h>

#include  <rpm/header.h>



void  rpmdepAddPackage(rpmDependencies rpmdep,

                      Header h);

21.2.10.3. rpmdepUpgradePackage()—Add a Package Upgrade to the Dependency Data Structure

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:


#include  <rpm/rpmlib.h>

#include  <rpm/header.h>



Page 321






void rpmdepUpgradePackage(rpmDependencies rpmdep,

                          Header h);

21.2.10.4. rpmdepRemovePackage()—Add a Package Removal to the Dependency Data Structure

This function adds the removal of the package whose RPM database offset is dboffset to the rpmDependencies data structure, rpmdep:


#include  <rpm/rpmlib.h>



void  rpmdepRemovePackage(rpmDependencies rpmdep,

                         int dboffset);

21.2.10.5. rpmdepAvailablePackage()—Add an Available Package to the Dependency Data Structure

This function adds the package whose header is h to the rpmDependencies structure, rpmdep:


#include  <rpm/rpmlib.h>

#include  <rpm/header.h>



void rpmdepAvailablePackage(rpmDependencies rpmdep,

                            Header h,

                             void * key);

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.

21.2.10.6. rpmdepCheck()—Perform a Dependency Check

This function performs a dependency check on the rpmDependencies structure rpmdep. It returns an array of size numConflicts, pointed to by conflicts:


#include  <rpm/rpmlib.h>



int  rpmdepCheck(rpmDependencies  rpmdep,

                      struct rpmDependencyConflict ** conflicts,

                    int * numConflicts);

This function returns 0 on success, and 1 on error.

21.2.10.7. rpmdepFreeConflicts()—Free Results of rpmdepCheck()

This function frees the dependency conflict information of size numConflicts that is pointed to by conflicts:


#include   <rpm/rpmlib.h>



void  rpmdepFreeConflicts(struct  rpmDependencyConflict  *   conflicts,

                               int numConflicts);





Previous | Table of Contents | Next