Submitting to F-Droid: Quick Start Guide
by Andy Balaam, original at artificialworlds.net
Here’s what I needed to get a dev environment for F-Droid up and running on Ubuntu 16.10, using F-Droid server version 0.7.0 (commit ID 8147f9235), so that I could submit a package for inclusion in the F-Droid repository.
Doing this is apparently the best way to get your own package into the repository, since you can provide a direct merge request for the metadata about your package, making it easy for the maintainers.
Building the F-Droid build server requires a fair amount of storage space.
As of April 2020, if you have 150 GB free in your
~), then you
should be good to go (this includes cloning the F-Droid git repositories
there as well).
During the build, approximately 124 GB will be used.
- 20 GB where the
fdroidservergit repository is cloned
- 16 GB in
~/.cache/fdroidserver, for caching several versions of Android SDK, NDK, Gradle etc
- 40 GB in
~/.vagrant.dwhile exporting the final VM image
- 48 GB in
~/VirtualBox VM, for the VM storage (VirtualBox default location)
After building the server, 85 GB are still in use. When running the server to build an actual Android APK, at least 48 GB more will be used for the build VM instance. And then of course even more for the data generated by the builds. The virtual size of the build server is over 930 GB, so that would be its maximum.
Before you start, manually install the Android SDK at ~/Android/Sdk/ - see Download Android Studio. I installed version 23.0.2, but you will probably have a later one and may need to adjust the version number below.
Note: If you’re only planning to contribute a package I’m fairly certain you don’t need to install the Android SDK at all - you can just use the build server by running ./makebuildserver as I outline below.
Also before you start, if you want to contribute to the server project you should fork the F-Droid server project by going to gitlab.com/fdroid/fdroidserver and clicking Fork. When you’ve done that, the git clone command below will need to change to clone your own fork via SSH, instead of the HTTPS one cloning the main repo that is shown below. Do the same for the F-Droid data project, which holds the information about the packages in F-Droid. It’s the data project where you will want to make changes if you are submitting a package.
Run these commands:
# Prerequisites sudo apt-get install openjdk-8-jdk subversion git git-svn \ mercurial bzr virtualbox ruby ruby-dev vagrant python3 python3-paramiko \ python3-pil python3-pyasn1-modules python3-clint python3-vagrant vagrant plugin install vagrant-cachier ln -s ~/Android/Sdk/build-tools/23.0.2/aapt ~/Android/Sdk/platform-tools/ # Get the code cd ~/code git clone https://gitlab.com/fdroid/fdroidserver.git git clone https://gitlab.com/fdroid/fdroiddata.git echo 'export PATH="~/code/fdroidserver:$PATH"' >> ~/.profile source ~/.profile # Config cd fdroiddata cp ../fdroidserver/examples/config.py ./ chmod 0600 config.py echo 'sdk_path = "$HOME/Android/Sdk"' >> config.py # Set up Vagrant build box cd ../fdroidserver cp ./examples/makebuildserver.config.py ./ ./makebuildserver # Now wait several hours for this to finish # Build a package (the F-Droid client) just to check it works cd ../fdroiddata mkdir repo fdroid update --create-key fdroid readmeta # Should give no output if it worked fdroid build --server org.fdroid.fdroid
Make your own package
Below I’m using my own package, Rabbit Escape, as an example. Its Android code is inside rabbit-escape-ui-android/app, whereas many programs will just have it directly in a directory called “app”.
Rabbit Escape also builds non-Android-specific Java and other things during its build, so your package may be simpler.
cd ../fdroiddata fdroid import --url https://github.com/andybalaam/rabbit-escape \ --subdir rabbit-escape-ui-android/app
Now edit the new file that was created - in my case it was called metadata/net.artificialworlds.rabbitescape.txt.
I set the following info:
Categories: - Games License: GPL-2.0-or-later AuthorName: Andy Balaam and the Rabbit Escape developers AuthorEmail: firstname.lastname@example.org WebSite: http://artificialworlds.net/rabbit-escape SourceCode: https://github.com/andybalaam/rabbit-escape IssueTracker: https://github.com/andybalaam/rabbit-escape/issues AutoName: Rabbit Escape Summary: Lemmings-like puzzle/action game Description: | 140 levels of puzzling action! ... blah blah ... RepoType: git Repo: https://github.com/andybalaam/rabbit-escape Binaries: https://github.com/andybalaam/rabbit-escape/releases/download/v%v/rabbit-escape-%v.apk Builds: - versionName: '0.10.2' versionCode: 102 commit: v0.10.2 subdir: rabbit-escape-ui-android/app gradle: - paid build: cd ../.. && make android-pre-fdroid AutoUpdateMode: Version v%v UpdateCheckMode: Tags v\d+\.\d+(\.\d+)? CurrentVersion: 0.10.2 CurrentVersionCode: 102
For more info, see the F-Droid Build Metadata Reference.
And then checked it all worked with:
cd ../fdroiddata fdroid lint net.artificialworlds.rabbitescape fdroid readmeta fdroid checkupdates net.artificialworlds.rabbitescape fdroid rewritemeta net.artificialworlds.rabbitescape
When I got the version stuff right the checkupdates command printed:
INFO: Processing net.artificialworlds.rabbitescape... INFO: ...updating to version 0.10.1 (101) INFO: Finished.
Then I made sure it built OK:
fdroid build --server -v -l net.artificialworlds.rabbitescape
Actually, it didn’t work, and I decided I had to request a new package (sox) be installed in the build machine environment (in the fdroidserver project). The relevant commit is here: 19e372026. Actually though, after discussion with the F-Droid devs we agreed I’d be better off not using sox during the build, so I didn’t need this.
Side note: if you do end up needing to modify the build environment for F-Droid, make sure you delete the fdroiddata/buildserver directory when you re-try your build. That one had me stuck for a few days, with the old environment being used no matter what caches I cleared and vagrant commands I ran.
And now I was ready to request my package be included in F-Droid by committing and pushing the changes I had made to the fdroiddata project to my forked repo, and clicking the Merge Request button in the GitLab UI. My merge request is here: gitlab.com/fdroid/fdroiddata/merge_requests/1965