mirror of
https://github.com/f-droid/fdroidserver.git
synced 2025-11-05 06:50:29 +03:00
Merge branch 'keep_cv' into 'master'
keep CVC of an app out of the archive Closes #385 See merge request fdroid/fdroidserver!701
This commit is contained in:
commit
619ccb8d5a
3 changed files with 75 additions and 22 deletions
|
|
@ -117,6 +117,10 @@ def get_all_icon_dirs(repodir):
|
||||||
yield get_icon_dir(repodir, density)
|
yield get_icon_dir(repodir, density)
|
||||||
|
|
||||||
|
|
||||||
|
def disabled_algorithms_allowed():
|
||||||
|
return options.allow_disabled_algorithms or config['allow_disabled_algorithms']
|
||||||
|
|
||||||
|
|
||||||
def update_wiki(apps, sortedids, apks):
|
def update_wiki(apps, sortedids, apks):
|
||||||
"""Update the wiki
|
"""Update the wiki
|
||||||
|
|
||||||
|
|
@ -460,7 +464,7 @@ def get_cache():
|
||||||
|
|
||||||
"""
|
"""
|
||||||
apkcachefile = get_cache_file()
|
apkcachefile = get_cache_file()
|
||||||
ada = options.allow_disabled_algorithms or config['allow_disabled_algorithms']
|
ada = disabled_algorithms_allowed()
|
||||||
if not options.clean and os.path.exists(apkcachefile):
|
if not options.clean and os.path.exists(apkcachefile):
|
||||||
with open(apkcachefile) as fp:
|
with open(apkcachefile) as fp:
|
||||||
apkcache = json.load(fp, object_pairs_hook=collections.OrderedDict)
|
apkcache = json.load(fp, object_pairs_hook=collections.OrderedDict)
|
||||||
|
|
@ -1598,7 +1602,7 @@ def process_apks(apkcache, repodir, knownapks, use_date_from_apk=False):
|
||||||
apks = []
|
apks = []
|
||||||
for apkfile in sorted(glob.glob(os.path.join(repodir, '*.apk'))):
|
for apkfile in sorted(glob.glob(os.path.join(repodir, '*.apk'))):
|
||||||
apkfilename = apkfile[len(repodir) + 1:]
|
apkfilename = apkfile[len(repodir) + 1:]
|
||||||
ada = options.allow_disabled_algorithms or config['allow_disabled_algorithms']
|
ada = disabled_algorithms_allowed()
|
||||||
(skip, apk, cachethis) = process_apk(apkcache, apkfilename, repodir, knownapks,
|
(skip, apk, cachethis) = process_apk(apkcache, apkfilename, repodir, knownapks,
|
||||||
use_date_from_apk, ada, True)
|
use_date_from_apk, ada, True)
|
||||||
if skip:
|
if skip:
|
||||||
|
|
@ -1823,12 +1827,20 @@ def archive_old_apks(apps, apks, archapks, repodir, archivedir, defaultkeepversi
|
||||||
|
|
||||||
def filter_apk_list_sorted(apk_list):
|
def filter_apk_list_sorted(apk_list):
|
||||||
res = []
|
res = []
|
||||||
|
currentVersionApk = None
|
||||||
for apk in apk_list:
|
for apk in apk_list:
|
||||||
if apk['packageName'] == appid:
|
if apk['packageName'] == appid:
|
||||||
|
if apk['versionCode'] == common.version_code_string_to_int(app.CurrentVersionCode):
|
||||||
|
currentVersionApk = apk
|
||||||
|
continue
|
||||||
res.append(apk)
|
res.append(apk)
|
||||||
|
|
||||||
# Sort the apk list by version code. First is highest/newest.
|
# Sort the apk list by version code. First is highest/newest.
|
||||||
return sorted(res, key=lambda apk: apk['versionCode'], reverse=True)
|
sorted_list = sorted(res, key=lambda apk: apk['versionCode'], reverse=True)
|
||||||
|
if currentVersionApk:
|
||||||
|
# Insert apk which corresponds to currentVersion at the front
|
||||||
|
sorted_list.insert(0, currentVersionApk)
|
||||||
|
return sorted_list
|
||||||
|
|
||||||
for appid, app in apps.items():
|
for appid, app in apps.items():
|
||||||
|
|
||||||
|
|
@ -1840,26 +1852,28 @@ def archive_old_apks(apps, apks, archapks, repodir, archivedir, defaultkeepversi
|
||||||
logging.debug(_("Checking archiving for {appid} - apks:{integer}, keepversions:{keep}, archapks:{arch}")
|
logging.debug(_("Checking archiving for {appid} - apks:{integer}, keepversions:{keep}, archapks:{arch}")
|
||||||
.format(appid=appid, integer=len(apks), keep=keepversions, arch=len(archapks)))
|
.format(appid=appid, integer=len(apks), keep=keepversions, arch=len(archapks)))
|
||||||
|
|
||||||
current_app_apks = filter_apk_list_sorted(apks)
|
all_app_apks = filter_apk_list_sorted(apks + archapks)
|
||||||
if len(current_app_apks) > keepversions:
|
|
||||||
# Move back the ones we don't want.
|
|
||||||
for apk in current_app_apks[keepversions:]:
|
|
||||||
move_apk_between_sections(repodir, archivedir, apk)
|
|
||||||
archapks.append(apk)
|
|
||||||
apks.remove(apk)
|
|
||||||
|
|
||||||
current_app_archapks = filter_apk_list_sorted(archapks)
|
# determine which apks to keep in repo
|
||||||
if len(current_app_apks) < keepversions and len(current_app_archapks) > 0:
|
keep = []
|
||||||
kept = 0
|
for apk in all_app_apks:
|
||||||
# Move forward the ones we want again, except DisableAlgorithm
|
if len(keep) == keepversions:
|
||||||
for apk in current_app_archapks:
|
break
|
||||||
if 'DisabledAlgorithm' not in apk['antiFeatures']:
|
if 'antiFeatures' not in apk:
|
||||||
move_apk_between_sections(archivedir, repodir, apk)
|
keep.append(apk)
|
||||||
archapks.remove(apk)
|
elif 'DisabledAlgorithm' not in apk['antiFeatures'] or disabled_algorithms_allowed():
|
||||||
apks.append(apk)
|
keep.append(apk)
|
||||||
kept += 1
|
|
||||||
if kept == keepversions:
|
# actually move apks to the target section
|
||||||
break
|
for apk in all_app_apks:
|
||||||
|
if apk in apks and apk not in keep:
|
||||||
|
apks.remove(apk)
|
||||||
|
archapks.append(apk)
|
||||||
|
move_apk_between_sections(repodir, archivedir, apk)
|
||||||
|
elif apk in archapks and apk in keep:
|
||||||
|
archapks.remove(apk)
|
||||||
|
apks.append(apk)
|
||||||
|
move_apk_between_sections(archivedir, repodir, apk)
|
||||||
|
|
||||||
|
|
||||||
def move_apk_between_sections(from_dir, to_dir, apk):
|
def move_apk_between_sections(from_dir, to_dir, apk):
|
||||||
|
|
|
||||||
Binary file not shown.
|
|
@ -387,6 +387,21 @@ if ! which apksigner; then
|
||||||
test -e archive/com.politedroid_5.apk
|
test -e archive/com.politedroid_5.apk
|
||||||
! test -e archive/com.politedroid_6.apk
|
! test -e archive/com.politedroid_6.apk
|
||||||
test -e repo/com.politedroid_6.apk
|
test -e repo/com.politedroid_6.apk
|
||||||
|
|
||||||
|
echo "set an earlier version as CVC and test that it's the only one not archived"
|
||||||
|
$sed -i.tmp 's,^Current Version Code:6,Current Version Code:5,' metadata/com.politedroid.txt
|
||||||
|
$fdroid update --pretty --nosign
|
||||||
|
test `grep '<package>' archive/index.xml | wc -l` -eq 3
|
||||||
|
test `grep '<package>' repo/index.xml | wc -l` -eq 1
|
||||||
|
grep -F com.politedroid_3.apk archive/index.xml
|
||||||
|
grep -F com.politedroid_4.apk archive/index.xml
|
||||||
|
grep -F com.politedroid_5.apk repo/index.xml
|
||||||
|
grep -F com.politedroid_6.apk archive/index.xml
|
||||||
|
test -e archive/com.politedroid_3.apk
|
||||||
|
test -e archive/com.politedroid_4.apk
|
||||||
|
test -e repo/com.politedroid_5.apk
|
||||||
|
! test -e repo/com.politedroid_6.apk
|
||||||
|
test -e archive/com.politedroid_6.apk
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -540,6 +555,30 @@ if ! which apksigner; then
|
||||||
test -e repo/com.politedroid_6.apk
|
test -e repo/com.politedroid_6.apk
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# test unarchiving when disabled_algorithms are allowed again
|
||||||
|
echo 'allow_disabled_algorithms = True' >> config.py
|
||||||
|
$fdroid update --pretty --nosign
|
||||||
|
test `grep '<package>' archive/index.xml | wc -l` -eq 2
|
||||||
|
test `grep '<package>' repo/index.xml | wc -l` -eq 6
|
||||||
|
grep -F com.politedroid_3.apk archive/index.xml
|
||||||
|
grep -F com.politedroid_4.apk repo/index.xml
|
||||||
|
grep -F com.politedroid_5.apk repo/index.xml
|
||||||
|
grep -F com.politedroid_6.apk repo/index.xml
|
||||||
|
grep -F org.bitbucket.tickytacky.mirrormirror_1.apk archive/index.xml
|
||||||
|
grep -F org.bitbucket.tickytacky.mirrormirror_2.apk repo/index.xml
|
||||||
|
grep -F org.bitbucket.tickytacky.mirrormirror_3.apk repo/index.xml
|
||||||
|
grep -F org.bitbucket.tickytacky.mirrormirror_4.apk repo/index.xml
|
||||||
|
! grep -F urzip-badsig.apk repo/index.xml
|
||||||
|
! grep -F urzip-badsig.apk archive/index.xml
|
||||||
|
test -e archive/com.politedroid_3.apk
|
||||||
|
test -e repo/com.politedroid_4.apk
|
||||||
|
test -e repo/com.politedroid_5.apk
|
||||||
|
test -e repo/com.politedroid_6.apk
|
||||||
|
test -e archive/org.bitbucket.tickytacky.mirrormirror_1.apk
|
||||||
|
test -e repo/org.bitbucket.tickytacky.mirrormirror_2.apk
|
||||||
|
test -e repo/org.bitbucket.tickytacky.mirrormirror_3.apk
|
||||||
|
test -e repo/org.bitbucket.tickytacky.mirrormirror_4.apk
|
||||||
|
test -e archive/urzip-badsig.apk
|
||||||
|
|
||||||
#------------------------------------------------------------------------------#
|
#------------------------------------------------------------------------------#
|
||||||
echo_header 'rename apks with `fdroid update --rename-apks`, --nosign for speed'
|
echo_header 'rename apks with `fdroid update --rename-apks`, --nosign for speed'
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue