mirror of
https://gitlab.com/fdroid/fdroidserver.git
synced 2024-11-19 21:30:10 +01:00
Don't include disabled apks in the index
This needs a rerun of `fdroid update --clean`. In case a build is disabled delete_disabled_builds takes care of deleting it from the repo. But this only works if the apk follows the normal name pattern. Otherwise it will stay in the folder and be picked up by process_apks and added to the index. Closes: #1002
This commit is contained in:
parent
40f761c482
commit
b07d23ff5c
@ -1415,7 +1415,7 @@ def scan_apk_androguard(apk, apkfile):
|
||||
|
||||
|
||||
def process_apk(apkcache, apkfilename, repodir, knownapks, use_date_from_apk=False,
|
||||
allow_disabled_algorithms=False, archive_bad_sig=False):
|
||||
allow_disabled_algorithms=False, archive_bad_sig=False, apps=None):
|
||||
"""Process the apk with the given filename in the given repo directory.
|
||||
|
||||
This also extracts the icons.
|
||||
@ -1468,6 +1468,12 @@ def process_apk(apkcache, apkfilename, repodir, knownapks, use_date_from_apk=Fal
|
||||
.format(apkfilename=apkfilename))
|
||||
return True, None, False
|
||||
|
||||
if apps:
|
||||
if apk['packageName'] in apps:
|
||||
for build in apps[apk['packageName']].get('Builds', []):
|
||||
if int(build['versionCode']) == apk['versionCode'] and build['disable']:
|
||||
return True, None, False
|
||||
|
||||
# Check for debuggable apks...
|
||||
if common.is_apk_and_debuggable(apkfile):
|
||||
logging.warning('{0} is set to android:debuggable="true"'.format(apkfile))
|
||||
@ -1560,7 +1566,7 @@ def process_apk(apkcache, apkfilename, repodir, knownapks, use_date_from_apk=Fal
|
||||
return False, apk, cachechanged
|
||||
|
||||
|
||||
def process_apks(apkcache, repodir, knownapks, use_date_from_apk=False):
|
||||
def process_apks(apkcache, repodir, knownapks, use_date_from_apk=False, apps=None):
|
||||
"""Process the apks in the given repo directory.
|
||||
|
||||
This also extracts the icons.
|
||||
@ -1596,7 +1602,7 @@ def process_apks(apkcache, repodir, knownapks, use_date_from_apk=False):
|
||||
apkfilename = apkfile[len(repodir) + 1:]
|
||||
ada = disabled_algorithms_allowed()
|
||||
(skip, apk, cachethis) = process_apk(apkcache, apkfilename, repodir, knownapks,
|
||||
use_date_from_apk, ada, True)
|
||||
use_date_from_apk, ada, True, apps)
|
||||
if skip:
|
||||
continue
|
||||
apks.append(apk)
|
||||
@ -2209,7 +2215,8 @@ def main():
|
||||
delete_disabled_builds(apps, apkcache, repodirs)
|
||||
|
||||
# Scan all apks in the main repo
|
||||
apks, cachechanged = process_apks(apkcache, repodirs[0], knownapks, options.use_date_from_apk)
|
||||
apks, cachechanged = process_apks(apkcache, repodirs[0], knownapks,
|
||||
options.use_date_from_apk, apps)
|
||||
|
||||
files, fcachechanged = scan_repo_files(apkcache, repodirs[0], knownapks,
|
||||
options.use_date_from_apk)
|
||||
@ -2272,7 +2279,8 @@ def main():
|
||||
|
||||
# Scan the archive repo for apks as well
|
||||
if len(repodirs) > 1:
|
||||
archapks, cc = process_apks(apkcache, repodirs[1], knownapks, options.use_date_from_apk)
|
||||
archapks, cc = process_apks(apkcache, repodirs[1], knownapks,
|
||||
options.use_date_from_apk, apps)
|
||||
if cc:
|
||||
cachechanged = True
|
||||
else:
|
||||
|
@ -1716,6 +1716,38 @@ class UpdateTest(unittest.TestCase):
|
||||
self.maxDiff = None
|
||||
self.assertEqual(apkaapt, apkandroguard)
|
||||
|
||||
def test_exclude_disabled_apks(self):
|
||||
testdir = tempfile.mkdtemp(
|
||||
prefix=inspect.currentframe().f_code.co_name, dir=self.tmpdir
|
||||
)
|
||||
os.chdir(testdir)
|
||||
os.mkdir('repo')
|
||||
testapk = os.path.join('repo', 'com.politedroid_6.apk')
|
||||
testapk_new = os.path.join('repo', 'Politedroid-1.5.apk')
|
||||
shutil.copy(os.path.join(self.basedir, testapk), testapk_new)
|
||||
|
||||
config = dict()
|
||||
fdroidserver.common.fill_config_defaults(config)
|
||||
config['ndk_paths'] = dict()
|
||||
fdroidserver.common.config = config
|
||||
fdroidserver.update.config = config
|
||||
|
||||
fdroidserver.common.options = Options
|
||||
fdroidserver.update.options = fdroidserver.common.options
|
||||
fdroidserver.update.options.clean = True
|
||||
|
||||
app = fdroidserver.metadata.App()
|
||||
app.id = 'com.politedroid'
|
||||
apps = {app.id: app}
|
||||
build = fdroidserver.metadata.Build()
|
||||
build.versionCode = 6
|
||||
build.disable = "disabled"
|
||||
app['Builds'] = [build]
|
||||
|
||||
knownapks = fdroidserver.common.KnownApks()
|
||||
apks, cachechanged = fdroidserver.update.process_apks({}, 'repo', knownapks, False, apps)
|
||||
self.assertEqual([], apks)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
os.chdir(os.path.dirname(__file__))
|
||||
|
Loading…
Reference in New Issue
Block a user