GitHub Actions 101 Continued: How to Self-Host a F-Droid Repo

Prequel: GitHub Actions 101

Preface

As RetroArch still hasn’t made its way to F-Droid as of October 2022, I decide to give GitHub Actions another try.

Idea

Same as the previous one. I’ll use fdroid and follow its setup instruction .

Progress

On my DevuanWSL, init the project:

# Make sure to install the 2.x.x version, although as long as you're not using oldstable, it should be fine
# https://tracker.debian.org/pkg/fdroidserver
apt-cache policy fdroidserver
sudo apt install fdroidserver

git clone --depth=1 https://github.com/xarantolus/fdroid
cd fdroid
# Watch out, don't delete the repo itself...
rm -rf ./fdroid
rm -rf .git
git init

mkdir ./fdroid
cd ./fdroid
# It will complain `No Android SDK`, but it's fine if you don't use it to build app
fdroid init

Change fdroid/config.yml as instructed:

repo_url: https://raw.githubusercontent.com/Vinfall/fdroid/main/fdroid/repo
#repo_url: https://fdroid.vinfall.com
repo_name: RetroArch Nightly F-Droid Repo (unofficial)
repo_description: >-
  This is an UNOFFICIAL RetroArch nightly repository compatible with F-Droid.
  Applications in this repository are official binaries built by the original
  application developers.  

archive_older: 0

Add repo secrets (NOT env secrets):

# Save the output as `CONFIG_YML` repo secret
base64 config.yml
# Save the output as `KEYSTORE_P12` repo secret
base64 keystore.p12

Go here to grab a personal access token WITHOUT any scopes and preferably No expiration, save it as GH_ACCESS_TOKEN repo secret.

Then edit apps.yaml as instructed. For RetroArch specifically, I get most of the content from F-Droid RFP recipe and F-Droid official Build Metadata Reference . I add a new Multimedia category as RetroArch does offer content management for images, music, videos etc.

Also, the really obsolete LibRetro F-Droid repo offers an insight for how the files should structure. I download icons/retroarch.png and renamed it to icons/icon.png(so I don’t have to explicitly specify its name in config.yml), downloaded the app from Buildbot and placed it under repo.

I don’t know why, but running fdroid update -c always throws WARNING: repo_icon "repo/icons/icon.png" does not exist! Check "config.yml". even if I have repo/icons/icon.png and even metadata/icon.png in place. I figure it out, so why does the warning says to place it in repo/icons when I need to place it just in repo?

After that, the setup doc forgets to mention an important command:

cd fdroid
fdroid update --create-metadata
# Or in short
fdroid update -c

This would generate the necessary metadata or fdroidserver would always complain about missing index-v1.json, index-v1.jar… It took me almost an hour to find out, sigh.

And future update is just add new apks to repo, run fdroid update -c , push repo/archive to remote, and it’s done.

F-Droid repo running on localhost

When an user copy the URL/scan the QR code, the fingerprint is appended automatically.

Ok, now everything should be fine, except that I’ll have to enable Git LFS (by running git lfs track repo/*apk) to upload the apk and really hosting it would be abusing GitHub’s ToS I’m afraid.

So I failed in the sense of hosting RetroArch nightly F-Droid repo on GitHub, fully automated (after initial setup) by GitHub Action.

But I set up a real F-Droid repo on VPS the next day, and the process is pretty much the same. Just make sure to generate the key on local machine and use fdroid deploy to rsync files (so it can never get exposed via misconfigured web server). The update process is also easy to automate (script + cron or just CI).

A sample repo is available on GitHub.

I hope RetroArch team could get it integrated into their CI and put the files in https://buildbot.libretro.com/nightly/android/, this way everyone is happy.

References

Vinfall's Geekademy

VENI VIDI VICI


Escape before it's too late.


Created 2022-10-11
Updated 2022-10-12
Contain 651 words

#ci #dev #game #github #linux #manual #server