Skip to content

Draft: add keep-latest-script

Andreas Redmer requested to merge ar-/fdroid-data-2:keep-latest-script into master

Script Purpose: The purpose of this script is to automate the process of removing unnecessary version blocks from YAML files used in an F-Droid build server environment. It replaces the manual "keep-latest" procedure by removing all versions that have been added by the "checkupdates" process, between the last built version and the last upstream version.

Script Overview:

  1. The script reads information from the "stats/known_apks.txt" file to determine the last known version of each app.
  2. It checks if a YAML file exists for each app in the "metadata" directory.
  3. If a YAML file exists and the app doesn't have a "VercodeOperation" specified, it proceeds to remove unnecessary version blocks.
  4. It reads the YAML file to get the list of version codes.
  5. It identifies the last known version of the app from the "known_apks.txt" file and retrieves the last version code from the YAML file.
  6. Based on the last known version and the last version code, it determines which version blocks need to be removed.
  7. It removes the unnecessary version blocks from the YAML file.
  8. Finally, it prints a message indicating the metadata update for each app and the versions that were removed.

Functions Overview:

  • get_all_app_names(): Retrieves a list of all app names from the "known_apks.txt" file.
  • get_last_known_version_from_known_apks(app_name): Retrieves the last known version of an app from the "known_apks.txt" file.
  • has_vercode_operation(app_name): Checks if a YAML file for the app contains a "VercodeOperation".
  • get_all_version_codes_in_yaml_file(app_name): Retrieves all version codes from the YAML file for an app.
  • get_values_between(values, start, end): Filters values between two given endpoints from a list.
  • remove_version_from_yaml_file(app_name, version_code_to_remove): Removes unnecessary version blocks from the YAML file for an app.
  • main(): The main function that orchestrates the entire process.

This script streamlines the management of version blocks in the F-Droid build server environment, ensuring that only the necessary ("latest") versions are retained in the metadata files.

The script can be run like this:

tools/keep-latest.py

there is 1 pip requirement:

pip install pyyaml

Edited by Andreas Redmer

Merge request reports