XGQT's blog: Posts tagged 'gentoo'urn:https-xgqt-gitlab-io:-blog-tags-gentoo-html2023-12-17T22:59:12Z.NET in Gentoo in 2023urn:https-xgqt-gitlab-io:-blog-posts-2023-12-17-net-in-gentoo-in-20232023-12-17T22:59:12Z2023-12-17T22:59:12ZMaciej Barć
<h2 id="net-ecosystem-in-gentoo-in-year-2023">.NET ecosystem in Gentoo in year 2023</h2>
<p>The Gentoo Dotnet project introduced better support for building .NET-based software using the <code>nuget</code>, <code>dotnet-pkg-base</code> and <code>dotnet-pkg</code> eclasses. This opened new opportunities of bringing new packages depending on .NET ecosystem to the official Gentoo ebuild repository and helping developers that use <code>dotnet-sdk</code> on Gentoo.</p>
<p>New software requiring .NET is constantly being added to the main Gentoo tree, among others that is:</p>
<ul>
<li><a href="https://packages.gentoo.org/packages/app-shells/pwsh">PowerShell</a> for Linux,</li>
<li><a href="https://packages.gentoo.org/packages/app-office/denaro">Denaro</a> — finance application,</li>
<li><a href="https://packages.gentoo.org/packages/games-emulation/ryujinx">Ryujinx</a> — NS emulator,</li>
<li><a href="https://packages.gentoo.org/packages/games-strategy/openra">OpenRA</a> — RTS engine for Command & Conquer, Red Alert and Dune2k,</li>
<li><a href="https://packages.gentoo.org/packages/media-gfx/pinta">Pinta</a> — graphics program,</li>
<li><a href="https://packages.gentoo.org/packages/media-gfx/pablodraw">Pablodraw</a> — Ansi, Ascii and RIPscrip art editor,</li>
<li><a href="https://packages.gentoo.org/packages/dev-lang/dafny">Dafny</a> — verification-aware programming language</li>
<li>many <a href="https://packages.gentoo.org/maintainer/dotnet@gentoo.org#dev-dotnet">packages</a> aimed straight at developing .NET projects.</li></ul>
<p>Dotnet project is also looking for new maintainers and users who are willing to help out here and there. Current state of .NET in Gentoo is very good but we can still do a lot better.</p>
<h2 id="special-thanks-to-people-who-helped-out">Special thanks to people who helped out</h2>
<ul>
<li><a href="https://github.com/navi-desu/">Anna Figueiredo Gomes</a></li>
<li><a href="https://github.com/mid-kid/">Esteve Varela Colominas</a></li>
<li><a href="https://github.com/Tatsh/">Andrew Udvare</a></li></ul>
<h2 id="links-to-bugs-and-announcements">Links to bugs and announcements</h2>
<ul>
<li>Bugs
<ul>
<li><a href="https://gitlab.gentoo.org/dotnet/gentoo-dotnet-2023/-/issues/1">gentoo-dotnet–2023/1</a></li>
<li><a href="https://bugs.gentoo.org/900597">900597</a></li></ul></li>
<li>Github PRs
<ul>
<li><a href="https://github.com/gentoo/gentoo/pull/21112/">21112</a></li>
<li><a href="https://github.com/gentoo/gentoo/pull/21451/">21451</a></li>
<li><a href="https://github.com/gentoo/gentoo/pull/29309/">29309</a></li>
<li><a href="https://github.com/gentoo/gentoo/pull/32109/">32109</a></li>
<li><a href="https://github.com/gentoo/gentoo/pull/33940/">33940</a></li></ul></li>
<li>Active Gentoo .NET projects
<ul>
<li><a href="https://gitlab.gentoo.org/dotnet/gentoo-dotnet-guide/">gentoo-dotnet-guide</a></li>
<li><a href="https://gitlab.gentoo.org/dotnet/gentoo-dotnet-maintainer-tools/">gentoo-dotnet-maintainer-tools</a></li>
<li><a href="https://gitlab.gentoo.org/dotnet/csharp-gentoodotnetinfo/">csharp-gentoodotnetinfo</a></li>
<li><a href="https://gitlab.gentoo.org/dotnet/eselect-dotnet/">eselect-dotnet</a></li>
<li><a href="https://gitlab.gentoo.org/dotnet/eselect-pwsh/">eselect-pwsh</a></li></ul></li></ul>Portage Continuous Deliveryurn:https-xgqt-gitlab-io:-blog-posts-2023-12-17-portage-continuous-delivery2023-12-17T00:50:15Z2023-12-17T00:50:15ZMaciej Barć
<h2 id="portage-as-a-cd-system">Portage as a CD system</h2>
<p>This is a very simple way to use any system with Portage installed as a Continuous Delivery server.</p>
<p>I think for a testing environment this is a valid solution to consider.</p>
<h3 id="create-a-repository-of-software-used-in-your-organization">Create a repository of software used in your organization</h3>
<p>Those articles from the Gentoo Wiki describe how to create a custom ebuild repository (overlay) pretty well:</p>
<ul>
<li><a href="https://wiki.gentoo.org/wiki/Ebuild_repository">Ebuild repository</a></li>
<li><a href="https://wiki.gentoo.org/wiki/Creating_an_ebuild_repository">Creating an ebuild repository</a></li></ul>
<h3 id="set-up-your-repo-with-eselect-repository">Set up your repo with eselect-repository</h3>
<p>Install the <code>my-org</code> repository:</p>
<div class="brush: shell">
<div class="source">
<table class="sourcetable">
<tbody>
<tr>
<td class="linenos">
<div class="linenodiv">
<pre><span class="normal">1</span></pre></div></td>
<td class="code">
<div>
<pre><span></span>eselect<span class="w"> </span>repository<span class="w"> </span>add<span class="w"> </span>my-org<span class="w"> </span>git<span class="w"> </span>https://git.my-org.local/portage/my-org.git
</pre></div></td></tr></tbody></table></div>
</div>
<p>Sync <code>my-org</code>:</p>
<div class="brush: shell">
<div class="source">
<table class="sourcetable">
<tbody>
<tr>
<td class="linenos">
<div class="linenodiv">
<pre><span class="normal">1</span></pre></div></td>
<td class="code">
<div>
<pre><span></span>emerge<span class="w"> </span>--sync<span class="w"> </span>my-org
</pre></div></td></tr></tbody></table></div>
</div>
<h3 id="install-live-packages-of-a-your-software">Install live packages of a your software</h3>
<p>First, enable live packages (keywordless) for your <code>my-org</code> repo:</p>
<div class="brush: shell">
<div class="source">
<table class="sourcetable">
<tbody>
<tr>
<td class="linenos">
<div class="linenodiv">
<pre><span class="normal">1</span></pre></div></td>
<td class="code">
<div>
<pre><span></span><span class="nb">echo</span><span class="w"> </span><span class="s1">'*/*::my-org'</span><span class="w"> </span>>><span class="w"> </span>/etc/portage/package.accept_keywords/0000_repo_my-org.conf
</pre></div></td></tr></tbody></table></div>
</div>
<p>Install some packages from <code>my-org</code>:</p>
<div class="brush: shell">
<div class="source">
<table class="sourcetable">
<tbody>
<tr>
<td class="linenos">
<div class="linenodiv">
<pre><span class="normal">1</span></pre></div></td>
<td class="code">
<div>
<pre><span></span>emerge<span class="w"> </span>-av<span class="w"> </span><span class="s2">"=mycategory/mysoftware-9999"</span>
</pre></div></td></tr></tbody></table></div>
</div>
<h3 id="install-smart-live-rebuild">Install smart-live-rebuild</h3>
<p><code>smart-live-rebuild</code> can automatically update live software packages that use git as their source URL.</p>
<h3 id="set-up-cron-to-run-smart-live-rebuild">Set up cron to run smart-live-rebuild</h3>
<p>Refresh your <code>my-org</code> repository every hour:</p>
<div class="brush: cron">
<div class="source">
<table class="sourcetable">
<tbody>
<tr>
<td class="linenos">
<div class="linenodiv">
<pre><span class="normal">1</span></pre></div></td>
<td class="code">
<div>
<pre><span></span>0 */1 * * * emerge --sync my-org
</pre></div></td></tr></tbody></table></div>
</div>
<p>Refresh the main Gentoo tree every other 6th hour:</p>
<div class="brush: cron">
<div class="source">
<table class="sourcetable">
<tbody>
<tr>
<td class="linenos">
<div class="linenodiv">
<pre><span class="normal">1</span></pre></div></td>
<td class="code">
<div>
<pre><span></span>0 */6 * * * emerge --sync gentoo
</pre></div></td></tr></tbody></table></div>
</div>
<p>Run <code>smart-live-rebuild</code> every other 3rd hour:</p>
<div class="brush: cron">
<div class="source">
<table class="sourcetable">
<tbody>
<tr>
<td class="linenos">
<div class="linenodiv">
<pre><span class="normal">1</span></pre></div></td>
<td class="code">
<div>
<pre><span></span>0 */3 * * * smart-live-rebuild
</pre></div></td></tr></tbody></table></div>
</div>
<h2 id="restarting-services-after-update">Restarting services after update</h2>
<h3 id="all-in-one-script">All-in-one script</h3>
<p>You can either restart all services after successful update:</p>
<p>File: <code>/opt/update.sh</code></p>
<div class="brush: shell">
<div class="source">
<table class="sourcetable">
<tbody>
<tr>
<td class="linenos">
<div class="linenodiv">
<pre><span class="normal">1</span>
<span class="normal">2</span>
<span class="normal">3</span>
<span class="normal">4</span>
<span class="normal">5</span>
<span class="normal">6</span>
<span class="normal">7</span>
<span class="normal">8</span></pre></div></td>
<td class="code">
<div>
<pre><span></span><span class="ch">#!/bin/sh</span>
<span class="nb">set</span><span class="w"> </span>-e
smart-live-rebuild
systemctl<span class="w"> </span>restart<span class="w"> </span>my-service-1.service
systemctl<span class="w"> </span>restart<span class="w"> </span>my-service-2.service
</pre></div></td></tr></tbody></table></div>
</div>
<p>Crontab:</p>
<div class="brush: cron">
<div class="source">
<table class="sourcetable">
<tbody>
<tr>
<td class="linenos">
<div class="linenodiv">
<pre><span class="normal">1</span></pre></div></td>
<td class="code">
<div>
<pre><span></span>0 */3 * * * /opt/update.sh
</pre></div></td></tr></tbody></table></div>
</div>
<h3 id="via-ebuilds-pkg-functions">Via ebuilds pkg_ functions</h3>
<p>File: <code>my-service-1.ebuild</code></p>
<div class="brush: shell">
<div class="source">
<table class="sourcetable">
<tbody>
<tr>
<td class="linenos">
<div class="linenodiv">
<pre><span class="normal">1</span>
<span class="normal">2</span>
<span class="normal">3</span></pre></div></td>
<td class="code">
<div>
<pre><span></span>pkg_postinst<span class="o">()</span><span class="w"> </span><span class="o">{</span>
<span class="w"> </span>systemctl<span class="w"> </span>restart<span class="w"> </span>my-service-1.service
<span class="o">}</span>
</pre></div></td></tr></tbody></table></div>
</div>
<p>More about <code>pkg_postinst</code>:</p>
<ul>
<li><a href="https://devmanual.gentoo.org/ebuild-writing/functions/pkg_postinst/">pkg_postinst</a></li>
<li><a href="https://devmanual.gentoo.org/ebuild-writing/functions/index.html">Phase Functions</a></li></ul>
<h2 id="example-gentoo-overlays">Example Gentoo overlays</h2>
<ul>
<li><a href="https://gitlab.com/xgqt/myov/">xgqt/myov</a></li>
<li><a href="https://gitlab.com/gentoo-racket/gentoo-racket-overlay/">gentoo-racket/gentoo-racket-overlay</a></li>
<li><a href="https://github.com/gentoo-mirror/guru/">gentoo-mirror/guru</a></li></ul>Genkernel in 2023urn:https-xgqt-gitlab-io:-blog-posts-2023-07-29-genkernel-in-20232023-07-29T17:10:35Z2023-07-29T17:10:35ZMaciej Barć
<p>I really wanted to look into the new kernel building solutions for Gentoo and maybe migrate to dracut, but last time I tried, ~1.5 years ago, the initreamfs was now working for me.</p>
<p>And now in 2023 I’m still running genkernel for my personal boxes as well as other servers running Gentoo.</p>
<p>I guess some short term solutions really become defined tools :P</p>
<p>So this is how I rebuild my kernel nowadays:</p>
<ol>
<li>
<p>Copy old config</p>
<div class="brush: shell">
<div class="source">
<table class="sourcetable">
<tbody>
<tr>
<td class="linenos">
<div class="linenodiv">
<pre><span class="normal">1</span>
<span class="normal">2</span></pre></div></td>
<td class="code">
<div>
<pre><span></span><span class="nb">cd</span><span class="w"> </span>/usr/src
cp<span class="w"> </span>linux-6.1.38-gentoo/.config<span class="w"> </span>linux-6.1.41-gentoo/
</pre></div></td></tr></tbody></table></div>
</div></li>
<li>
<p>Remove old kernel build directories</p>
<div class="brush: shell">
<div class="source">
<table class="sourcetable">
<tbody>
<tr>
<td class="linenos">
<div class="linenodiv">
<pre><span class="normal">1</span></pre></div></td>
<td class="code">
<div>
<pre><span></span>rm<span class="w"> </span>-r<span class="w"> </span>linux-6.1.31-gentoo
</pre></div></td></tr></tbody></table></div>
</div></li>
<li>
<p>Run initial preparation</p>
<div class="brush: shell">
<div class="source">
<table class="sourcetable">
<tbody>
<tr>
<td class="linenos">
<div class="linenodiv">
<pre><span class="normal">1</span></pre></div></td>
<td class="code">
<div>
<pre><span></span><span class="o">(</span><span class="w"> </span>eselect<span class="w"> </span>kernel<span class="w"> </span><span class="nb">set</span><span class="w"> </span><span class="m">1</span><span class="w"> </span><span class="o">&&</span><span class="w"> </span><span class="nb">cd</span><span class="w"> </span>/usr/src/linux<span class="w"> </span><span class="o">&&</span><span class="w"> </span>make<span class="w"> </span>olddefconfig<span class="w"> </span><span class="o">)</span>
</pre></div></td></tr></tbody></table></div>
</div></li>
<li>
<p>Call genkernel</p>
<div class="brush: shell">
<div class="source">
<table class="sourcetable">
<tbody>
<tr>
<td class="linenos">
<div class="linenodiv">
<pre><span class="normal"> 1</span>
<span class="normal"> 2</span>
<span class="normal"> 3</span>
<span class="normal"> 4</span>
<span class="normal"> 5</span>
<span class="normal"> 6</span>
<span class="normal"> 7</span>
<span class="normal"> 8</span>
<span class="normal"> 9</span>
<span class="normal">10</span>
<span class="normal">11</span>
<span class="normal">12</span></pre></div></td>
<td class="code">
<div>
<pre><span></span>genkernel<span class="w"> </span><span class="se">\</span>
<span class="w"> </span>--no-menuconfig<span class="w"> </span><span class="se">\</span>
<span class="w"> </span>--no-clean<span class="w"> </span><span class="se">\</span>
<span class="w"> </span>--no-clear-cachedir<span class="w"> </span><span class="se">\</span>
<span class="w"> </span>--no-cleanup<span class="w"> </span><span class="se">\</span>
<span class="w"> </span>--no-mrproper<span class="w"> </span><span class="se">\</span>
<span class="w"> </span>--lvm<span class="w"> </span><span class="se">\</span>
<span class="w"> </span>--luks<span class="w"> </span><span class="se">\</span>
<span class="w"> </span>--mdadm<span class="w"> </span><span class="se">\</span>
<span class="w"> </span>--nfs<span class="w"> </span><span class="se">\</span>
<span class="w"> </span>--kernel-localversion<span class="o">=</span><span class="s2">"-</span><span class="k">$(</span>hostname<span class="k">)</span><span class="s2">-</span><span class="k">$(</span>date<span class="w"> </span><span class="s1">'+%Y.%m.%d'</span><span class="k">)</span><span class="s2">"</span><span class="w"> </span><span class="se">\</span>
<span class="w"> </span>all
</pre></div></td></tr></tbody></table></div>
</div></li>
<li>
<p>Rebuild the modules</p>
<p>If in your <code>/etc/genkernel.conf</code> you have <code>MODULEREBUILD</code> turned off, then also call emerge:</p>
<div class="brush: shell">
<div class="source">
<table class="sourcetable">
<tbody>
<tr>
<td class="linenos">
<div class="linenodiv">
<pre><span class="normal">1</span></pre></div></td>
<td class="code">
<div>
<pre><span></span>emerge<span class="w"> </span>-1<span class="w"> </span>@module-rebuild
</pre></div></td></tr></tbody></table></div>
</div></li></ol>ELisp ebuilds good practicesurn:https-xgqt-gitlab-io:-blog-posts-2023-07-15-elisp-ebuilds-good-practices2023-07-15T19:25:25Z2023-07-15T19:25:25ZMaciej Barć
<h1 id="check-load-path">Check load path</h1>
<p>Some Elisp package compilation failures are caused by not setting the loadpath correctly. It mostly happens when you compile source from a directory that is not the current working directory. For example:</p>
<div class="brush: bash">
<div class="source">
<table class="sourcetable">
<tbody>
<tr>
<td class="linenos">
<div class="linenodiv">
<pre><span class="normal">1</span></pre></div></td>
<td class="code">
<div>
<pre><span></span>elisp-compile<span class="w"> </span>elisp/*.el
</pre></div></td></tr></tbody></table></div>
</div>
<p>In most cases you can <code>cd</code> or override the <code>S</code> variable to set it to location where ELisp source resides.</p>
<p>But in other cases you can append to load path the directory with source, see:</p>
<div class="brush: bash">
<div class="source">
<table class="sourcetable">
<tbody>
<tr>
<td class="linenos">
<div class="linenodiv">
<pre><span class="normal">1</span></pre></div></td>
<td class="code">
<div>
<pre><span></span><span class="nv">BYTECOMPFLAGS</span><span class="o">=</span><span class="s2">"</span><span class="si">${</span><span class="nv">BYTECOMPFLAGS</span><span class="si">}</span><span class="s2"> -L elisp"</span><span class="w"> </span>elisp-compile<span class="w"> </span>elisp/*.el
</pre></div></td></tr></tbody></table></div>
</div>
<h1 id="do-not-rename-auto-generated-autoload-file">Do not rename auto-generated autoload file</h1>
<p><code>elisp-make-autoload-file</code> allows to name the generated autoload file. For sake of easier debugging and writing Gentoo <code>SITEFILE</code>s, please do not rename the generated file.</p>
<p>The name of that file should always be <code>${PN}-autoloads.el</code>.</p>
<h1 id="use-new-elisp-enable-tests-function">Use new elisp-enable-tests function</h1>
<p><code>elisp-enable-tests</code> allows to set up <code>IUSE</code>, <code>RESTRICT</code>, <code>BDEPEND</code> and the test runner function for running tests with the specified test runner.</p>
<p>The 1st (<code>test-runner</code>) argument must be one of:</p>
<ul>
<li><code>buttercup</code> — for <code>buttercup</code> provided via <code>app-emacs/buttercup</code>,</li>
<li><code>ert-runner</code> — for <code>ert-runner</code> provided via <code>app-emacs/ert-runner</code>,</li>
<li><code>ert</code> — for ERT, the built-in GNU Emacs test utility.</li></ul>
<p>The 2nd argument is the directory where test are located, the leftover arguments are passed to the selected test runner.</p>
<p>Example:</p>
<div class="brush: bash">
<div class="source">
<table class="sourcetable">
<tbody>
<tr>
<td class="linenos">
<div class="linenodiv">
<pre><span class="normal"> 1</span>
<span class="normal"> 2</span>
<span class="normal"> 3</span>
<span class="normal"> 4</span>
<span class="normal"> 5</span>
<span class="normal"> 6</span>
<span class="normal"> 7</span>
<span class="normal"> 8</span>
<span class="normal"> 9</span>
<span class="normal">10</span></pre></div></td>
<td class="code">
<div>
<pre><span></span><span class="nv">EAPI</span><span class="o">=</span><span class="m">8</span>
inherit<span class="w"> </span>elisp
<span class="c1"># Other package settings ...</span>
<span class="nv">SITEFILE</span><span class="o">=</span><span class="s2">"50</span><span class="si">${</span><span class="nv">PN</span><span class="si">}</span><span class="s2">-gentoo.el"</span>
<span class="nv">DOCS</span><span class="o">=(</span><span class="w"> </span>README.md<span class="w"> </span><span class="o">)</span>
elisp-enable-tests<span class="w"> </span>buttercup<span class="w"> </span><span class="nb">test</span>
</pre></div></td></tr></tbody></table></div>
</div>
<h1 id="remove-empty-sitefiles">Remove empty SITEFILEs</h1>
<p>Recently a feature was added to <code>elisp.eclass</code> that will cause build process to generate the required <code>SITEFILE</code> with boilerplate code if it does not exist.</p>
<p>So if your <code>SITEFILE</code> looked like this:</p>
<div class="brush: lisp">
<div class="source">
<table class="sourcetable">
<tbody>
<tr>
<td class="linenos">
<div class="linenodiv">
<pre><span class="normal">1</span></pre></div></td>
<td class="code">
<div>
<pre><span></span><span class="p">(</span><span class="nv">add-to-list</span><span class="w"> </span><span class="ss">'load-path</span><span class="w"> </span><span class="s">"@SITELISP@"</span><span class="p">)</span>
</pre></div></td></tr></tbody></table></div>
</div>
<p>… then, you can just remove that file.</p>
<p>But remember to keep the <code>SITEFILE</code> variable inside your ebuild:</p>
<div class="brush: bash">
<div class="source">
<table class="sourcetable">
<tbody>
<tr>
<td class="linenos">
<div class="linenodiv">
<pre><span class="normal">1</span></pre></div></td>
<td class="code">
<div>
<pre><span></span><span class="nv">SITEFILE</span><span class="o">=</span><span class="s2">"50</span><span class="si">${</span><span class="nv">PN</span><span class="si">}</span><span class="s2">-gentoo.el"</span>
</pre></div></td></tr></tbody></table></div>
</div>
<h1 id="remove-pkgel-files">Remove pkg.el files</h1>
<p>The <code>*-pkg.el</code> files are useless to Gentoo distribution model of Emacs Lisp packages and should be removed. It is as simple as adding this line to a ebuild:</p>
<div class="brush: bash">
<div class="source">
<table class="sourcetable">
<tbody>
<tr>
<td class="linenos">
<div class="linenodiv">
<pre><span class="normal">1</span></pre></div></td>
<td class="code">
<div>
<pre><span></span><span class="nv">ELISP_REMOVE</span><span class="o">=</span><span class="s2">"</span><span class="si">${</span><span class="nv">PN</span><span class="si">}</span><span class="s2">-pkg.el"</span>
</pre></div></td></tr></tbody></table></div>
</div>
<p>Beware that some packages will try to find their <code>${PN}-pkg.el</code> file, but in most cases this will show up in failing package tests.</p>
<h1 id="use-official-repository">Use official repository</h1>
<p>It is tedious to repackage Elpa tarballs, so use the official upstream even if you have to snapshot a specific commit.</p>
<p>To snapshot GitHub repos you would generally use this code:</p>
<div class="brush: bash">
<div class="source">
<table class="sourcetable">
<tbody>
<tr>
<td class="linenos">
<div class="linenodiv">
<pre><span class="normal"> 1</span>
<span class="normal"> 2</span>
<span class="normal"> 3</span>
<span class="normal"> 4</span>
<span class="normal"> 5</span>
<span class="normal"> 6</span>
<span class="normal"> 7</span>
<span class="normal"> 8</span>
<span class="normal"> 9</span>
<span class="normal">10</span></pre></div></td>
<td class="code">
<div>
<pre><span></span><span class="c1"># First check if we have the correct version to prevent</span>
<span class="c1"># autobumping package version without changing the commit.</span>
<span class="o">[[</span><span class="w"> </span><span class="si">${</span><span class="nv">PV</span><span class="si">}</span><span class="w"> </span><span class="o">==</span><span class="w"> </span>*_p20220325<span class="w"> </span><span class="o">]]</span><span class="w"> </span><span class="o">&&</span><span class="w"> </span><span class="nv">COMMIT</span><span class="o">=</span>65c496d3d1d1298345beb9845840067bffb2ffd8
<span class="c1"># Use correct URL that supports snapshots.</span>
<span class="nv">SRC_URI</span><span class="o">=</span><span class="s2">"https://github.com/domtronn/</span><span class="si">${</span><span class="nv">PN</span><span class="si">}</span><span class="s2">/archive/</span><span class="si">${</span><span class="nv">COMMIT</span><span class="si">}</span><span class="s2">.tar.gz</span>
<span class="s2"> -> </span><span class="si">${</span><span class="nv">P</span><span class="si">}</span><span class="s2">.tar.gz"</span>
<span class="c1"># Override the temporary build directory variable.</span>
<span class="nv">S</span><span class="o">=</span><span class="s2">"</span><span class="si">${</span><span class="nv">WORKDIR</span><span class="si">}</span><span class="s2">"</span>/<span class="si">${</span><span class="nv">PN</span><span class="si">}</span>-<span class="si">${</span><span class="nv">COMMIT</span><span class="si">}</span>
</pre></div></td></tr></tbody></table></div>
</div>
<h1 id="include-live-version-support">Include live version support</h1>
<p>We do not want to be worse than the <a href="https://melpa.org/">Melpa unstable</a> :D</p>
<p>So, why not allow the given package to be used live?</p>
<p>Even if you do not push the live package to the overlay, please include support for it.</p>
<div class="brush: bash">
<div class="source">
<table class="sourcetable">
<tbody>
<tr>
<td class="linenos">
<div class="linenodiv">
<pre><span class="normal">1</span>
<span class="normal">2</span>
<span class="normal">3</span>
<span class="normal">4</span>
<span class="normal">5</span>
<span class="normal">6</span>
<span class="normal">7</span>
<span class="normal">8</span></pre></div></td>
<td class="code">
<div>
<pre><span></span><span class="k">if</span><span class="w"> </span><span class="o">[[</span><span class="w"> </span><span class="si">${</span><span class="nv">PV</span><span class="si">}</span><span class="w"> </span><span class="o">==</span><span class="w"> </span>*9999*<span class="w"> </span><span class="o">]]</span><span class="w"> </span><span class="p">;</span><span class="w"> </span><span class="k">then</span>
<span class="w"> </span>inherit<span class="w"> </span>git-r3
<span class="w"> </span><span class="nv">EGIT_REPO_URI</span><span class="o">=</span><span class="s2">"https://github.com/example/</span><span class="si">${</span><span class="nv">PN</span><span class="si">}</span><span class="s2">.git"</span>
<span class="k">else</span>
<span class="w"> </span><span class="nv">SRC_URI</span><span class="o">=</span><span class="s2">"https://github.com/example/</span><span class="si">${</span><span class="nv">PN</span><span class="si">}</span><span class="s2">/archive/</span><span class="si">${</span><span class="nv">PV</span><span class="si">}</span><span class="s2">.tar.gz</span>
<span class="s2"> -> </span><span class="si">${</span><span class="nv">P</span><span class="si">}</span><span class="s2">.tar.gz"</span>
<span class="w"> </span><span class="nv">KEYWORDS</span><span class="o">=</span><span class="s2">"~amd64 ~x86"</span>
<span class="k">fi</span>
</pre></div></td></tr></tbody></table></div>
</div>
<h1 id="ask-for-tags">Ask for tags</h1>
<p>Git is good, git tags are good. In case if upstream does not tag their package or just forgets to, kindly ask them to create a git tag when bumping Emacs package versions.</p>Bubblewrap cross-architecture chrooturn:https-xgqt-gitlab-io:-blog-posts-2023-04-28-bubblewrap-cross-architecture-chroot2023-04-28T17:06:33Z2023-04-28T17:06:33ZMaciej Barć
<h1 id="system-preparation">System preparation</h1>
<h2 id="qemu">Qemu</h2>
<p>Emerge <code>qemu</code> with <code>static-user</code> USE enabled and your wanted architectures.</p>
<div class="brush: conf">
<div class="source">
<table class="sourcetable">
<tbody>
<tr>
<td class="linenos">
<div class="linenodiv">
<pre><span class="normal">1</span>
<span class="normal">2</span>
<span class="normal">3</span>
<span class="normal">4</span>
<span class="normal">5</span>
<span class="normal">6</span>
<span class="normal">7</span>
<span class="normal">8</span></pre></div></td>
<td class="code">
<div>
<pre><span></span>app-emulation/qemu QEMU_SOFTMMU_TARGETS: aarch64 arm x86_64
app-emulation/qemu QEMU_USER_TARGETS: aarch64 arm x86_64
app-emulation/qemu static-user
dev-libs/glib static-libs
sys-apps/attr static-libs
sys-libs/zlib static-libs
dev-libs/libpcre2 static-libs
</pre></div></td></tr></tbody></table></div>
</div>
<h2 id="openrc">OpenRC</h2>
<p>Enable <code>qemu-binfmt</code>:</p>
<div class="brush: shell">
<div class="source">
<table class="sourcetable">
<tbody>
<tr>
<td class="linenos">
<div class="linenodiv">
<pre><span class="normal">1</span></pre></div></td>
<td class="code">
<div>
<pre><span></span>rc-update<span class="w"> </span>add<span class="w"> </span>qemu-binfmt<span class="w"> </span>default
</pre></div></td></tr></tbody></table></div>
</div>
<p>Start <code>qemu-binfmt</code>:</p>
<div class="brush: shell">
<div class="source">
<table class="sourcetable">
<tbody>
<tr>
<td class="linenos">
<div class="linenodiv">
<pre><span class="normal">1</span></pre></div></td>
<td class="code">
<div>
<pre><span></span>rc-service<span class="w"> </span>qemu-binfmt<span class="w"> </span>start
</pre></div></td></tr></tbody></table></div>
</div>
<h1 id="chrooting">Chrooting</h1>
<ul>
<li>select chroot location (eg <code>/chroots/gentoo-arm64-musl-stable</code>)</li>
<li>unpack the desired rootfs</li>
<li>create needed directories
<ul>
<li><code>mkdir -p /chroots/gentoo-arm64-musl-stable/var/cache/distfiles</code></li></ul></li>
<li>execute <code>bwrap</code>
<ul>
<li>with last <code>ro-bind</code> mount the qemu emulator binary (eg <code>qemu-aarch64</code>)</li>
<li>execute the mounted emulator binary giving it a shell program (eg <code>bash</code>)</li></ul></li></ul>
<p>Chroot with <code>bwrap</code>:</p>
<div class="brush: shell">
<div class="source">
<table class="sourcetable">
<tbody>
<tr>
<td class="linenos">
<div class="linenodiv">
<pre><span class="normal"> 1</span>
<span class="normal"> 2</span>
<span class="normal"> 3</span>
<span class="normal"> 4</span>
<span class="normal"> 5</span>
<span class="normal"> 6</span>
<span class="normal"> 7</span>
<span class="normal"> 8</span>
<span class="normal"> 9</span>
<span class="normal">10</span></pre></div></td>
<td class="code">
<div>
<pre><span></span>bwrap<span class="w"> </span><span class="se">\</span>
<span class="w"> </span>--bind<span class="w"> </span>/chroots/gentoo-arm64-musl-stable<span class="w"> </span>/<span class="w"> </span><span class="se">\</span>
<span class="w"> </span>--dev<span class="w"> </span>/dev<span class="w"> </span><span class="se">\</span>
<span class="w"> </span>--proc<span class="w"> </span>/proc<span class="w"> </span><span class="se">\</span>
<span class="w"> </span>--perms<span class="w"> </span><span class="m">1777</span><span class="w"> </span>--tmpfs<span class="w"> </span>/dev/shm<span class="w"> </span><span class="se">\</span>
<span class="w"> </span>--tmpfs<span class="w"> </span>/run<span class="w"> </span><span class="se">\</span>
<span class="w"> </span>--ro-bind<span class="w"> </span>/etc/resolv.conf<span class="w"> </span>/etc/resolv.conf<span class="w"> </span><span class="se">\</span>
<span class="w"> </span>--bind<span class="w"> </span>/var/cache/distfiles<span class="w"> </span>/var/cache/distfiles<span class="w"> </span><span class="se">\</span>
<span class="w"> </span>--ro-bind<span class="w"> </span>/usr/bin/qemu-aarch64<span class="w"> </span>/usr/bin/qemu-aarch64<span class="w"> </span><span class="se">\</span>
<span class="w"> </span>/usr/bin/qemu-aarch64<span class="w"> </span>/bin/bash<span class="w"> </span>-l
</pre></div></td></tr></tbody></table></div>
</div>Installing PowerShell modules via Portageurn:https-xgqt-gitlab-io:-blog-posts-2023-04-07-installing-powershell-modules-via-portage2023-04-07T02:26:43Z2023-04-07T02:26:43ZMaciej Barć
<h1 id="building-powershell">Building PowerShell</h1>
<p>As a part of my work of modernizing the way .NET SDK packages are distributed in Gentoo I delved into packaging a from-source build of PowerShell for Gentoo using the <a href="https://gitlab.com/xgqt/gentoo-dotnet-2023/-/blob/master/eclass/dotnet-pkg.eclass">dotnet-pkg eclass</a>.</p>
<p>Packaging <code>pwsh</code> was a little tricky but I got a lot of help from reading the Alpine Linux’s <a href="https://git.alpinelinux.org/aports/tree/community/powershell/APKBUILD?id=26cea8a350cfadb92820b471d11e9d00d4e020a6">APKBUILD</a>. I had to generate special C# code bindings with <code>ResGen</code> and repackage the PowerShell tarball. Other than this trick, restoring and building PowerShell was pretty straight forward with the NuGet package management support from the <code>dotnet-pkg.eclass</code>.</p>
<p>Alternatively if you do not want to build PowerShell you can install the binary package, I have in plans to keep that package around even after we get the non-binary <a href="https://gitlab.com/xgqt/gentoo-dotnet-2023/-/tree/master/app-shells/pwsh">app-shells/pwsh</a> into the official Gentoo ebuild repository.</p>
<h1 id="why-install-modules-via-portage">Why install modules via Portage?</h1>
<p>But why stop on PowerShell when we can also package multiple PS modules?</p>
<p>Installing modules via Portage has many benefits:</p>
<ul>
<li>better version control,</li>
<li>more control over global install,</li>
<li>no need to enable PS Gallery,</li>
<li>sandboxed builds,</li>
<li>using system .NET runtime.</li></ul>
<h1 id="merging-the-modules">Merging the modules</h1>
<p>PowerShell’s method of finding modules is at follows: check paths from the <code>PSModulePath</code> environment variable for directories containing valid <code>.psd1</code> files which define the PS modules.</p>
<p>By default <code>pwsh</code> tries to find modules in paths:</p>
<ul>
<li>user’s modules directory — <code>~/.local/share/powershell/Modules</code></li>
<li>system modules directory in <code>/usr/local</code> — <code>/usr/local/share/powershell/Modules</code></li>
<li><code>Modules</code> directory inside the <code>pwsh</code> home — for example <code>/usr/share/pwsh-7.3/Modules</code></li></ul>
<p>Because we do not want to touch either <code>/usr/local</code> nor <code>pwsh</code> home, we embed a special environment variable inside the <code>pwsh</code> launcher script to extend the path where <code>pwsh</code> looks for PS modules. The new module directory is located at <code>/usr/share/GentooPowerShell/Modules</code>.</p>
<div class="brush: shell">
<div class="source">
<table class="sourcetable">
<tbody>
<tr>
<td class="linenos">
<div class="linenodiv">
<pre><span class="normal">1</span>
<span class="normal">2</span></pre></div></td>
<td class="code">
<div>
<pre><span></span>dotnet-pkg-utils_append_launchervar<span class="w"> </span><span class="se">\</span>
<span class="w"> </span><span class="s1">'PSModulePath="${PSModulePath}:/usr/share/GentooPowerShell/Modules:"'</span>
</pre></div></td></tr></tbody></table></div>
</div>
<p>So every PowerShell module will install it’s files inside <code>/usr/share/GentooPowerShell/Modules</code>.</p>
<p>To follow PS module location convention we add to that path a segment for the real module name and a segment for module version. This also enables us to have proper multi-slotting because most of the time the modules will not block installing other versions.</p>
<p>Take a look at this example from the <a href="https://gitlab.com/xgqt/gentoo-dotnet-2023/-/blob/cfcb425e097a3782d067d4abaca2ec06be3f4fde/app-pwsh/posh-dotnet/posh-dotnet-1.2.3.ebuild">app-pwsh/posh-dotnet–1.2.3</a> ebuild:</p>
<div class="brush: shell">
<div class="source">
<table class="sourcetable">
<tbody>
<tr>
<td class="linenos">
<div class="linenodiv">
<pre><span class="normal">1</span>
<span class="normal">2</span>
<span class="normal">3</span>
<span class="normal">4</span>
<span class="normal">5</span>
<span class="normal">6</span></pre></div></td>
<td class="code">
<div>
<pre><span></span>src_install<span class="o">()</span><span class="w"> </span><span class="o">{</span>
<span class="w"> </span>insinto<span class="w"> </span>/usr/share/GentooPowerShell/Modules/<span class="si">${</span><span class="nv">PN</span><span class="si">}</span>/<span class="si">${</span><span class="nv">PV</span><span class="si">}</span>
<span class="w"> </span>doins<span class="w"> </span><span class="si">${</span><span class="nv">PN</span><span class="si">}</span>.psd1<span class="w"> </span><span class="si">${</span><span class="nv">PN</span><span class="si">}</span>.psm1
<span class="w"> </span>einstalldocs
<span class="o">}</span>
</pre></div></td></tr></tbody></table></div>
</div>
<p>And that is it. Some packages do not even need to be compiled, they just need files placed into specific location. But when compilation of C# code is needed we have <code>dotnet-pkg</code> to help.</p>Binary packages in Gentoourn:https-xgqt-gitlab-io:-blog-posts-2023-03-23-binary-packages-in-gentoo2023-03-23T09:01:04Z2023-03-23T09:01:04ZMaciej Barć
<h1 id="binpkgs-generated-by-user">Binpkgs generated by user</h1>
<p>The binary packages generated by user can have architecture-specific optimizations because they are generated after they were compiled by the host Portage installation.</p>
<p>In addition binpkgs are generated from ebuilds so if there is a
<u>USE</u> flag incompatibility on the consumer system then the binpkg will not be installed on the host and Portage will fall back to
<u>from-source</u> compilation.</p>
<p>Those binary packages can use two formats: <a href="https://wiki.gentoo.org/wiki/Binary_package_guide#XPAK_format">XPAK</a> and <a href="https://www.gentoo.org/glep/glep-0078.html">GPKG</a>.</p>
<p>XPAK had many issues and is getting superseded by the GPKG format. Beware of upcoming GPKG transition and if you <strong>must</strong> use XPAKs then you should explicitly enable it in your system’s Portage configuration.</p>
<p>To host a binary package distribution server see the <a href="https://wiki.gentoo.org/wiki/Binary_package_guide">Binary package guide</a> on the Gentoo wiki.</p>
<h1 id="bin-packages-in-a-repository">Bin packages in a repository</h1>
<p>Binary packages in <code>::gentoo</code> (the official Gentoo repository) have the
<u>-bin</u> suffix.</p>
<p>Those packages might have USE flags but generally they are very limited in case of customizations or code optimizations because they were compiled either by a Gentoo developer or by a given package
<u>upstream</u> maintainer (or their CI/CD system).</p>
<p>Those packages land in <code>::gentoo</code> mostly because it is too hard (or even impossible) to compile them natively by Portage. Most of the time those packages use very complicated build systems or do not play nice with network sandbox like (e.g. Scala-based projects) or use very large frameworks/libraries like (e.g.
<u>Electron</u>).</p>
<p>They can also be added to the repository because they are very
<u>desirable</u> either by normal users (e.g. <a href="https://packages.gentoo.org/packages/www-client/firefox-bin">www-client/firefox-bin</a>) or for (from-source) package
<u>bootstrapping</u> purposes (e.g. <a href="https://packages.gentoo.org/packages/dev-java/openjdk-bin">dev-java/openjdk-bin</a>). Such packages are sometimes generated from the regular source packages inside <code>::gentoo</code> and later repackaged.</p>Ebuild lit testsurn:https-xgqt-gitlab-io:-blog-posts-2023-02-24-ebuild-lit-tests2023-02-24T00:00:00Z2023-02-24T00:00:00ZMaciej Barć
<h1 id="patching">Patching</h1>
<p>The file <code>lit.site.cfg</code> has to be inspected for any incorrect calls to executables. For example see <code>src_prepare</code> function form <a href="https://gitweb.gentoo.org/repo/gentoo.git/tree/dev-lang/boogie">dev-lang/boogie</a>.</p>
<h1 id="eclasses">Eclasses</h1>
<p>Because we will need to specify how many threads should <code>lit</code> run we need to inherit <code>multiprocessing</code> to detect how many parallel jobs the portage config sets.</p>
<div class="brush: shell">
<div class="source">
<table class="sourcetable">
<tbody>
<tr>
<td class="linenos">
<div class="linenodiv">
<pre><span class="normal">1</span></pre></div></td>
<td class="code">
<div>
<pre><span></span>inherit<span class="w"> </span>multiprocessing
</pre></div></td></tr></tbody></table></div>
</div>
<h1 id="dependencies">Dependencies</h1>
<p>Ensure that <code>dev-python/lit</code> is in <code>BDEPEND</code>, but also additional packages may be needed, for example <code>dev-python/OutputCheck</code>.</p>
<div class="brush: shell">
<div class="source">
<table class="sourcetable">
<tbody>
<tr>
<td class="linenos">
<div class="linenodiv">
<pre><span class="normal">1</span>
<span class="normal">2</span>
<span class="normal">3</span>
<span class="normal">4</span>
<span class="normal">5</span>
<span class="normal">6</span>
<span class="normal">7</span></pre></div></td>
<td class="code">
<div>
<pre><span></span><span class="nv">BDEPEND</span><span class="o">=</span><span class="s2">"</span>
<span class="s2"> </span><span class="si">${</span><span class="nv">RDEPEND</span><span class="si">}</span>
<span class="s2"> test? (</span>
<span class="s2"> dev-python/lit</span>
<span class="s2"> dev-python/OutputCheck</span>
<span class="s2"> )</span>
<span class="s2">"</span>
</pre></div></td></tr></tbody></table></div>
</div>
<h1 id="bad-tests">Bad tests</h1>
<p>To deal with bad test you can simply remove the files causing the failures.</p>
<div class="brush: shell">
<div class="source">
<table class="sourcetable">
<tbody>
<tr>
<td class="linenos">
<div class="linenodiv">
<pre><span class="normal">1</span>
<span class="normal">2</span>
<span class="normal">3</span>
<span class="normal">4</span>
<span class="normal">5</span>
<span class="normal">6</span>
<span class="normal">7</span>
<span class="normal">8</span>
<span class="normal">9</span></pre></div></td>
<td class="code">
<div>
<pre><span></span><span class="nb">local</span><span class="w"> </span>-a<span class="w"> </span><span class="nv">bad_tests</span><span class="o">=(</span>
<span class="w"> </span>civl/inductive-sequentialization/BroadcastConsensus.bpl
<span class="w"> </span>civl/inductive-sequentialization/PingPong.bpl
<span class="w"> </span>livevars/bla1.bpl
<span class="o">)</span>
<span class="nb">local</span><span class="w"> </span>bad_test
<span class="k">for</span><span class="w"> </span>bad_test<span class="w"> </span><span class="k">in</span><span class="w"> </span><span class="si">${</span><span class="nv">bad_tests</span><span class="p">[@]</span><span class="si">}</span><span class="w"> </span><span class="p">;</span><span class="w"> </span><span class="k">do</span>
<span class="w"> </span>rm<span class="w"> </span><span class="s2">"</span><span class="si">${</span><span class="nv">S</span><span class="si">}</span><span class="s2">"</span>/Test/<span class="si">${</span><span class="nv">bad_test</span><span class="si">}</span><span class="w"> </span><span class="o">||</span><span class="w"> </span>die
<span class="k">done</span>
</pre></div></td></tr></tbody></table></div>
</div>
<h1 id="test-phase">Test phase</h1>
<p><code>--threads $(makeopts_jobs)</code> specifies how many parallel tests to run.</p>
<p><code>--verbose</code> option will show output of failed tests.</p>
<p>Last <code>lit</code> argument specifies where <code>lit</code> should look for <code>lit.site.cfg</code> and tests.</p>
<div class="brush: shell">
<div class="source">
<table class="sourcetable">
<tbody>
<tr>
<td class="linenos">
<div class="linenodiv">
<pre><span class="normal">1</span>
<span class="normal">2</span>
<span class="normal">3</span></pre></div></td>
<td class="code">
<div>
<pre><span></span>src_test<span class="o">()</span><span class="w"> </span><span class="o">{</span>
<span class="w"> </span>lit<span class="w"> </span>--threads<span class="w"> </span><span class="k">$(</span>makeopts_jobs<span class="k">)</span><span class="w"> </span>--verbose<span class="w"> </span><span class="s2">"</span><span class="si">${</span><span class="nv">S</span><span class="si">}</span><span class="s2">"</span>/Test<span class="w"> </span><span class="o">||</span><span class="w"> </span>die
<span class="o">}</span>
</pre></div></td></tr></tbody></table></div>
</div>Ebuild-modeurn:https-xgqt-gitlab-io:-blog-posts-2022-12-30-ebuild-mode2022-12-30T00:00:00Z2022-12-30T00:00:00ZMaciej Barć
<h1 id="portage">Portage</h1>
<p>Configure the following for Portage.</p>
<div class="brush: conf">
<div class="source">
<table class="sourcetable">
<tbody>
<tr>
<td class="linenos">
<div class="linenodiv">
<pre><span class="normal">1</span></pre></div></td>
<td class="code">
<div>
<pre><span></span>dev-util/pkgcheck emacs
</pre></div></td></tr></tbody></table></div>
</div>
<h2 id="emerge">Emerge</h2>
<p>Emerge the following packages:</p>
<ul>
<li><code>app-emacs/company-ebuild</code></li>
<li><code>dev-util/pkgcheck</code></li></ul>
<p>Company-Ebuild should pull in <code>app-emacs/ebuild-mode</code>, if that does not happen, then report a bug ;-D</p>
<h1 id="standard">Standard</h1>
<p>Add the following to your user's Emacs initialization file. The initialization file is either <code>~/.emacs.d/init.el</code> or <code>~/.config/emacs/init.el</code> for newer versions of GNU Emacs.</p>
<div class="brush: elisp">
<div class="source">
<table class="sourcetable">
<tbody>
<tr>
<td class="linenos">
<div class="linenodiv">
<pre><span class="normal">1</span>
<span class="normal">2</span>
<span class="normal">3</span>
<span class="normal">4</span>
<span class="normal">5</span>
<span class="normal">6</span>
<span class="normal">7</span>
<span class="normal">8</span></pre></div></td>
<td class="code">
<div>
<pre><span></span><span class="p">(</span><span class="nb">require</span><span class="w"> </span><span class="ss">'ebuild-mode</span><span class="p">)</span>
<span class="p">(</span><span class="nb">require</span><span class="w"> </span><span class="ss">'company-ebuild</span><span class="p">)</span>
<span class="p">(</span><span class="nb">require</span><span class="w"> </span><span class="ss">'flycheck</span><span class="p">)</span>
<span class="p">(</span><span class="nb">require</span><span class="w"> </span><span class="ss">'flycheck-pkgcheck</span><span class="p">)</span>
<span class="p">(</span><span class="nv">add-hook</span><span class="w"> </span><span class="ss">'ebuild-mode-hook</span><span class="w"> </span><span class="ss">'company-ebuild-setup</span><span class="p">)</span>
<span class="p">(</span><span class="nv">add-hook</span><span class="w"> </span><span class="ss">'ebuild-mode-hook</span><span class="w"> </span><span class="ss">'flycheck-mode</span><span class="p">)</span>
<span class="p">(</span><span class="nv">add-hook</span><span class="w"> </span><span class="ss">'ebuild-mode-hook</span><span class="w"> </span><span class="ss">'flycheck-pkgcheck-setup</span><span class="p">)</span>
</pre></div></td></tr></tbody></table></div>
</div>
<h1 id="use-package">Use-Package</h1>
<p>We can also configure our environment using a <code>use-package</code> macro that simplifies the setup a little bit.</p>
<p>To use the below configuration the <code>app-emacs/use-package</code> package will have to be installed.</p>
<div class="brush: elisp">
<div class="source">
<table class="sourcetable">
<tbody>
<tr>
<td class="linenos">
<div class="linenodiv">
<pre><span class="normal">1</span>
<span class="normal">2</span>
<span class="normal">3</span>
<span class="normal">4</span>
<span class="normal">5</span>
<span class="normal">6</span>
<span class="normal">7</span>
<span class="normal">8</span>
<span class="normal">9</span></pre></div></td>
<td class="code">
<div>
<pre><span></span><span class="p">(</span><span class="nb">require</span><span class="w"> </span><span class="ss">'use-package</span><span class="p">)</span>
<span class="p">(</span><span class="nb">use-package</span><span class="w"> </span><span class="nv">ebuild-mode</span>
<span class="w"> </span><span class="nb">:defer</span><span class="w"> </span><span class="no">t</span>
<span class="w"> </span><span class="nb">:mode</span><span class="w"> </span><span class="s">"\\.\\(ebuild\\|eclass\\)\\'"</span>
<span class="w"> </span><span class="nb">:hook</span>
<span class="w"> </span><span class="p">((</span><span class="nv">ebuild-mode</span><span class="w"> </span><span class="o">.</span><span class="w"> </span><span class="nv">company-ebuild-setup</span><span class="p">)</span>
<span class="w"> </span><span class="p">(</span><span class="nv">ebuild-mode</span><span class="w"> </span><span class="o">.</span><span class="w"> </span><span class="nv">flycheck-mode</span><span class="p">)</span>
<span class="w"> </span><span class="p">(</span><span class="nv">ebuild-mode</span><span class="w"> </span><span class="o">.</span><span class="w"> </span><span class="nv">flycheck-pkgcheck-setup</span><span class="p">)))</span>
</pre></div></td></tr></tbody></table></div>
</div>
<p>The <code>:defer t</code> and <code>:mode "..."</code> enable deferred loading which theoretically speeds up GNU Emacs initialization time at the cost of running the whole <code>use-package</code> block of <code>ebuild-mode</code> configuration when the <code>:mode</code> condition is met.</p>src_snapshoturn:https-xgqt-gitlab-io:-blog-posts-2022-12-30-src-snapshot2022-12-30T00:00:00Z2022-12-30T00:00:00ZMaciej Barć
<h1 id="prototype">Prototype</h1>
<p>Recently while browsing the Alpine git repo I noticed they have a function called <code>snapshot</code>, see: <a href="https://git.alpinelinux.org/aports/tree/testing/dart/APKBUILD#n45">https://git.alpinelinux.org/aports/tree/testing/dart/APKBUILD#n45</a> I am not 100% sure about how that works but a wild guess is that the developers can run that function to fetch the sources and maybe later upload them to the Alpine repo or some sort of (cloud?) storage.</p>
<p>In Portage there exists a <code>pkg_config</code> function used to run miscellaneous configuration for packages. The only major difference between <code>src_snapshot</code> and that would of course be that users would never run <code>snapshot</code>.</p>
<h2 id="sandbox">Sandbox</h2>
<p>Probably only the <code>network sandbox</code> would have to be lifted out… to fetch the sources of course.</p>
<p>But also a few (at least one?) special directories and variables would be useful.</p>Pkgcheck-Flycheckurn:https-xgqt-gitlab-io:-blog-posts-2022-08-06-pkgcheck-flycheck2022-08-06T00:00:00Z2022-08-06T00:00:00ZMaciej Barć
<h1 id="news">News</h1>
<h2 id="repository">Repository</h2>
<p>With <a href="https://github.com/pkgcore/pkgcheck/commit/9089bd15a89db904e62a2b1a5db6c24b281676a0/">this commit</a> first <a href="https://www.gnu.org/software/emacs/">GNU Emacs</a> integration was merged into the <a href="https://pkgcore.github.io/pkgcheck/">pkgcheck</a> repository.</p>
<h2 id="history">History</h2>
<ul>
<li><a href="https://github.com/pkgcore/pkgcheck/issues/417">https://github.com/pkgcore/pkgcheck/issues/417</a></li>
<li><a href="https://github.com/pkgcore/pkgcheck/pull/420">https://github.com/pkgcore/pkgcheck/pull/420</a></li>
<li><a href="https://github.com/gentoo/gentoo/pull/26700">https://github.com/gentoo/gentoo/pull/26700</a></li></ul>
<h2 id="thanks">Thanks</h2>
<p>Huge thanks to <a href="https://github.com/thesamesam/">Sam James</a> and <a href="https://github.com/arthurzam/">Arthur Zamarin</a> for support and interest in getting this feature done.</p>
<h1 id="installation">Installation</h1>
<h2 id="unmasking">Unmasking</h2>
<p>The Flycheck integration is unreleased as of now, this will (hopefully) change in the future, but for now You need live versions of <code>snakeoil</code>, <code>pkgcore</code> and <code>pkgcheck</code>.</p>
<p>File: <code>/etc/portage/package.accept_keywords/pkgcore.conf</code></p>
<div class="brush: conf">
<div class="source">
<table class="sourcetable">
<tbody>
<tr>
<td class="linenos">
<div class="linenodiv">
<pre><span class="normal">1</span>
<span class="normal">2</span>
<span class="normal">3</span></pre></div></td>
<td class="code">
<div>
<pre><span></span>dev-python/snakeoil **
sys-apps/pkgcore **
dev-util/pkgcheck **
</pre></div></td></tr></tbody></table></div>
</div>
<p>Also You will need to unmask <code>app-emacs/flycheck</code> and its dependencies.</p>
<p>File: <code>/etc/portage/package.accept_keywords/emacs.conf</code></p>
<div class="brush: conf">
<div class="source">
<table class="sourcetable">
<tbody>
<tr>
<td class="linenos">
<div class="linenodiv">
<pre><span class="normal">1</span>
<span class="normal">2</span>
<span class="normal">3</span></pre></div></td>
<td class="code">
<div>
<pre><span></span>app-emacs/epl
app-emacs/pkg-info
app-emacs/flycheck
</pre></div></td></tr></tbody></table></div>
</div>
<h2 id="emerging">Emerging</h2>
<p>Install pkgcheck with the <code>emacs</code> USE flag enabled.</p>
<p>File: <code>/etc/portage/package.use/pkgcore.conf</code></p>
<div class="brush: conf">
<div class="source">
<table class="sourcetable">
<tbody>
<tr>
<td class="linenos">
<div class="linenodiv">
<pre><span class="normal">1</span></pre></div></td>
<td class="code">
<div>
<pre><span></span>dev-util/pkgcheck emacs
</pre></div></td></tr></tbody></table></div>
</div>
<p>Afterwards run:</p>
<div class="brush: shell">
<div class="source">
<table class="sourcetable">
<tbody>
<tr>
<td class="linenos">
<div class="linenodiv">
<pre><span class="normal">1</span>
<span class="normal">2</span></pre></div></td>
<td class="code">
<div>
<pre><span></span>emerge<span class="w"> </span>-1av<span class="w"> </span>dev-python/snakeoil<span class="w"> </span>sys-apps/pkgcore<span class="w"> </span>dev-util/pkgcheck
emerge<span class="w"> </span>-av<span class="w"> </span>--noreplace<span class="w"> </span>dev-util/pkgcheck
</pre></div></td></tr></tbody></table></div>
</div>
<h1 id="configuration">Configuration</h1>
<p>Following is what I would suggest to put into your Emacs config file:</p>
<div class="brush: elisp">
<div class="source">
<table class="sourcetable">
<tbody>
<tr>
<td class="linenos">
<div class="linenodiv">
<pre><span class="normal">1</span>
<span class="normal">2</span>
<span class="normal">3</span>
<span class="normal">4</span>
<span class="normal">5</span>
<span class="normal">6</span>
<span class="normal">7</span>
<span class="normal">8</span></pre></div></td>
<td class="code">
<div>
<pre><span></span><span class="p">(</span><span class="nb">require</span><span class="w"> </span><span class="ss">'ebuild-mode</span><span class="p">)</span>
<span class="p">(</span><span class="nb">require</span><span class="w"> </span><span class="ss">'flycheck</span><span class="p">)</span>
<span class="p">(</span><span class="nb">require</span><span class="w"> </span><span class="ss">'flycheck-pkgcheck</span><span class="p">)</span>
<span class="p">(</span><span class="k">setq</span><span class="w"> </span><span class="nv">flycheck-pkgcheck-enable</span><span class="w"> </span><span class="no">t</span><span class="p">)</span>
<span class="p">(</span><span class="nv">add-hook</span><span class="w"> </span><span class="ss">'ebuild-mode-hook</span><span class="w"> </span><span class="ss">'flycheck-mode</span><span class="p">)</span>
<span class="p">(</span><span class="nv">add-hook</span><span class="w"> </span><span class="ss">'ebuild-mode-hook</span><span class="w"> </span><span class="ss">'flycheck-pkgcheck-setup</span><span class="p">)</span>
</pre></div></td></tr></tbody></table></div>
</div>
<p>If You are using <code>use-package</code>:</p>
<div class="brush: elisp">
<div class="source">
<table class="sourcetable">
<tbody>
<tr>
<td class="linenos">
<div class="linenodiv">
<pre><span class="normal"> 1</span>
<span class="normal"> 2</span>
<span class="normal"> 3</span>
<span class="normal"> 4</span>
<span class="normal"> 5</span>
<span class="normal"> 6</span>
<span class="normal"> 7</span>
<span class="normal"> 8</span>
<span class="normal"> 9</span>
<span class="normal">10</span>
<span class="normal">11</span></pre></div></td>
<td class="code">
<div>
<pre><span></span><span class="p">(</span><span class="nb">use-package</span><span class="w"> </span><span class="nv">flycheck</span>
<span class="w"> </span><span class="nb">:ensure</span><span class="w"> </span><span class="no">nil</span><span class="p">)</span>
<span class="p">(</span><span class="nb">use-package</span><span class="w"> </span><span class="nv">ebuild-mode</span>
<span class="w"> </span><span class="nb">:ensure</span><span class="w"> </span><span class="no">nil</span>
<span class="w"> </span><span class="nb">:hook</span><span class="w"> </span><span class="p">((</span><span class="nv">ebuild-mode</span><span class="w"> </span><span class="o">.</span><span class="w"> </span><span class="nv">flycheck-mode</span><span class="p">)))</span>
<span class="p">(</span><span class="nb">use-package</span><span class="w"> </span><span class="nv">flycheck-pkgcheck</span>
<span class="w"> </span><span class="nb">:ensure</span><span class="w"> </span><span class="no">nil</span>
<span class="w"> </span><span class="nb">:custom</span><span class="w"> </span><span class="p">((</span><span class="nv">flycheck-pkgcheck-enable</span><span class="w"> </span><span class="no">t</span><span class="p">))</span>
<span class="w"> </span><span class="nb">:hook</span><span class="w"> </span><span class="p">((</span><span class="nv">ebuild-mode</span><span class="w"> </span><span class="o">.</span><span class="w"> </span><span class="nv">flycheck-pkgcheck-setup</span><span class="p">)))</span>
</pre></div></td></tr></tbody></table></div>
</div>
<p>The lines with <code>:ensure nil</code> are there to prevent <code>use-package</code> from trying to download the particular package from Elpa (because we use system packages for this configuration).</p>Portage CIurn:https-xgqt-gitlab-io:-blog-posts-2022-03-08-portage-ci2022-03-08T00:00:00Z2022-03-08T00:00:00ZMaciej Barć
<h1 id="potential-benefits">Potential benefits</h1>
<h2 id="running-tests">Running tests</h2>
<ul>
<li>test BEFORE (<code>src_test</code>) and AFTER (<code>pkg_postinst</code>) installation</li>
<li>test if and how services break if they are not reloaded</li>
<li>test buildsystem configuration</li>
<li>sandbox enforces strict and consistent build rules</li>
<li>benchmarking with different compilation flags and libraries versions/releases</li></ul>
<h2 id="configuration-matrix">Configuration matrix</h2>
<p>We can test across Cartesian product of different configuration settings, like:</p>
<ul>
<li><a href="https://wiki.gentoo.org/wiki/USE_flag">USE flags</a></li>
<li>MAKEOPTS</li>
<li>CFLAGS, CXXFLAGS, CPPFLAGS, LDFAGS, RUSTFLAGS, etc.</li>
<li>arches (cross-compilation or run in qemu)</li>
<li>static linking</li>
<li>supported releases & versions of libraries (eg. glibc & musl)</li></ul>
<p>Also, we could create diffs of installed files across different merges.</p>
<h2 id="reproducibility">Reproducibility</h2>
<ul>
<li>mini <a href="https://wiki.gentoo.org/wiki/Ebuild_repository">overlay</a> with ::gentoo or any other (eg. company's own) as master</li>
<li>record VCS (eg. git) hash of the dependent overlays</li></ul>
<h2 id="binaries">Binaries</h2>
<ul>
<li>grab dependencies from <a href="https://wiki.gentoo.org/wiki/Binary_package_guide#Setting_up_a_binary_package_host">binhosts</a></li>
<li>distribute built binaries (maybe upload to a company's own artifacts server)</li>
<li>make <a href="https://appimage.org/">AppImage</a>s</li></ul>
<h1 id="getting-there">Getting there</h1>
<h2 id="how-do-we-run-this">How do we run this?</h2>
<p>Do we want to write a proper tool, which we probably do or do we just run Portage + shells scripts?</p>
<p>Do we want to run under root, user, in <a href="https://wiki.gentoo.org/wiki/Project:Prefix">eprefix</a>, maybe all in docker?</p>
<h2 id="configuration-files">Configuration files</h2>
<p>The <code>.portci</code> directory contains the configuration.</p>
<h2 id="bug-799626">Bug 799626</h2>
<p>Link: <a href="https://bugs.gentoo.org/799626">bugs.gentoo.org/799626</a></p>
<p>Instead of using Ansible, Python, Yaml or Scheme we might use something similar to this for simple configuration, or if gets merged to upstream Portage the better.</p>
<p>Worth mentioning is the idea from Michał Górny who proposes to configure portage with toml files, like the example given in the bug report.</p>
<div class="brush: conf">
<div class="source">
<table class="sourcetable">
<tbody>
<tr>
<td class="linenos">
<div class="linenodiv">
<pre><span class="normal">1</span>
<span class="normal">2</span>
<span class="normal">3</span>
<span class="normal">4</span>
<span class="normal">5</span>
<span class="normal">6</span>
<span class="normal">7</span>
<span class="normal">8</span></pre></div></td>
<td class="code">
<div>
<pre><span></span>[package.unmask]
~virtual/libcrypt-2
[package.use.mask]
sys-libs/libxcrypt -system -split-usr
[package.use.force]
sys-libs/glibc -crypt
</pre></div></td></tr></tbody></table></div>
</div>
<p>Also, <code>package.x</code> + Toml == a match made in heaven, it looks very nice!</p>Portageurn:https-xgqt-gitlab-io:-blog-posts-2021-09-26-portage2021-09-26T00:00:00Z2021-09-26T00:00:00ZMaciej Barć
<h1 id="switching-from-a-git-repository-hosting">Switching from a git repository hosting</h1>
<p>For nearly 2 years I have been synchronizing settings between my Gentoo machines <a href="https://gitlab.com/xgqt/genlica">via a git repository</a> that is installed system-wide via portage itself.</p>
<p>This actually gets a little tiresome and slow as the package that installs the configuration has to be re-installed each time we want to update the settings.</p>
<p>So I thought it could be cool if I can just push files around between my machines with one command. Now: we can use <code>rsync</code> or <code>scp</code> but <code>/etc/portage</code> is owned by root so we either have to change the permissions to a user we use to ssh or a group that user is in.</p>
<h1 id="portage-users">Portage users</h1>
<p>First change portage permissions of <code>/etc/portage</code>, now all users in the <code>portage</code> group will be able to modify the configuration</p>
<div class="brush: {.bash org-language="sh"}">
<div class="source">
<table class="sourcetable">
<tbody>
<tr>
<td class="linenos">
<div class="linenodiv">
<pre><span class="normal">1</span>
<span class="normal">2</span></pre></div></td>
<td class="code">
<div>
<pre><span></span>chown -R root:portage /etc/portage
chmod -R g+w /etc/portage
</pre></div></td></tr></tbody></table></div>
</div>
<h1 id="synchronizing">Synchronizing</h1>
<p>We can do a <code>rsync</code> from different machine with:</p>
<div class="brush: {.bash org-language="sh"}">
<div class="source">
<table class="sourcetable">
<tbody>
<tr>
<td class="linenos">
<div class="linenodiv">
<pre><span class="normal">1</span></pre></div></td>
<td class="code">
<div>
<pre><span></span>rsync -r /etc/portage REMOTEHOST:/etc --exclude=".git" --exclude="make.profile" --copy-unsafe-links
</pre></div></td></tr></tbody></table></div>
</div>
<p>Reminder that this can also be done as a <code>cron</code> job!</p>
<h1 id="portage-snapshots-with-git">Portage snapshots with git</h1>
<p>Probably the best thing I got out of genlica is that I engineered a script to automatically do a git commit of the changes to the portage configuration.</p>
<p>Emerge git</p>
<div class="brush: {.bash org-language="sh"}">
<div class="source">
<table class="sourcetable">
<tbody>
<tr>
<td class="linenos">
<div class="linenodiv">
<pre><span class="normal">1</span></pre></div></td>
<td class="code">
<div>
<pre><span></span>emerge --noreplace --verbose dev-vcs/git
</pre></div></td></tr></tbody></table></div>
</div>
<p>Copy the file that does the snapshots</p>
<div class="brush: {.bash org-language="sh"}">
<div class="source">
<table class="sourcetable">
<tbody>
<tr>
<td class="linenos">
<div class="linenodiv">
<pre><span class="normal">1</span>
<span class="normal">2</span></pre></div></td>
<td class="code">
<div>
<pre><span></span>mkdir -p /etc/portage/postsync.d
curl -o /etc/portage/postsync.d/99-degitmerge.sh "https://gitlab.com/xgqt/genlica/-/raw/master/portage/postsync.d/99-degitmerge.sh"
</pre></div></td></tr></tbody></table></div>
</div>Sage Math on Gentoourn:https-xgqt-gitlab-io:-blog-posts-2021-03-23-sage-math-on-gentoo2021-03-23T00:00:00Z2021-03-23T00:00:00ZMaciej Barć
<h1 id="intro">Intro</h1>
<p><a href="https://www.sagemath.org/">Sage</a> may be available on your distro but on Gentoo such frivolities for students are not there yet, so I had to install it the manual way.</p>
<h1 id="user">User</h1>
<p>I went to the Sage website, to the <a href="https://www.sagemath.org/download-source.html">"download-source"</a> link. The source mirror I picked was <a href="http://www-ftp.lip6.fr/pub/math/sagemath/src/sage-9.2.tar.gz">France</a>.</p>
<p>Ok, so let's follow Sage Math build instructions and get it going</p>
<div class="brush: bash">
<div class="source">
<table class="sourcetable">
<tbody>
<tr>
<td class="linenos">
<div class="linenodiv">
<pre><span class="normal">1</span>
<span class="normal">2</span>
<span class="normal">3</span>
<span class="normal">4</span>
<span class="normal">5</span></pre></div></td>
<td class="code">
<div>
<pre><span></span>wget<span class="w"> </span>www-ftp.lip6.fr/pub/math/sagemath/src/sage-9.2.tar.gz
tar<span class="w"> </span>xvf<span class="w"> </span>sage-9.2.tar.gz
<span class="nb">cd</span><span class="w"> </span>sage-9.2
./configure
make
</pre></div></td></tr></tbody></table></div>
</div>
<p>And now, let's wait…</p>
<h1 id="portage">Portage</h1>
<p>After a long, long, long time waiting I remembered that there existed a <a href="https://github.com/cschwan/sage-on-gentoo">Gentoo overlay for Sage</a>. And in the meantime I thought I'd try that solution instead since some good Gentoo people already did most of the effort.</p>
<p>Just a few files to edit…</p>
<p>File: /etc/portage/repos.conf/sage-on-gentoo.conf</p>
<div class="brush: conf">
<div class="source">
<table class="sourcetable">
<tbody>
<tr>
<td class="linenos">
<div class="linenodiv">
<pre><span class="normal"> 1</span>
<span class="normal"> 2</span>
<span class="normal"> 3</span>
<span class="normal"> 4</span>
<span class="normal"> 5</span>
<span class="normal"> 6</span>
<span class="normal"> 7</span>
<span class="normal"> 8</span>
<span class="normal"> 9</span>
<span class="normal">10</span>
<span class="normal">11</span>
<span class="normal">12</span>
<span class="normal">13</span>
<span class="normal">14</span></pre></div></td>
<td class="code">
<div>
<pre><span></span># -*- conf -*-
[sage-on-gentoo]
auto-sync = yes
location = /var/db/repos/sage-on-gentoo
priority = 999
sync-git-clone-extra-opts = --depth=999999999 --no-shallow-submodules --verbose
sync-git-pull-extra-opts = --verbose
sync-type = git
sync-umask = 022
sync-uri = https://github.com/cschwan/sage-on-gentoo.git
sync-user = root:portage
</pre></div></td></tr></tbody></table></div>
</div>
<p>File: /etc/portage/package.accept~keywords~/zz-sage</p>
<div class="brush: conf">
<div class="source">
<table class="sourcetable">
<tbody>
<tr>
<td class="linenos">
<div class="linenodiv">
<pre><span class="normal"> 1</span>
<span class="normal"> 2</span>
<span class="normal"> 3</span>
<span class="normal"> 4</span>
<span class="normal"> 5</span>
<span class="normal"> 6</span>
<span class="normal"> 7</span>
<span class="normal"> 8</span>
<span class="normal"> 9</span>
<span class="normal">10</span>
<span class="normal">11</span>
<span class="normal">12</span>
<span class="normal">13</span>
<span class="normal">14</span>
<span class="normal">15</span>
<span class="normal">16</span>
<span class="normal">17</span>
<span class="normal">18</span>
<span class="normal">19</span>
<span class="normal">20</span></pre></div></td>
<td class="code">
<div>
<pre><span></span># -*- conf -*-
sci-mathematics/sage **
*/*::sage-on-gentoo
dev-python/cvxopt
media-gfx/tachyon
sci-libs/bliss
sci-libs/dsdp
sci-libs/fflas-ffpack
sci-libs/fplll
sci-libs/libhomfly
sci-libs/linbox
sci-libs/m4rie
sci-mathematics/glpk
</pre></div></td></tr></tbody></table></div>
</div>
<p>File: /etc/portage/package.use/zz-sage</p>
<div class="brush: conf">
<div class="source">
<table class="sourcetable">
<tbody>
<tr>
<td class="linenos">
<div class="linenodiv">
<pre><span class="normal"> 1</span>
<span class="normal"> 2</span>
<span class="normal"> 3</span>
<span class="normal"> 4</span>
<span class="normal"> 5</span>
<span class="normal"> 6</span>
<span class="normal"> 7</span>
<span class="normal"> 8</span>
<span class="normal"> 9</span>
<span class="normal">10</span>
<span class="normal">11</span>
<span class="normal">12</span>
<span class="normal">13</span>
<span class="normal">14</span>
<span class="normal">15</span>
<span class="normal">16</span>
<span class="normal">17</span>
<span class="normal">18</span>
<span class="normal">19</span>
<span class="normal">20</span></pre></div></td>
<td class="code">
<div>
<pre><span></span># -*- conf -*-
sci-mathematics/sage -doc-html -doc-html-bin
sci-mathematics/sage -doc-pdf -doc-pdf-bin
sci-mathematics/sage -jmol
sci-mathematics/sage X bliss meataxe
dev-python/pplpy doc
sci-libs/cddlib tools
sci-libs/pynac -giac
sci-mathematics/eclib flint
sci-mathematics/flint ntl
sci-mathematics/glpk gmp
sci-mathematics/gmp-ecm -openmp
sci-mathematics/lcalc pari
sci-mathematics/maxima ecls
sci-mathematics/pari gmp doc
</pre></div></td></tr></tbody></table></div>
</div>
<p>Now - let's build Sage with Portage!</p>
<p><a href="https://fosstodon.org/@xgqt/105940287356177246">>>> Emerging (1 of 100) sci-mathematics/cliquer–1.21::gentoo</a></p>
<p>At least I know more or less how long I'm going to wait and know what exactly fails to build, if anything does.</p>
<h1 id="final">Final</h1>
<h2 id="build">Build</h2>
<blockquote>
<p>$ qlop -tv sage</p>
<p>> 2021–03–23T20:49:12 >>> sci-mathematics/sage–9999: 55′04″</p></blockquote>
<h2 id="git-stats">Git stats</h2>
<h3 id="overlays">Overlays</h3>
<p>This info we can easily gather with executing:</p>
<div class="brush: bash">
<div class="source">
<table class="sourcetable">
<tbody>
<tr>
<td class="linenos">
<div class="linenodiv">
<pre><span class="normal">1</span></pre></div></td>
<td class="code">
<div>
<pre><span></span>emerge<span class="w"> </span>--info
</pre></div></td></tr></tbody></table></div>
</div>
<p>Gentoo' HEAD: <code>33f2d770c28307b1e9a1199c681e1c543602c6d4</code></p>
<p>Sage-on-Gentoo's HEAD: <code>f7eac5b7e1a844132164b7593dab85cd87918664</code></p>
<h3 id="sage">Sage</h3>
<p>Sage repository's HEAD (because we are using the live (9999) ebuild):</p>
<div class="brush: bash">
<div class="source">
<table class="sourcetable">
<tbody>
<tr>
<td class="linenos">
<div class="linenodiv">
<pre><span class="normal">1</span></pre></div></td>
<td class="code">
<div>
<pre><span></span>cat<span class="w"> </span>/var/cache/distfiles/git3-src/sagemath_sage.git/refs/heads/develop
</pre></div></td></tr></tbody></table></div>
</div>
<p>Which returns: <code>5cb72aade9b297c10bb0f1ae8529466e5b5eb41d</code></p>Portage system replicationurn:https-xgqt-gitlab-io:-blog-posts-2020-11-14-portage-system-replication2020-11-14T00:00:00Z2020-11-14T00:00:00ZMaciej Barć
<h1 id="intro">Intro</h1>
<p>Backing up using this method takes a lot less space - ~60MB (without distfiles) and can be restored on almost any system (running portage) and tweaked afterwards for, say, CPU architecture. I've created a a short script with similar method in <a href="https://gitlab.com/xgqt/mydot/-/blob/master/scripts/.local/share/bin/bak-portage">here</a>.</p>
<h1 id="what-we-need">What we need</h1>
<ul>
<li>ebuild repositories are installed with git</li>
<li>distfiles (those might be gone when we want to replicate)</li></ul>
<h1 id="backup">Backup</h1>
<div class="brush: shell">
<div class="source">
<table class="sourcetable">
<tbody>
<tr>
<td class="linenos">
<div class="linenodiv">
<pre><span class="normal"> 1</span>
<span class="normal"> 2</span>
<span class="normal"> 3</span>
<span class="normal"> 4</span>
<span class="normal"> 5</span>
<span class="normal"> 6</span>
<span class="normal"> 7</span>
<span class="normal"> 8</span>
<span class="normal"> 9</span>
<span class="normal">10</span>
<span class="normal">11</span>
<span class="normal">12</span>
<span class="normal">13</span>
<span class="normal">14</span>
<span class="normal">15</span>
<span class="normal">16</span>
<span class="normal">17</span>
<span class="normal">18</span>
<span class="normal">19</span>
<span class="normal">20</span>
<span class="normal">21</span>
<span class="normal">22</span>
<span class="normal">23</span>
<span class="normal">24</span></pre></div></td>
<td class="code">
<div>
<pre><span></span><span class="c1"># System info</span>
emerge<span class="w"> </span>--info<span class="w"> </span>><span class="w"> </span>info.txt
<span class="c1"># Portage tree</span>
cp<span class="w"> </span>-Lr<span class="w"> </span>/etc/portage<span class="w"> </span>.
<span class="c1"># Portage layout</span>
tree<span class="w"> </span>-a<span class="w"> </span>-L<span class="w"> </span><span class="m">2</span><span class="w"> </span>/etc/portage<span class="w"> </span>><span class="w"> </span>layout.txt
<span class="c1"># Packages in @world</span>
cp<span class="w"> </span>/var/lib/portage/world<span class="w"> </span>.
<span class="c1"># Installed sets</span>
cp<span class="w"> </span>/var/lib/portage/world_sets<span class="w"> </span>.
<span class="c1"># Installed packages (with versions)</span>
qlist<span class="w"> </span>--installed<span class="w"> </span>--nocolor<span class="w"> </span>--umap<span class="w"> </span>><span class="w"> </span>qlist-use.txt
qlist<span class="w"> </span>--installed<span class="w"> </span>--nocolor<span class="w"> </span>--verbose<span class="w"> </span>><span class="w"> </span>qlist-ver.txt
<span class="c1"># Distfiles</span>
cp<span class="w"> </span>-rv<span class="w"> </span><span class="s2">"</span><span class="k">$(</span>portageq<span class="w"> </span>envvar<span class="w"> </span>DISTDIR<span class="k">)</span><span class="s2">"</span><span class="w"> </span>distfiles
<span class="c1"># Ebuild database</span>
cp<span class="w"> </span>-r<span class="w"> </span>/var/db/pkg<span class="w"> </span>pkgdb
</pre></div></td></tr></tbody></table></div>
</div>
<h1 id="restoration">Restoration</h1>
<p>To faithfully restore the system perform those actions as root</p>
<div class="brush: shell">
<div class="source">
<table class="sourcetable">
<tbody>
<tr>
<td class="linenos">
<div class="linenodiv">
<pre><span class="normal"> 1</span>
<span class="normal"> 2</span>
<span class="normal"> 3</span>
<span class="normal"> 4</span>
<span class="normal"> 5</span>
<span class="normal"> 6</span>
<span class="normal"> 7</span>
<span class="normal"> 8</span>
<span class="normal"> 9</span>
<span class="normal">10</span>
<span class="normal">11</span>
<span class="normal">12</span>
<span class="normal">13</span>
<span class="normal">14</span>
<span class="normal">15</span>
<span class="normal">16</span>
<span class="normal">17</span></pre></div></td>
<td class="code">
<div>
<pre><span></span><span class="c1"># Copy the portage tree to /etc</span>
rm<span class="w"> </span>-dr<span class="w"> </span>/etc/portage
cp<span class="w"> </span>-r<span class="w"> </span>portage<span class="w"> </span>/etc/portage
<span class="c1"># Checkout the gentoo repo to a commit specified in info.txt</span>
<span class="nb">cd</span><span class="w"> </span><span class="s2">"</span><span class="k">$(</span>portageq<span class="w"> </span>get_repo_path<span class="w"> </span>/<span class="w"> </span>gentoo<span class="k">)</span><span class="s2">"</span>
git<span class="w"> </span>checkout<span class="w"> </span><span class="c1"># <commit ID></span>
<span class="c1"># Copy distfiles</span>
cp<span class="w"> </span>-r<span class="w"> </span>distfiles/*<span class="w"> </span><span class="s2">"</span><span class="k">$(</span>portageq<span class="w"> </span>envvar<span class="w"> </span>DISTDIR<span class="k">)</span><span class="s2">"</span>/
<span class="c1"># Fake-install @world and sets</span>
cp<span class="w"> </span>world<span class="w"> </span>/var/lib/portage/world
cp<span class="w"> </span>world_sets<span class="w"> </span>/var/lib/portage/world_sets
<span class="c1"># Emerge the exact packages from qlist-ver.txt</span>
emerge<span class="w"> </span>--keep-going<span class="o">=</span>y<span class="w"> </span>-1Oav<span class="w"> </span><span class="k">$(</span>sed<span class="w"> </span><span class="s1">'s/^/=/'</span><span class="w"> </span>qlist-ver.txt<span class="k">)</span>
</pre></div></td></tr></tbody></table></div>
</div>