fdroidserver.index module¶
- fdroidserver.index.add_mirrors_to_repodict(repo_section, repodict)¶
Convert config into final dict of mirror metadata for the repo.
Internally and in index-v2, mirrors is a list of dicts, but it can be specified in the config as a string or list of strings. Also, index v0 and v1 use a list of URL strings as the data structure.
The first entry is traditionally the primary mirror and canonical URL. ‘mirrors’ should not be present in the index if there is only the canonical URL, and no other mirrors.
The metadata items for each mirror entry are sorted by key to ensure minimum diffs in the index files.
- fdroidserver.index.convert_datetime(obj)¶
- fdroidserver.index.convert_version(version, app, repodir)¶
Convert the internal representation of Builds: into index-v2 versions.
The diff algorithm of index-v2 uses null/None to mean a field to be removed, so this function handles any Nones that are in the metadata file.
- fdroidserver.index.dict_diff(source, target)¶
- fdroidserver.index.download_repo_index(url_str, etag=None, verify_fingerprint=True, timeout=600)¶
Download and verifies index v1 file, then returns its data.
Use the versioned functions to be sure you are getting the expected data format.
- fdroidserver.index.download_repo_index_v1(url_str, etag=None, verify_fingerprint=True, timeout=600)¶
Download and verifies index v1 file, then returns its data.
Downloads the repository index from the given :param url_str and verifies the repository’s fingerprint if :param verify_fingerprint is not False.
- Returns:
- A tuple consisting of:
The index in JSON v1 format or None if the index did not change
The new eTag as returned by the HTTP request
- Raises:
- VerificationException() if the repository could not be verified
- fdroidserver.index.download_repo_index_v2(url_str, etag=None, verify_fingerprint=True, timeout=600)¶
Download and verifies index v2 file, then returns its data.
Downloads the repository index from the given :param url_str and verifies the repository’s fingerprint if :param verify_fingerprint is not False. In order to verify the data, the fingerprint must be provided as part of the URL.
- Returns:
- A tuple consisting of:
The index in JSON v2 format or None if the index did not change
The new eTag as returned by the HTTP request
- Raises:
- VerificationException() if the repository could not be verified
- fdroidserver.index.extract_pubkey()¶
Extract and return the repository’s public key from the keystore.
- Returns:
- public key in hex
- repository fingerprint
- fdroidserver.index.get_index_from_jar(jarfile, fingerprint=None, allow_deprecated=False)¶
Return the data, public key and fingerprint from an index JAR with one JSON file.
The F-Droid index files always contain a single data file and a JAR Signature. Since index-v1, the data file is always JSON. That single data file is named the same as the JAR file.
- Parameters:
- fingerprint is the SHA-256 fingerprint of signing key. Only
hex digits count, all other chars will can be discarded.
- Raises:
- VerificationException() if the repository could not be verified
- fdroidserver.index.get_mirror_service_urls(url)¶
Get direct URLs from git service for use by fdroidclient.
Via ‘servergitmirrors’, fdroidserver can create and push a mirror to certain well known git services like GitLab or GitHub. This will always use the ‘master’ branch since that is the default branch in git. The files are then accessible via alternate URLs, where they are served in their raw format via a CDN rather than from git.
Both of the GitLab URLs will work with F-Droid, but only the GitLab Pages will work in the browser This is because the “raw” URLs are not served with the correct mime types, so any index.html which is put in the repo will not be rendered. Putting an index.html file in the repo root is a common way for to make information about the repo available to end user.
- fdroidserver.index.get_public_key_from_jar(jar)¶
Get the public key and its fingerprint from a JAR file.
- Parameters:
- jar
a zipfile.ZipFile object
- Returns:
- the public key from the jar and its fingerprint
- Raises:
- VerificationException() if the JAR was not signed exactly once
- fdroidserver.index.make(apps, apks, repodir, archive)¶
Generate the repo index files.
This requires properly initialized options and config objects.
- Parameters:
- apps
OrderedDict of apps to go into the index, each app should have at least one associated apk
- apks
list of apks to go into the index
- repodir
the repo directory
- archive
True if this is the archive repo, False if it’s the main one.
- fdroidserver.index.make_v0(apps, apks, repodir, repodict, requestsdict, fdroid_signing_key_fingerprints)¶
Aka index.jar aka index.xml.
- fdroidserver.index.make_v1(apps, packages, repodir, repodict, requestsdict, fdroid_signing_key_fingerprints)¶
- fdroidserver.index.make_v2(apps, packages, repodir, repodict, requestsdict, fdroid_signing_key_fingerprints, archive)¶
- fdroidserver.index.make_website(apps, repodir, repodict)¶
- fdroidserver.index.package_metadata(app, repodir)¶
- fdroidserver.index.v1_sort_packages(packages, fdroid_signing_key_fingerprints)¶
Sort the supplied list to ensure a deterministic sort order for package entries in the index file.
This sort-order also expresses installation preference to the clients. (First in this list = first to install)
- Parameters:
- packages
list of packages which need to be sorted before but into index file.
- fdroidserver.index.v2_repo(repodict, repodir, archive)¶