mirror of
				https://github.com/kewlfft/ansible-aur.git
				synced 2025-11-04 10:02:30 +03:00 
			
		
		
		
	add check_mode for upgrade
This commit is contained in:
		@@ -181,6 +181,20 @@ def install_with_makepkg(module, package, extra_args, skip_pgp_check, ignore_arc
 | 
				
			|||||||
    return (rc, out, err)
 | 
					    return (rc, out, err)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					def check_upgrade(module, use):
 | 
				
			||||||
 | 
					    """
 | 
				
			||||||
 | 
					    Inform user how many packages would be upgraded
 | 
				
			||||||
 | 
					    """
 | 
				
			||||||
 | 
					    rc, stdout, stderr = module.run_command([use, '-Qu'], check_rc=True)
 | 
				
			||||||
 | 
					    data = stdout.split('\n')
 | 
				
			||||||
 | 
					    data.remove('')
 | 
				
			||||||
 | 
					    module.exit_json(
 | 
				
			||||||
 | 
					        changed=len(data) > 0,
 | 
				
			||||||
 | 
					        msg="{} package(s) would be upgraded".format(len(data)),
 | 
				
			||||||
 | 
					        helper=use,
 | 
				
			||||||
 | 
					    )
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def upgrade(module, use, extra_args, aur_only):
 | 
					def upgrade(module, use, extra_args, aur_only):
 | 
				
			||||||
    """
 | 
					    """
 | 
				
			||||||
    Upgrade the whole system
 | 
					    Upgrade the whole system
 | 
				
			||||||
@@ -296,12 +310,16 @@ def make_module():
 | 
				
			|||||||
def apply_module(module, use):
 | 
					def apply_module(module, use):
 | 
				
			||||||
    params = module.params
 | 
					    params = module.params
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if module.check_mode:
 | 
					    if params.get('upgrade', False):
 | 
				
			||||||
        check_packages(module, params['name'])
 | 
					        if module.check_mode:
 | 
				
			||||||
    elif params.get('upgrade', False):
 | 
					            check_upgrade(module, use)
 | 
				
			||||||
        upgrade(module, use, params['extra_args'], params['aur_only'])
 | 
					        else:
 | 
				
			||||||
 | 
					            upgrade(module, use, params['extra_args'], params['aur_only'])
 | 
				
			||||||
    else:
 | 
					    else:
 | 
				
			||||||
        install_packages(module, params['name'], use, params['extra_args'], params['state'], params['skip_pgp_check'], params['ignore_arch'], params['aur_only'])
 | 
					        if module.check_mode:
 | 
				
			||||||
 | 
					            check_packages(module, params['name'])
 | 
				
			||||||
 | 
					        else:
 | 
				
			||||||
 | 
					            install_packages(module, params['name'], use, params['extra_args'], params['state'], params['skip_pgp_check'], params['ignore_arch'], params['aur_only'])
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def main():
 | 
					def main():
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user