<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Packaging</title><link>https://jwheel.org/tags/packaging/</link><description>Homepage of Justin Wheeler, an Open Source contributor and Free Software advocate from Georgia, USA.</description><generator>Hugo -- gohugo.io</generator><language>en-us</language><managingEditor>Justin Wheeler</managingEditor><lastBuildDate>Tue, 07 Nov 2017 00:00:00 +0000</lastBuildDate><atom:link href="https://jwheel.org/rss/tags/packaging/index.xml" rel="self" type="application/rss+xml"/><item><title>How I created my first RPM package in Fedora</title><link>https://jwheel.org/blog/2017/11/first-rpm-package-fedora/</link><pubDate>Tue, 07 Nov 2017 00:00:00 +0000</pubDate><guid>https://jwheel.org/blog/2017/11/first-rpm-package-fedora/</guid><description><![CDATA[<p>Over the summer, I migrated my desktop environment to <a href="https://i3wm.org/">i3</a>, a tiling window manager. Switching to i3 was a challenge at first, since I had to replace many things that GNOME handled for me. One of these things was changing screen brightness. <code>xbacklight</code>, the standard way of changing backlight brightness on laptops, doesn&rsquo;t work on my hardware.</p>
<p>Recently, I discovered <a href="https://github.com/multiplexd/brightlight">brightlight</a>, a tool that changes backlight brightness. I decided to try it, and it worked with root privileges. However, I found there was no RPM package in Fedora for brightlight. I decided this was the right time to try creating a package in Fedora and learn how to create an RPM.</p>
<p>In this article, I&rsquo;ll cover and share how I…</p>
<ul>
<li>Created the RPM SPEC file</li>
<li>Built the package in Koji and Copr</li>
<li>Worked through an issue with debug package</li>
<li>Submitted the package to Fedora package collection</li>
</ul>

<h2 id="pre-requisites">Pre-requisites&nbsp;<a class="hanchor" href="#pre-requisites" aria-label="Anchor link for: Pre-requisites">🔗</a></h2>
<p>On Fedora, I installed these packages for all steps of the package building process.</p>
<pre tabindex="0"><code>sudo dnf install fedora-packager fedpkg fedrepo_req copr-cli
</code></pre>
<h2 id="creating-the-rpm-spec-file">Creating the RPM SPEC file&nbsp;<a class="hanchor" href="#creating-the-rpm-spec-file" aria-label="Anchor link for: Creating the RPM SPEC file">🔗</a></h2>
<p>The first step to create a RPM is to create the SPEC file. These are the specifications, or instructions, that tell RPM how to build the package. This is how you tell RPM to create a binary file from the package&rsquo;s source code. Creating the SPEC file is likely the hardest part of the packaging process and its difficulty depends on the project.</p>
<p>Fortunately for me, <a href="https://github.com/multiplexd/brightlight">brightlight</a> is a simple application written in C. The maintainer made it easy to create a binary application with a Makefile. Building it was a matter of simply running <code>make</code> in the repo. So now I had a simple project to learn RPM packaging.</p>

<h4 id="finding-documentation">Finding documentation&nbsp;<a class="hanchor" href="#finding-documentation" aria-label="Anchor link for: Finding documentation">🔗</a></h4>
<p>Googling &ldquo;how to create an RPM package&rdquo; yields many results. I started with <a href="https://www.ibm.com/developerworks/library/l-rpm1/index.html">IBM&rsquo;s documentation</a>. However, I found it confusing and difficult to understand (although quite detailed; it might be more useful for a complicated app). I also found the <a href="https://fedoraproject.org/wiki/How_to_create_an_RPM_package">package creation instructions</a> on the Fedora wiki. The documentation here was good at explaining the composition and process, but I was still confused on how to begin.</p>
<p>Finally, I found the <a href="https://rpm-packaging-guide.github.io/#packaging-software">RPM Packaging Guidelines</a>, written by the amazing <a href="https://github.com/maxamillion">Adam Miller</a>. These instructions were helpful and included three excellent examples for Bash, C, and Python applications. This guide helped me better understand how to compose a RPM SPEC, and more importantly, how all the pieces fit together.</p>
<p>After this, I was able to write my <a href="https://src.fedoraproject.org/rpms/brightlight/blob/master/f/brightlight.spec">first SPEC file</a> for <code>brightlight</code>. Since it is so simple, the SPEC file is short and easy to understand. Once I had my SPEC file, I linted the file for errors. After cleaning a few mistakes, I created the source RPM (SRPM) and the binary RPM, then linted each for errors.</p>
<pre tabindex="0"><code>rpmlint SPECS/brightlight.spec
rpmbuild -bs SPECS/brightlight.spec
rpmlint SRPMS/brightlight-5-1.fc26.src.rpm
rpmbuild -bb SRPMS/brightlight-5-1.fc26.src.rpm
rpmlint RPMS/x86_64/brightlight-5-1.fc26.x86_64.rpm
</code></pre><p>Now, I had a valid RPM to send to the Fedora repositories.</p>

<h2 id="building-in-copr-and-koji">Building in Copr and Koji&nbsp;<a class="hanchor" href="#building-in-copr-and-koji" aria-label="Anchor link for: Building in Copr and Koji">🔗</a></h2>
<p>Next, I read the <a href="https://fedoraproject.org/wiki/Join_the_package_collection_maintainers">guidelines</a> to becoming a Fedora packager. Before submitting anything, they encouraged packagers to test their packages by hosting the project in a <a href="https://copr.fedoraproject.org/">Copr</a> repo and building in <a href="https://koji.fedoraproject.org/koji/">Koji</a>.</p>

<h4 id="using-copr">Using Copr&nbsp;<a class="hanchor" href="#using-copr" aria-label="Anchor link for: Using Copr">🔗</a></h4>
<p>First, I created a <a href="https://copr.fedorainfracloud.org/coprs/jflory7/brightlight/">Copr repository</a> for <code>brightlight</code>. <a href="https://developer.fedoraproject.org/deployment/copr/about.html">Copr</a> is a service in Fedora&rsquo;s infrastructure that builds your package and sets up a custom repo for whatever version of Fedora or EPEL that you choose. It&rsquo;s handy to get your RPM hosted quickly and to share it with others for testing. You don&rsquo;t need special approval to host a Copr.</p>
<p>I created my Copr project from the web interface, but you can also use the <code>copr-cli</code> tool. There is an <a href="https://developer.fedoraproject.org/deployment/copr/copr-cli.html">excellent guide</a> in the Fedora Developer portal. After I created my repo on the website, I built my package with this command.</p>
<pre tabindex="0"><code>copr-cli build brightlight SRPMS/brightlight.5-1.fc26.src.rpm
</code></pre><p>My packages successfully built for Copr and I was able to install it on my Fedora system easily.</p>

<h4 id="using-koji">Using Koji&nbsp;<a class="hanchor" href="#using-koji" aria-label="Anchor link for: Using Koji">🔗</a></h4>
<p>Anyone can use <a href="https://koji.fedoraproject.org/koji/">Koji</a> to test their package on multiple architectures and versions of Fedora or CentOS / RHEL. To test on Koji, you must have a source RPM. I wanted to package <code>brightlight</code> on all supported versions of Fedora, so I ran these commands.</p>
<pre tabindex="0"><code>koji build --scratch f25 SRPMS/brightlight-5-1.fc26.src.rpm
koji build --scratch f26 SRPMS/brightlight-5-1.fc26.src.rpm
koji build --scratch f27 SRPMS/brightlight-5-1.fc26.src.rpm
</code></pre><p>It took some time, but Koji built all the packages. Everything was fine for Fedora 25 and 26, but Fedora 27 failed. Koji scratch builds keep me on the right track and make sure my packages build successfully.</p>

<h2 id="problem-fedora-27-builds-failing">Problem: Fedora 27 builds failing!&nbsp;<a class="hanchor" href="#problem-fedora-27-builds-failing" aria-label="Anchor link for: Problem: Fedora 27 builds failing!">🔗</a></h2>
<p>Now I know that my Fedora 27 package was failing to build on Koji. But why? I discovered two relevant changes for Fedora 27.</p>
<ul>
<li><a href="https://fedoraproject.org/wiki/Changes/SubpackageAndSourceDebuginfo">Subpackage and Source Debuginfo</a></li>
<li><a href="https://fedoraproject.org/wiki/Changes/RPM-4.14">RPM 4.14</a> (specifically, the debuginfo package rewrite)</li>
</ul>
<p>These changes mean that RPM packages must build with a <code>debuginfo</code> package. This is helpful for troubleshooting or debugging an application. In my case, this wasn&rsquo;t critical or too necessary, but I needed to build one.</p>
<p>Thanks to Igor Gnatenko, he helped me understand what I needed to add to my package SPEC for it to build on Fedora 27. Before the <code>%make_build</code> macro, I added these lines.</p>
<pre tabindex="0"><code>export CFLAGS=&#34;%{optflags}&#34;
export LDFLAGS=&#34;%{__global_ldflags}&#34;
</code></pre><p>I built a new SRPM and submitted it to Koji to build on Fedora 27. And success! It built successfully.</p>

<h2 id="submitting-the-package">Submitting the package&nbsp;<a class="hanchor" href="#submitting-the-package" aria-label="Anchor link for: Submitting the package">🔗</a></h2>
<p>Now that I verified my package successfully built on Fedora 25 to 27, it&rsquo;s time to begin the packaging process for Fedora. The first step to submitting a package is to create a new bug in the Red Hat Bugzilla to ask for a package review. I <a href="https://bugzilla.redhat.com/show_bug.cgi?id=1505026">created a ticket</a> for <code>brightlight</code>. Since this was my first package, I made an explicit note that this was my first package and I was seeking a sponsor. In the ticket, I linked to the SPEC and SRPM files in my git repository.</p>

<h4 id="getting-into-dist-git">Getting into dist-git&nbsp;<a class="hanchor" href="#getting-into-dist-git" aria-label="Anchor link for: Getting into dist-git">🔗</a></h4>
<p><em>Edit, 2022 Feb. 14th</em>: It was pointed out <a href="https://twitter.com/Det_Conan_Kudo/status/1491931714179973127">on Twitter</a> that the <code>fedrepo-req</code> tool is no longer used. See the documentation linked throughout this blog post for more guidance on best practices for today.</p>
<p><a href="https://fedoraproject.org/wiki/User:Ignatenkobrain">Igor Gnatenko</a> sponsored me into the Fedora Packagers group and left feedback on my package. I learned of some other things specific for packaging C applications. After he sponsored me, I was able to ask for a repo in <a href="https://src.fedoraproject.org/">dist-git</a>, Fedora&rsquo;s collection of RPM package repositories that host SPEC files for all of Fedora.</p>
<p>A handy Python tool helps make this part easy. <a href="https://pagure.io/fedrepo_req"><code>fedrepo-req</code></a> is a tool that creates a request for a new dist-git repository. I submitted my request with this command.</p>
<pre tabindex="0"><code>fedrepo-req brightlight \
    --ticket 1505026 \
    --description &#34;CLI tool to change screen back light brightness&#34; \
    --upstreamurl https://github.com/multiplexd/brightlight
</code></pre><p>This created a <a href="https://pagure.io/releng/fedora-scm-requests/issue/2489">new ticket</a> for me in the <a href="https://pagure.io/releng/fedora-scm-requests">fedora-scm-requests</a> repo. The next day, an admin <a href="https://src.fedoraproject.org/rpms/brightlight">created the repository</a> for me. Now, I was in business!</p>
<p>
<figure>
  <img src="/blog/2017/11/Screenshot-from-2017-11-05-19-58-47.png" alt="My first RPM in Fedora dist-git – woohoo!" loading="lazy">
  <figcaption>My first RPM (<a href="https://src.fedoraproject.org/rpms/brightlight" class="bare">https://src.fedoraproject.org/rpms/brightlight</a>) in Fedora dist-git – woohoo!</figcaption>
</figure>
</p>

<h4 id="working-with-dist-git">Working with dist-git&nbsp;<a class="hanchor" href="#working-with-dist-git" aria-label="Anchor link for: Working with dist-git">🔗</a></h4>
<p>Next, <code>fedpkg</code> is the tool used for interacting with dist-git repositories. I changed directories into my git working directory and ran this command.</p>
<p><code>fedpkg clone brightlight</code></p>
<p><code>fedpkg</code> then clones my package&rsquo;s repo from dist-git. For the <strong>first branch only</strong>, you need to import the SRPM.</p>
<pre tabindex="0"><code>fedpkg import SRPMS/brightlight-5-1.fc26.src.rpm
</code></pre><p><code>fedpkg</code> imports your package&rsquo;s SRPM into the repo and sets up the sources for you. It&rsquo;s important to use <code>fedpkg</code> for this because it helps provision the repo in a Fedora-friendly way (as compared to adding the files manually yourself). Once you import the SRPM, push the changes to the dist-git repo.</p>
<pre tabindex="0"><code>git commit -m &#34;Initial import (#1505026).&#34;
git push
</code></pre>
<h4 id="building-the-package">Building the package&nbsp;<a class="hanchor" href="#building-the-package" aria-label="Anchor link for: Building the package">🔗</a></h4>
<p>Once you push the first import to your dist-git repo, you&rsquo;re ready to do a <em>real</em> Koji build of your project. To build your project, run this command.</p>
<pre tabindex="0"><code>fedpkg build
</code></pre><p>This builds your package in Koji for Rawhide, the unversioned branch of Fedora. You must build successfully for Rawhide before you can build for other branches. IF everything builds successfully, you can now ask for other branches for your project.</p>
<pre tabindex="0"><code>fedrepo-req brightlight f27 -t 1505026
fedrepo-req brightlight f26 -t 1505026
fedrepo-req brightlight f25 -t 1505026
</code></pre>
<h4 id="note-about-building-other-branches">Note about building other branches&nbsp;<a class="hanchor" href="#note-about-building-other-branches" aria-label="Anchor link for: Note about building other branches">🔗</a></h4>
<p>Once you import the SRPM initially, remember to merge your master branch to other branches, if you choose to create them. For example, if you later request a branch for Fedora 27, you would want to use these commands.</p>
<pre tabindex="0"><code>fedpkg switch-branch f27
git merge master
git push
fedpkg build
</code></pre>
<h4 id="submitting-update-to-bodhi">Submitting update to Bodhi&nbsp;<a class="hanchor" href="#submitting-update-to-bodhi" aria-label="Anchor link for: Submitting update to Bodhi">🔗</a></h4>
<p>The last step of the process is to submit your new package as an update to Bodhi. When you first submit your package as an update, it goes to the testing repositories. Anyone can test your package and add karma to the update. If your update receives +3 votes (or as Bodhi calls it, karma), your package automatically pushes to the stable repositories. Otherwise, it pushes after a week in the testing repositories.</p>
<p>To submit your update to Bodhi, you only need one command.</p>
<pre tabindex="0"><code>fedpkg update
</code></pre><p>This opens a Vim window with different configuration options for your package. Usually, you only need to specify the type (e.g. <code>newpackage</code>) and the ticket ID number for your package review. For a more in-depth explanation, there is an <a href="https://fedoraproject.org/wiki/Package_update_HOWTO">update guide</a> on the Fedora wiki.</p>
<p>After saving and exiting the file, <code>fedpkg</code> submits your package as an update to Bodhi and eventually synchronizes to the Fedora testing repositories. I was able to install my package with this command.</p>
<pre tabindex="0"><code>sudo dnf install brightlight -y --enablerepo=updates-testing --refresh
</code></pre>
<h2 id="were-stable">We&rsquo;re stable!&nbsp;<a class="hanchor" href="#were-stable" aria-label="Anchor link for: We&rsquo;re stable!">🔗</a></h2>
<p>My package was recently submitted to <a href="https://bodhi.fedoraproject.org/updates/brightlight-5-1.fc26">Fedora 26 stable repositories</a> and will soon enter <a href="https://bodhi.fedoraproject.org/updates/FEDORA-2017-8071ee299f">Fedora 25</a> and <a href="https://bodhi.fedoraproject.org/updates/FEDORA-2017-f3f085b86e">Fedora 27</a> stable repositories. Thanks for everyone who helped me with my first package. I look forward to more opportunities to add more packages to the distribution.</p>]]></description></item><item><title>Mumble ready for testing</title><link>https://jwheel.org/blog/2015/12/mumble/</link><pubDate>Thu, 03 Dec 2015 00:00:00 +0000</pubDate><guid>https://jwheel.org/blog/2015/12/mumble/</guid><description><![CDATA[<h2 id="mumble-is-back-in-fedora">Mumble is back in Fedora&nbsp;<a class="hanchor" href="#mumble-is-back-in-fedora" aria-label="Anchor link for: Mumble is back in Fedora">🔗</a></h2>
<p>
<figure>
  <img src="https://communityblog.fedoraproject.org/wp-content/uploads/2015/12/Mumble.png" alt="Mumble, a free and open-source VoIP program" loading="lazy">
  <figcaption>Mumble, a free and open-source VoIP program</figcaption>
</figure>
</p>
<p>The popular Voice Over IP (VoIP) program, <a href="http://wiki.mumble.info/wiki/Main_Page">Mumble</a>, is being repackaged again for Fedora 22 and 23. Fedora contributor <a href="https://bodhi.fedoraproject.org/users/fedpop">fedpop</a> unretired the package from the Fedora Package Database and is working on getting it added to the stable repositories.</p>
<p>Mumble is available for testing for Fedora 22 and 23 users. Once enough positive feedback is received, it will be added back to the stable repositories for all users. Testers are welcome, especially for Fedora 22!</p>

<h2 id="how-to-test-mumble">How to test Mumble&nbsp;<a class="hanchor" href="#how-to-test-mumble" aria-label="Anchor link for: How to test Mumble">🔗</a></h2>
<p>To test, open a command line and run the following command.</p>
<pre tabindex="0"><code>$ sudo dnf install mumble --enablerepo=updates-testing
</code></pre><p>Confirm the installation and the application will appear on your system. Give it a run and make sure everything works as expected! If it all checks out, leave feedback for the build in Bodhi so the package. This helps move it closer to being packaged for the stable repositories (links are below).</p>
<p>For help enabling the testing repository, see the <a href="https://fedoraproject.org/wiki/QA:Updates_Testing">QA Testing wiki article</a>.</p>

<h2 id="why-i-love-mumble">Why I love Mumble&nbsp;<a class="hanchor" href="#why-i-love-mumble" aria-label="Anchor link for: Why I love Mumble">🔗</a></h2>
<p>Mumble is a package I originally installed when I first began using Fedora in Fedora 20. It is one of the few major VoIP clients that can be classified as &ldquo;FOSS&rdquo; (Free and Open Source) and is available on multiple platforms. It&rsquo;s fairly simple to get a server (Murmur) up and running, and it&rsquo;s a great way for communicating over voice with friends, family, or communities. I used to use it often when I was active in various Minecraft server communities, and for a short time, I used it for my own Minecraft community as well.</p>
<p>When it originally disappeared in Fedora 21, I was disappointed since Mumble is an important piece of software that I think is important in any modern Linux distribution. Finally, Fedora users will once again be able to seamlessly install it without having to manually compile the software.</p>
<p>Big hat tip to fedpop for repackaging this awesome piece of software! This also seems to be his first experience as a Fedora packager, so a big welcome goes out to him as well. I can&rsquo;t wait to start recommending Mumble again for Fedora users.</p>

<h2 id="find-it-in-bodhi">Find it in Bodhi&nbsp;<a class="hanchor" href="#find-it-in-bodhi" aria-label="Anchor link for: Find it in Bodhi">🔗</a></h2>
<p><strong><a href="https://bodhi.fedoraproject.org/updates/FEDORA-2015-789c21d8a6">Fedora 22</a></strong></p>
<p><strong><a href="https://bodhi.fedoraproject.org/updates/FEDORA-2015-934a0702cf">Fedora 23</a></strong></p>]]></description></item></channel></rss>