beakerlib-rpms - Man Page

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 space separated list of requirements defined in Makefile using 'Requires' attribute.

Return 0 if success.

rlGetYAMLdeps

Prints space separated list of requirements defined in metadata.yaml using 'require' and / or 'recommend' attribute.

Full fmf ids and library references are to be ignored.

    rlGetYAMLdeps DEP_TYPE [array_var_name]
DEP_TYPE

Dependency type defined as a regexp. Expected values are 'require', 'recommend', or 'require|recommend'. The matching attribute values are then processed. Defaults to 'require'.

array_var_name

Name of the variable to put the output to in a form of an array. This can hold also dependencies with specific version. If used, the output to stdout is suppressed.

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. Moreover, the requirement can be written the same way as the Require in the spec file, including the version specification, e.g. "bash >= 4.4". The comparsion operator may be any of supported by rlTestVersion(), see its manual.

Returns number of unsatisfied requirements.

rlCheckMakefileRequires

Check presence of required packages / binaries defined in metadata.yaml provided by tmt or Makefile of the test.

Also check presence of recommended packages / binaries defined in metadata.yaml provided by tmt. These however do not participate on the return code, these are just informative.

Example

    rlRun "rlCheckMakefileRequires"

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

rlGetRequired =head3 rlGetRecommended

Get a list of required or recommended packages / binaries defined in metadata.yaml provided by tmt or in a Makefile of the test.

    rlGetRequired [ARRAY_VAR_NAME]
    rlGetRecommended [ARRAY_VAR_NAME]
ARRAY_VAR_NAME

If provided the variable is populated as an array with the respective dependencies. Otherwise the dependencies are printed out to the STDOUT.

Return 255 if requirements could not be retrieved, 0 otherwise.

rlCheckRequired =head3 rlCheckRecommended =head3 rlCheckDependencies

Check presence of required, recommended or both packages / binaries defined in metadata.yaml provided by tmt or in a Makefile of the test.

Example

    rlRun "rlCheckRequired"
    rlRun "rlCheckRecommended"
    rlRun "rlCheckDependencies"

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

rlAssertRequired

Ensures that all required packages provided in either metadata.yaml or 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 direct download from build system (brew).

yum

Use yumdownloader or dnf download.

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 also additions or changes done 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, specifically from https://kojipkgs.fedoraproject.org/packages.

rlRpmInstall

Try to install specified package from local Red Hat sources.

    rlRpmInstall [--quiet] package version release arch
--quiet

Make the download and the install process be quiet.

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 successfully.

rlRpmDownload

Try to download specified package.

    rlRpmDownload [--quiet] {package version release arch|N-V-R.A}
    rlRpmDownload [--quiet] --source {package version release|N-V-R}
--quiet

Make the download process be quiet.

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 successfully.

rlFetchSrcForInstalled

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

    rlFetchSrcForInstalled [--quiet] package
--quiet

Make the download process be quiet.

package

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

Returns 0 if the source package was successfully downloaded.

Authors

Info

2024-07-17 perl v5.40.0 User Contributed Perl Documentation