Add incremental support and update docs

This commit is contained in:
Tom Marshall 2020-08-07 21:58:19 +02:00
parent 21425b4b3a
commit 5af124c277
2 changed files with 34 additions and 14 deletions

View File

@ -19,13 +19,18 @@
## Usage
The script expects OTA files to be named as follows:
_project_\__device_-ota-_version_-_buildtype_-_incremental_.zip
Full OTA files:
* _project_\__device_-ota-_version_-_buildtype_-_incremental_.zip
Incremental OTA files:
* _project_\__device_-ota-_version_-_buildtype_-_base_\__incremental_.zip
Where:
* _project_ is the project/ROM name, eg. "lineage".
* _device_ is the device name, eg. "mako".
* _version_ is the project/ROM version, eg. "16.0".
* _buildtype_ is the buildtype, eg. "unofficial".
* _base_ is the base incremental version (the starting build).
* _incremental_ is the incremental version, eg. "eng.user.20200807.162000".
The default OTA and target-files file names include all of these fields
@ -33,7 +38,9 @@ except _incremental_. This is the value of `ro.build.version.incremental`
in the system build properties. It is different from `ro.build.date.utc`.
They are __not__ interchangeable.
Example: lineage_mako-ota-16.0-unofficial-eng.user.20200807.162000.zip
Examples:
* lineage_mako-ota-16.0-unofficial-eng.user.20200807.162000.zip
* lineage_mako-ota-16.0-unofficial-eng.user.20200806.162000_eng.user.20200807.162000.zip
The OTA directory may contain subdirectories of arbitrary depth.

View File

@ -80,12 +80,19 @@ def filename_properties(pathname):
if fields[1] != 'ota':
raise ValueError("Not an OTA file")
(project, device) = fields[0].split('_', 1)
incr_fields = fields[4].split('_')
if len(incr_fields) > 2:
raise ValueError("Incorrect incremental value")
props = dict()
props['project'] = project
props['device'] = device
props['version'] = fields[2]
props['buildtype'] = fields[3]
props['incremental'] = fields[4]
if len(incr_fields) == 1:
props['incremental'] = incr_fields[0]
else:
props['incrbase'] = incr_fields[0]
props['incremental'] = incr_fields[1]
return props
@ -172,17 +179,23 @@ def find_roms(device=None, buildtype=None, incremental=None):
if buildtype and props['buildtype'] != buildtype:
continue
if incremental:
try:
req_incr_stamp = incremental_stamp(incremental)
except ValueError:
continue
try:
ota_incr_stamp = incremental_stamp(props['incremental'])
except ValueError:
dbg("Failed to parse cache incremental field")
continue
if ota_incr_timestamp <= req_incr_timestamp:
continue
if 'incrbase' in props:
# Incremental
if incremental != props['incrbase']:
continue
else:
# Full
try:
req_incr_stamp = incremental_stamp(incremental)
except ValueError:
continue
try:
ota_incr_stamp = incremental_stamp(props['incremental'])
except ValueError:
dbg("Failed to parse cache incremental field")
continue
if ota_incr_stamp <= req_incr_stamp:
continue
roms.append(v)