Create an account


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Fedora - Packit – auto-package your projects into Fedora

#1
Packit – auto-package your projects into Fedora

<div style="margin: 5px 5% 10px 5%;"><img src="http://www.sickgaming.net/blog/wp-content/uploads/2019/05/packit-auto-package-your-projects-into-fedora.png" width="1024" height="781" title="" alt="" /></div><div><p></p>
<h2>What is packit</h2>
<p>Packit (<a href="https://packit.dev/">https://packit.dev/)</a> is a CLI tool that helps you auto-package your upstream projects into the Fedora operating system. But what does it really mean? </p>
<p>As a developer, you might want to add or update your package in Fedora. If you’ve done it in the past, you know it’s no easy task. If you haven’t let me reiterate: it’s no easy task.</p>
<p>And this is exactly where packit can help: with just one configuration file in your upstream repository, packit will automatically package your software into Fedora and update it when you update your source code upstream.</p>
<p>Furthermore, packit can synchronize downstream changes to a SPEC file back into the upstream repository. This could be useful if the SPEC file of your package is changed in Fedora repositories and you would like to synchronize it into your upstream project.</p>
<p>Packit also provides a way to build an SRPM package based on an upstream repository checkout, which can be used for building RPM packages in COPR.</p>
<p>Last but not least, packit provides a status command. This command provides information about upstream and downstream repositories, like pull requests, release and more others.</p>
<p>Packit provides also another two commands: <em>build </em>and<em> create-update</em>.</p>
<p>The command <em>packit build</em> performs a production build of your project in Fedora build system – koji. You can Fedora version you want to build against using an option <em>–dist-git-branch</em>. The command <em>packit create-updates</em> creates a Bodhi update for the specific branch using the option —<em>dist-git-branch</em>. </p>
<h2>Installation</h2>
<p>You can install packit on Fedora using dnf:</p>
<pre class="wp-block-preformatted">sudo dnf install -y packit</pre>
<h2>Configuration</h2>
<p>For demonstration use case, I have selected the upstream repository of <strong>colin</strong> (<a href="https://github.com/user-cont/colin">https://github.com/user-cont/colin)</a>. Colin is a tool to check generic rules and best-practices for containers, dockerfiles, and container images. </p>
<p>First of all, clone <strong>colin</strong> git repository:</p>
<pre class="wp-block-preformatted">$ git clone https://github.com/user-cont/colin.git<br />$ cd colin</pre>
<p>Packit expects to run in the root of your git repository.</p>
<p>Packit (<a href="https://github.com/packit-service/packit/">https://github.com/packit-service/packit/)</a> needs information about your project, which has to be stored in the upstream repository in the <em>.packit.yaml</em> file (<a href="https://github.com/packit-service/packit/blob/master/docs/configuration.md#projects-configuration-file">https://github.com/packit-service/packit/blob/master/docs/configuration.md#projects-configuration-file</a>).</p>
<p>See colin’s packit configuration file:</p>
<pre class="wp-block-preformatted">$ cat .packit.yaml<br />specfile_path: colin.spec<br />synced_files:<br /> &nbsp;-.packit.yaml<br /> &nbsp;- colin.spec<br />upstream_project_name: colin<br />downstream_package_name: colins</pre>
<p>What do the values mean?</p>
<ul>
<li><em>specfile_path</em> – a relative path to a spec file within the upstream repository (mandatory)</li>
<li><em>synced_files</em> – a list of relative paths to files in the upstream repo which are meant to be copied to dist-git during an update</li>
<li><em>upstream_project_name</em> – name of the upstream repository (e.g. in PyPI); this is used in %prep section</li>
<li><em>downstream_package_name</em> – name of the package in Fedora (mandatory)</li>
</ul>
<p>For more information see the packit configuration documentation (<a href="https://github.com/packit-service/packit/blob/master/docs/configuration.md">https://github.com/packit-service/packit/blob/master/docs/configuration.md</a>)</p>
<h2>What can packit do?</h2>
<p>Prerequisite for using packit is that you are in a working directory of a git checkout of your upstream project.</p>
<p>Before running any packit command, you need to do several actions. These actions are mandatory for filing a PR into the upstream or downstream repositories and to have access into the Fedora dist-git repositories.</p>
<p>Export GitHub token taken from <a href="https://github.com/settings/tokens">https://github.com/settings/tokens</a>:</p>
<pre class="wp-block-preformatted">$ export GITHUB_TOKEN=&lt;YOUR_TOKEN&gt;<br /></pre>
<p>Obtain your Kerberos ticket needed for Fedora Account System (FAS) :</p>
<pre class="wp-block-preformatted">$ kinit &lt;yourname&gt;@FEDORAPROJECT.ORG<br /></pre>
<p>Export your Pagure API keys taken from <a href="https://src.fedoraproject.org/settings#nav-api-tab">https://src.fedoraproject.org/settings#nav-api-tab</a>:</p>
<pre class="wp-block-preformatted">$ export PAGURE_USER_TOKEN=&lt;PAGURE_USER_TOKEN&gt;<br /></pre>
<p>Packit also needs a fork token to create a pull request. The token is taken from <a href="https://src.fedoraproject.org/fork/YOU/rpms/PACKAGE/settings#apikeys-tab">https://src.fedoraproject.org/fork/YOU/rpms/PACKAGE/settings#apikeys-tab</a></p>
<p>Do it by running:</p>
<pre class="wp-block-preformatted">$ export PAGURE_FORK_TOKEN=&lt;PAGURE_FORK_TOKEN&gt;<br /></pre>
<p>Or store these tokens in the <strong>~/.config/packit.yaml</strong> file:</p>
<pre class="wp-block-preformatted">$ cat ~/.config/packit.yaml<br /><br />github_token: &lt;GITHUB_TOKEN&gt;<br />pagure_user_token: &lt;PAGURE_USER_TOKEN&gt;<br />pagure_fork_token: &lt;PAGURE_FORK_TOKEN&gt;<br /></pre>
<h3>Propose a new upstream release in Fedora</h3>
<p>The command for this first use case is called <em><strong>propose-update</strong> </em>(<a href="https://github.com/jpopelka/packit/blob/master/docs/propose_update.md">https://github.com/jpopelka/packit/blob/master/docs/propose_update.md</a>). The command creates a new pull request in Fedora dist-git repository using a selected or the latest upstream release.</p>
<pre class="wp-block-preformatted">$ packit propose-update<br /><br />INFO: Running 'anitya' versioneer<br />Version in upstream registries is '0.3.1'.<br />Version in spec file is '0.3.0'.<br />WARNING &nbsp;Version in spec file is outdated<br />Picking version of the latest release from the upstream registry.<br />Checking out upstream version 0.3.1<br />Using 'master' dist-git branch<br />Copying /home/vagrant/colin/colin.spec to /tmp/tmptfwr123c/colin.spec.<br />Archive colin-0.3.0.tar.gz found in lookaside cache (skipping upload).<br />INFO: Downloading file from URL https://files.pythonhosted.org/packages/....tar.gz<br />100%[=============================&gt;] &nbsp;&nbsp;&nbsp; 3.18M &nbsp;eta 00:00:00<br />Downloaded archive: '/tmp/tmptfwr123c/colin-0.3.0.tar.gz'<br />About to upload to lookaside cache<br />won't be doing kinit, no credentials provided<br />PR created: https://src.fedoraproject.org/rpms/colin...st/14</pre>
<p>Once the command finishes, you can see a PR in the Fedora Pagure instance which is based on the latest upstream release. Once you review it, it can be merged.</p>
<figure class="wp-block-image"><img src="http://www.sickgaming.net/blog/wp-content/uploads/2019/05/packit-auto-package-your-projects-into-fedora.png" alt="" class="wp-image-28017" /></figure>
<h3>Sync downstream changes back to the upstream repository</h3>
<p>Another use case is to sync downstream changes into the upstream project repository.</p>
<p>The command for this purpose is called<em><strong> sync-from-downstream</strong></em> (<a href="https://github.com/jpopelka/packit/blob/master/docs/sync-from-downstream.md">https://github.com/jpopelka/packit/blob/master/docs/sync-from-downstream.md</a>). Files synced into the upstream repository are mentioned in the <em>packit.yaml</em> configuration file under the <em>synced_files </em>value.</p>
<pre class="wp-block-preformatted">$ packit sync-from-downstream<br /><br />upstream active branch master<br />using "master" dist-git branch<br />Copying /tmp/tmplvxqtvbb/colin.spec to /home/vagrant/colin/colin.spec.<br />Creating remote fork-ssh with URL [email protected]:phracek/colin.git.<br />Pushing to remote fork-ssh using branch master-downstream-sync.<br />PR created: <a href="https://github.com/user-cont/colin/pull/229">https://github.com/user-cont/colin/pull/229</a></pre>
<p>As soon as packit finishes, you can see the latest changes taken from the Fedora dist-git repository in the upstream repository. This can be useful, e.g. when Release Engineering performs mass-rebuilds and they update your SPEC file in the Fedora dist-git repository.</p>
<figure class="wp-block-image"><img src="http://www.sickgaming.net/blog/wp-content/uploads/2019/05/packit-auto-package-your-projects-into-fedora-1.png" alt="" class="wp-image-28019" /></figure>
<h3>Get the status of your upstream project</h3>
<p>If you are a developer, you may want to get all the information about the latest releases, tags, pull requests, etc. from the upstream and the downstream repository. Packit provides the <em><strong>status</strong></em> command for this purpose.</p>
<pre class="wp-block-preformatted">$ packit status<br />Downstream PRs:<br /> &nbsp;ID &nbsp;Title &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; URL<br />---- &nbsp;-------------------------------- &nbsp;---------------------------------------------------------<br /> &nbsp;14 &nbsp;Update to upstream release 0.3.1 &nbsp;<a href="https://src.fedoraproject.org//rpms/colin/pull-request/14">https://src.fedoraproject.org//rpms/colin/pull-request/14</a><br /> &nbsp;12 &nbsp;Upstream pr: 226 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href="https://src.fedoraproject.org//rpms/colin/pull-request/12">https://src.fedoraproject.org//rpms/colin/pull-request/12</a><br /> &nbsp;11 &nbsp;Upstream pr: 226 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href="https://src.fedoraproject.org//rpms/colin/pull-request/11">https://src.fedoraproject.org//rpms/colin/pull-request/11</a><br /> &nbsp;&nbsp;8 Upstream pr: 226 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href="https://src.fedoraproject.org//rpms/colin/pull-request/8">https://src.fedoraproject.org//rpms/colin/pull-request/8</a><br /><br />Dist-git versions:<br />f27: 0.2.0<br />f28: 0.2.0<br />f29: 0.2.0<br />f30: 0.2.0<br />master: 0.2.0<br /><br />GitHub upstream releases:<br />0.3.1<br />0.3.0<br />0.2.1<br />0.2.0<br />0.1.0<br /><br />Latest builds:<br />f27: colin-0.2.0-1.fc27<br />f28: colin-0.3.1-1.fc28<br />f29: colin-0.3.1-1.fc29<br />f30: colin-0.3.1-2.fc30<br /><br />Latest bodhi updates:<br />Update &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Karma &nbsp;status<br />------------------ &nbsp;------- --------<br />colin-0.3.1-1.fc29 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1 &nbsp;stable<br />colin-0.3.1-1.fc28 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1 &nbsp;stable<br />colin-0.3.0-2.fc28 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0 &nbsp;obsolete</pre>
<h3>Create an SRPM</h3>
<p>The last packit use case is to generate an SRPM package based on a git checkout of your upstream project. The packit command for SRPM generation is <em><strong>srpm</strong></em>.</p>
<pre class="wp-block-preformatted">$ packit srpm<br />Version in spec file is '0.3.1.37.g00bb80e'.<br />SRPM: /home/phracek/work/colin/colin-0.3.1.37.g00bb80e-1.fc29.src.rpm</pre>
<h2>Packit as a service</h2>
<p>In the summer, the people behind packit would like to introduce packit as a service (<a href="https://github.com/packit-service/packit-service">https://github.com/packit-service/packit-service</a>). In this case, the packit GitHub application will be installed into the upstream repository and packit will perform all the actions automatically, based on the events it receives from GitHub or fedmsg.</p>
</div>
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

Forum software by © MyBB Theme © iAndrew 2016