Difference between revisions of "Setup an FDroid App Repo"

From F-Droid
Jump to: navigation, search
(modernize and simplify)
(moved to https://f-droid.org/docs/Setup_an_FDroid_App_Repo)
 
Line 1: Line 1:
F-Droid.org is the default package repository (repo) in the FDroid client, but it is not the only possibility.  Anyone can create their own repo, and users can control which repos their client is using, including even disabling the default f-droid.org repo.  This model is modeled somewhat after the [https://www.debian.org Debian GNU/Linux] distro.  Like Debian and Ubuntu, you can also setup your own repos for anyone to use.
+
moved to https://f-droid.org/docs/Setup_an_FDroid_App_Repo
 
+
This is a quick HOWTO to setup your own repository wherever you want to host it.  It is somewhat technical, you will use the terminal, but you don't need to be a terminal expert to follow along.  First, this HOWTO will walk through setting up a test repo that is not very secure.  Then it will walk through setting up a repo for real world use, with the signing key on a separate machine from the public webserver.  Before you start, you need to get [https://f-droid.org/wiki/page/Installing_the_Server/Repo_Tools the <code>fdroidserver</code> tools] and a webserver.  For the webserver, this HOWTO will use <em>nginx</em> since its lightweight, but any will do if you already have one running.
+
 
+
<pre>
+
sudo apt-get install nginx
+
</pre>
+
 
+
In the case of this HOWTO, we're going to setup a "[https://f-droid.org/manual/fdroid.html#Simple-Binary-Repository Simple Binary Repository]" to host a collection of APKs.  The repo will be set up in the recommended <code>fdroid/</code> subdirectory.  This gives the <code>fdroid</code> tool its own directory to work in, and makes the repo URL clearly marked as an FDroid repo.  Also, the F-Droid client will automatically search for a repository at the "/fdroid/repo" path if the user only the server (e.g. "https://f-droid.org").  Let's give our normal user control over this subdirectory in the web root so that we don't need to run the F-Droid tools as root (with <em>nginx</em>, the webroot is <code>/usr/share/nginx/www</code>, it is different for other webservers):
+
 
+
<pre>
+
sudo mkdir /usr/share/nginx/www/fdroid
+
sudo chown -R $USER /usr/share/nginx/www/fdroid
+
cd /usr/share/nginx/www/fdroid
+
fdroid init
+
</pre>
+
 
+
Now put your APK files into <code>/usr/share/nginx/www/fdroid/repo</code> and you are ready to run the commands to build the repo (if <code>fdroid init</code> cannot find your Android SDK in <code>/opt/android-sdk</code> or <code>$ANDROID_HOME</code>, it will prompt you for the path):
+
 
+
<pre>
+
cd /usr/share/nginx/www/fdroid
+
cp /path/to/*.apk /usr/share/nginx/www/fdroid/repo/
+
fdroid update --create-metadata
+
</pre>
+
 
+
Voila!  Now you have a working F-Droid Repo!  Remember, this is **just a test** setup, remember to move on to the [https://f-droid.org/wiki/page/Setup_an_FDroid_App_Repo#Real_World_Setup Real World Setup] after this!  Add your new repo to an F-Droid client on your Android device to test it out.  That is done in the <strong>Manage Repos</strong> screen available from the menu.  Your repo URL will be the hostname or IP address of your machine with <code>/fdroid/repo/</code> added to the end of it, i.e. <code>https://mysecureserver.com/fdroid/repo/</code> or <code>http://192.168.2.53/fdroid/repo/</code>.  You can temporarily uncheck the official repos to easily see what F-Droid found in your new repo.
+
 
+
 
+
<h2>Customization</h2>
+
 
+
You can also customize your repo by editing the config file. Be sure to use a programming text editor, like <code>editor /usr/share/nginx/www/fdroid/config.py</code>.  In the config file, you can set the name of the repo, the description, the icon, paths to specific versions of the build tools, links to a related wiki, and whether to keep stats.  Here's the basic repo description block:
+
 
+
<pre>
+
repo_url = "http://guardianproject.info/fdroid/repo"
+
repo_name = "My Local Repo"
+
repo_icon = "GP_Logo_hires.png"
+
repo_description = """
+
This is a local test repository of Hans-Christoph Steiner <hans@guardianproject.info>.  It is a repository of Guardian Project apps.
+
"""
+
</pre>
+
 
+
To put your icon into your repo, choose a PNG image to put in your repo.  The PNG goes in <code>/usr/share/nginx/www/fdroid/</code>, the file can be named whatever you want (by default its <code>fdroid-icon.png</code>).  If you change the name from the default, be sure to update <code>repo_icon</code> and <code>archive_icon</code> in <code>/usr/share/nginx/www/fdroid/config.py</code>.
+
 
+
A final note about security: this setup is not a good setup for a real public repo, instead it is a quick and easy way to test out FDroid.  At the very least, when generating the repo in place, make sure that <code>config.py</code> is not accessible via the web, since it contains passwords.  If the file permissions are correct (e.g. <code>chmod 0600 config.py</code>), then <code>config.py</code> will not be readable by the webserver.
+
 
+
 
+
<h2>App Metadata</h2>
+
 
+
You can control lots of aspects of how an app is represented in your repo by editing the app's metadata.  Running <code>fdroid update --create-metadata</code> creates stub files for you, in order to have a working repo.  Then you can edit those files to add a description, donation links, bug tracker, license, home page, etc. See [https://f-droid.org/manual/fdroid.html#Metadata the manual] for more info on what all the options are.
+
 
+
<code>Current Version Code</code> provides a handy way to deploy beta releases in the same stream as your full releases.  You can set <code>Current Version Code</code> to your current stable release, then add APKs to your repo.  Users will only be updated automatically to the version code you specify.  Any APKs for a given app in your repo that have a newer version code will not be automatically installed.  Instead, the user can see them in the app detail view in the client, and can manually install them.
+
 
+
 
+
<h1>Real World Setup</h1>
+
 
+
Now that you have a working repo, it is straightforward to create a real world setup.  Generating a repo in place like we did above is very easy, that is why this HOWTO started there, but it is not as secure as it should be if your repo is going to be your main distribution point.  For example, the repo signing keys should not ever be on a public server.
+
 
+
To improve this situation, generate the repo on a non-public machine like your laptop, keeping <code>config.py</code> and the keystore only on that machine (remember to make backups!).  Then use <code>fdroid server update</code> to publish the changes to your repo on a separate server via ssh.  So start a new repo from scratch on your non-public machine:
+
 
+
<pre>
+
mkdir ~/fdroid
+
cd ~/fdroid
+
fdroid init
+
cp /path/to/*.apk ~/fdroid/repo/
+
fdroid update --create-metadata
+
emacs config.py  # add the serverwebroot, etc.
+
fdroid server update -v
+
</pre>
+
 
+
Now edit <code>config.py</code> to set <code>serverwebroot</code>, it is in the form of a standard SCP file destination.  Then <code>fdroid server update</code> will do the publishing via rsync over ssh.  So both computers will have to have ssh and rsync installed and setup. You can also use your own existing signing key rather than the one generated by <code>fdroid init</code>, just edit <code>repo_keyalias</code>, <code>keystore</code>, <code>keystorepass</code>, <code>keypass</code>, and <code>keydname</code> in <code>~/fdroid/config.py</code>
+

Latest revision as of 14:04, 17 October 2017

moved to https://f-droid.org/docs/Setup_an_FDroid_App_Repo