diff --git a/archive_build.sh b/archive_build.sh index d050fd52ca..a7b767e162 100755 --- a/archive_build.sh +++ b/archive_build.sh @@ -106,10 +106,8 @@ if [ $FLAGS_test_mod -eq $FLAGS_TRUE ] then echo "Modifying image for test" SRC_IMAGE="${FLAGS_from}/chromiumos_image.bin" - cp -f "${SRC_IMAGE}" "${FLAGS_from}/chromiumos_image_bkup.bin" ./enter_chroot.sh -- ./mod_image_for_test.sh --board $FLAGS_board --yes mv "$SRC_IMAGE" "${FLAGS_from}/chromiumos_test_image.bin" - mv "${FLAGS_from}/chromiumos_image_bkup.bin" "$SRC_IMAGE" cd "${FLAGS_chroot}/build/${FLAGS_board}/usr/local" echo "Archiving autotest build artifacts" tar cjf "${FLAGS_from}/autotest.tar.bz2" autotest diff --git a/build_image b/build_image index baeb224fef..0ba6531200 100755 --- a/build_image +++ b/build_image @@ -237,6 +237,7 @@ create_developer_image() { trap - EXIT $SCRIPTS_DIR/mount_gpt_image.sh -u -r "$root_fs_dir" -s "$stateful_dir" + sudo rm -rf "$root_fs_dir" "$stateful_dir" echo "Developer image built and stored at $output_img" } diff --git a/common.sh b/common.sh index 4d0834cee6..395310b43c 100644 --- a/common.sh +++ b/common.sh @@ -369,6 +369,26 @@ function safe_umount { fi } +# 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}/*") + 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. diff --git a/image_to_usb.sh b/image_to_usb.sh index cd11df764c..844e3758f1 100755 --- a/image_to_usb.sh +++ b/image_to_usb.sh @@ -30,6 +30,8 @@ DEFINE_boolean copy_kernel ${FLAGS_FALSE} \ "Copy the kernel to the fourth partition." DEFINE_boolean test_image "${FLAGS_FALSE}" \ "Copies normal image to chromiumos_test_image.bin, modifies it for test." +DEFINE_string image_name "chromiumos_image.bin" \ + "Base name of the image" i DEFINE_string build_root "/build" \ "The root location for board sysroots." @@ -88,7 +90,7 @@ FLAGS_from=`eval readlink -f ${FLAGS_from}` FLAGS_to=`eval readlink -f ${FLAGS_to}` # Use this image as the source image to copy -SRC_IMAGE="${FLAGS_from}/chromiumos_image.bin" +SRC_IMAGE="${FLAGS_from}/${FLAGS_image_name}" STATEFUL_DIR="${FLAGS_from}/stateful_partition" mkdir -p "${STATEFUL_DIR}" diff --git a/mount_gpt_image.sh b/mount_gpt_image.sh index a40a6bc315..64e2a4034d 100755 --- a/mount_gpt_image.sh +++ b/mount_gpt_image.sh @@ -44,6 +44,7 @@ function unmount_image() { # Reset symlinks in /usr/local. setup_symlinks_on_root "/usr/local" "/var" \ "${FLAGS_stateful_mountpt}" + fix_broken_symlinks "${FLAGS_rootfs_mountpt}" sudo umount "${FLAGS_rootfs_mountpt}/usr/local" sudo umount "${FLAGS_rootfs_mountpt}/var" sudo umount -d "${FLAGS_stateful_mountpt}"