chiark / gitweb /
set up install/delete lists for "push" commands from server
authorHans-Christoph Steiner <hans@eds.org>
Tue, 16 Aug 2016 19:02:15 +0000 (21:02 +0200)
committerHans-Christoph Steiner <hans@eds.org>
Tue, 16 Aug 2016 19:02:15 +0000 (21:02 +0200)
It is now possible for the server operator to specify lists of apps that
must be installed or deleted on the client (aka "push installs).  If
the user has opted in, or the device is already setup to respond to
these requests, then fdroidclient will automatically install/delete
the packageNames listed.  This is protected by the same signing key
as the app index metadata.

It generates single XML elements with the data set in the attributes. This
keeps the XML compact and easily extensible, e.g. for adding versionCode,
signingKey, etc as attributes:

    <install packageName="com.fsck.k9"/>
    <install packageName="at.bitfire.davdroid"/>
    <delete packageName="com.facebook.orca"/>

Copyright: 2016 Blue Jay Wireless
Signed-off-by: Hans-Christoph Steiner <hans@eds.org>
closes #177

examples/config.py
fdroidserver/update.py
tests/run-tests

index d2c0105eb73b2bc98005870201f4240622d62e2f..d33ddfac484cd58924e1c1c035bf11f87faafcd4 100644 (file)
@@ -246,3 +246,21 @@ The repository of older versions of applications from the main demo repository.
 #     'Summary': 80,
 #     'Description': 4000,
 # }
+
+# It is possible for the server operator to specify lists of apps that
+# must be installed or deleted on the client (aka "push installs).  If
+# the user has opted in, or the device is already setup to respond to
+# these requests, then fdroidclient will automatically install/delete
+# the packageNames listed.  This is protected by the same signing key
+# as the app index metadata.
+#
+# install_list = {
+#     'at.bitfire.davdroid',
+#     'com.fsck.k9',
+#     'us.replicant',
+# }
+#
+# delete_list = {
+#     'com.facebook.orca',
+#     'com.android.vending',
+# }
index 07c8db3024422f34522f108ae971a96fe16da715..9f1ad43c0babf6b398ab6f036b9140c41dbcc178 100644 (file)
@@ -1,8 +1,10 @@
 #!/usr/bin/env python3
 #
 # update.py - part of the FDroid server tools
-# Copyright (C) 2010-2015, Ciaran Gultnieks, ciaran@ciarang.com
-# Copyright (C) 2013-2014 Daniel Martí <mvdan@mvdan.cc>
+# Copyright (C) 2016, Blue Jay Wireless
+# Copyright (C) 2014-2016, Hans-Christoph Steiner <hans@eds.org>
+# Copyright (C) 2010-2015, Ciaran Gultnieks <ciaran@ciarang.com>
+# Copyright (C) 2013-2014, Daniel Martí <mvdan@mvdan.cc>
 #
 # This program is free software: you can redistribute it and/or modify
 # it under the terms of the GNU Affero General Public License as published by
@@ -951,6 +953,21 @@ def make_index(apps, sortedids, apks, repodir, archive, categories):
     repoel.setAttribute("pubkey", extract_pubkey().decode('utf-8'))
     root.appendChild(repoel)
 
+    for command in ('install', 'delete'):
+        packageNames = []
+        key = command + '_list'
+        if key in config:
+            if isinstance(config[key], str):
+                packageNames = [config[key]]
+            elif all(isinstance(item, str) for item in config[key]):
+                packageNames = config[key]
+            else:
+                raise TypeError('only accepts strings, lists, and tuples')
+        for packageName in packageNames:
+            element = doc.createElement(command)
+            root.appendChild(element)
+            element.setAttribute('packageName', packageName)
+
     for appid in sortedids:
         app = apps[appid]
 
index c55319da8ada9f97841b0735585b4561b58b17f9..7e0eb2aaaf29a271e543a1e6f9a0e13243c17bb7 100755 (executable)
@@ -146,10 +146,14 @@ cd $REPOROOT
 $fdroid init
 cp -a $WORKSPACE/tests/metadata $WORKSPACE/tests/repo $REPOROOT/
 echo "accepted_formats = ['json', 'txt', 'xml', 'yml']" >> config.py
+echo "install_list = 'org.adaway'" >> config.py
+echo "delete_list = {'com.android.vending', 'com.facebook.orca',}" >> config.py
 $fdroid update --verbose
 test -e repo/index.xml
 test -e repo/index.jar
 grep -F '<application id=' repo/index.xml > /dev/null
+grep -F '<install packageName=' repo/index.xml > /dev/null
+grep -F '<delete packageName=' repo/index.xml > /dev/null
 
 
 #------------------------------------------------------------------------------#