fdroidserver.checkupdates module

Check for updates to applications.

fdroidserver.checkupdates.check_http(app: App) tuple[Optional[str], Optional[int]]

Check for a new version by looking at a document retrieved via HTTP.

The app’s UpdateCheckData field is used to provide the information required.

Parameters:
app

The App instance to check for updates for.

Returns:
version

The found versionName or None if the versionName should be ignored according to UpdateCheckIgnore.

vercode

The found versionCode or None if the versionCode should be ignored according to UpdateCheckIgnore.

Raises:
FDroidException

If UpdateCheckData is missing or is an invalid URL or if there is no match for the provided versionName or versionCode regex.

fdroidserver.checkupdates.check_repomanifest(app: App, branch: Optional[str] = None) tuple[str, int]

Check for a new version by looking at the AndroidManifest.xml at the HEAD of the source repo.

Whether this can be used reliably or not depends on the development procedures used by the project’s developers. Use it with caution, because it’s inappropriate for many projects.

Parameters:
app

The App instance to check for updates for.

branch

The VCS branch where to search for versionCode, versionName.

Returns:
versionName

The highest found versionName.

versionCode

The highest found versionCode.

Raises:
FDroidException

If no package id or no version information could be found.

fdroidserver.checkupdates.check_tags(app: App, pattern: str) tuple[str, int, str]

Check for a new version by looking at the tags in the source repo.

Whether this can be used reliably or not depends on the development procedures used by the project’s developers. Use it with caution, because it’s inappropriate for many projects.

Parameters:
app

The App instance to check for updates for.

pattern

The pattern a tag needs to match to be considered.

Returns:
versionName

The highest found versionName.

versionCode

The highest found versionCode.

ref

The Git reference, commit hash or tag name, of the highest found versionName, versionCode.

Raises:
MetaDataException

If this function is not suitable for the RepoType of the app or information is missing to perform this type of check.

FDroidException

If no matching tags or no information whatsoever could be found.

fdroidserver.checkupdates.checkout_appid_branch(appid)

Prepare the working branch named after the appid.

This sets up everything for checkupdates_app() to run and add commits. If there is an existing branch named after the appid, and it has commits from users other than the checkupdates-bot, then this will return False. Otherwise, it returns True.

The checkupdates-runner must set the committer email address in the git config. Then any commit with a committer or author that does not match that will be considered to have human edits. That email address is currently set in: https://gitlab.com/fdroid/checkupdates-runner/-/blob/1861899262a62a4ed08fa24e5449c0368dfb7617/.gitlab-ci.yml#L36

fdroidserver.checkupdates.checkupdates_app(app: App, auto: bool, commit: bool = False) None

Check for new versions and updated name of a single app.

Also write back changes to the metadata file and create a Git commit if requested.

Parameters:
app

The app to check for updates for.

Raises:
MetaDataException

If the app has an invalid UpdateCheckMode or AutoUpdateMode.

FDroidException

If no version information could be found, the current version is newer than the found version, auto-update was requested but an app has no CurrentVersionCode or (Git) commiting the changes failed.

fdroidserver.checkupdates.dirs_with_manifest(startdir: str)

Find directories containing a manifest file.

Yield all directories under startdir that contain any of the manifest files, and thus are probably an Android project.

Parameters:
startdir

Directory to be walked down for search

Yields:
pathpathlib.Path or None

A directory that contains a manifest file of an Android project, None if no directory could be found

fdroidserver.checkupdates.fetch_autoname(app: App, tag: str) Optional[str]

Fetch AutoName.

Get the to be displayed name of an app from the source code and adjust the App instance in case it is different name has been found.

Parameters:
app

The App instance to get the AutoName for.

tag

Tag to fetch AutoName at.

Returns:
commitmsg

Commit message about the name change. None in case checking for the name is disabled, a VCSException occured or no name could be found.

fdroidserver.checkupdates.get_changes_versus_ref(git_repo, ref, f)
fdroidserver.checkupdates.get_last_build_from_app(app: App) Build

Get the last build entry of an app.

fdroidserver.checkupdates.get_upstream_main_branch(git_repo)
fdroidserver.checkupdates.main()

Check for updates for one or more apps.

The behaviour of this function is influenced by the configuration file as well as command line parameters.

fdroidserver.checkupdates.operate_vercode(operation: str, vercode: int) int

Calculate a new versionCode from a mathematical operation.

Parameters:
operation

The operation to execute to get the new versionCode.

vercode

The versionCode for replacing “%c” in the operation.

Returns:
vercode

The new versionCode obtained by executing the operation.

Raises:
MetaDataException

If the operation is invalid.

fdroidserver.checkupdates.possible_subdirs(app: App)

Try to find a new subdir starting from the root build_dir.

Yields said subdir relative to the build dir if found, None otherwise.

Parameters:
app

The app to check for subdirs

Yields:
subdirpathlib.Path or None

A possible subdir, None if no subdir could be found

fdroidserver.checkupdates.prune_empty_appid_branches(git_repo=None, main_branch='main')

Remove empty branches from checkupdates-bot git remote.

fdroidserver.checkupdates.push_commits(branch_name='checkupdates', verbose=False)

Make git branch then push commits as merge request.

The appid is parsed from the actual file that was changed so that only the right branch is ever updated.

This uses the appid as the standard branch name so that there is only ever one open merge request per-app. If multiple apps are included in the branch, then ‘checkupdates’ is used as branch name. This is to support the old way operating, e.g. in batches.

This uses GitLab “Push Options” to create a merge request. Git Push Options are config data that can be sent via git push –push-option=… origin foo.

References

fdroidserver.checkupdates.status_update_json(processed: list, failed: dict) None

Output a JSON file with metadata about this run.

fdroidserver.checkupdates.try_init_submodules(app: App, last_build: Build, vcs: vcs)

Try to init submodules if the last build entry uses them.

They might have been removed from the app’s repo in the meantime, so if we can’t find any submodules we continue with the updates check. If there is any other error in initializing them then we stop the check.