mirror of
https://github.com/f-droid/fdroidserver.git
synced 2025-10-08 18:31:07 +03:00
regexs for getting packageName and versionCode from filenames
This is useful for parsing APK files, which can include packageName, versionCode, and optionally 7 char signing key ID (i.e. <sig>). This also can set the packageName and versionCoe for non APK files, so that it is easy to assign them to metadata files, and to allow for upgrades by setting the versionCode in the filename.
This commit is contained in:
parent
ceac6d25cb
commit
9471bf2731
4 changed files with 71 additions and 9 deletions
|
@ -853,14 +853,10 @@ def scan_repo_files(apkcache, repodir, knownapks, use_date_from_file=False):
|
|||
# the static ID is the SHA256 unless it is set in the metadata
|
||||
repo_file['packageName'] = shasum
|
||||
|
||||
n = name_utf8.rsplit('_', maxsplit=1)
|
||||
if len(n) == 2:
|
||||
packageName = n[0]
|
||||
versionCode = n[1].split('.')[0]
|
||||
if re.match('^-?[0-9]+$', versionCode) \
|
||||
and common.is_valid_package_name(n[0]):
|
||||
repo_file['packageName'] = packageName
|
||||
repo_file['versionCode'] = int(versionCode)
|
||||
m = common.STANDARD_FILE_NAME_REGEX.match(name_utf8)
|
||||
if m:
|
||||
repo_file['packageName'] = m.group(1)
|
||||
repo_file['versionCode'] = int(m.group(2))
|
||||
srcfilename = name + b'_src.tar.gz'
|
||||
if os.path.exists(os.path.join(repodir, srcfilename)):
|
||||
repo_file['srcname'] = srcfilename.decode('utf-8')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue