From afff45366a5e4b524e6fee4bb335e9f76d5610d0 Mon Sep 17 00:00:00 2001 From: David Michael Date: Mon, 27 Aug 2018 13:16:36 +0000 Subject: [PATCH 1/4] build_toolchains: Update sysroot settings for newer portage Since EAPI=7 was supported, portage can no longer use different ROOT and SYSROOT values. This adjusts the paths so that the first phase builds cross-toolchains under /usr/${CHOST}, then the native toolchains are built under /build/${BOARD} (as was being done previously). Now that the cross-toolchain development files can't be used when building the native toolchain, the headers and libs are stupidly copied into the board root to be used used and then overwritten by the board packages as they are built. Since this is all done in a chroot, these changes shouldn't affect the SDK host. --- build_library/catalyst_toolchains.sh | 9 +++++++-- build_library/toolchain_util.sh | 4 ++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/build_library/catalyst_toolchains.sh b/build_library/catalyst_toolchains.sh index 07428f7350..2ab4c46dae 100644 --- a/build_library/catalyst_toolchains.sh +++ b/build_library/catalyst_toolchains.sh @@ -19,17 +19,22 @@ configure_target_root() { CBUILD="$(portageq envvar CBUILD)" \ CHOST="${cross_chost}" \ ROOT="/build/${board}" \ - SYSROOT="/usr/${cross_chost}" \ + SYSROOT="/build/${board}" \ _configure_sysroot "${profile}" } build_target_toolchain() { local board="$1" local ROOT="/build/${board}" + local SYSROOT="/usr/$(get_board_chost "${board}")" + + mkdir -p "${ROOT}/usr" + cp -at "${ROOT}" "${SYSROOT}"/lib* + cp -at "${ROOT}"/usr "${SYSROOT}"/usr/include "${SYSROOT}"/usr/lib* # --root is required because run_merge overrides ROOT= PORTAGE_CONFIGROOT="$ROOT" \ - run_merge -u --root="$ROOT" "${TOOLCHAIN_PKGS[@]}" + run_merge -u --root="$ROOT" --sysroot="$ROOT" "${TOOLCHAIN_PKGS[@]}" } configure_crossdev_overlay / /tmp/crossdev diff --git a/build_library/toolchain_util.sh b/build_library/toolchain_util.sh index d8649a12d1..53f829a4b4 100644 --- a/build_library/toolchain_util.sh +++ b/build_library/toolchain_util.sh @@ -257,7 +257,7 @@ _configure_sysroot() { $sudo eselect profile set --force "$profile" $sudo tee "${ROOT}/etc/portage/make.conf" >/dev/null </dev/null # OK, clear as mud? Install those dependencies now! - PORTAGE_CONFIGROOT="$ROOT" ROOT="$ROOT" $sudo emerge "$@" -u $cross_deps + PORTAGE_CONFIGROOT="$ROOT" $sudo emerge --root="$ROOT" --sysroot="$ROOT" "$@" -u $cross_deps } # Get the latest GCC profile for a given CHOST From 8556474e6a4b13967a2cb029773008cc39cbea0f Mon Sep 17 00:00:00 2001 From: David Michael Date: Tue, 28 Aug 2018 02:39:59 +0000 Subject: [PATCH 2/4] build_torcx_store: Update for newer portage versions Since EAPI=7 was supported, portage can no longer use different ROOT and SYSROOT values. The torcx images were installed into a temporary root directory after being built using the board's development files. To continue using this setup, the torcx image's packages are built as normal binary packages for the board root without being installed, then the binary packages are installed in the temporary torcx root. --- build_torcx_store | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/build_torcx_store b/build_torcx_store index b17a027775..3e1d59a9ec 100755 --- a/build_torcx_store +++ b/build_torcx_store @@ -79,12 +79,25 @@ function torcx_build() ( [ -s "${tmproot}/etc/portage/bashrc" ] && . "${tmproot}/etc/portage/bashrc" + # Build binary packages using dev files in the board root. + emerge-${BOARD} \ + --buildpkg \ + --buildpkgonly \ + --nodeps \ + --oneshot \ + --quiet \ + --root-deps=rdeps \ + "${pkg}" + + # Install the binary packages in the temporary torcx image root. emerge-${BOARD} \ --nodeps \ --oneshot \ + --quiet \ --root="${tmproot}" \ --root-deps=rdeps \ - --quiet \ + --sysroot="${tmproot}" \ + --usepkgonly \ "${pkg}" ) From ce2e7e8a17a8026d5681d771f34df633ac6aec98 Mon Sep 17 00:00:00 2001 From: David Michael Date: Tue, 28 Aug 2018 13:46:27 +0000 Subject: [PATCH 3/4] setup_board: Drop needless SYSROOT when installing binpkgs For the less common case where binpkgs are not used, restructure this so that it builds binpkgs in /usr/${CHOST} without installing them, use those binpkgs to initialize /build/${BOARD}. --- setup_board | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/setup_board b/setup_board index ec6129a8fe..6e16283f8a 100755 --- a/setup_board +++ b/setup_board @@ -305,19 +305,28 @@ if [[ ${FLAGS_regen_configs} -eq ${FLAGS_FALSE} ]]; then EMERGE_FLAGS+=" --usepkg" fi EMERGE_FLAGS+=" --getbinpkg" - EMERGE_TOOLCHAIN_FLAGS+=" --usepkgonly --getbinpkg --rebuilt-binaries n" - else - # When binary packages are disabled we need to make sure the cross - # sysroot includes any build dependencies for the toolchain. - info "Installing toolchain build dependencies" - install_cross_libs "${BOARD_CHOST}" ${EMERGE_FLAGS} --buildpkg=n fi info "Installing baselayout" "${EMERGE_WRAPPER}" ${EMERGE_FLAGS} --nodeps sys-apps/baselayout + if [[ "${FLAGS_usepkg}" -ne "${FLAGS_TRUE}" || + "${FLAGS_getbinpkg}" -ne "${FLAGS_TRUE}" ]] + then + # When binary packages are disabled we need to make sure the cross + # sysroot includes any build dependencies for the toolchain. + info "Installing toolchain build dependencies" + install_cross_libs "${BOARD_CHOST}" ${EMERGE_FLAGS} --buildpkg=n + + info "Building toolchain" + "${EMERGE_WRAPPER}" --buildpkg --buildpkgonly \ + --root="/usr/${BOARD_CHOST}" --sysroot="/usr/${BOARD_CHOST}" \ + ${EMERGE_TOOLCHAIN_FLAGS} "${TOOLCHAIN_PKGS[@]}" + fi + info "Installing toolchain" - SYSROOT="/usr/${BOARD_CHOST}" "${EMERGE_WRAPPER}" \ + "${EMERGE_WRAPPER}" \ + --usepkgonly --getbinpkg --rebuilt-binaries n \ ${EMERGE_TOOLCHAIN_FLAGS} "${TOOLCHAIN_PKGS[@]}" fi From 5ffb93893438395e2f9558e3744fc149670b87e8 Mon Sep 17 00:00:00 2001 From: David Michael Date: Thu, 30 Aug 2018 00:53:17 +0000 Subject: [PATCH 4/4] image_to_vm: Fix OEM install roots for new portage --- build_library/vm_image_util.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/build_library/vm_image_util.sh b/build_library/vm_image_util.sh index 7fd5408124..2732ac2391 100644 --- a/build_library/vm_image_util.sh +++ b/build_library/vm_image_util.sh @@ -464,7 +464,7 @@ install_oem_package() { # build anything else from source here. emerge doesn't have a way to # enforce this in a single command. info "Building ${oem_pkg}" - USE="${oem_use}" emerge-${BOARD} --root="${oem_tmp}" \ + USE="${oem_use}" emerge-${BOARD} \ --nodeps --buildpkgonly --usepkg n \ --quiet "${oem_pkg}" @@ -474,7 +474,8 @@ install_oem_package() { fi info "Installing ${oem_pkg} to OEM partition" - USE="${oem_use}" emerge-${BOARD} --root="${oem_tmp}" \ + USE="${oem_use}" emerge-${BOARD} \ + --root="${oem_tmp}" --sysroot="${oem_tmp}" \ --root-deps=rdeps --usepkgonly ${getbinpkg} \ --quiet --jobs=2 "${oem_pkg}" sudo rsync -a "${oem_tmp}/usr/share/oem/" "${VM_TMP_ROOT}/usr/share/oem/"