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

This is just a bit smarted wrapper of

rlCheckRequirements $(rlGetYAMLdeps 'require|recommend') || 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 and recommends specified in the metadata.yaml are installed. If no metadata.yaml is present a fallback to Makefile is done to check 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 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 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 [--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

2021-03-25 perl v5.32.1 User Contributed Perl Documentation