def check_packages(module, xbps_path, packages, state):
 would_be_changed = []
 for package in packages:
  (installed, updated) = query_package(module, xbps_path, package)
  if (((state in ['present', 'latest']) and (not installed)) or ((state == 'absent') and installed) or ((state == 'latest') and (not updated))):
   would_be_changed.append(package)
 if would_be_changed:
  if (state == 'absent'):
   state = 'removed'
  module.exit_json(changed=True, msg=('%s package(s) would be %s' % (len(would_be_changed), state)), packages=would_be_changed)
 else:
  module.exit_json(changed=False, msg=('package(s) already %s' % state), packages=[])

def check_packages ( module , xbps_path , packages , state ) : would_be_changed = [ ] for package in packages : ( installed , updated ) = query_package ( module , xbps_path , package ) if ( ( ( state in [ 'present' , 'latest' ] ) and ( not installed ) ) or ( ( state == 'absent' ) and installed ) or ( ( state == 'latest' ) and ( not updated ) ) ) : would_be_changed . append ( package ) if would_be_changed : if ( state == 'absent' ) : state = 'removed' module . exit_json ( changed = True , msg = ( '%s package(s) would be %s' % ( len ( would_be_changed ) , state ) ) , packages = would_be_changed ) else : module . exit_json ( changed = False , msg = ( 'package(s) already %s' % state ) , packages = [ ] )
returns change status of command .