"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "salt/modules/aptpkg.py" between
salt-3002.1.tar.gz and salt-3002.2.tar.gz

About: SaltStack is a systems management software for data center automation, cloud orchestration, server provisioning, configuration management and more. Community version.

aptpkg.py  (salt-3002.1):aptpkg.py  (salt-3002.2)
skipping to change at line 13 skipping to change at line 13
.. important:: .. important::
If you feel that Salt should be using this module to manage packages on a If you feel that Salt should be using this module to manage packages on a
minion, and it is using a different module (or gives an error similar to minion, and it is using a different module (or gives an error similar to
*'pkg.install' is not available*), see :ref:`here *'pkg.install' is not available*), see :ref:`here
<module-provider-override>`. <module-provider-override>`.
For repository management, the ``python-apt`` package must be installed. For repository management, the ``python-apt`` package must be installed.
""" """
# Import python libs
import copy import copy
import datetime import datetime
import fnmatch import fnmatch
import logging import logging
import os import os
import re import re
import time import time
from urllib.error import HTTPError
from urllib.request import Request as _Request
from urllib.request import urlopen as _urlopen
# Import salt libs
import salt.config import salt.config
import salt.syspaths import salt.syspaths
import salt.utils.args import salt.utils.args
import salt.utils.data import salt.utils.data
import salt.utils.environment import salt.utils.environment
import salt.utils.files import salt.utils.files
import salt.utils.functools import salt.utils.functools
import salt.utils.itertools import salt.utils.itertools
import salt.utils.json import salt.utils.json
import salt.utils.path import salt.utils.path
import salt.utils.pkg import salt.utils.pkg
import salt.utils.pkg.deb import salt.utils.pkg.deb
import salt.utils.stringutils import salt.utils.stringutils
import salt.utils.systemd import salt.utils.systemd
import salt.utils.versions import salt.utils.versions
import salt.utils.yaml import salt.utils.yaml
from salt.exceptions import CommandExecutionError, MinionError, SaltInvocationEr ror from salt.exceptions import CommandExecutionError, MinionError, SaltInvocationEr ror
# Import third party libs
# pylint: disable=no-name-in-module,import-error,redefined-builtin
from salt.ext import six
from salt.ext.six.moves.urllib.error import HTTPError
from salt.ext.six.moves.urllib.request import Request as _Request
from salt.ext.six.moves.urllib.request import urlopen as _urlopen
from salt.modules.cmdmod import _parse_env from salt.modules.cmdmod import _parse_env
# pylint: enable=no-name-in-module,import-error,redefined-builtin
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
# pylint: disable=import-error # pylint: disable=import-error
try: try:
import apt.cache import apt.cache
import apt.debfile import apt.debfile
from aptsources import sourceslist from aptsources import sourceslist
HAS_APT = True HAS_APT = True
except ImportError: except ImportError:
skipping to change at line 94 skipping to change at line 86
"deb https://{0}private-ppa.launchpad.net/{1}/{2}/ubuntu" " {3} main" "deb https://{0}private-ppa.launchpad.net/{1}/{2}/ubuntu" " {3} main"
) )
_MODIFY_OK = frozenset(["uri", "comps", "architectures", "disabled", "file", "di st"]) _MODIFY_OK = frozenset(["uri", "comps", "architectures", "disabled", "file", "di st"])
DPKG_ENV_VARS = { DPKG_ENV_VARS = {
"APT_LISTBUGS_FRONTEND": "none", "APT_LISTBUGS_FRONTEND": "none",
"APT_LISTCHANGES_FRONTEND": "none", "APT_LISTCHANGES_FRONTEND": "none",
"DEBIAN_FRONTEND": "noninteractive", "DEBIAN_FRONTEND": "noninteractive",
"UCF_FORCE_CONFFOLD": "1", "UCF_FORCE_CONFFOLD": "1",
} }
if six.PY2:
# Ensure no unicode in env vars on PY2, as it causes problems with
# subprocess.Popen()
DPKG_ENV_VARS = salt.utils.data.encode(DPKG_ENV_VARS)
# Define the module's virtual name # Define the module's virtual name
__virtualname__ = "pkg" __virtualname__ = "pkg"
def __virtual__(): def __virtual__():
""" """
Confirm this module is on a Debian-based system Confirm this module is on a Debian-based system
""" """
# If your minion is running an OS which is Debian-based but does not have # If your minion is running an OS which is Debian-based but does not have
# an "os_family" grain of Debian, then the proper fix is NOT to check for # an "os_family" grain of Debian, then the proper fix is NOT to check for
skipping to change at line 2293 skipping to change at line 2281
repo_architectures, repo_architectures,
repo_uri, repo_uri,
repo_dist, repo_dist,
repo_comps, repo_comps,
) = _split_repo_str(repo) ) = _split_repo_str(repo)
except SyntaxError: except SyntaxError:
raise SyntaxError( raise SyntaxError(
"Error: repo '{}' not a well formatted definition".format(repo) "Error: repo '{}' not a well formatted definition".format(repo)
) )
full_comp_list = set(repo_comps) full_comp_list = {comp.strip() for comp in repo_comps}
no_proxy = __salt__["config.option"]("no_proxy") no_proxy = __salt__["config.option"]("no_proxy")
if "keyid" in kwargs: if "keyid" in kwargs:
keyid = kwargs.pop("keyid", None) keyid = kwargs.pop("keyid", None)
keyserver = kwargs.pop("keyserver", None) keyserver = kwargs.pop("keyserver", None)
if not keyid or not keyserver: if not keyid or not keyserver:
error_str = "both keyserver and keyid options required." error_str = "both keyserver and keyid options required."
raise NameError(error_str) raise NameError(error_str)
if not isinstance(keyid, list): if not isinstance(keyid, list):
keyid = [keyid] keyid = [keyid]
skipping to change at line 2372 skipping to change at line 2360
cmd = ["apt-key", "add", "-"] cmd = ["apt-key", "add", "-"]
out = __salt__["cmd.run_stdout"]( out = __salt__["cmd.run_stdout"](
cmd, stdin=key_text, python_shell=False, **kwargs cmd, stdin=key_text, python_shell=False, **kwargs
) )
if not out.upper().startswith("OK"): if not out.upper().startswith("OK"):
raise CommandExecutionError( raise CommandExecutionError(
"Error: failed to add key:\n{}".format(key_text) "Error: failed to add key:\n{}".format(key_text)
) )
if "comps" in kwargs: if "comps" in kwargs:
kwargs["comps"] = kwargs["comps"].split(",") kwargs["comps"] = [comp.strip() for comp in kwargs["comps"].split(",")]
full_comp_list |= set(kwargs["comps"]) full_comp_list |= set(kwargs["comps"])
else: else:
kwargs["comps"] = list(full_comp_list) kwargs["comps"] = list(full_comp_list)
if "architectures" in kwargs: if "architectures" in kwargs:
kwargs["architectures"] = kwargs["architectures"].split(",") kwargs["architectures"] = kwargs["architectures"].split(",")
else: else:
kwargs["architectures"] = repo_architectures kwargs["architectures"] = repo_architectures
if "disabled" in kwargs: if "disabled" in kwargs:
skipping to change at line 2515 skipping to change at line 2503
else: else:
repo = LP_SRC_FORMAT.format(owner_name, ppa_name, dist) repo = LP_SRC_FORMAT.format(owner_name, ppa_name, dist)
if "file" not in kwargs: if "file" not in kwargs:
filename = "/etc/apt/sources.list.d/{0}-{1}-{2}.list" filename = "/etc/apt/sources.list.d/{0}-{1}-{2}.list"
kwargs["file"] = filename.format(owner_name, ppa_name, dist) kwargs["file"] = filename.format(owner_name, ppa_name, dist)
source_entry = sourceslist.SourceEntry(repo) source_entry = sourceslist.SourceEntry(repo)
for list_args in ("architectures", "comps"): for list_args in ("architectures", "comps"):
if list_args in kwargs: if list_args in kwargs:
kwargs[list_args] = kwargs[list_args].split(",") kwargs[list_args] = [
kwarg.strip() for kwarg in kwargs[list_args].split(",")
]
for kwarg in _MODIFY_OK: for kwarg in _MODIFY_OK:
if kwarg in kwargs: if kwarg in kwargs:
setattr(source_entry, kwarg, kwargs[kwarg]) setattr(source_entry, kwarg, kwargs[kwarg])
sanitized["file"] = source_entry.file sanitized["file"] = source_entry.file
sanitized["comps"] = getattr(source_entry, "comps", []) sanitized["comps"] = getattr(source_entry, "comps", [])
sanitized["disabled"] = source_entry.disabled sanitized["disabled"] = source_entry.disabled
sanitized["dist"] = source_entry.dist sanitized["dist"] = source_entry.dist
sanitized["type"] = source_entry.type sanitized["type"] = source_entry.type
sanitized["uri"] = source_entry.uri sanitized["uri"] = source_entry.uri
 End of changes. 9 change blocks. 
18 lines changed or deleted 8 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)