Skip to content

Commit

Permalink
updater: add --signal-no-updates flag
Browse files Browse the repository at this point in the history
  • Loading branch information
piotrbartman committed Jun 26, 2024
1 parent cd36a0e commit 51f9465
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
4 changes: 3 additions & 1 deletion vmupdate/tests/test_vmupdate.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,11 @@
@patch('logging.FileHandler')
@patch('logging.getLogger')
def test_no_options_do_nothing(_logger, _log_file, _chmod, _chown, test_qapp):
args = []
test_qapp.domains = test_qapp.Domains()
TestVM("dom0", test_qapp, klass="AdminVM")
args = []
assert main(args, test_qapp) == 0
args = ['--signal-no-updates']
assert main(args, test_qapp) == 100


Expand Down
8 changes: 6 additions & 2 deletions vmupdate/vmupdate.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def main(args=None, app=qubesadmin.Qubes()):
if not targets:
if not args.quiet:
print("No qube selected for update")
return 100
return 100 if args.signal_no_updates else 0

independent = [target for target in targets if target.klass in (
'TemplateVM', 'StandaloneVM')]
Expand All @@ -75,7 +75,7 @@ def main(args=None, app=qubesadmin.Qubes()):
args, independent, templ_statuses, app_statuses, log)

ret_code = max(ret_code_independent, ret_code_appvm, ret_code_restart)
if ret_code == 0 and no_updates:
if ret_code == 0 and no_updates and args.signal_no_updates:
return 100
return ret_code

Expand All @@ -97,6 +97,10 @@ def parse_args(args, app):
help='Do not remove updater files from target qube')
parser.add_argument('--dry-run', action='store_true',
help='Just print what happens.')
parser.add_argument(
'--signal-no-updates', action='store_true',
help='Return exit code 100 instread of 0 '
'if there is no updates available.')

restart = parser.add_mutually_exclusive_group()
restart.add_argument(
Expand Down

0 comments on commit 51f9465

Please sign in to comment.