install_cross_libs: fix toolchain dependency installation

`./setup_board --nousepkg --nogetbinpkg` currently fails with a
circular dependency due to pulling in the whole systemd-cryptsetup-udev
dependency chain. This is due to several issue:

* `emerge --root=$ROOT --emptytree` considers ROOT=/ to also be empty,
  so it pulls in all host packages. This must've not always been the case.
  So we need to pipe the dependency package list through `egrep $ROOT`
  to filter only those that would get installed into the desired ROOT
* if SYSROOT=/ and not SYSROOT=ROOT, then virtual/os-headers is missing
  from $ROOT package list
* the final filter expression tries to previously looked like this:
  (=sys-devel/gcc|sys-devel/binutils-0.9) which also matches
  sys-devel/gcc-config and sys-devel/binutils-config, which are
  necessary dependencies. Rework the match expression to not filter
  those out.
This commit is contained in:
Jeremi Piotrowski 2022-07-13 15:43:15 +02:00
parent 13889874e3
commit a66bded4ce

View File

@ -262,8 +262,9 @@ _get_dependency_list() {
PORTAGE_CONFIGROOT="$ROOT" emerge "$@" --pretend \ PORTAGE_CONFIGROOT="$ROOT" emerge "$@" --pretend \
--emptytree --root-deps=rdeps --onlydeps --quiet | \ --emptytree --root-deps=rdeps --onlydeps --quiet | \
egrep "$ROOT" |
sed -e 's/[^]]*\] \([^ :]*\).*/=\1/' | sed -e 's/[^]]*\] \([^ :]*\).*/=\1/' |
egrep -v "(=$(echo "${pkgs[*]}")-[0-9])" egrep -v "=($(echo "${pkgs[*]}"))-[0-9]"
} }
# Configure a new ROOT # Configure a new ROOT
@ -392,7 +393,7 @@ install_cross_libs() {
# In order to get a dependency list we must calculate it before # In order to get a dependency list we must calculate it before
# updating package.provided. Otherwise portage will no-op. # updating package.provided. Otherwise portage will no-op.
$sudo rm -f "${package_provided}/cross-${cross_chost}" $sudo rm -f "${package_provided}/cross-${cross_chost}"
local cross_deps=$(ROOT="$ROOT" _get_dependency_list \ local cross_deps=$(ROOT="$ROOT" SYSROOT="$ROOT" _get_dependency_list \
"$@" "${TOOLCHAIN_PKGS[@]}" | $sudo tee \ "$@" "${TOOLCHAIN_PKGS[@]}" | $sudo tee \
"$ROOT/etc/portage/cross-${cross_chost}-depends") "$ROOT/etc/portage/cross-${cross_chost}-depends")