package_manager: Change complementary package handling to not include soft dependencies

We've some long standing bugs where the RDEPENDS from -dev packages causes
problems, e.g. dropbear and openssh components on an image working fine together
but then the SDK failing to build as the main openssh and dropbear packages
conflict with each other (pulled in by openssh-dev and dropbear-dev).

We propose changing the behavour of complementary package installation to
ignore RRECOMMENDS. If we then change the ${PN}-dev dependency on ${PN}
to a RRECOMMENDS, we can avoid many of the issues people run into yet still
have the desired behaviour of ${PN}-dev pulling in ${PN}.

This therefore changes the package manager code so that it doesn't follow
RRECOMMENDS for completementary package globs.

[RP: Added deb support]
(From OE-Core rev: b44b0b9294675f89aa51ff84f532664f4c479677)

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Ross Burton
2022-06-24 16:31:04 +01:00
committed by Richard Purdie
parent e8f188c510
commit 4705dd2646
4 changed files with 14 additions and 8 deletions

View File

@@ -266,7 +266,7 @@ class PackageManager(object, metaclass=ABCMeta):
pass pass
@abstractmethod @abstractmethod
def install(self, pkgs, attempt_only=False): def install(self, pkgs, attempt_only=False, hard_depends_only=False):
""" """
Install a list of packages. 'pkgs' is a list object. If 'attempt_only' is Install a list of packages. 'pkgs' is a list object. If 'attempt_only' is
True, installation failures are ignored. True, installation failures are ignored.
@@ -396,7 +396,7 @@ class PackageManager(object, metaclass=ABCMeta):
bb.note("Installing complementary packages ... %s (skipped already provided packages %s)" % ( bb.note("Installing complementary packages ... %s (skipped already provided packages %s)" % (
' '.join(install_pkgs), ' '.join(install_pkgs),
' '.join(skip_pkgs))) ' '.join(skip_pkgs)))
self.install(install_pkgs) self.install(install_pkgs, hard_depends_only=True)
except subprocess.CalledProcessError as e: except subprocess.CalledProcessError as e:
bb.fatal("Could not compute complementary packages list. Command " bb.fatal("Could not compute complementary packages list. Command "
"'%s' returned %d:\n%s" % "'%s' returned %d:\n%s" %

View File

@@ -289,14 +289,18 @@ class DpkgPM(OpkgDpkgPM):
self.deploy_dir_unlock() self.deploy_dir_unlock()
def install(self, pkgs, attempt_only=False): def install(self, pkgs, attempt_only=False, hard_depends_only=False):
if attempt_only and len(pkgs) == 0: if attempt_only and len(pkgs) == 0:
return return
os.environ['APT_CONFIG'] = self.apt_conf_file os.environ['APT_CONFIG'] = self.apt_conf_file
cmd = "%s %s install --allow-downgrades --allow-remove-essential --allow-change-held-packages --allow-unauthenticated --no-remove %s" % \ extra_args = ""
(self.apt_get_cmd, self.apt_args, ' '.join(pkgs)) if hard_depends_only:
extra_args = "--no-install-recommends"
cmd = "%s %s install --allow-downgrades --allow-remove-essential --allow-change-held-packages --allow-unauthenticated --no-remove %s %s" % \
(self.apt_get_cmd, self.apt_args, extra_args, ' '.join(pkgs))
try: try:
bb.note("Installing the following packages: %s" % ' '.join(pkgs)) bb.note("Installing the following packages: %s" % ' '.join(pkgs))

View File

@@ -337,7 +337,7 @@ class OpkgPM(OpkgDpkgPM):
self.deploy_dir_unlock() self.deploy_dir_unlock()
def install(self, pkgs, attempt_only=False): def install(self, pkgs, attempt_only=False, hard_depends_only=False):
if not pkgs: if not pkgs:
return return
@@ -346,6 +346,8 @@ class OpkgPM(OpkgDpkgPM):
cmd += " --add-exclude %s" % exclude cmd += " --add-exclude %s" % exclude
for bad_recommendation in (self.d.getVar("BAD_RECOMMENDATIONS") or "").split(): for bad_recommendation in (self.d.getVar("BAD_RECOMMENDATIONS") or "").split():
cmd += " --add-ignore-recommends %s" % bad_recommendation cmd += " --add-ignore-recommends %s" % bad_recommendation
if hard_depends_only:
cmd += " --no-install-recommends"
cmd += " install " cmd += " install "
cmd += " ".join(pkgs) cmd += " ".join(pkgs)

View File

@@ -181,7 +181,7 @@ class RpmPM(PackageManager):
os.environ['NATIVE_ROOT'] = self.d.getVar('STAGING_DIR_NATIVE') os.environ['NATIVE_ROOT'] = self.d.getVar('STAGING_DIR_NATIVE')
def install(self, pkgs, attempt_only = False): def install(self, pkgs, attempt_only=False, hard_depends_only=False):
if len(pkgs) == 0: if len(pkgs) == 0:
return return
self._prepare_pkg_transaction() self._prepare_pkg_transaction()
@@ -192,7 +192,7 @@ class RpmPM(PackageManager):
output = self._invoke_dnf((["--skip-broken"] if attempt_only else []) + output = self._invoke_dnf((["--skip-broken"] if attempt_only else []) +
(["-x", ",".join(exclude_pkgs)] if len(exclude_pkgs) > 0 else []) + (["-x", ",".join(exclude_pkgs)] if len(exclude_pkgs) > 0 else []) +
(["--setopt=install_weak_deps=False"] if self.d.getVar('NO_RECOMMENDATIONS') == "1" else []) + (["--setopt=install_weak_deps=False"] if (hard_depends_only or self.d.getVar('NO_RECOMMENDATIONS') == "1") else []) +
(["--nogpgcheck"] if self.d.getVar('RPM_SIGN_PACKAGES') != '1' else ["--setopt=gpgcheck=True"]) + (["--nogpgcheck"] if self.d.getVar('RPM_SIGN_PACKAGES') != '1' else ["--setopt=gpgcheck=True"]) +
["install"] + ["install"] +
pkgs) pkgs)