|
|
@ -274,6 +274,7 @@ APT_GET_ZERO = "\n0 upgraded, 0 newly installed"
|
|
|
|
APTITUDE_ZERO = "\n0 packages upgraded, 0 newly installed"
|
|
|
|
APTITUDE_ZERO = "\n0 packages upgraded, 0 newly installed"
|
|
|
|
APT_LISTS_PATH = "/var/lib/apt/lists"
|
|
|
|
APT_LISTS_PATH = "/var/lib/apt/lists"
|
|
|
|
APT_UPDATE_SUCCESS_STAMP_PATH = "/var/lib/apt/periodic/update-success-stamp"
|
|
|
|
APT_UPDATE_SUCCESS_STAMP_PATH = "/var/lib/apt/periodic/update-success-stamp"
|
|
|
|
|
|
|
|
APT_MARK_INVALID_OP = 'Invalid operation'
|
|
|
|
|
|
|
|
|
|
|
|
HAS_PYTHON_APT = True
|
|
|
|
HAS_PYTHON_APT = True
|
|
|
|
try:
|
|
|
|
try:
|
|
|
@ -468,6 +469,22 @@ def parse_diff(output):
|
|
|
|
return {'prepared': '\n'.join(diff[diff_start:diff_end])}
|
|
|
|
return {'prepared': '\n'.join(diff[diff_start:diff_end])}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def mark_installed_manually(m, packages):
|
|
|
|
|
|
|
|
if not packages:
|
|
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
apt_mark_cmd_path = m.get_bin_path("apt-mark", required=True)
|
|
|
|
|
|
|
|
cmd = "%s manual %s" % (apt_mark_cmd_path, ' '.join(packages))
|
|
|
|
|
|
|
|
rc, out, err = m.run_command(cmd)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if APT_MARK_INVALID_OP in err:
|
|
|
|
|
|
|
|
cmd = "%s unmarkauto %s" % (apt_mark_cmd_path, ' '.join(packages))
|
|
|
|
|
|
|
|
rc, out, err = m.run_command(cmd)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if rc != 0:
|
|
|
|
|
|
|
|
m.fail_json(msg="'%s' failed: %s" % (cmd, err), stdout=out, stderr=err, rc=rc)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def install(m, pkgspec, cache, upgrade=False, default_release=None,
|
|
|
|
def install(m, pkgspec, cache, upgrade=False, default_release=None,
|
|
|
|
install_recommends=None, force=False,
|
|
|
|
install_recommends=None, force=False,
|
|
|
|
dpkg_options=expand_dpkg_options(DPKG_OPTIONS),
|
|
|
|
dpkg_options=expand_dpkg_options(DPKG_OPTIONS),
|
|
|
@ -476,6 +493,7 @@ def install(m, pkgspec, cache, upgrade=False, default_release=None,
|
|
|
|
pkg_list = []
|
|
|
|
pkg_list = []
|
|
|
|
packages = ""
|
|
|
|
packages = ""
|
|
|
|
pkgspec = expand_pkgspec_from_fnmatches(m, pkgspec, cache)
|
|
|
|
pkgspec = expand_pkgspec_from_fnmatches(m, pkgspec, cache)
|
|
|
|
|
|
|
|
package_names = []
|
|
|
|
for package in pkgspec:
|
|
|
|
for package in pkgspec:
|
|
|
|
if build_dep:
|
|
|
|
if build_dep:
|
|
|
|
# Let apt decide what to install
|
|
|
|
# Let apt decide what to install
|
|
|
@ -483,6 +501,7 @@ def install(m, pkgspec, cache, upgrade=False, default_release=None,
|
|
|
|
continue
|
|
|
|
continue
|
|
|
|
|
|
|
|
|
|
|
|
name, version = package_split(package)
|
|
|
|
name, version = package_split(package)
|
|
|
|
|
|
|
|
package_names.append(name)
|
|
|
|
installed, upgradable, has_files = package_status(m, name, version, cache, state='install')
|
|
|
|
installed, upgradable, has_files = package_status(m, name, version, cache, state='install')
|
|
|
|
if (not installed and not only_upgrade) or (upgrade and upgradable):
|
|
|
|
if (not installed and not only_upgrade) or (upgrade and upgradable):
|
|
|
|
pkg_list.append("'%s'" % package)
|
|
|
|
pkg_list.append("'%s'" % package)
|
|
|
@ -544,9 +563,14 @@ def install(m, pkgspec, cache, upgrade=False, default_release=None,
|
|
|
|
if rc:
|
|
|
|
if rc:
|
|
|
|
status = False
|
|
|
|
status = False
|
|
|
|
data = dict(msg="'%s' failed: %s" % (cmd, err), stdout=out, stderr=err, rc=rc)
|
|
|
|
data = dict(msg="'%s' failed: %s" % (cmd, err), stdout=out, stderr=err, rc=rc)
|
|
|
|
return (status, data)
|
|
|
|
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
return (True, dict(changed=False))
|
|
|
|
status = True
|
|
|
|
|
|
|
|
data = dict(changed=False)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if not build_dep:
|
|
|
|
|
|
|
|
mark_installed_manually(m, package_names)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return (status, data)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def get_field_of_deb(m, deb_file, field="Version"):
|
|
|
|
def get_field_of_deb(m, deb_file, field="Version"):
|
|
|
|