<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Lxc on mm-dev</title>
    <link>https://mm-dev.rocks/tags/lxc/</link>
    <description>Recent content in Lxc on mm-dev</description>
    <generator>Hugo -- gohugo.io</generator>
    <language>en-gb</language>
    <lastBuildDate>Tue, 30 Jul 2024 17:11:22 +0100</lastBuildDate><atom:link href="https://mm-dev.rocks/tags/lxc/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Setting Up the LXC Container</title>
      <link>https://mm-dev.rocks/posts/my-fdroid-build-setup/setting-up-the-lxc-container/</link>
      <pubDate>Tue, 30 Jul 2024 17:11:22 +0100</pubDate>
      <guid>https://mm-dev.rocks/posts/my-fdroid-build-setup/setting-up-the-lxc-container/</guid>
      <description>&lt;p&gt;I&amp;rsquo;m using &lt;a href = &#34;https://linuxcontainers.org/&#34; target = &#34;_blank&#34; rel = &#34;nofollow noopener noreferrer&#34;&gt;LXC containers&lt;/a&gt; on &lt;a href = &#34;https://www.proxmox.com/en/&#34; target = &#34;_blank&#34; rel = &#34;nofollow noopener noreferrer&#34;&gt;Proxmox&lt;/a&gt;. If you have a different method of working with containers I&amp;rsquo;m pretty sure you&amp;rsquo;ll be able to use the info here and repurpose it to your preferences.&lt;/p&gt;
&lt;h3 id=&#34;create-an-alpine-container&#34;&gt;Create an Alpine container&lt;/h3&gt;
&lt;p&gt;I won&amp;rsquo;t go into the details of how to do this as it&amp;rsquo;s specific to Proxmox and no different to setting up any other LXC container in Proxmox.&lt;/p&gt;
&lt;p&gt;I&amp;rsquo;m using &lt;a href = &#34;https://alpinelinux.org/&#34; target = &#34;_blank&#34; rel = &#34;nofollow noopener noreferrer&#34;&gt;Alpine Linux&lt;/a&gt; as the container distro as it&amp;rsquo;s very lightweight and the F-Droid tools don&amp;rsquo;t need anything fancy.&lt;/p&gt;
&lt;p&gt;&lt;del&gt;In terms of resources, it doesn&amp;rsquo;t need much, the following has been more than enough for me so far:&lt;/del&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;del&gt;512MB RAM&lt;/del&gt;&lt;/li&gt;
&lt;li&gt;&lt;del&gt;512MB swap&lt;/del&gt;&lt;/li&gt;
&lt;li&gt;&lt;del&gt;8GB disk&lt;/del&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;How naive of me, Gradle is much more greedy than I originally thought and I was getting build errors due to low resources. So I set the container up with:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;6GB RAM&lt;/li&gt;
&lt;li&gt;1GB swap&lt;/li&gt;
&lt;li&gt;16GB disk&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&#34;set-up-the-container-for-f-droid-builds&#34;&gt;Set up the container for F-Droid builds&lt;/h3&gt;
&lt;p&gt;While logged into my Alpine container, first I set up some basics:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c1&#34;&gt;# Ensure everything is up to date&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;apk update
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;apk upgrade
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c1&#34;&gt;# Install and configure git&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;apk add git vim
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;git config --global user.name &lt;span class=&#34;s2&#34;&gt;&amp;#34;&amp;lt;YOUR_NAME&amp;gt;&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;git config --global user.email &lt;span class=&#34;s2&#34;&gt;&amp;#34;&amp;lt;YOUR_EMAIL&amp;gt;&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;ssh-keygen
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;cat .ssh/id_rsa.pub 
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c1&#34;&gt;# ... then copy key to gitlab SSH keys&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;F-Droid build instructions depend on docker, so:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;apk add docker
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c1&#34;&gt;# Start docker on boot&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;rc-update add docker boot
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c1&#34;&gt;# Start docker now (or reboot so the above command can take effect)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;service docker start
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Now get the F-Droid stuff installed:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;git clone --depth&lt;span class=&#34;o&#34;&gt;=&lt;/span&gt;&lt;span class=&#34;m&#34;&gt;1&lt;/span&gt; git@gitlab.com:&amp;lt;YOUR_ACCOUNT&amp;gt;/fdroiddata.git ~/fdroiddata
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;nb&#34;&gt;cd&lt;/span&gt; ~/fdroiddata
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;git checkout -b com.example
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;cp templates/build-gradle.yml metadata/com.example.yml
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c1&#34;&gt;# If (like me) you already created a fork before it&amp;#39;s a little different &lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c1&#34;&gt;# and you have to do this instead of the above&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c1&#34;&gt;# git clone --depth=1 git@gitlab.com:&amp;lt;YOUR_ACCOUNT&amp;gt;/fdroiddata.git ~/fdroiddata&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c1&#34;&gt;# cd fdroiddata/&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c1&#34;&gt;# Shallow cloning makes other branches inaccessible, fix that&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c1&#34;&gt;# git remote set-branches origin &amp;#39;*&amp;#39;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c1&#34;&gt;# git fetch -v --depth=1&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c1&#34;&gt;# And now the branch can be checked out&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c1&#34;&gt;# git checkout com.example&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The container is set up now, later on on we&amp;rsquo;ll get around to how to actually use it&amp;hellip;&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>Intro</title>
      <link>https://mm-dev.rocks/posts/my-fdroid-build-setup/intro/</link>
      <pubDate>Tue, 30 Jul 2024 17:11:20 +0100</pubDate>
      <guid>https://mm-dev.rocks/posts/my-fdroid-build-setup/intro/</guid>
      <description>&lt;p&gt;Building apps for F-Droid is a fairly complex process, involving:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;A couple of git repos (besides any your own project may have)&lt;/li&gt;
&lt;li&gt;Using docker&lt;/li&gt;
&lt;li&gt;Forking and merge requests on GitLab&lt;/li&gt;
&lt;li&gt;F-Droid&amp;rsquo;s specialised build commands&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;F-Droid gives instructions on their process &lt;a href = &#34;https://f-droid.org/en/docs/Submitting_to_F-Droid_Quick_Start_Guide/&#34; target = &#34;_blank&#34; rel = &#34;nofollow noopener noreferrer&#34;&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;I managed to get my first Android app (&lt;a href = &#34;https://mm-dev.rocks/posts/bendystraw-android-app/&#34; title = &#34;BendyStraw (Android App)&#34; target = &#34;_blank&#34; rel = &#34;nofollow noopener noreferrer&#34;&gt;BendyStraw&lt;/a&gt;) &lt;a href = &#34;https://f-droid.org/en/packages/rocks.mm_dev.BendyStraw/&#34; target = &#34;_blank&#34; rel = &#34;nofollow noopener noreferrer&#34;&gt;published on F-Droid&lt;/a&gt; but felt a little out of my depth at times and didn&amp;rsquo;t have a clear mental model of all the moving parts.&lt;/p&gt;
&lt;p&gt;So in this series of articles I&amp;rsquo;m going to write up the process in my own words. I&amp;rsquo;ll add a couple of scripts which help reduce some repetitive steps, and as the &lt;code&gt;fdroid build&lt;/code&gt; command can take a while I&amp;rsquo;ve set things up so that I can automatically be sent a message on Telegram when the process is finished.&lt;/p&gt;
&lt;h3 id=&#34;proxmox&#34;&gt;Proxmox&lt;/h3&gt;
&lt;p&gt;My main development machine runs &lt;a href = &#34;https://www.proxmox.com&#34; target = &#34;_blank&#34; rel = &#34;nofollow noopener noreferrer&#34;&gt;Proxmox&lt;/a&gt;, a special OS which just hosts virtual machines and containers. Roughly speaking, a virtual machine virtualises the hardware, whereas a container virtualises the operating system.&lt;/p&gt;
&lt;p&gt;With Proxmox the main OS is only used for managing these virtual systems. Everyday computer usage such as development work is always done inside a virtual environment, for example if I&amp;rsquo;m writing Flutter code I&amp;rsquo;ll be working inside a Debian virtual machine.&lt;/p&gt;
&lt;p&gt;I decided to make a small separate container dedicated only to building apps for F-Droid. I&amp;rsquo;ll be releasing more apps on F-Droid in future so it will be nice to have a clean environment siloed off for the job. Proxmox uses LXC containers and I chose to use an Alpine Linux template to get me started because Alpine is very lean.&lt;/p&gt;
</description>
    </item>
    
  </channel>
</rss>
