Jeremiah Mahler

home

Fedora Package Development Notes

28 Jun 2018

Getting Started

  1. Get a Fedora machine setup for development. Spinning up an EC2 instance with the latest Fedora is probably the easiest way [14]. Using Docker is another option but it is more complicated [13].

  2. Build a Hello World RPM [1].

  3. Upgrade to Rawhide.

  4. Learn how to use the Koji build system [3].

  5. Fix a bug in an existing package [15, 16].

Command Quickref

Setup a local build environment:

$ rpmdev-setuptree
(~/rpmbuild)

This will setup a hierarchy like the following:

~/rpmbuild/
  SPECS/
  SRPMS/
  SOURCES/
  RPMS/
  ...

Running a build (rpmbuild -ba) on a spec file under SPECS/, assuming sources have been placed in SOURCES/, will produce rpms in RPMS/ and/or SRPMS/.

Build a package locally:

$ rpmbuild -ba hello.spec

Build using a Koji build server:

$ koji build --scratch f29 ~/rpmbuild/SRPMS/hello-2.10-2.fc28.src.rpm
https://koji.fedoraproject.org/koji/userinfo?userID=4194

How to clean the mock cache (/var/cache/mock):

$ mock --scrub all

Download sources for a spec file:

$ rpmbuild --undefine=_disable_source_fetch -ba package.spec

$ spectool -g -R package.spec

Install dependencies needed for rpmbuild:

$ dnf builddep package.spec
$ dnf builddep package.src.rpm

Packaging Tips

The shebang line for Python scripts in RPMs should be #!/usr/bin/python2 or #!/usr/bin/python3 and not #!/usr/bin/env python [17]. This is for two reasons. The python version should be explicitly specified. And env should be avoid to avoid picking up a users non-system version of python.

How to Build RPMs with a Docker Image

TODO [13]

Docker Notes

docker container ls
docker container ls -a

How to copy to/from a container:

# to a running container
docker cp HELLO.txt 25322d67c71b:/

# from a running container
docker cp 25322d67c71b:/HELLO.txt .

Start a stopped container:

docker start 25322d67c71b

Accessing a running container:

docker run -it fedora:23 /bin/bash

# exiting attach will stop the container
docker attach 25322d67c71b

# exiting from exec will not stop the container
docker exec -it 25322d67c71b bash

References

[1] https://fedoraproject.org/wiki/How_to_create_a_GNU_Hello_RPM_package

[2] https://developer.fedoraproject.org/tools/docker/docker-images.html

[3] https://fedoraproject.org/wiki/Using_the_Koji_build_system

[4] https://koji.fedoraproject.org/koji/

[5] https://fedoraproject.org/wiki/Reproducible_Builds

[6] https://tests.reproducible-builds.org/rpms/fedora-23.html

[7] https://tests.reproducible-builds.org/rpms/fedora-23/x86_64/fail2ban/fail2ban-0.9.3-1.fc23.noarch.rpm.html

[8] https://fedoraproject.org/wiki/Join_the_package_collection_maintainers

[9] http://ftp.rpm.org/max-rpm/

[10] https://fedoraproject.org/wiki/Packaging:Scriptlets

[11] https://discussion.fedoraproject.org

[12] https://github.com/rpm-software-management/dnf

[13] https://github.com/mmornati/docker-mock-rpmbuilder

[14] https://alt.fedoraproject.org/cloud/

[15] https://fedoraproject.org/wiki/Join_the_package_collection_maintainers#One-off_contributions

[16] https://bugzilla.redhat.com/buglist.cgi?bug_status=ASSIGNED&bug_status=FAILS_QA&bug_status…

[17]: https://fedoraproject.org/wiki/Packaging:Python