How I use the COPR to build and host rpms for CentOS and Fedora

Introduction

For about a year now, I have been using the Fedora Project’s public Cool Other Packages Repository (copr) to build and host rpms for my Fedora and CentOS GNU/Linux installations.
This post documents the process I use to take an upstream package, build the packages for the different chroots, and host them for download.

The process

No local tools are required, other than the source control software, normally git.

Select the upstream package

My example will use FreeFileSync, which is a great program and it’s quick to compile.
Additionally, because the upstream provides only a zip file, I am using my collaborative Opensource Tracking repo for the tarball which dpkg seemed to require and I gave up investigating how to get it to use a zip file as a source.

Prepare the spec file and additional artifacts

My spec file, patches, and additional items for building FreeFileSync on Fedora are on my gitlab page. This topic today is not intended to show you how to use rpmbuild, which is a deep and useful topic.

Add a package to copr

With the rpm sources available on the Internet, we’re ready to work in the copr environment.

Create a project

A project can host a single package or many. Also useful to note, that a spec file can produce more than one rpm. So for the copr, a “package” can include either a single rpm artifact or multiple. For example, a libssl.spec will probably produce a libssl-devel, libssl, and libss-docs rpms. You would only have to set up the libssl.spec, and any produced rpms will just be handled automatically.
So, on the main page of COPR, select “New Project.”

Name the project and include any long-form text you care to share. The build options, farther down the page, are important. You can always change these options later, so don’t feel that you have to be extremely careful right now. Select the chroot arch environments you want to build the rpms for.

The external repositories section is really nice. If you need the packages from your favorite Internet yum repo, you can paste the baseurl values here.

Create a new package

In your shiny new project, you will want to add some packages!
Select the Packages tab, and then “New package.”

Plug in the relevant information.
For FreeFileSync, my rpmbuild input artifacts are at https://gitlab.com/bgstack15/stackrpms.git, with a committish (I love that term!) of “freefilesync-bump” which is the dev tree I use for testing the latest version of FreeFileSync.
The subdir for just the freefilesync package, in my entire git tree, is freefilesync/. I’ve got a lot of other spec files in there, but the copr can look in just one dir, which is pretty great.
Use the “rpkg” option, based on the git source. I don’t actually know how the other methods work, and the rpkg has always been good enough for git-hosted spec files for me.

If the package needs to be excluded from certain architectures, there’s a blacklist field you can use.
Save the package settings.

Trigger a build

On the package list, find the new package and select “Rebuild.”

You can choose which chroots to use, and the checkboxes are pre-populated with your defaults and blacklist. My freefilesync package has some unresolvable build dependencies on EL6, so I have excluded those.

Also, specifically, FreeFileSync needed some very custom dependencies co build on EL7– some higher versions of libs like curl and openssl, so it’s a complex dependency tree so either include copr://bgstack15/FreeFileSync in your project’s external repository list.

Notes for Yum repositories for CentOS and Fedora

This is my scratch page for third-party centos and fedora repositories that are useful. I’ve used these at least once in my personal experience. There’s obviously a lot more, and they’re only an internet search away.

EPEL
SCL
city-fan
remi
rpmfusion
negativo17
ius
nuxref

Lists of additional ones:
https://rpmfusion.org/FedoraThirdPartyRepos

Sites for “rpm find”:
https://www.rpmfind.net/
http://rpm.pbone.net/

FreeFileSync 10.9 on CentOS 7

Now, you can go install FreeFileSync 10.9 on CentOS 7 from an rpm built on CentOS 7! The upstream release follows some newer versions of libs (clearly compiled on a different platform than CentOS or even Fedora), and I have now compiled those versions based on the work of a genius fellow over at city-fan.

To get FreeFileSync on CentOS 7, you need to load up two of my coprs as seen in the following table.

COPR name repo file
bgstack15/stackrpms bgstack15-stackrpms-epel-7.repo
bgstack15/FreeFileSync bgstack15-FreeFileSync-epel-7.repo

The application depends on some newer libs, which are all available in a second copr.

======================================================================================
 Package                   Arch   Version                Repository              Size
======================================================================================
Installing:
 freefilesync              x86_64 10.9-2.el7             bgstack15-stackrpms    3.2 M
Installing for dependencies:
 libpsl                    x86_64 0.7.0-1.el7            bgstack15-FreeFileSync  45 k
 openssl-freefilesync-libs x86_64 1:1.1.0h-3.stack.el7   bgstack15-FreeFileSync 1.2 M
Updating for dependencies:
 curl                      x86_64 7.64.0-2.0.cf.rhel7    bgstack15-FreeFileSync 557 k
 libcurl                   x86_64 7.64.0-2.0.cf.rhel7    bgstack15-FreeFileSync 502 k
 libssh2                   x86_64 1.8.0-10.0.stack.rhel7 bgstack15-FreeFileSync 103 k

Transaction Summary
======================================================================================
Install  1 Package  (+2 Dependent packages)
Upgrade             ( 3 Dependent packages)

Total download size: 5.6 M
Is this ok [y/d/N]: 

The artifacts used to produce this build are in my gitlab.

rpm rebuild db

On rare occasions, rpm locks up. The issue is probably a broken database, so try cleaning it and rebuilding it.

Remove the rpm db files
Rebuild the database.

rm -f /var/lib/rpm/__db*
rpm --rebuilddb

Additionally, you can clean up the .lock files, after confirming no yum or rpm processes are running.

rm -f /var/lib/rpm/.*.lock

So many Internet references discuss rebuilding the rpm database, so so specific sources are provided.

Extract src.rpm files

Command is borrowed from How To: Extract an RPM Package Files Without Installing It (cyberciti.biz)

rpm2cpio myrpmfile.rpm | cpio -idmv

When you search for “rpm2cpio” it shows that page, but you have to click into it and scroll down to find the one command. Maybe this page will supplant that one in the Internet searches and make it easier to see the command to run from the lede in the search results.

Rpm spec macros and variables

A nice place to read about the macros in rpm specs is https://fedoraproject.org/wiki/Packaging:RPMMacros. You can also run a command similar to rpm -E ‘%{dist}’ to see a variable’s definition.

To use your own variable in a spec, you can use a %define.

%define myvar 3.1415926

To get even fancier, you can do shell commands in a definition.

%define version_num "%( echo %version | tr -d '\.' )"

This takes %{version} which could be 4.51 and sets a variable to “451” for which I had a use.

VeraCrypt rpm for Fedora

Last updated: 2018-09-26

Update: I now package veracrypt in an rpm on my copr. So use:

dnf copr enable bgstack15/stackrpms
dnf install veracrypt

In these post-TrueCrypt days, I migrated to VeraCrypt. For a very long time now, I have been maintaining an encrypted file container on a flash drive on my keychain. Additionally, I keep various binaries to help open it, like on Windows or GNU/Linux, should I ever need emergency access to my files when not on one of my regular machines. I’m not NSA-proof, but I do intend to keep my private files out of the view of the general public or any random person who might find a lost flash drive.

So about VeraCrypt, A user can download the latest binary packages, even for GNU/Linux, from the offical downloads page. And the source code is on gitlab at https://gitlab.com/veracrypt/VeraCrypt.

But nobody I could find on the Internet has a Fedora rpm package for it. Well, I present to you now my Veracrypt rpm project. It took me a while to figure out the different releases of VeraCrypt don’t compile on Fedora 27 for various bug-related reasons. But the freshest commit version does, so this rpm is generated from the beta upstream point in time where I saved a copy of the repo.

The normal way to compile any of my rpms is to use the usr/share/${package}/build/pack script. It will download sources, prepare the file list in the spec, and perform the rpmbuild.

xfe spec Fedora 26 with proper build dependencies

See the spec file at https://gist.github.com/bgstack15/ec1677daa1d19a9e1f5124068619e813.

The wonderful X File Explorer does not properly describe what is needed to compile it. So here is my research to help anyone else trying to compile it on Fedora 26.

dnf install rpm-build intltool fox-devel glib-devel libpng-devel libXft-devel freetype-devel gcc-c++

Dnf ignore weak dependencies

tl;dr

dnf --setopt=install_weak_deps=False --best install newpackage

dnf do not install weak dependencies

In the new paradigm for rpm package management (rpmpm?), we use dnf. I am fine with using the latest and greatest, but sometimes yum looks nicer in hindsight than dnf.

One of the more recent features added to rpms is weak dependencies. Debian has had weak dependencies for a longer time, so it’s nice to see rpm adding such a feature.

I recently went through a spell where I wanted to install my own package but exclude the recommended options.

After a lot of research and man dnf dnf.conf, I derived the command I needed.

dnf --setopt=install_weak_deps=False --best install newpackage

History

I tried an ugly hack, which technically worked.

dnf --disablerepo=* install ./bgscripts*

But all it does is disable all repos. I was using a local file, so it could get to the rpm I required, but any hard dependencies would be not found. I then tried another option, which technically worked.

dnf install ./bgscripts* -x freerdp

But I had to run a dnf command to see what packages would be installed, and then manually named the packages in the exclude list.

References

Weblinks

  1. https://fedoraproject.org/wiki/PackagingDrafts/WeakDependencies
  2. https://www.debian.org/doc/debian-policy/ch-relationships.html

Man pages

dnf

dnf.conf