def package_command(self, command, args=None, pkgs=None): if pkgs is None: pkgs = [] e = os.environ.copy() # See: http://tiny.cc/kg91fw # Or: http://tiny.cc/mh91fw e['DEBIAN_FRONTEND'] = 'noninteractive' cmd = list(self.get_option("apt_get_command", APT_GET_COMMAND)) if args and isinstance(args, str): cmd.append(args) elif args and isinstance(args, list): cmd.extend(args) subcmd = command if command == "upgrade": subcmd = self.get_option("apt_get_upgrade_subcommand", "dist-upgrade") cmd.append(subcmd) pkglist = util.expand_package_list('%s=%s', pkgs) cmd.extend(pkglist) # Allow the output of this to flow outwards (ie not be captured) util.subp(cmd, env=e, capture=False)
def package_command(self, command, args=None, pkgs=None): if pkgs is None: pkgs = [] if util.which('dnf'): LOG.debug('Using DNF for package management') cmd = ['dnf'] else: LOG.debug('Using YUM for package management') # the '-t' argument makes yum tolerant of errors on the command # line with regard to packages. # # For example: if you request to install foo, bar and baz and baz # is installed; yum won't error out complaining that baz is already # installed. cmd = ['yum', '-t'] # Determines whether or not yum prompts for confirmation # of critical actions. We don't want to prompt... cmd.append("-y") if args and isinstance(args, str): cmd.append(args) elif args and isinstance(args, list): cmd.extend(args) cmd.append(command) pkglist = util.expand_package_list('%s-%s', pkgs) cmd.extend(pkglist) # Allow the output of this to flow outwards (ie not be captured) util.subp(cmd, capture=False)
def package_command(self, command, args=None, pkgs=None): if pkgs is None: pkgs = [] if subp.which("dnf"): LOG.debug("Using DNF for package management") cmd = ["dnf"] else: LOG.debug("Using YUM for package management") # the '-t' argument makes yum tolerant of errors on the command # line with regard to packages. # # For example: if you request to install foo, bar and baz and baz # is installed; yum won't error out complaining that baz is already # installed. cmd = ["yum", "-t"] # Determines whether or not yum prompts for confirmation # of critical actions. We don't want to prompt... cmd.append("-y") if args and isinstance(args, str): cmd.append(args) elif args and isinstance(args, list): cmd.extend(args) cmd.append(command) pkglist = util.expand_package_list("%s-%s", pkgs) cmd.extend(pkglist) # Allow the output of this to flow outwards (ie not be captured) subp.subp(cmd, capture=False)
def package_command(self, command, args=None, pkgs=None): if pkgs is None: pkgs = [] e = os.environ.copy() # See: http://manpages.ubuntu.com/manpages/xenial/man7/debconf.7.html e['DEBIAN_FRONTEND'] = 'noninteractive' wcfg = self.get_option("apt_get_wrapper", APT_GET_WRAPPER) cmd = _get_wrapper_prefix( wcfg.get('command', APT_GET_WRAPPER['command']), wcfg.get('enabled', APT_GET_WRAPPER['enabled'])) cmd.extend(list(self.get_option("apt_get_command", APT_GET_COMMAND))) if args and isinstance(args, str): cmd.append(args) elif args and isinstance(args, list): cmd.extend(args) subcmd = command if command == "upgrade": subcmd = self.get_option("apt_get_upgrade_subcommand", "dist-upgrade") cmd.append(subcmd) pkglist = util.expand_package_list('%s=%s', pkgs) cmd.extend(pkglist) # Allow the output of this to flow outwards (ie not be captured) util.log_time(logfunc=LOG.debug, msg="apt-%s [%s]" % (command, ' '.join(cmd)), func=subp.subp, args=(cmd,), kwargs={'env': e, 'capture': False})
def package_command(self, command, args=None, pkgs=None): if pkgs is None: pkgs = [] e = os.environ.copy() # See: http://tiny.cc/kg91fw # Or: http://tiny.cc/mh91fw e['DEBIAN_FRONTEND'] = 'noninteractive' wcfg = self.get_option("apt_get_wrapper", APT_GET_WRAPPER) cmd = _get_wrapper_prefix( wcfg.get('command', APT_GET_WRAPPER['command']), wcfg.get('enabled', APT_GET_WRAPPER['enabled'])) cmd.extend(list(self.get_option("apt_get_command", APT_GET_COMMAND))) if args and isinstance(args, str): cmd.append(args) elif args and isinstance(args, list): cmd.extend(args) subcmd = command if command == "upgrade": subcmd = self.get_option("apt_get_upgrade_subcommand", "dist-upgrade") cmd.append(subcmd) pkglist = util.expand_package_list('%s=%s', pkgs) cmd.extend(pkglist) # Allow the output of this to flow outwards (ie not be captured) util.log_time(logfunc=LOG.debug, msg="apt-%s [%s]" % (command, ' '.join(cmd)), func=util.subp, args=(cmd,), kwargs={'env': e, 'capture': False})
def package_command(self, command, args=None, pkgs=None): if pkgs is None: pkgs = [] cmd = ['yum'] # If enabled, then yum will be tolerant of errors on the command line # with regard to packages. # For example: if you request to install foo, bar and baz and baz is # installed; yum won't error out complaining that baz is already # installed. cmd.append("-t") # Determines whether or not yum prompts for confirmation # of critical actions. We don't want to prompt... cmd.append("-y") if args and isinstance(args, str): cmd.append(args) elif args and isinstance(args, list): cmd.extend(args) cmd.append(command) pkglist = util.expand_package_list('%s-%s', pkgs) cmd.extend(pkglist) # Allow the output of this to flow outwards (ie not be captured) util.subp(cmd, capture=False)
def package_command(self, command, args=None, pkgs=None): if pkgs is None: pkgs = [] if command == "install": cmd = self.pkg_cmd_install_prefix elif command == "remove": cmd = self.pkg_cmd_remove_prefix elif command == "update": if not self.pkg_cmd_update_prefix: return cmd = self.pkg_cmd_update_prefix elif command == "upgrade": if not self.pkg_cmd_upgrade_prefix: return cmd = self.pkg_cmd_upgrade_prefix if args and isinstance(args, str): cmd.append(args) elif args and isinstance(args, list): cmd.extend(args) pkglist = util.expand_package_list("%s-%s", pkgs) cmd.extend(pkglist) # Allow the output of this to flow outwards (ie not be captured) subp.subp(cmd, env=self._get_pkg_cmd_environ(), capture=False)
def package_command(self, command, args=None, pkgs=None): """Run the given package command. On Debian, this will run apt-get (unless APT_GET_COMMAND is set). command: The command to run, like "upgrade" or "install" args: Arguments passed to apt itself in addition to any specified in APT_GET_COMMAND pkgs: Apt packages that the command will apply to """ if pkgs is None: pkgs = [] e = os.environ.copy() # See: http://manpages.ubuntu.com/manpages/xenial/man7/debconf.7.html e["DEBIAN_FRONTEND"] = "noninteractive" wcfg = self.get_option("apt_get_wrapper", APT_GET_WRAPPER) cmd = _get_wrapper_prefix( wcfg.get("command", APT_GET_WRAPPER["command"]), wcfg.get("enabled", APT_GET_WRAPPER["enabled"]), ) cmd.extend(list(self.get_option("apt_get_command", APT_GET_COMMAND))) if args and isinstance(args, str): cmd.append(args) elif args and isinstance(args, list): cmd.extend(args) subcmd = command if command == "upgrade": subcmd = self.get_option("apt_get_upgrade_subcommand", "dist-upgrade") cmd.append(subcmd) pkglist = util.expand_package_list("%s=%s", pkgs) cmd.extend(pkglist) self._wait_for_apt_command( short_cmd=command, subp_kwargs={ "args": cmd, "env": e, "capture": False }, )
def package_command(self, command, args=None, pkgs=None): if pkgs is None: pkgs = [] cmd = ['tdnf', '-y'] if args and isinstance(args, str): cmd.append(args) elif args and isinstance(args, list): cmd.extend(args) cmd.append(command) pkglist = util.expand_package_list('%s-%s', pkgs) cmd.extend(pkglist) # Allow the output of this to flow outwards (ie not be captured) _ret, _out, _err = self.exec_cmd(cmd, capture=False)
def package_command(self, command, args=None, pkgs=None): if not pkgs: pkgs = [] cmd = ["tdnf", "-y"] if args and isinstance(args, str): cmd.append(args) elif args and isinstance(args, list): cmd.extend(args) cmd.append(command) pkglist = util.expand_package_list("%s-%s", pkgs) cmd.extend(pkglist) ret, _out, err = self.exec_cmd(cmd) if ret: LOG.error("Error while installing packages: %s", err)
def package_command(self, command, args=None, pkgs=None): if pkgs is None: pkgs = [] cmd = ['pacman', "-Sy", "--quiet", "--noconfirm"] # Redirect output if args and isinstance(args, str): cmd.append(args) elif args and isinstance(args, list): cmd.extend(args) if command: cmd.append(command) pkglist = util.expand_package_list('%s-%s', pkgs) cmd.extend(pkglist) # Allow the output of this to flow outwards (ie not be captured) util.subp(cmd, capture=False)
def package_command(self, command, args=None, pkgs=None): if pkgs is None: pkgs = [] cmd = ['pacman', "-Sy", "--quiet", "--noconfirm"] # Redirect output if args and isinstance(args, str): cmd.append(args) elif args and isinstance(args, list): cmd.extend(args) if command: cmd.append(command) pkglist = util.expand_package_list('%s-%s', pkgs) cmd.extend(pkglist) # Allow the output of this to flow outwards (ie not be captured) subp.subp(cmd, capture=False)
def package_command(self, command, args=None, pkgs=None): if pkgs is None: pkgs = [] cmd = ['tdnf'] # Determines whether or not tdnf prompts for confirmation # of critical actions. We don't want to prompt... cmd.append("-y") if args and isinstance(args, str): cmd.append(args) elif args and isinstance(args, list): cmd.extend(args) cmd.append(command) pkglist = util.expand_package_list('%s-%s', pkgs) cmd.extend(pkglist) # Allow the output of this to flow outwards (ie not be captured) util.subp(cmd, capture=False)
def package_command(self, command, args=None, pkgs=None): if pkgs is None: pkgs = [] # TODO neither freebsd nor netbsd handles a command 'upgrade' # provided by cloudinit/config/cc_package_update_upgrade_install.py if command == 'install': cmd = self.pkg_cmd_install_prefix elif command == 'remove': cmd = self.pkg_cmd_remove_prefix if args and isinstance(args, str): cmd.append(args) elif args and isinstance(args, list): cmd.extend(args) pkglist = util.expand_package_list('%s-%s', pkgs) cmd.extend(pkglist) # Allow the output of this to flow outwards (ie not be captured) util.subp(cmd, env=self._get_pkg_cmd_environ(), capture=False)
def package_command(self, command, args=None, pkgs=None): if pkgs is None: pkgs = [] e = os.environ.copy() e['ASSUME_ALWAYS_YES'] = 'YES' cmd = ['pkg'] if args and isinstance(args, str): cmd.append(args) elif args and isinstance(args, list): cmd.extend(args) if command: cmd.append(command) pkglist = util.expand_package_list('%s-%s', pkgs) cmd.extend(pkglist) # Allow the output of this to flow outwards (ie not be captured) util.subp(cmd, env=e, capture=False)
def package_command(self, command, args=None, pkgs=None): if pkgs is None: pkgs = [] cmd = list("emerge") # Redirect output cmd.append("--quiet") if args and isinstance(args, str): cmd.append(args) elif args and isinstance(args, list): cmd.extend(args) if command: cmd.append(command) pkglist = util.expand_package_list("%s-%s", pkgs) cmd.extend(pkglist) # Allow the output of this to flow outwards (ie not be captured) subp.subp(cmd, capture=False)
def package_command(self, command, args=None, pkgs=None): if pkgs is None: pkgs = [] cmd = ['zypper'] # No user interaction possible, enable non-interactive mode cmd.append('--non-interactive') # Comand is the operation, such as install cmd.append(command) # args are the arguments to the command, not global options if args and isinstance(args, str): cmd.append(args) elif args and isinstance(args, list): cmd.extend(args) pkglist = util.expand_package_list('%s-%s', pkgs) cmd.extend(pkglist) # Allow the output of this to flow outwards (ie not be captured) util.subp(cmd, capture=False)
def package_command(self, command, args=None, pkgs=None): if pkgs is None: pkgs = [] cmd = ['apk'] # Redirect output cmd.append("--quiet") if args and isinstance(args, str): cmd.append(args) elif args and isinstance(args, list): cmd.extend(args) if command: cmd.append(command) if command == 'upgrade': cmd.extend(["--update-cache", "--available"]) pkglist = util.expand_package_list('%s-%s', pkgs) cmd.extend(pkglist) # Allow the output of this to flow outwards (ie not be captured) subp.subp(cmd, capture=False)