Overview
The custom source method executes a script that generates a spec file and optionally any other files needed to build a source RPM (tarballs, patches, etc.). The script runs in a mock chroot under a non-privileged user (mockbuild) with internet access.
The script cannot be an SRPM itself. If your tool generates an SRPM, you must extract it within the script.
Required Configuration
Only two parameters are required:Script
The script file content, written in any scripting language. Important:- Specify the shebang properly (e.g.,
#!/bin/shfor shell scripts) - The interpreter must be available in the chroot (may need to request via
builddeps) - Output files go to the current working directory by default
Chroot
The mock chroot where the script executes. Default isfedora-latest-x86_64 (the latest stable or branched Fedora available at build time).
Optional Parameters
builddeps
builddeps
Space-separated list of packages pre-installed into the build chroot before script execution.
resultdir
resultdir
Directory where the script generates output. Defaults to current working directory.
Environment Variables
Copr defines these environment variables for your script:| Variable | Description | Example |
|---|---|---|
COPR_OWNER | Owner of the project (user or group) | @copr or username |
COPR_PROJECT | Name of the project | my-project |
COPR_PACKAGE | Name of the package being built | my-package |
COPR_RESULTDIR | Output directory (see resultdir parameter) | /builddir/results |
Script Requirements
Your script must generate:- Spec file (required)
- Source archives referenced by
Sourcestatements (typically tarballs) - Patches referenced by
Patchstatements (optional)
resultdir directory.
Extracting Existing SRPMs
If your tool generates an SRPM, extract it within the script:Examples
Simple Spec File Download
Using SRPM Source
Python Package with Git Submodules
A more complex example showing git cloning, tarball generation, and dynamic versioning:Webhook Support
Custom source method supports custom webhooks. Unlike other methods, the custom method doesn’t parse webhook payloads automatically - that’s your responsibility.Hook Payload
When a webhook triggers a build, the payload is dumped to$PWD/hook_payload file. Your script must:
- Read and parse the
hook_payloadfile - Determine what to build based on the payload
- Generate appropriate sources
It’s valid to trigger custom webhooks without any payload:
Best Practices
- Use
set -eto fail fast on errors - Use
set -xfor verbose output to aid debugging - Specify absolute paths or use
$COPR_RESULTDIRfor output - Test locally in a mock chroot before deploying
- Keep scripts portable - avoid root-requiring operations
- Declare all dependencies in
builddepsparameter