From d3a3a8876826311ad4d425ffd56b44c6957af018 Mon Sep 17 00:00:00 2001 From: Michael Marineau Date: Sun, 1 Dec 2013 14:31:01 -0800 Subject: [PATCH] fix(base_image_util.sh): Install glibc and gcc libs via emerge. --- build_library/base_image_util.sh | 47 +++++-------------------------- build_library/build_image_util.sh | 21 ++++++++++++++ build_library/dev_image_util.sh | 8 ++---- 3 files changed, 30 insertions(+), 46 deletions(-) diff --git a/build_library/base_image_util.sh b/build_library/base_image_util.sh index d3cc554bfb..61ce7749df 100755 --- a/build_library/base_image_util.sh +++ b/build_library/base_image_util.sh @@ -146,53 +146,20 @@ create_base_image() { sudo -E USE=build "emerge-${BOARD}" --root="${root_fs_dir}" \ --usepkg=n --buildpkg=n --oneshot --quiet --nodeps sys-apps/baselayout - # We need to install libc manually from the cross toolchain. - # TODO: Improve this? It would be ideal to use emerge to do this. - PKGDIR="/var/lib/portage/pkgs" - LIBC_TAR="glibc-${LIBC_VERSION}.tbz2" - LIBC_PATH="${PKGDIR}/cross-${CHOST}/${LIBC_TAR}" - - if ! [[ -e ${LIBC_PATH} ]]; then - die_notrace \ - "${LIBC_PATH} does not exist. Try running ./setup_board" \ - "--board=${BOARD} to update the version of libc installed on that board." - fi - - # Strip out files we don't need in the final image at runtime. - local libc_excludes=( - # Compile-time headers. - 'usr/include' 'sys-include' - # Link-time objects. - '*.[ao]' - # Empty lib dirs, replaced by symlinks - 'lib' - # Locales and info pages - usr/share/{i18n,info,locale} - ) - - mkdir -p "${root_fs_dir}"/sbin "${root_fs_dir}"/lib64 - lbzip2 -dc "${LIBC_PATH}" | \ - sudo tar xpf - -C "${root_fs_dir}" ./usr/${CHOST} \ - --strip-components=3 "${libc_excludes[@]/#/--exclude=}" \ - --exclude=${CHOST}/sbin --exclude=${CHOST}/lib64 - lbzip2 -dc "${LIBC_PATH}" | \ - sudo tar xpf - -C "${root_fs_dir}"/lib64 ./usr/${CHOST}/lib64 \ - --strip-components=4 "${libc_excludes[@]/#/--exclude=}" - lbzip2 -dc "${LIBC_PATH}" | \ - sudo tar xpf - -C "${root_fs_dir}"/sbin ./usr/${CHOST}/sbin \ - --strip-components=4 "${libc_excludes[@]/#/--exclude=}" - - board_ctarget=$(get_ctarget_from_board "${BOARD}") - for atom in $(portageq match / cross-$board_ctarget/gcc); do - copy_gcc_libs "${root_fs_dir}" $atom - done + # FIXME(marineam): Work around glibc setting EROOT=$ROOT + # https://bugs.gentoo.org/show_bug.cgi?id=473728#c12 + sudo mkdir -p "${root_fs_dir}/etc/ld.so.conf.d" # We "emerge --root=${root_fs_dir} --root-deps=rdeps --usepkgonly" all of the # runtime packages for chrome os. This builds up a chrome os image from # binary packages with runtime dependencies only. We use INSTALL_MASK to # trim the image size as much as possible. + emerge_prod_gcc --root="${root_fs_dir}" emerge_to_image --root="${root_fs_dir}" ${BASE_PACKAGE} + # Make sure profile.env and ld.so.cache has been generated + sudo ROOT="${root_fs_dir}" env-update + # Record directories installed to the state partition. # Ignore /var/tmp, systemd covers this entry. sudo "${BUILD_LIBRARY_DIR}/gen_tmpfiles.py" --root="${root_fs_dir}" \ diff --git a/build_library/build_image_util.sh b/build_library/build_image_util.sh index 1adc1055ec..f9288e0627 100755 --- a/build_library/build_image_util.sh +++ b/build_library/build_image_util.sh @@ -142,3 +142,24 @@ emerge_to_image() { sudo -E INSTALL_MASK="$mask" ${emerge_cmd} "$@" } + +# The GCC package includes both its libraries and the compiler. +# In prod images we only need the shared libraries. +emerge_prod_gcc() { + local mask="${INSTALL_MASK:-$(portageq-$BOARD envvar PROD_INSTALL_MASK)}" + test -n "$mask" || die "PROD_INSTALL_MASK not defined" + + mask="${mask} + /usr/bin + /usr/*/gcc-bin + /usr/lib/gcc/*/*/*.o + /usr/lib/gcc/*/*/include + /usr/lib/gcc/*/*/include-fixed + /usr/lib/gcc/*/*/plugin + /usr/libexec + /usr/share/gcc-data/*/*/c89 + /usr/share/gcc-data/*/*/c99 + /usr/share/gcc-data/*/*/python" + + INSTALL_MASK="${mask}" emerge_to_image --nodeps sys-devel/gcc "$@" +} diff --git a/build_library/dev_image_util.sh b/build_library/dev_image_util.sh index 9b7f9ffa75..d48129bb52 100755 --- a/build_library/dev_image_util.sh +++ b/build_library/dev_image_util.sh @@ -22,12 +22,8 @@ install_dev_packages() { # Install developer packages described in coreos-dev. emerge_to_image --root="${root_fs_dir}" coreos-base/coreos-dev - # Copy over the libc debug info so that gdb - # works with threads and also for a better debugging experience. - sudo mkdir -p "${root_fs_dir}/usr/lib/debug" - lbzip2 -dc "${LIBC_PATH}" | \ - sudo tar xpf - -C "${root_fs_dir}/usr/lib/debug" \ - ./usr/lib/debug/usr/${CHOST} --strip-components=6 + # Make sure profile.env and ld.so.cache has been generated + sudo ROOT="${root_fs_dir}" env-update # Install the bare necessary files so that the "emerge" command works sudo mkdir -p ${root_fs_dir}/etc/make.profile