mirror of
https://gitlab.com/fdroid/fdroidserver.git
synced 2024-10-02 09:10:11 +02:00
[checkupdates] Exit 1 in case of errors
This commit is contained in:
parent
e19a66bec6
commit
a2db8f4a62
@ -487,8 +487,7 @@ def checkupdates_app(app):
|
|||||||
msg = 'Checking disabled'
|
msg = 'Checking disabled'
|
||||||
noverok = True
|
noverok = True
|
||||||
else:
|
else:
|
||||||
version = None
|
raise MetaDataException(_('Invalid UpdateCheckMode: {mode}').format(mode=mode))
|
||||||
msg = 'Invalid update check method'
|
|
||||||
|
|
||||||
if version and vercode and app.VercodeOperation:
|
if version and vercode and app.VercodeOperation:
|
||||||
if not common.VERCODE_OPERATION_RE.match(app.VercodeOperation):
|
if not common.VERCODE_OPERATION_RE.match(app.VercodeOperation):
|
||||||
@ -513,7 +512,7 @@ def checkupdates_app(app):
|
|||||||
else:
|
else:
|
||||||
logging.warning(logmsg)
|
logging.warning(logmsg)
|
||||||
elif vercode == app.CurrentVersionCode:
|
elif vercode == app.CurrentVersionCode:
|
||||||
logging.info("...up to date")
|
logging.debug("...up to date")
|
||||||
elif int(vercode) > int(app.CurrentVersionCode):
|
elif int(vercode) > int(app.CurrentVersionCode):
|
||||||
logging.debug("...updating - old vercode={0}, new vercode={1}".format(
|
logging.debug("...updating - old vercode={0}, new vercode={1}".format(
|
||||||
app.CurrentVersionCode, vercode))
|
app.CurrentVersionCode, vercode))
|
||||||
@ -521,9 +520,11 @@ def checkupdates_app(app):
|
|||||||
app.CurrentVersionCode = str(int(vercode))
|
app.CurrentVersionCode = str(int(vercode))
|
||||||
updating = True
|
updating = True
|
||||||
else:
|
else:
|
||||||
logging.info("Refusing to auto update, since the current version is newer")
|
raise FDroidException(
|
||||||
logging.debug("...old vercode={0}, new vercode={1}".format(
|
_('current version is newer: old vercode={old}, new vercode={new}').format(
|
||||||
app.CurrentVersionCode, vercode))
|
old=app.CurrentVersionCode, new=vercode
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
commitmsg = fetch_autoname(app, tag)
|
commitmsg = fetch_autoname(app, tag)
|
||||||
|
|
||||||
@ -536,7 +537,9 @@ def checkupdates_app(app):
|
|||||||
if options.auto:
|
if options.auto:
|
||||||
mode = app.AutoUpdateMode
|
mode = app.AutoUpdateMode
|
||||||
if not app.CurrentVersionCode:
|
if not app.CurrentVersionCode:
|
||||||
logging.warning("Can't auto-update app with no CurrentVersionCode: " + app.id)
|
raise MetaDataException(
|
||||||
|
_("Can't auto-update app with no CurrentVersionCode")
|
||||||
|
)
|
||||||
elif mode in ('None', 'Static'):
|
elif mode in ('None', 'Static'):
|
||||||
pass
|
pass
|
||||||
elif mode.startswith('Version'):
|
elif mode.startswith('Version'):
|
||||||
@ -557,7 +560,11 @@ def checkupdates_app(app):
|
|||||||
latest = build
|
latest = build
|
||||||
|
|
||||||
if int(latest.versionCode) > int(app.CurrentVersionCode):
|
if int(latest.versionCode) > int(app.CurrentVersionCode):
|
||||||
logging.info("Refusing to auto update, since the latest build is newer")
|
raise FDroidException(
|
||||||
|
_(
|
||||||
|
'latest build recipe is newer: old vercode={old}, new vercode={new}'
|
||||||
|
).format(old=latest.versionCode, new=app.CurrentVersionCode)
|
||||||
|
)
|
||||||
|
|
||||||
if not gotcur:
|
if not gotcur:
|
||||||
newbuild = copy.deepcopy(latest)
|
newbuild = copy.deepcopy(latest)
|
||||||
@ -577,7 +584,9 @@ def checkupdates_app(app):
|
|||||||
ver = _getcvname(app)
|
ver = _getcvname(app)
|
||||||
commitmsg = "Update %s to %s" % (name, ver)
|
commitmsg = "Update %s to %s" % (name, ver)
|
||||||
else:
|
else:
|
||||||
logging.warning('Invalid auto update mode "' + mode + '" on ' + app.id)
|
raise MetaDataException(
|
||||||
|
_('Invalid AutoUpdateMode: {mode}').format(mode=mode)
|
||||||
|
)
|
||||||
|
|
||||||
if commitmsg:
|
if commitmsg:
|
||||||
metadata.write_metadata(app.metadatapath, app)
|
metadata.write_metadata(app.metadatapath, app)
|
||||||
@ -705,6 +714,7 @@ def main():
|
|||||||
locallog = ''
|
locallog = ''
|
||||||
processed = []
|
processed = []
|
||||||
failed = dict()
|
failed = dict()
|
||||||
|
exit_code = 0
|
||||||
for appid, app in apps.items():
|
for appid, app in apps.items():
|
||||||
|
|
||||||
if options.autoonly and app.AutoUpdateMode in ('None', 'Static'):
|
if options.autoonly and app.AutoUpdateMode in ('None', 'Static'):
|
||||||
@ -721,12 +731,15 @@ def main():
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
msg = _("...checkupdate failed for {appid} : {error}").format(appid=appid, error=e)
|
msg = _("...checkupdate failed for {appid} : {error}").format(appid=appid, error=e)
|
||||||
logging.error(msg)
|
logging.error(msg)
|
||||||
|
logging.debug(traceback.format_exc())
|
||||||
locallog += msg + '\n'
|
locallog += msg + '\n'
|
||||||
failed[appid] = str(e)
|
failed[appid] = str(e)
|
||||||
|
exit_code = 1
|
||||||
|
|
||||||
update_wiki(None, locallog)
|
update_wiki(None, locallog)
|
||||||
status_update_json(processed, failed)
|
status_update_json(processed, failed)
|
||||||
logging.info(_("Finished"))
|
logging.info(_("Finished"))
|
||||||
|
sys.exit(exit_code)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
@ -65,7 +65,8 @@ class CheckupdatesTest(unittest.TestCase):
|
|||||||
):
|
):
|
||||||
with mock.patch('fdroidserver.metadata.write_metadata', mock.Mock()):
|
with mock.patch('fdroidserver.metadata.write_metadata', mock.Mock()):
|
||||||
with mock.patch('subprocess.call', lambda cmd: 0):
|
with mock.patch('subprocess.call', lambda cmd: 0):
|
||||||
fdroidserver.checkupdates.checkupdates_app(app)
|
with self.assertRaises(FDroidException):
|
||||||
|
fdroidserver.checkupdates.checkupdates_app(app)
|
||||||
build = app['Builds'][-1]
|
build = app['Builds'][-1]
|
||||||
self.assertEqual(build.versionName, '1.1.9')
|
self.assertEqual(build.versionName, '1.1.9')
|
||||||
self.assertEqual(build.commit, '1.1.9')
|
self.assertEqual(build.commit, '1.1.9')
|
||||||
|
@ -688,7 +688,7 @@ LOCAL_COPY_DIR=`create_test_dir`/fdroid
|
|||||||
mkdir -p $LOCAL_COPY_DIR/repo
|
mkdir -p $LOCAL_COPY_DIR/repo
|
||||||
echo "local_copy_dir: $LOCAL_COPY_DIR" >> config.yml
|
echo "local_copy_dir: $LOCAL_COPY_DIR" >> config.yml
|
||||||
|
|
||||||
$fdroid checkupdates --allow-dirty
|
$fdroid checkupdates --allow-dirty || true
|
||||||
which gpg && $fdroid gpgsign
|
which gpg && $fdroid gpgsign
|
||||||
$fdroid lint
|
$fdroid lint
|
||||||
$fdroid readmeta
|
$fdroid readmeta
|
||||||
|
Loading…
Reference in New Issue
Block a user