Welcome to rpg’s documentation!

Warning

RPG is in alpha stage and the docs could change at any time without any notice

Contents:

RPG Command Reference

Synopsis

rpg [options]

Description

RPG is tool, that guides people through the creation of a RPM package. RPG makes packaging much easier due to the automatic analysis of packaged files. Beginners can get familiar with packaging process or the advanced users can use our tool for a quick creation of a package.

Options

-h, --help
Show help message and exit.
--plugin-dir <dir> [<dir> ...]
Include plugin directory.
--disable-plugin <plugin-name> [<plugin-name> ...]
Exclude specific plugin.
--disable-dnf
Disable loading DNF sack.

Writing plugins

Plugins are the main part of RPG. Their purpose is to append Spec class with tags and scripts. Whole process of creating spec file from source code in RPG app is following:

  • plugins are triggered in project directory - they set some tags/scripts in Spec instance
  • guessed values from Spec are auto filled in GUI forms and user can modify them
  • next spec command (%prep, %build, %install, %files) is executed and new directory is created
  • repeat steps for new directory

Plugin is a class that is derived from rpg.plugin.Plugin and overrides at least one of following methods: download, extraction, extracted, patched, compiled, installed, package_built. Each of them takes (spec, current_dir, sack) parameters. spec is instance of Spec class, sack is initialized sack from DNF and current_dir is pathlib.Path instance where are project files of future RPM package located. current_dir is different in each phase.

Phases
Phase Description Base call
download downloads archive from url. This is because url adress may be github repository - then plugin only add archive/master.zip to the url and downloads it
extraction method that extract files from archive. This exists because there are many types of archives like tar, zip, ...
extracted raw files are extracted from chosen archive or copied files from project working directory extracted source analysis
patched after application of patches on source files patched source analysis
compiled after execution of %build script (e.g. calling make) compiled source analysis
installed directory containing files after make install installed source analysis
package_built path to final rpm package
mock_recover after building project in mock enviroment, build errors (if there are any) are passed as parameter to this method. This should fix build by parsing the errors and finding the solution, i.e. append missing required files to build_required_files

Inside plugin can be helper methods that should not be named as any of the phase. It should follow conventions as any private Python method (e.g. _helper_method).

For plugin examples take a look at core plugins folder.

Base class

Command module

Plugin class

class plugin.Plugin

Class from which are plugins derived

def extraction(self, source, dest):
pass
def download(self, source, dest):
pass
def extracted(self, project_dir, spec, sack):
pass
def patched(self, project_dir, spec, sack):
pass
def compiled(self, project_dir, spec, sack):
pass
def installed(self, project_dir, spec, sack):
pass
def package_build(self, package_path, spec, sack):
pass
def mock_recover(self, log, spec):
pass

Spec module

class spec.Spec

SPEC properties holder

Example:
>>> from rpg.spec import Spec
>>> spec = Spec()
>>> spec.Name = "Example"
>>> spec.Version = "0.6.11"
>>> spec.Release = "1%{?snapshot}%{?dist}"
>>> spec.License = "GPLv2"
>>> spec.Summary = "Example ..."
>>> spec.description = ("Example ...")
>>> spec.URL = "https://github.com/example_repo"
BuildArch = None

initial value: “”

BuildRequires = None

initial value: set()

BuildRoot = None

initial value: “”

class Changelog(date, author, email, *message)
Spec.Conflicts = None

initial value: “”

Spec.Group = None

initial value: “”

Spec.License = None

initial value: “”

Spec.Name = None

initial value: “”

Spec.Obsoletes = None

initial value: “”

Spec.Packager = None

initial value: “”

Spec.Patch = None

initial value: “”

Spec.Provides = None

initial value: set()

Spec.Release = None

initial value: “”

Spec.Requires = None

initial value: set()

Spec.Source = None

initial value: “”

Spec.Summary = None

initial value: “”

Spec.URL = None

initial value: “”

Spec.Vendor = None

initial value: “”

Spec.Version = None

initial value: “”

Spec.build = None

initial value: Command()

Spec.changelog = None

initial value: []

Spec.changelogs = []
Spec.check = None

initial value: Command()

Spec.clean = None

initial value: Command()

Spec.description = None

initial value: “”

Spec.files = None

initial value: []

Spec.install = None

initial value: Command()

Spec.package = None

initial value: “”

Spec.post = None

initial value: Command()

Spec.posttrans = None

initial value: Command()

Spec.postun = None

initial value: Command()

Spec.pre = None

initial value: Command()

Spec.prep = None

initial value: Command()

Spec.pretrans = None

initial value: Command()

Spec.preun = None

initial value: Command()

Indices and tables