Skip to content

DevConf2020 Workshop

Tomas Tomecek edited this page Jan 25, 2020 · 14 revisions

Workshop

What is packit?

A GitHub app and a CLI tool that helps you integrate your upstream project into Fedora OS and CentOS Stream.

What can you do with it?

  • Validate changes on your PR

    • Can it be built in a distribution (fedora)
    • Do the tests pass on the built package?
  • Automate the release process for Fedora packages

  • more to come....

How can we do it?

  • packit tool - CLI
  • Github Application - Packit-as-a-Service

What packages can use packit?

  • packages which have an RPM spec file
  • custom commands/actions for creating archive, getting versions, patches, ...

And now more practically

Prerequisities

Choice of the project

Installation of the app

  1. https://github.com/apps/packit-as-a-service
  2. -> install / configure
  3. choose the repo(s)

Whitelist

Packit configuration

Examples:

specfile_path: hello.spec
upstream_package_name: hello
downstream_package_name: hello
jobs:
- job: copr_build
  trigger: pull_request
  metadata:
    targets:
    - fedora-30-x86_64
    - fedora-31-x86_64
    - fedora-rawhide-x86_64

- job: tests
  trigger: pull_request
  metadata:
    targets:
    - fedora-30-x86_64
    - fedora-31-x86_64
    - fedora-rawhide-x86_64
- job: propose_downstream
  trigger: release
  metadata:
    dist-git-branch: fedora-all
specfile_path: python-ogr.spec
upstream_package_name: ogr
downstream_package_name: python-ogr
upstream_project_url: https://github.com/packit-service/ogr

# the version is different than with basic git describe
create_tarball_command: ["python3", "setup.py", "sdist", "--dist-dir", "."]
current_version_command: ["python3", "setup.py", "--version"]

jobs:
- job: sync_from_downstream
  trigger: commit

- job: propose_downstream
  trigger: release
  metadata:
    dist-git-branch: fedora-all

- job: copr_build
  trigger: pull_request
  metadata:
    targets: fedora-all

- job: tests
  trigger: pull_request
  metadata:
    targets: fedora-all
specfile_path: packit.spec
synced_files:
  - packit.spec
  - .packit.yaml
  - src: fedora-tests/
    dest: tests/
# packit was already taken on PyPI
upstream_package_name: packitos
downstream_package_name: packit
upstream_project_url: https://github.com/packit-service/packit

actions:
  create-archive:
  - "python3 setup.py sdist --dist-dir ."
  - "sh -c 'echo packitos-$(python3 setup.py --version).tar.gz'"
  get-current-version:
  - "python3 setup.py --version"


jobs:
- job: propose_downstream
  trigger: release
  metadata:
    dist-git-branch: fedora-all
- job: sync_from_downstream
  trigger: commit
- job: copr_build
  trigger: pull_request
  metadata:
    targets:
    - fedora-all
- job: tests
  trigger: pull_request
  metadata:
    targets:
    - fedora-stable # on rawhide we have problems with the new marshmallow
specfile_path: tmt.spec
synced_files:
    - tmt.spec

upstream_project_name: tmt
downstream_package_name: tmt

current_version_command: ["make", "packit-version"]

actions:
  create-archive:
  - make packit-tarball
  - make packit-path

jobs:
- job: copr_build
  trigger: pull_request
  metadata:
    targets:
      - fedora-all

- job: tests
  trigger: pull_request
  metadata:
    targets:
    - fedora-all

Local SRPM

  • clone the repository
  • add the packit configuration file
  • run packit srpm (works also for various refs)
$ packit srpm --help
Usage: packit srpm [OPTIONS] [PATH_OR_URL]

  Create new SRPM (.src.rpm file) using content of the upstream repository.

  PATH_OR_URL argument is a local path or a URL to the upstream git
  repository, it defaults to the current working directory

Options:
  --output FILE        Write the SRPM to FILE instead of current dir.
  --remote TEXT        Name of the remote to discover upstream project URL, If
                       this is not specified, default to origin.
  --upstream-ref TEXT  Git ref of the last upstream commit in the current
                       branch from which packit should generate patches (this
                       option implies the repository is source-git).
  -h, --help           Show this message and exit.
  • You can add also URL as an argument:
$ packit srpm https://github.com/packit-service/ogr
Packit 0.8.1.dev36+g5856e95 is being used.
Input is a URL to a git repo: https://github.com/packit-service/ogr
Input directory is an upstream repository.
SRPM is /tmp/python-ogr-0.9.1.dev20+g8f89fe2-1.fc31.src.rpm
SRPM: /tmp/python-ogr-0.9.1.dev20+g8f89fe2-1.fc31.src.rpm
$ packit srpm https://src.fedoraproject.org/rpms/python-ogr
Packit 0.8.1.dev36+g5856e95 is being used.
Input is a URL to a git repo: https://src.fedoraproject.org/rpms/python-ogr
Input directory is a downstream repository.
SRPM is /tmp/python-ogr-0.9.1.dev20+g8f89fe2-1.fc31.src.rpm
SRPM: /tmp/python-ogr-0.9.1.dev20+g8f89fe2-1.fc31.src.rpm

Status from CLI

  • Check the status of the package in various places:
$ packit status https://src.fedoraproject.org/rpms/packit
Packit 0.8.1.dev36+g5856e95 is being used.
Input is a URL to a git repo: https://src.fedoraproject.org/rpms/packit
WARNING  'upstream_project_name' configuration key was renamed to 'upstream_package_name', please update your configuration file
Input directory is a downstream repository.
ERROR    Failed when getting Copr builds: There is no config file: /home/flachman/.config/copr

No downstream PRs found.

Dist-git versions:
f30: 0.8.1
master: 0.7.1
f29: 0.7.1
f31: 0.8.1

Upstream releases:
0.8.1
0.8.0
0.7.1
0.7.0
0.6.1

Latest Bodhi updates:
Update                 Karma  status
-------------------  -------  --------
packit-0.8.1-1.fc30        2  testing
packit-0.8.1-1.fc31        3  stable
packit-0.7.1-1.fc30        1  stable

Latest Koji builds:
fc31: packit-0.8.1-1.fc31
fc30: packit-0.8.1-1.fc30
fc29: packit-0.6.1-1.fc29
fc32: packit-0.7.1-1.fc32

No Copr builds found.