beakerlib-rpms man page

BeakerLib — rpms — Package manipulation helpers

Description

Functions in this BeakerLib script are used for RPM manipulation.

Functions

Rpm Handling

rlCheckRpm

Check whether a package is installed.

    rlCheckRpm name [version] [release] [arch]
name

Package name like "kernel"

version

Package version like 2.6.25.6

release

Package release like "55.fc9"

arch

Package architucture like "i386"

Returns 0 if the specified package is installed.

rlAssertRpm

Assertion making sure that a package is installed.

    rlAssertRpm name [version] [release] [arch]>
    rlAssertRpm --all
name

Package name like "kernel"

version

Package version like 2.6.25.6

release

Package release like "55.fc9"

arch

Package architucture like "i386"

--all

Assert all packages listed in the $PACKAGES $REQUIRES and $COLLECTIONS environment variables.

Returns 0 and asserts PASS if the specified package is installed.

rlAssertNotRpm

Assertion making sure that a package is not installed. This is just inverse of "rlAssertRpm".

    rlAssertNotRpm name [version] [release] [arch]>
name

Package name like "kernel"

version

Package version like 2.6.25.6

release

Package release like "55.fc9"

arch

Package architucture like "i386"

Returns 0 and asserts PASS if the specified package is not installed.

Example

Function "rlAssertRpm" is useful especially in prepare phase where it causes abort if a package is missing, while "rlCheckRpm" is handy when doing something like:

    if ! rlCheckRpm package; then
         yum install package
         rlAssertRpm package
    fi

rlAssertBinaryOrigin

Assertion making sure that given binary is owned by (one of) the given package(s).

    rlAssertBinaryOrigin binary package [package2 [...]]
    PACKAGES=... rlAssertBinaryOrigin binary
binary

Binary name like "ksh" or "/bin/ksh"

package

List of packages like "ksh mksh". The parameter is optional. If missing, contents of environment variable $PACKAGES are taken into account.

Returns 0 and asserts PASS if the specified binary belongs to (one of) the given package(s). Returns 1 and asserts FAIL if the specified binary does not belong to (any of) the given package(s). Returns 2 and asserts FAIL if the specified binary is not found. Returns 3 and asserts FAIL if no packages are given. Returns 100 and asserts FAIL if invoked with no parameters.

Example

Function "rlAssertBinaryOrigin" is useful especially in prepare phase where it causes abort if a binary is missing or is owned by different package:

    PACKAGES=mksh rlAssertBinaryOrigin ksh
    or
    rlAssertBinaryOrigin ksh mksh

Returns true if ksh is owned by the mksh package (in this case: /bin/ksh is a symlink pointing to /bin/mksh).

rlGetMakefileRequires

Prints comma separated list of requirements defined in Makefile using 'Requires' attribute.

Return 0 if success.

rlCheckRequirements

Check that all given requirements are covered eigther by installed package or by binary available in PATHs or by some package's provides.

    rlRun "rlCheckRequirements REQ..."
REQ

Requirement to be checked. It can be package name, provides string or binary name.

Returns number of unsatisfied requirements.

rlCheckMakefileRequires

This is just a bit smarted wrapper of

"rlCheckRequirements $(rlGetMakefileRequires)"

Example

    rlRun "rlCheckMakefileRequires"

Return 255 if requirements could not be retrieved, 0 if all requirements are satisfied or number of unsatisfied requirements.

rlAssertRequired

Ensures that all Requires, specified in beakerlib-style beaker-wizard layout Makefile, are installed.

    rlAssertRequired

Prints out a verbose list of installed/missing packages during operation.

Returns 0 if all required packages are installed, 1 if one or more packages are missing or if no Makefile is present.

Getting RPMs

Download methods

Functions handling rpm downloading/installing can use more methods for actual download of the rpm.

Currently there are two download methonds available:

direct

Use use dirct download from build system (brew).

yum

Use yumdownloader.

The methods and their order are defined by BEAKERLIB_RPM_DOWNLOAD_METHODS variable as space separated list. By default it is 'direct yum'. This can be overridden by user. There may be done also additions  or changes to the original value, e.g. BEAKERLIB_RPM_DOWNLOAD_METHODS='yum ${BEAKERLIB_RPM_DOWNLOAD_METHODS/yum/}'

Beakerlib is prepared for more Koji-based sources of packages while usigng direct download method. By default packages are fetched from Koji, particularly from https://kojipkgs.fedoraproject.org/packages.

rlRpmInstall

Try to install specified package from local Red Hat sources.

    rlRpmInstall package version release arch
package

Package name like "kernel"

version

Package version like 2.6.25.6

release

Package release like "55.fc9"

arch

Package arch like "i386"

Returns 0 if specified package was installed succesfully.

rlRpmDownload

Try to download specified package.

    rlRpmDownload package version release arch
    rlRpmDownload --source package version release
    rlRpmDownload N-V-R.A
    rlRpmDownload --source N-V-R
package

Package name like "kernel"

version

Package version like 2.6.25.6

release

Package release like "55.fc9"

arch

Package arch like "i386"

Returns 0 if specified package was downloaded succesfully.

rlFetchSrcForInstalled

Tries various ways to download source rpm for specified installed rpm.

    rlFetchSrcForInstalled package
package

Installed package name like "kernel". It accepts in-direct names. Eg for the package name "krb5-libs" will the function download the "krb5" source rpm.

Returns 0 if the source package was succesfully downloaded.

Authors

Info

2017-07-26 perl v5.26.0 User Contributed Perl Documentation