Sponsor:

Your company here — click to reach over 10,000 unique daily visitors

rpkg - Man Page

RPM packaging utility

Synopsis

rpkg [ global_options ] command [ command_options ] [ command_arguments ]
rpkg help
rpkg command --help

Description

rpkg is a script to manage spec enriched Git repositories - meaning any repositories which contain an rpm spec file. It is designed to work with expanded application sources as well as with standard DistGit tarballs and patches. Note that you should trust the .spec files you work with because many operations (like `rpkg srpm` or `rpkg lint`) involve parsing the spec file, which brings along evaluation of any shell or lua scriplets present in it.

Global Options

Command Overview

rpkg add [-h] [--all] [paths ...]

Add changes to index

rpkg build [-h] [--outdir OUTDIR] [--spec SPEC] [--config CONFIG] [--wait] [project]

Alias for copr-build

rpkg ci [-h] [--message MESSAGE | --file FILE] [--all] [--amend] [--with-changelog] [--tag] [--push] [--signoff] [file ...]

Alias for commit

rpkg clean [-h] [--dry-run] [-x] [--force] [-d]

Remove untracked files

rpkg clog [-h] [--raw]

Output top changelog entry to stdout

rpkg clone [-h] [--branches] [--branch BRANCH] [--anonymous] repo_path [directory]

Clone and checkout a repository

rpkg commit [-h] [--message MESSAGE | --file FILE] [--all] [--amend] [--with-changelog] [--tag] [--push] [--signoff] [file ...]

Commit changes

rpkg compile [-h] [--target TARGET] [--with OPTION] [--without OPTION] [--outdir OUTDIR] [--spec SPEC] [--short-circuit SHORT_CIRCUIT] [--nocheck]

Local test rpmbuild compile

rpkg config [-h]

Do nothing, only output used config

rpkg copr-build [-h] [--outdir OUTDIR] [--spec SPEC] [--config CONFIG] [--wait] [project]

Build package in Copr build system

rpkg diff [-h] [--cached] [file ...]

Show changes between the last commit and working tree, etc.

rpkg gimmespec [-h]

Print auto-located input spec file name

rpkg import [-h] [--repo-path REPO_PATH] [--skip-diffs] [--offline] srpm

Import srpm content

rpkg install [-h] [--target TARGET] [--with OPTION] [--without OPTION] [--outdir OUTDIR] [--spec SPEC] [--short-circuit SHORT_CIRCUIT] [--nocheck]

Local test rpmbuild install

rpkg lint [-h] [--info] [--rpmlint-config RPMLINT_CONFIG] [target_path]

Run rpmlint against rendered spec and build products if present. Needs rpmlint to be installed.

rpkg local [-h] [--target TARGET] [--with OPTION] [--without OPTION] [--outdir OUTDIR] [--spec SPEC] [--nocheck]

Local test rpmbuild binary

rpkg log [-h] [--graph] [--all] [--show-signature] [revision ...] [path ...]

Display git log history

rpkg merge [-h] [--no-commit] [--squash] [--message MESSAGE] [--file FILE] [--signoff] [--abort] [--continue] [commit ...]

Incorporates changes from the named commits into the current branch

rpkg new [-h] [--outdir OUTDIR] [--spec SPEC]

Diff against last package tag

rpkg nvr [-h] [--outdir OUTDIR] [--spec SPEC]

Print package name-version-release

rpkg prep [-h] [--target TARGET] [--with OPTION] [--without OPTION] [--outdir OUTDIR] [--spec SPEC]

Prep test rpmbuild binary

rpkg pull [-h] [--rebase] [--no-rebase]

Pull changes from the remote repository and update the working copy

rpkg push [-h] [--follow-tags] [--force]

Push changes and annotated tags to remote repository

rpkg reset [-h] [--soft | --mixed | --hard] [commit|path]

Reset branch tip, index, or the working tree

rpkg sources [-h] [--repo-path REPO_PATH] [--outdir OUTDIR]

Download source files from lookaside cache

rpkg spec [-h] [--outdir OUTDIR] [--spec SPEC] [--sources] [--print]

Generate spec file from a spec template

rpkg srpm [-h] [--target TARGET] [--with OPTION] [--without OPTION] [--outdir OUTDIR] [--spec SPEC]

Create a source rpm

rpkg status [-h] [pathspec ...]

Display git status of the current working tree and index

rpkg switch [-h] [--create] [--detach] [--list-branches] [--fetch] [target]

Work with branches

rpkg tag [-h] [--list] [--delete] [--skip-edit] [--name NAME] [--version VERSION] [--release RELEASE] [tag]

Manage git tags

rpkg unused-patches [-h]

Print list of patches in CWD not referenced by name in the specfile

rpkg upload [-h] [--repo-path REPO_PATH] [--offline] file [file ...]

Upload source files

rpkg verify-files [-h] [target_dir]

Locally verify %%files section

Command Reference

rpkg add

 usage: rpkg add [-h] [--all] [paths ...]
 
 This command updates the index with changes found in the working tree.
 
 positional arguments:
   paths       Specific paths to add changes for.
 
 options:
   -h, --help  show this help message and exit
   --all, -A   Update index with all changes found in the working tree.
 

rpkg build

 usage: rpkg build [-h] [--outdir OUTDIR] [--spec SPEC] [--config CONFIG]
                   [--wait]
                   [project]
 
 Build package in Copr build system. You need to have copr-cli installed and
 also set up Copr API key. For more information about the API key, see API KEY
 section in copr-cli(1) man page. NOTE: This method of building the package
 does not support with, without, and rpmdefines rpkg configuration options.
 These options are used to build an srpm which is then sent to Copr but rpm
 build in Copr happens without these options already, which is important for
 the resulting build. If you want these options applied, you should rather
 setup auto-rebuilding in Copr that will react to new pushes into your
 repository.
 
 positional arguments:
   project          Name of the project in format OWNER/PROJECT. You can omit
                    it if you have specified copr_project configuration option.
 
 options:
   -h, --help       show this help message and exit
   --outdir OUTDIR  Where to put any generated rpm content. Directory must
                    exist.
   --spec SPEC      An input spec template. If not given, the spec template is
                    auto-located in <path> as a file ending either with
                    ".spec.rpkg" or ".spec" suffix (in this order). The
                    directory of the template then also becomes search location
                    for the associated sources and rpkg.conf file. By default,
                    these files are being looked up in <path>. Essentially,
                    this argument changes the subpackage we work with and which
                    is determined by the --path argument initially (with CWD as
                    the default value for it).
   --config CONFIG  Path to an alternative Copr configuration file
   --wait, -w       Wait for build to finish.
 

rpkg ci

 usage: rpkg ci [-h] [--message MESSAGE | --file FILE] [--all] [--amend]
                [--with-changelog] [--tag] [--push] [--signoff]
                [file ...]
 
 Alias for commit.
 
 positional arguments:
   file                  Optional list of specific files to commit
 
 options:
   -h, --help            show this help message and exit
   --message MESSAGE, -m MESSAGE
                         Use the given <msg> as the commit message summary
   --file FILE, -F FILE  Take the commit message from the given file
   --all, -a             Tell the command to automatically stage files that
                         have been modified or deleted.
   --amend               Replace the tip of the current branch by creating a
                         new commit.
   --with-changelog      Get the last changelog from SPEC as commit message
                         content. This option must be used with -m together.
   --tag, -t             Create a tag for this commit
   --push, -p            Commit and push as one action
   --signoff, -s         Include a signed-off-by
 

rpkg clean

 usage: rpkg clean [-h] [--dry-run] [-x] [--force] [-d]
 
 This command can be used to clean up your work tree from untracked files and,
 files described by .gitignore additionally if -x option is passed.
 
 options:
   -h, --help     show this help message and exit
   --dry-run, -n  Don't actually remove anything, just show what would be done.
   -x             Don't exclude files described by .gitignore rules from
                  deletion.
   --force, -f    This option is required to perform deletion of any files or
                  directories if git configuration variable clean.requireForce
                  is set to true. It is passed by default if rpkg configuration
                  variable git.clean_force is set to true.
   -d             Remove whole directories in addition to files. This option is
                  passed by default if rpkg configuration variable
                  git.clean_dirs is set to true.
 

rpkg clog

 usage: rpkg clog [-h] [--raw]
 
 This will output the latest rpm changelog entry to stdout. The leading "- "
 text will be stripped.
 
 options:
   -h, --help  show this help message and exit
   --raw       Generate a more "raw" clog without twiddling the contents
 

rpkg clone

 usage: rpkg clone [-h] [--branches] [--branch BRANCH] [--anonymous]
                   repo_path [directory]
 
 This command will clone the named repository from the configured repository
 base URL. By default it will also checkout the master branch for your working
 copy.
 
 positional arguments:
   repo_path             Name of the repository to clone or full clone url. If
                         just a basename is specified, preconfigured git clone
                         urls and default namespace is used to construct the
                         final clone url.
   directory             Directory in which to clone the repository
 
 options:
   -h, --help            show this help message and exit
   --branches, -B        Checkout a subdirectory for each branch
   --branch BRANCH, -b BRANCH
                         Check out a specific branch. This has no effect if
                         --branches/-B is specified.
   --anonymous, -a       Check out a repository anonymously
 

rpkg commit

 usage: rpkg commit [-h] [--message MESSAGE | --file FILE] [--all] [--amend]
                    [--with-changelog] [--tag] [--push] [--signoff]
                    [file ...]
 
 This invokes a git commit. All tracked files with changes will be committed
 unless a specific file list is provided. $EDITOR will be used to generate a
 changelog message unless one is given to the command. A tag or push can be
 done at the same time. If you have set git.gpg_keyid rpkg configuration
 option, commit and tag will be created signed with the configured GPG key.
 
 positional arguments:
   file                  Optional list of specific files to commit
 
 options:
   -h, --help            show this help message and exit
   --message MESSAGE, -m MESSAGE
                         Use the given <msg> as the commit message summary
   --file FILE, -F FILE  Take the commit message from the given file
   --all, -a             Tell the command to automatically stage files that
                         have been modified or deleted.
   --amend               Replace the tip of the current branch by creating a
                         new commit.
   --with-changelog      Get the last changelog from SPEC as commit message
                         content. This option must be used with -m together.
   --tag, -t             Create a tag for this commit
   --push, -p            Commit and push as one action
   --signoff, -s         Include a signed-off-by
 

rpkg compile

 usage: rpkg compile [-h] [--target TARGET] [--with OPTION] [--without OPTION]
                     [--outdir OUTDIR] [--spec SPEC]
                     [--short-circuit SHORT_CIRCUIT] [--nocheck]
 
 This command calls rpmbuild to compile the source. By default the prep and
 configure stages will be done as well, unless the short-circuit option is
 used.
 
 options:
   -h, --help            show this help message and exit
   --target TARGET       Prep for a specific arch or arch-vendor-os.
   --with OPTION         Enable %bcond spec OPTION. Can be specified multiple
                         times.
   --without OPTION      Disable %bcond spec OPTION. Can be specified multiple
                         times.
   --outdir OUTDIR       Where to put any generated rpm content. Directory must
                         exist.
   --spec SPEC           An input spec template. If not given, the spec
                         template is auto-located in <path> as a file ending
                         either with ".spec.rpkg" or ".spec" suffix (in this
                         order). The directory of the template then also
                         becomes search location for the associated sources and
                         rpkg.conf file. By default, these files are being
                         looked up in <path>. Essentially, this argument
                         changes the subpackage we work with and which is
                         determined by the --path argument initially (with CWD
                         as the default value for it).
   --short-circuit SHORT_CIRCUIT
                         short-circuit compile
   --nocheck             nocheck compile
 

rpkg config

 usage: rpkg config [-h]
 
 Do nothing, only output used config.
 
 options:
   -h, --help  show this help message and exit
 

rpkg copr-build

 usage: rpkg copr-build [-h] [--outdir OUTDIR] [--spec SPEC] [--config CONFIG]
                        [--wait]
                        [project]
 
         Build package in Copr build system.
 
         You need to have copr-cli installed and also set up Copr API key.
         For more information about the API key, see API KEY section in
         copr-cli(1) man page.
 
         NOTE: This method of building the package does not support
         with, without, and rpmdefines rpkg configuration options.
         These options are used to build an srpm which is then
         sent to Copr but rpm build in Copr happens without
         these options already, which is important for the
         resulting build. If you want these options applied,
         you should rather setup auto-rebuilding in Copr
         that will react to new pushes into your repository.
         
 
 positional arguments:
   project          Name of the project in format OWNER/PROJECT. You can omit
                    it if you have specified copr_project configuration option.
 
 options:
   -h, --help       show this help message and exit
   --outdir OUTDIR  Where to put any generated rpm content. Directory must
                    exist.
   --spec SPEC      An input spec template. If not given, the spec template is
                    auto-located in <path> as a file ending either with
                    ".spec.rpkg" or ".spec" suffix (in this order). The
                    directory of the template then also becomes search location
                    for the associated sources and rpkg.conf file. By default,
                    these files are being looked up in <path>. Essentially,
                    this argument changes the subpackage we work with and which
                    is determined by the --path argument initially (with CWD as
                    the default value for it).
   --config CONFIG  Path to an alternative Copr configuration file
   --wait, -w       Wait for build to finish.
 

rpkg diff

 usage: rpkg diff [-h] [--cached] [file ...]
 
 Use git diff to show changes that have been made to tracked files. By default
 cached changes (changes that have been git added) will not be shown.
 
 positional arguments:
   file        Optionally diff specific files
 
 options:
   -h, --help  show this help message and exit
   --cached    View staged changes
 

rpkg gimmespec

 usage: rpkg gimmespec [-h]
 
 Print auto-located input spec file name
 
 options:
   -h, --help  show this help message and exit
 

rpkg import

 usage: rpkg import [-h] [--repo-path REPO_PATH] [--skip-diffs] [--offline]
                    srpm
 
 This will extract sources, patches, and the spec file from an srpm and
 overwrites the current package content accordingly. It will import to the
 current branch by default. Newly discovered sources will be uploaded and
 .gitignore and sources file updated accordingly.
 
 positional arguments:
   srpm                  Source rpm to import. It can be also an URL in which
                         case the target srpm will be downloaded first.
 
 options:
   -h, --help            show this help message and exit
   --repo-path REPO_PATH
                         Path to git repository for which to upload sources. If
                         not specified, it will be automatically derived from
                         remote URL configured for the current branch.
   --skip-diffs          Don't show diffs when importing.
   --offline             Do not actually upload the files but do all the rest.
 

rpkg install

 usage: rpkg install [-h] [--target TARGET] [--with OPTION] [--without OPTION]
                     [--outdir OUTDIR] [--spec SPEC]
                     [--short-circuit SHORT_CIRCUIT] [--nocheck]
 
 This will call rpmbuild to run the install section. All leading sections will
 be processed as well, unless the short-circuit option is used.
 
 options:
   -h, --help            show this help message and exit
   --target TARGET       Prep for a specific arch or arch-vendor-os.
   --with OPTION         Enable %bcond spec OPTION. Can be specified multiple
                         times.
   --without OPTION      Disable %bcond spec OPTION. Can be specified multiple
                         times.
   --outdir OUTDIR       Where to put any generated rpm content. Directory must
                         exist.
   --spec SPEC           An input spec template. If not given, the spec
                         template is auto-located in <path> as a file ending
                         either with ".spec.rpkg" or ".spec" suffix (in this
                         order). The directory of the template then also
                         becomes search location for the associated sources and
                         rpkg.conf file. By default, these files are being
                         looked up in <path>. Essentially, this argument
                         changes the subpackage we work with and which is
                         determined by the --path argument initially (with CWD
                         as the default value for it).
   --short-circuit SHORT_CIRCUIT
                         short-circuit install
   --nocheck             nocheck install
 

rpkg lint

 usage: rpkg lint [-h] [--info] [--rpmlint-config RPMLINT_CONFIG] [target_path]
 
 Rpmlint can be configured using the --rpmlint-config/-r option or by setting
 rpkg.rpmlint_config variable.
 
 positional arguments:
   target_path           Directory with rpm items to be linted or just a single
                         rpm item like a .spec file. if not specified, the
                         latest package directory from base output path will be
                         selected.
 
 options:
   -h, --help            show this help message and exit
   --info, -i            Display explanations for reported messages
   --rpmlint-config RPMLINT_CONFIG, -r RPMLINT_CONFIG
                         Use a specific configuration file for rpmlint
 

rpkg local

 usage: rpkg local [-h] [--target TARGET] [--with OPTION] [--without OPTION]
                   [--outdir OUTDIR] [--spec SPEC] [--nocheck]
 
 Locally test run of rpmbuild producing binary RPMs.
 
 options:
   -h, --help        show this help message and exit
   --target TARGET   Prep for a specific arch or arch-vendor-os.
   --with OPTION     Enable %bcond spec OPTION. Can be specified multiple
                     times.
   --without OPTION  Disable %bcond spec OPTION. Can be specified multiple
                     times.
   --outdir OUTDIR   Where to put any generated rpm content. Directory must
                     exist.
   --spec SPEC       An input spec template. If not given, the spec template is
                     auto-located in <path> as a file ending either with
                     ".spec.rpkg" or ".spec" suffix (in this order). The
                     directory of the template then also becomes search
                     location for the associated sources and rpkg.conf file. By
                     default, these files are being looked up in <path>.
                     Essentially, this argument changes the subpackage we work
                     with and which is determined by the --path argument
                     initially (with CWD as the default value for it).
   --nocheck         nocheck local build
 

rpkg log

 usage: rpkg log [-h] [--graph] [--all] [--show-signature]
                 [revision ...] [path ...]
 
 Display git log history. Can be configured by git.log_graph and git.log_all
 rpkg configuration options.
 
 positional arguments:
   revision          Specific revisions or revision range to be shown.
   path              Limit commits to those that touch the specific path(s).
                     You might need to use a -- to explicitly separate paths
                     from revisions. In that case, you also need to insert
                     another -- to first separate options from all the
                     positional arguments.
 
 options:
   -h, --help        show this help message and exit
   --graph           Draw a text-based graphical representation of the commit
                     history. By default enabled by rpkg configuration option
                     git.log_graph.
   --all             Pretend as if all the refs in refs/, along with HEAD, are
                     listed on the command line as a revision. By default
                     enabled by rpkg configuration option git.log_all.
   --show-signature  Show gpg signatures and check their validity.
 

rpkg merge

 usage: rpkg merge [-h] [--no-commit] [--squash] [--message MESSAGE]
                   [--file FILE] [--signoff] [--abort] [--continue]
                   [commit ...]
 
 Incorporates changes from the named commits (since the time their histories
 diverged from the current branch) into the current branch.
 
 positional arguments:
   commit                Commits, usually other branch heads, to merge into our
                         branch. If no commit is given, merge the remote-
                         tracking branches that the current branch is
                         configured to use as its upstream.
 
 options:
   -h, --help            show this help message and exit
   --no-commit           Perform the merge but do not auto-commit.
   --squash              Produce the working tree and index state as if a real
                         merge happened but do not auto-commit. The next commit
                         will have only a single parent and contain all the
                         merged changes.
   --message MESSAGE, -m MESSAGE
                         Use the given <msg> as the commit message summary.
   --file FILE, -F FILE  Take the commit message from the given file.
   --signoff             Add Signed-off-by line by the committer.
   --abort               Abort the current conflict resolution process, and try
                         to reconstruct the pre-merge state.
   --continue            When all your merge conflicts have been resolved, you
                         can conclude the merge by running this command.
 

rpkg new

 usage: rpkg new [-h] [--outdir OUTDIR] [--spec SPEC]
 
 This will use git to show a diff of all the changes (even uncommitted changes)
 since the last package tag was created.
 
 options:
   -h, --help       show this help message and exit
   --outdir OUTDIR  Where to put any generated rpm content. Directory must
                    exist.
   --spec SPEC      An input spec template. If not given, the spec template is
                    auto-located in <path> as a file ending either with
                    ".spec.rpkg" or ".spec" suffix (in this order). The
                    directory of the template then also becomes search location
                    for the associated sources and rpkg.conf file. By default,
                    these files are being looked up in <path>. Essentially,
                    this argument changes the subpackage we work with and which
                    is determined by the --path argument initially (with CWD as
                    the default value for it).
 

rpkg nvr

 usage: rpkg nvr [-h] [--outdir OUTDIR] [--spec SPEC]
 
 Print package name-version-release
 
 options:
   -h, --help       show this help message and exit
   --outdir OUTDIR  Where to put any generated rpm content. Directory must
                    exist.
   --spec SPEC      An input spec template. If not given, the spec template is
                    auto-located in <path> as a file ending either with
                    ".spec.rpkg" or ".spec" suffix (in this order). The
                    directory of the template then also becomes search location
                    for the associated sources and rpkg.conf file. By default,
                    these files are being looked up in <path>. Essentially,
                    this argument changes the subpackage we work with and which
                    is determined by the --path argument initially (with CWD as
                    the default value for it).
 

rpkg prep

 usage: rpkg prep [-h] [--target TARGET] [--with OPTION] [--without OPTION]
                  [--outdir OUTDIR] [--spec SPEC]
 
 Use rpmbuild to "prep" the sources (unpack the source archive(s) and apply any
 patches).
 
 options:
   -h, --help        show this help message and exit
   --target TARGET   Prep for a specific arch or arch-vendor-os.
   --with OPTION     Enable %bcond spec OPTION. Can be specified multiple
                     times.
   --without OPTION  Disable %bcond spec OPTION. Can be specified multiple
                     times.
   --outdir OUTDIR   Where to put any generated rpm content. Directory must
                     exist.
   --spec SPEC       An input spec template. If not given, the spec template is
                     auto-located in <path> as a file ending either with
                     ".spec.rpkg" or ".spec" suffix (in this order). The
                     directory of the template then also becomes search
                     location for the associated sources and rpkg.conf file. By
                     default, these files are being looked up in <path>.
                     Essentially, this argument changes the subpackage we work
                     with and which is determined by the --path argument
                     initially (with CWD as the default value for it).
 

rpkg pull

 usage: rpkg pull [-h] [--rebase] [--no-rebase]
 
 This command uses git to fetch remote changes and apply them to the current
 working copy. A rebase option is available which can be used to avoid merges.
 
 options:
   -h, --help   show this help message and exit
   --rebase     Rebase the locally committed changes on top of the remote
                changes after fetching. This can avoid a merge commit, but does
                rewrite local history.
   --no-rebase  Do not rebase, overriding .git settings to the contrary
 

rpkg push

 usage: rpkg push [-h] [--follow-tags] [--force]
 
 Push changes and annotated tags to remote repository.
 
 options:
   -h, --help     show this help message and exit
   --follow-tags  Push all the refs that would be pushed without this option
                  and also push annotated tags reachable from the refs that are
                  pushed by default. This option is passed by default if
                  git.push_follow_tags configuration variable is set to true.
   --force, -f    Force push
 

rpkg reset

 usage: rpkg reset [-h] [--soft | --mixed | --hard] [commit|path]
 
 Reset HEAD to the specified commit and update index and/or working tree.
 Alternatively, if path is passed instead of commit, reset the respective index
 entry to its state at HEAD.
 
 positional arguments:
   commit|path  Commit or path. If path is passed, the respective index entry
                is updated to its HEAD state, otherwise the action depends on
                the specified option switch (--mixed is implicit).
 
 options:
   -h, --help   show this help message and exit
   --soft       Does not touch the index file or the working tree. Only resets
                the head to the specified commit.
   --mixed      Resets the index but not the working tree. This is the default
                action.
   --hard       Resets the index and working tree. Any changes to tracked files
                in the working tree since the specified commit are discarded.
 

rpkg sources

 usage: rpkg sources [-h] [--repo-path REPO_PATH] [--outdir OUTDIR]
 
 Download source files from lookaside cache.
 
 options:
   -h, --help            show this help message and exit
   --repo-path REPO_PATH
                         Path to git repository for which to download sources.
                         If not specified, it will be automatically derived
                         from remote URL configured for the current branch.
   --outdir OUTDIR       Directory to put downloaded files into (defaults to
                         cwd)
 

rpkg spec

 usage: rpkg spec [-h] [--outdir OUTDIR] [--spec SPEC] [--sources] [--print]
 
 Preprocess a given spec template and put the resulting spec file into outdir.
 The spec template is simply copied into the outdir if spec preprocessing is
 turned off or if the input spec template does not contain any preprocessor
 macros.
 
 options:
   -h, --help       show this help message and exit
   --outdir OUTDIR  Where to put any generated rpm content. Directory must
                    exist.
   --spec SPEC      An input spec template. If not given, the spec template is
                    auto-located in <path> as a file ending either with
                    ".spec.rpkg" or ".spec" suffix (in this order). The
                    directory of the template then also becomes search location
                    for the associated sources and rpkg.conf file. By default,
                    these files are being looked up in <path>. Essentially,
                    this argument changes the subpackage we work with and which
                    is determined by the --path argument initially (with CWD as
                    the default value for it).
   --sources        Enable source generation by the input spec template. By
                    default disabled.
   --print, -p      Print rendered spec file to stdout.
 

rpkg srpm

 usage: rpkg srpm [-h] [--target TARGET] [--with OPTION] [--without OPTION]
                  [--outdir OUTDIR] [--spec SPEC]
 
 Create a source rpm
 
 options:
   -h, --help        show this help message and exit
   --target TARGET   Prep for a specific arch or arch-vendor-os.
   --with OPTION     Enable %bcond spec OPTION. Can be specified multiple
                     times.
   --without OPTION  Disable %bcond spec OPTION. Can be specified multiple
                     times.
   --outdir OUTDIR   Where to put any generated rpm content. Directory must
                     exist.
   --spec SPEC       An input spec template. If not given, the spec template is
                     auto-located in <path> as a file ending either with
                     ".spec.rpkg" or ".spec" suffix (in this order). The
                     directory of the template then also becomes search
                     location for the associated sources and rpkg.conf file. By
                     default, these files are being looked up in <path>.
                     Essentially, this argument changes the subpackage we work
                     with and which is determined by the --path argument
                     initially (with CWD as the default value for it).
 

rpkg status

 usage: rpkg status [-h] [pathspec ...]
 
 Display git status of the current working tree and index.
 
 positional arguments:
   pathspec    Limit status information to the specific subpaths.
 
 options:
   -h, --help  show this help message and exit
 

rpkg switch

 usage: rpkg switch [-h] [--create] [--detach] [--list-branches] [--fetch]
                    [target]
 
 Switch to a given git branch. If --detach option is given, also tag, or a
 commit can be used as a target for switching. Additionally, this command can
 be used to list the existing local and remote branches or to fetch new refs
 from remote.
 
 positional arguments:
   target               Target branch name or alternatively, commit or tag to
                        switch to. If provided with a remote branch name that
                        does not have a local match, it creates one and sets it
                        to track the corresponding remote branch.
 
 options:
   -h, --help           show this help message and exit
   --create, -c         Create a new local branch even if it does not have the
                        corresponding remote and switch to it.
   --detach, -d         Detach HEAD at target commit or tag.
   --list-branches, -l  List both remote-tracking branches and local branches.
                        Implied when target is not specified.
   --fetch              Fetch branches and tags from remote before switch.
 

rpkg tag

 usage: rpkg tag [-h] [--list] [--delete] [--skip-edit] [--name NAME]
                 [--version VERSION] [--release RELEASE]
                 [tag]
 
 This command uses git to create, list, or delete tags. If you have set
 git.gpg_keyid in rpkg configuraion, the tags will be created signed.
 
 positional arguments:
   tag                   Name of the tag. Overrides any of the --name,
                         --version, --release args if specified
 
 options:
   -h, --help            show this help message and exit
   --list, -l            List all tags with a given pattern, or all if not
                         pattern is given
   --delete, -d          Delete a tag
   --skip-edit, -s       Skip changelog editing when creating a tag.
   --name NAME, -n NAME  Set package name part of the tag name to specific
                         value.
   --version VERSION, -v VERSION
                         Set version part of the tag name to specific value.
   --release RELEASE, -r RELEASE
                         Set release part of the tag name to specific value.
 

rpkg unused-patches

 usage: rpkg unused-patches [-h]
 
 Print list of patches in current working directory not referenced by name in
 the specfile.
 
 options:
   -h, --help  show this help message and exit
 

rpkg upload

 usage: rpkg upload [-h] [--repo-path REPO_PATH] [--offline] file [file ...]
 
 This command will upload new source file(s) to lookaside cache. Source file
 names are appended to sources file, and .gitignore will be also updated with
 new uploaded file(s). Please remember to commit them.
 
 positional arguments:
   file                  List of files to upload
 
 options:
   -h, --help            show this help message and exit
   --repo-path REPO_PATH
                         Path to git repository for which to upload sources. If
                         not specified, it will be automatically derived from
                         remote URL configured for the current branch.
   --offline             Do not actually upload the files but do all the rest,
                         which involves updating .gitignore and sources file.
 

rpkg verify-files

 usage: rpkg verify-files [-h] [target_dir]
 
 Locally run 'rpmbuild -bl' to verify the spec file's %%files sections. This
 requires a successful run of the install commaned in advance.
 
 positional arguments:
   target_dir  Directory with build results to verify. If not specified, the
               latest package directory from base output path will be selected.
 
 options:
   -h, --help  show this help message and exit
 

Configuration

rpkg reads configuration options from the following files in this order:

   /etc/rpkg.conf, ~/.config/rpkg.conf, <git_root>/rpkg.conf, <pkg_path>/rpkg.conf

Configuration found in <pkg_path>/rpkg.conf has the highest priority. Configuration found in /etc/rpkg.conf has the lowest priority. <git_root> placeholder above is the top level of the Git repository we are working in. If we are in a plain directory (i.e. there is not .git subdir) and all our parent directories are also plain, reading of <git_root>/rpkg.conf is skipped. <pkg_path> is CWD, by default, but it can be overriden with --path argument and --spec argument, the latter having higher priority.

There are also built-in default values for each variable that are used if the variable is not specified in any configuration file. You can see them below together with the variable descriptions.

Default Configuration with Descriptions

   [rpkg]
   # Whether to enable spec preprocessing,
   # that is parsing and evaluation of {{{ ... }}} expressions
   # type: bool
   preprocess_spec = True

   # Base directory where generated files should be put.
   # The files will not be put directly there but
   # instead into dynamically generated subdirectories
   # type: string
   base_output_path = /tmp/rpkg

   # Path to user preproc macros. You may use ${git_props:root}
   # variable to anchor the path to top-level of your git repo.
   # type: list of space-separated strings
   user_macros =

   # rpm bcondition "with" specifier
   # type: list of space-separated strings
   with =

   # rpm bcondition "without" specifier
   # type: list of space-separated strings
   without =

   # Defines rpm variables for spec parsing
   # type: list of space-separated quoted string pairs (e.g. 'dist %nil')
   rpmdefines =

   # Defines rpm variables for spec parsing during
   # version/release bumping (see the tag subcommand)
   # This list is not being concatenated with rpmdefines.
   # type: list of space-separated quoted string pairs
   bump_rpmdefines = 'dist %nil'

   # Path to rpmlint configuration (see the lint subcommand)
   # type: string
   rpmlint_config =

   # Paths to default preproc macros relative to
   # /usr/lib/rpkg.macros.d directory
   # type: list of space-separated strings
   default_macros = git.bash

   [git]
   # Default Git repository URL, used by `rpkg clone <repo_path>`
   # type: string
   clone_url =

   # Default Git repository URL, used by `rpkg clone -a <repo_path>`
   # type: string
   anon_clone_url =

   # If you clone a project with rpkg clone and specify only
   # its basename (i.e. the last part like "dist-git"), then
   # default namespace (e.g. rpms) will be automatically
   # prepended to it together with ending slash if specified.
   # type: string
   default_namespace =

   # Whether to automatically push tags with rpkg push
   # type: bool
   push_follow_tags = True

   # Allows removing of files and directories
   # for rpkg clean operation
   # type: bool
   clean_force = True

   # Whether rpkg clean should descend into
   # untracked directories
   # type: bool
   clean_dirs = True

   # Whether rpkg log should be in graph form
   # type: bool
   log_graph = True

   # Whether rpkg log should display all branches
   # type: bool
   log_all = True

   # Key to sign commits and tags with. Specifying
   # it enables signing.
   # type: bool
   gpg_keyid =

   # In which Copr project to build a package by using
   # rpkg build command, in form: user/project or @group/project
   # type: string
   copr_project =

   [lookaside]
   # Download URL for DistGit lookaside cache, used by rpkg sources.
   # There are some dynamic variables that you can use:
   # %(repo_path)s is a fully-namespaced repository name (e.g. rpms/rpkg-util)
   # %(ns<n>)s, ..., %(ns2)s, %(ns1)s, %(name)s is %(repo_path)s split into individual components.
   # E.g. forks/praiskup/rpms/passwd path will provide variables: %(ns3)s == forks, %(ns2)s == praiskup, %(ns1)s == rpms, %(name)s == passwd
   # %(filename)s, %(hashtype)s, %(hash)s fields are read from 'sources' file, if present.
   # Further, you can use ${git_props:remote_netloc} interpolation
   # variable to base the download URL on git clone URL.
   # type: string
   download_url =

   # Upload URL for DistGit lookaside cache, used by rpkg upload.
   # You can use ${git_props:remote_netloc} interpolation
   # variable to base the download URL on git clone URL.
   # type: string
   upload_url =

   # For client certificate authentication if employed
   # by the server
   # type: string
   client_cert =

   # For client certificate authentication if employed
   # by the server
   # type: string
   client_key =

   # For client certificate authentication if employed
   # by the server
   # type: string
   ca_cert =

Dynamic Configuration Sections

There are also other config sections which are dynamically added by rpkg during runtime. These are [DEFAULT] (containing user, path, and pkg_path properties) and [git_props] (containing lots of git status specific information). You can print the whole final config (including those sections) with rpkg config command.

Interpolation

When specifying configuration values, you can use interpolation to reference another configuration variable even from another section. The syntax is: ${<section name>:<param name>} (e.g. ${git_props:remote_netloc}).

There is also %(<var>)s interpolation for some fields like lookaside:download_url. The variables you can interpolate like this are always field-specific.

Examples

Run %prep phase of an rpm build:

   $ rpkg prep
   git_dir_pack: packing path /home/clime/rpkg-util
   git_dir_pack: Wrote: /tmp/rpkg/rpkg-util-12-ft3gm2mw/rpkg-util-f01b36d7-dirty.tar.gz
   Wrote: /tmp/rpkg/rpkg-util-12-ft3gm2mw/rpkg-util.spec
   Executing(%prep): /bin/sh -e /var/tmp/rpm-tmp.iqrI6z
   + umask 022
   + cd /tmp/rpkg/rpkg-util-12-ft3gm2mw
   + cd /tmp/rpkg/rpkg-util-12-ft3gm2mw
   + rm -rf rpkg-util
   + /usr/bin/gzip -dc /tmp/rpkg/rpkg-util-12-ft3gm2mw/rpkg-util-f01b36d7-dirty.tar.gz
   + /usr/bin/tar -xof -
   + STATUS=0
   + '[' 0 -ne 0 ']'
   + cd rpkg-util
   + /usr/bin/chmod -Rf a+rX,u+w,g-w,o-w .
   + RPM_EC=0
   ++ jobs -p
   + exit 0

Generate spec file from a template:

   $ rpkg spec
   Wrote: /tmp/rpkg/rpkg-util-13-53194610/rpkg-util.spec

Build srpm:

   $ rpkg srpm
   git_dir_pack: packing path /home/clime/rpkg-util
   git_dir_pack: Wrote: /tmp/rpkg/rpkg-util-14-q3t0g4um/rpkg-util-f01b36d7-dirty.tar.gz
   Wrote: /tmp/rpkg/rpkg-util-14-q3t0g4um/rpkg-util.spec
   Wrote: /tmp/rpkg/rpkg-util-14-q3t0g4um/rpkg-util-3.prototype.git.229.f01b36d7.dirty.02idw5-1.fc31.src.rpm

Spec Templates

Apart from being useful as a means to handle unpacked as well as packed content, they also make it possible to generate certain parts of your spec file automatically from a Git repository where your spec file is located. You need to have "preprocess_spec" configuration option set to True in rpkg config to use this functionality.

Basic Example

   Name:       {{{ git_dir_name }}}
   Version:    {{{ git_dir_version }}}
   Release:    1%{?dist}
   Summary:    This is a test package.

   License:    GPLv2+
   URL:        https://someurl.org
   VCS:        {{{ git_dir_vcs }}}

   Source:     {{{ git_dir_pack }}}

   %description
   This is a test package.

   %prep
   {{{ git_dir_setup_macro }}}

   %changelog
   {{{ git_dir_changelog }}}

Having a spec template like this in your project (instead of just a plain spec file) allows you to build source and rpm packages automatically following git history of your project.

Macro Reference

Please, see dedicated rpkg-macros page.

User-Defined Macros

You can define your own rpkg macros. They are basically just standard bash functions read from file specified by user_macros config variable. When used, standard output of your custom macro will be captured and the {{{ <macro_name> }}} invocation in an input spec file will be replaced with it.

Example of a custom macro placed in repo-specific rpkg.macros file:

   function my_git_commits_no {
       total_commits=$(git rev-list --all --count)
       echo -n "$total_commits"
   }

If you have got rpkg.macros file with this content in git top-level directory for your project, then also create rpkg.conf file in your top-level dir with at least the following content:

   [rpkg]
   user_macros = ${git_props:root}/rpkg.macros

This will enable reading of the custom user macros. In the spec file, you can then e.g. use this snippet:

Release: {{{ my_git_commits_no }}}

to enable generating release based on total number of commits.

See Also

https://pagure.io/rpkg-util/

Info

2024-01-26 rpm-packager