Mathieu Bridon - flatpakhttps://mathieu.daitauha.fr/2018-07-26T10:00:00+02:00Following GNOME nightly Flatpak builds2018-07-26T10:00:00+02:002018-07-26T10:00:00+02:00Mathieu Bridontag:mathieu.daitauha.fr,2018-07-26:/blog/2018/07/26/following-gnome-nightly-flatpak-builds/<p><strong>Edit on 2018-10-03:</strong> the dashboard moved to
<a href="https://mbridon.pages.gitlab.gnome.org/flatpak-master-dashboard/">https://mbridon.pages.gitlab.gnome.org/flatpak-master-dashboard/</a>.</p>
<hr />
<p>Over at GNOME, we build <a href="https://gitlab.gnome.org/GNOME/gnome-sdk-images/">an SDK</a>
and <a href="https://gitlab.gnome.org/GNOME/gnome-apps-nightly/">lots of apps</a> as
flatpaks, directly from Git master. Unfortunately, the builds are quite
regularly broken, and need a lot of baby-sitting to fix issues.</p>
<p>I used to …</p><p><strong>Edit on 2018-10-03:</strong> the dashboard moved to
<a href="https://mbridon.pages.gitlab.gnome.org/flatpak-master-dashboard/">https://mbridon.pages.gitlab.gnome.org/flatpak-master-dashboard/</a>.</p>
<hr />
<p>Over at GNOME, we build <a href="https://gitlab.gnome.org/GNOME/gnome-sdk-images/">an SDK</a>
and <a href="https://gitlab.gnome.org/GNOME/gnome-apps-nightly/">lots of apps</a> as
flatpaks, directly from Git master. Unfortunately, the builds are quite
regularly broken, and need a lot of baby-sitting to fix issues.</p>
<p>I used to do that regularly, but stopped sometimes after GUADEC 2017. With the
<a href="https://gitlab.com/freedesktop-sdk/freedesktop-sdk/">freedesktop-sdk</a> effort,
I decided to get back into doing that.</p>
<p>Typically, you have to go to one of two addresses:</p>
<ul>
<li><a href="http://sdkbuilder.gnome.org/logs/">http://sdkbuilder.gnome.org/logs/</a> for the i386 and x86_64 build logs;</li>
<li><a href="https://gnome2.codethink.co.uk/logs/">https://gnome2.codethink.co.uk/logs/</a> for the arm build logs;</li>
</ul>
<p>And then browse the directories to find the latest build logs for each module,
see if they were failures, and try to fix them.</p>
<p>This manual browsing of directories is no fun, and it gets old very quickly,
contributing to the general lack of desire to monitor and fix issues.</p>
<p>So I made something:</p>
<p><a href="https://www.daitauha.fr/static/gnome-master-flatpak/report.html"><img alt="GNOME master build dashboard" src="https://mathieu.daitauha.fr/images/gnome-master-builds.png" /></a></p>
<p><a class="center" href="https://www.daitauha.fr/static/gnome-master-flatpak/report.html">https://www.daitauha.fr/static/gnome-master-flatpak/report.html</a></p>
<p>It's a quick and dirty <a href="https://www.daitauha.fr/static/gnome-master-flatpak/get-gnome-master-build-failures.py">Python script</a>
running every 10 minutes in a cronjob on my server, generating
a dashboard. There's even
<a href="https://www.daitauha.fr/static/gnome-master-flatpak/gnome-master-build-failures-wip-notes.json">some notes about failures</a>
to keep track of the work in progress fixing them.</p>
<p>Now it's much easier to see all the build failures (and successes!) in one
place, with links to the last build logs for each app / SDK.</p>
<p>Ideally something like this should end up in the GNOME infrastructure rather
than on my personal server…</p>
<p>However, since we're eventually going to deprecate <a href="https://gitlab.gnome.org/GNOME/gnome-sdk-images/">gnome-sdk-images</a>
and maybe even <a href="https://gitlab.gnome.org/GNOME/gnome-apps-nightly/">gnome-apps-nightly</a>
in favour of <a href="https://gitlab.gnome.org/GNOME/gnome-build-meta">gnome-build-meta</a>,
it's probably not worth spending too much time on this.</p>
<p>I hope this helps. For now I'm going back to fixing the last few 30 or so
build failures.</p>Flatpaking a web server2018-07-10T22:40:00+02:002018-07-10T22:40:00+02:00Mathieu Bridontag:mathieu.daitauha.fr,2018-07-10:/blog/2018/07/10/flatpaking-a-web-server/<p>Someone asked in <a href="irc://irc.freenode.net/flatpak">#flatpak</a> whether it was
possible to package a web server.</p>
<p>I knew it was possible, but was curious as to how exactly.</p>
<p>So I wrote a trivial "web server":</p>
<div class="highlight"><pre><span></span><span class="ch">#!/bin/bash</span>
/usr/bin/python3 -m http.server <span class="m">8000</span>
</pre></div>
<p>And a Flatpak manifest to package that script:</p>
<div class="highlight"><pre><span></span><span class="p">{</span>
<span class="nt">"id …</span></pre></div><p>Someone asked in <a href="irc://irc.freenode.net/flatpak">#flatpak</a> whether it was
possible to package a web server.</p>
<p>I knew it was possible, but was curious as to how exactly.</p>
<p>So I wrote a trivial "web server":</p>
<div class="highlight"><pre><span></span><span class="ch">#!/bin/bash</span>
/usr/bin/python3 -m http.server <span class="m">8000</span>
</pre></div>
<p>And a Flatpak manifest to package that script:</p>
<div class="highlight"><pre><span></span><span class="p">{</span>
<span class="nt">"id"</span><span class="p">:</span> <span class="s2">"fr.daitauha.WebServer"</span><span class="p">,</span>
<span class="nt">"runtime"</span><span class="p">:</span> <span class="s2">"org.freedesktop.Platform"</span><span class="p">,</span>
<span class="nt">"sdk"</span><span class="p">:</span> <span class="s2">"org.freedesktop.Sdk"</span><span class="p">,</span>
<span class="nt">"runtime-version"</span><span class="p">:</span> <span class="s2">"1.6"</span><span class="p">,</span>
<span class="nt">"command"</span><span class="p">:</span> <span class="s2">"httpd"</span><span class="p">,</span>
<span class="nt">"finish-args"</span><span class="p">:</span> <span class="p">[</span>
<span class="s2">"--share=network"</span>
<span class="p">],</span>
<span class="nt">"modules"</span><span class="p">:</span> <span class="p">[</span>
<span class="p">{</span>
<span class="nt">"name"</span><span class="p">:</span> <span class="s2">"httpd"</span><span class="p">,</span>
<span class="nt">"buildsystem"</span><span class="p">:</span> <span class="s2">"simple"</span><span class="p">,</span>
<span class="nt">"build-commands"</span><span class="p">:</span> <span class="p">[</span>
<span class="s2">"install -m755 -D webserver /app/bin/httpd"</span>
<span class="p">],</span>
<span class="nt">"sources"</span><span class="p">:</span> <span class="p">[</span>
<span class="p">{</span>
<span class="nt">"type"</span><span class="p">:</span> <span class="s2">"file"</span><span class="p">,</span>
<span class="nt">"path"</span><span class="p">:</span> <span class="s2">"webserver"</span>
<span class="p">}</span>
<span class="p">]</span>
<span class="p">}</span>
<span class="p">]</span>
<span class="p">}</span>
</pre></div>
<p>The important part above is the <code>--share=network</code> argument. By default, the
Flatpak sandbox prevents apps from accessing the network, whether as clients
or servers. This option gives them full network access.</p>
<p>Let's build it:</p>
<div class="highlight"><pre><span></span><span class="gp">$</span> flatpak-builder --install --user app fr.daitauha.WebServer.json
<span class="go">Emptying app dir 'app'</span>
<span class="go">Downloading sources</span>
<span class="go">Initializing build dir</span>
<span class="go">Committing stage init to cache</span>
<span class="go">Starting build of fr.daitauha.WebServer</span>
<span class="go">========================================================================</span>
<span class="go">Building module httpd in /home/mathieu/.cache/flatpak-builder/build/httpd-1</span>
<span class="go">========================================================================</span>
<span class="go">Running: install -m755 -D webserver /app/bin/httpd</span>
<span class="go">Committing stage build-httpd to cache</span>
<span class="go">Cleaning up</span>
<span class="go">Committing stage cleanup to cache</span>
<span class="go">Finishing app</span>
<span class="go">Please review the exported files and the metadata</span>
<span class="go">Committing stage finish to cache</span>
<span class="go">Exporting fr.daitauha.WebServer to repo</span>
<span class="go">Commit: a639e450e42d3938d00d00be9d87bfc6e15a0fac1cea6dcabaaace5b91d7436c</span>
<span class="go">Metadata Total: 9</span>
<span class="go">Metadata Written: 1</span>
<span class="go">Content Total: 3</span>
<span class="go">Content Written: 0</span>
<span class="go">Content Bytes Written: 0 (0 bytes)</span>
<span class="go">Installing in user:</span>
<span class="go">fr.daitauha.WebServer/x86_64/master fr.daitauha.WebServer-origin a639e450e42d</span>
<span class="go"> permissions: network</span>
<span class="go">Installing for user: fr.daitauha.WebServer/x86_64/master from fr.daitauha.WebServer-origin</span>
<span class="go">[####################] 3 metadata, 3 content objects imported</span>
<span class="go">Now at a639e450e42d.</span>
<span class="go">Pruning cache</span>
</pre></div>
<p>We can now run it:</p>
<div class="highlight"><pre><span></span><span class="go">flatpak run fr.daitauha.WebServer</span>
<span class="go">Serving HTTP on 0.0.0.0 port 8000 ...</span>
</pre></div>
<p>And voilà:</p>
<p><img alt="Browsing the web server" src="https://mathieu.daitauha.fr/images/flatpaked-web-server.png" /></p>
<p>This is probably not very useful though. Flatpak focuses on desktop apps,
and that's where it really shines.</p>
<p>For services such as a web server, other container technologies like Docker
are doing a better job.</p>