util.rpmpack

Module Contents

class util.rpmpack.RpmPack
NAME = 'contest-pack'
VERSION = 1
RELEASE = 1
ARCH = 'noarch'
HEADER
NVR = 'contest-pack-1-1'
FILE = 'contest-pack-1-1.noarch.rpm'
class RpmPackFilePath

Bases: tuple

source
target
class RpmPackFileContents

Bases: tuple

target
contents
files = []
requires = []
softreq = []
scripts
add_file(source, target=None)

Add a file path to the RPM, ‘source’ specifies a file path on the host, ‘target’ is the installed path in the RPM.

If ‘target’ is not specified, it is equal to ‘source’, which then must be an absolute path.

add_file_contents(target, contents)

Add arbitrary text file contents as a file path in the RPM. Here, ‘target’ is the installed path in the RPM, and ‘contents’ are file contents to be installed at that path.

add_host_repos()
add_script(script_type, content)

Add a shell script under a given ‘script_type’, which can be ‘%pre’, ‘%post’ or any other RPM scriptlet, incl. with arguments like ‘%triggerun – sendmail’.

If there is only one content for a given type when building the RPM, the content is used as-is. If there are multiple contents (from several add_script() calls with the same ‘script_type’), they will be joined together and isolated using ( ) bash subshells, hopefully GEFN.

See https://docs.fedoraproject.org/en-US/packaging-guidelines/Scriptlets/#_syntax for details about using $1 to check for upgrade.

add_sshd_late_start()

The sshd daemon starts on network.target, but some other important services rely on network-online.target or even multi-user.target, sometimes starting much, much later than sshd. When we connect and run oscap scan, these falsely show as ‘inactive’ (because we’re too quick with ssh connection).

To fix this, make sshd start after multi-user.target, making our connection more representative of a longer-running system.

create_spec()
build()

Build the binary RPM and return a path to a temporary .rpm file.

build_as_repo()

Build the binary RPM and return a path to a temporary directory with YUM/DNF metadata (serving as a repository) containing the binary RPM.

install()

Build the binary RPM and call ‘dnf install’ on it.

uninstall()

Call ‘dnf remove’ on a previously-installed built RPM.