diff --git a/build_library/base_image_util.sh b/build_library/base_image_util.sh index 598785bdc0..97cd3b0c14 100755 --- a/build_library/base_image_util.sh +++ b/build_library/base_image_util.sh @@ -125,28 +125,13 @@ create_base_image() { sudo mount -o loop "${oem_fs_img}" "${oem_fs_dir}" # Prepare state partition with some pre-created directories. - for i in ${ROOT_OVERLAYS}; do + info "Binding directories from state partition onto the rootfs" + for i in "${ROOT_OVERLAYS[@]}"; do sudo mkdir -p "${state_fs_dir}/overlays/$i" sudo mkdir -p "${root_fs_dir}/$i" sudo mount --bind "${state_fs_dir}/overlays/$i" "${root_fs_dir}/$i" done - sudo mkdir -p "${state_fs_dir}/overlays/usr/local" - - # Create symlinks so that /usr/local/usr based directories are symlinked to - # /usr/local/ directories e.g. /usr/local/usr/bin -> /usr/local/bin, etc. - setup_symlinks_on_root "${state_fs_dir}/overlays/usr/local" \ - "${state_fs_dir}/overlays/var" \ - "${state_fs_dir}" - - # Perform binding rather than symlinking because directories must exist - # on rootfs so that we can bind at run-time since rootfs is read-only. - info "Binding directories from state partition onto the rootfs" - - # Setup the dev image for developer tools - sudo mkdir -p "${root_fs_dir}/usr/local" - sudo mount --bind "${state_fs_dir}/overlays/usr/local" "${root_fs_dir}/usr/local" - # TODO(bp): remove these temporary fixes for /mnt/stateful_partition going moving sudo mkdir -p "${root_fs_dir}/mnt/stateful_partition/" sudo ln -s /media/state/overlays/usr/local "${root_fs_dir}/mnt/stateful_partition/dev_image" @@ -154,8 +139,6 @@ create_base_image() { sudo ln -s /media/state/overlays/var "${root_fs_dir}/mnt/stateful_partition/var_overlay" sudo ln -s /media/state/etc "${root_fs_dir}/mnt/stateful_partition/etc" - sudo mkdir -p "${root_fs_dir}/dev" - info "Binding directories from OEM partition onto the rootfs" sudo mkdir -p "${root_fs_dir}/usr/share/oem" sudo mount --bind "${oem_fs_dir}" "${root_fs_dir}/usr/share/oem" @@ -237,11 +220,6 @@ create_base_image() { test_image_content "$root_fs_dir" fi - # Clean up symlinks so they work on a running target rooted at "/". - # Here development packages are rooted at /usr/local. However, do not - # create /usr/local or /var on host (already exist on target). - setup_symlinks_on_root "/usr/local" "/var" "${state_fs_dir}" - # Zero all fs free space to make it more compressible so auto-update # payloads become smaller, not fatal since it won't work on linux < 3.2 sudo fstrim "${root_fs_dir}" || true diff --git a/build_library/dev_image_util.sh b/build_library/dev_image_util.sh index c05410aed6..59140e6df5 100755 --- a/build_library/dev_image_util.sh +++ b/build_library/dev_image_util.sh @@ -19,26 +19,17 @@ install_dev_packages() { mount_image "${BUILD_DIR}/${image_name}" "${root_fs_dir}" \ "${state_fs_dir}" "${esp_fs_dir}" - # Determine the root dir for developer packages. - local root_dev_dir="${root_fs_dir}/usr/local" - - # Install developer packages described in chromeos-dev. - emerge_to_image --root="${root_dev_dir}" coreos-base/coreos-dev + # 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/local/usr/lib/debug" + sudo mkdir -p "${root_fs_dir}/usr/lib/debug" pbzip2 -dc --ignore-trailing-garbage=1 "${LIBC_PATH}" | \ - sudo tar xpf - -C "${root_fs_dir}/usr/local/usr/lib/debug" \ + sudo tar xpf - -C "${root_fs_dir}/usr/lib/debug" \ ./usr/lib/debug/usr/${CHOST} --strip-components=6 - # Since gdb only looks in /usr/lib/debug, symlink the /usr/local - # path so that it is found automatically. - sudo ln -s /usr/local/usr/lib/debug "${root_fs_dir}/usr/lib/debug" # Install the bare necessary files so that the "emerge" command works - sudo sed -i s,/usr/bin/wget,wget, \ - ${root_fs_dir}/usr/share/portage/config/make.globals - sudo mkdir -p ${root_fs_dir}/etc/make.profile # Mark the image as a developer image (input to chromeos_startup). @@ -48,53 +39,6 @@ install_dev_packages() { sudo mkdir -p "${root_fs_dir}/root" sudo touch "${root_fs_dir}/root/.dev_mode" - # Additional changes to developer image. - - # Leave core files for developers to inspect. - sudo touch "${root_fs_dir}/root/.leave_core" - - # This hack is only needed for devs who have old versions of glibc, which - # filtered out ldd when cross-compiling. TODO(davidjames): Remove this hack - # once everybody has upgraded to a new version of glibc. - if [[ ! -x "${root_fs_dir}/usr/bin/ldd" ]]; then - sudo cp -a "$(which ldd)" "${root_fs_dir}/usr/bin" - fi - - # If vim is installed, then a vi symlink would probably help. - if [[ -x "${root_fs_dir}/usr/local/bin/vim" ]]; then - sudo ln -sf vim "${root_fs_dir}/usr/local/bin/vi" - fi - - # If pygtk is installed in stateful-dev, then install a path. - if [[ -d \ - "${root_fs_dir}/usr/local/lib/python2.6/site-packages/gtk-2.0" ]]; then - sudo bash -c "\ - echo gtk-2.0 > \ - ${root_fs_dir}/usr/local/lib/python2.6/site-packages/pygtk.pth" - fi - - # File searches /usr/share by default, so add a wrapper script so it - # can find the right path in /usr/local. - local path="${root_fs_dir}/usr/local/bin/file" - if [[ -x ${path} ]]; then - sudo mv "${path}" "${path}.bin" - sudo_clobber "${path}" <.*$/\1/' } -# Fixes symlinks that are incorrectly prefixed with the build root $1 -# rather than the real running root '/'. -# TODO(sosa) - Merge setup - cleanup below with this method. -fix_broken_symlinks() { - local build_root=$1 - local symlinks=$(find "${build_root}/usr/local" -lname "${build_root}/*") - local symlink - for symlink in ${symlinks}; do - echo "Fixing ${symlink}" - local target=$(ls -l "${symlink}" | cut -f 2 -d '>') - # Trim spaces from target (bashism). - target=${target/ /} - # Make new target (removes rootfs prefix). - new_target=$(echo ${target} | sed "s#${build_root}##") - - echo "Fixing symlink ${symlink}" - sudo unlink "${symlink}" - sudo ln -sf "${new_target}" "${symlink}" - done -} - -# Sets up symlinks for the developer root. It is necessary to symlink -# usr and local since the developer root is mounted at /usr/local and -# applications expect to be installed under /usr/local/bin, etc. -# This avoids packages installing into /usr/local/usr/local/bin. -# $1 specifies the symlink target for the developer root. -# $2 specifies the symlink target for the var directory. -# $3 specifies the location of the stateful partition. -setup_symlinks_on_root() { - # Give args better names. - local dev_image_target=$1 - local var_target=$2 - local dev_image_root="$3/overlays/usr/local" - - # If our var target is actually the standard var, we are cleaning up the - # symlinks (could also check for /usr/local for the dev_image_target). - if [[ ${var_target} == "/var" ]]; then - echo "Cleaning up /usr/local symlinks for ${dev_image_root}" - else - echo "Setting up symlinks for /usr/local for ${dev_image_root}" - fi - - # Set up symlinks that should point to ${dev_image_target}. - local path - for path in usr local; do - if [[ -h ${dev_image_root}/${path} ]]; then - sudo unlink "${dev_image_root}/${path}" - elif [[ -e ${dev_image_root}/${path} ]]; then - die "${dev_image_root}/${path} should be a symlink if exists" - fi - sudo ln -s "${dev_image_target}" "${dev_image_root}/${path}" - done - - # Setup var symlink. - if [[ -h ${dev_image_root}/var ]]; then - sudo unlink "${dev_image_root}/var" - elif [[ -e ${dev_image_root}/var ]]; then - die "${dev_image_root}/var should be a symlink if it exists" - fi - - sudo ln -s "${var_target}" "${dev_image_root}/var" -} - # These two helpers clobber the ro compat value in our root filesystem. # # When the system is built with --enable_rootfs_verification, bit-precise diff --git a/mount_gpt_image.sh b/mount_gpt_image.sh index e6302f7cd9..579f9d7853 100755 --- a/mount_gpt_image.sh +++ b/mount_gpt_image.sh @@ -79,12 +79,6 @@ unmount_image() { "and ${FLAGS_rootfs_mountpt}" # Don't die on error to force cleanup set +e - # Reset symlinks in /usr/local. - if mount | egrep -q ".* ${FLAGS_stateful_mountpt} .*\(rw,"; then - setup_symlinks_on_root "/usr/local" "/var" \ - "${FLAGS_stateful_mountpt}" - fix_broken_symlinks "${FLAGS_rootfs_mountpt}" - fi safe_umount "${FLAGS_rootfs_mountpt}/usr/local" safe_umount "${FLAGS_rootfs_mountpt}/var" if [[ -n "${FLAGS_esp_mountpt}" ]]; then @@ -183,12 +177,6 @@ mount_image() { "${FLAGS_rootfs_mountpt}/var" sudo mount --bind "${FLAGS_stateful_mountpt}/overlays/usr/local" \ "${FLAGS_rootfs_mountpt}/usr/local" - # Setup symlinks in /usr/local so you can emerge packages into /usr/local. - - if [ ${FLAGS_read_only} -eq ${FLAGS_FALSE} ]; then - setup_symlinks_on_root "${FLAGS_stateful_mountpt}/overlays/usr/local" \ - "${FLAGS_stateful_mountpt}/overlays/var" "${FLAGS_stateful_mountpt}" - fi info "Image specified by ${FLAGS_from} mounted at"\ "${FLAGS_rootfs_mountpt} successfully." }