Cleanup of adding pristine image and fixing of symlinks in developer image.

TEST=Tested with building a new image, looking in the output directory, running
the image and running vi.

Review URL: http://codereview.chromium.org/2075019
This commit is contained in:
Chris Sosa 2010-05-20 10:14:06 -07:00
parent 7c982f7398
commit d44550272c
5 changed files with 25 additions and 3 deletions

View File

@ -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

View File

@ -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"
}

View File

@ -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.

View File

@ -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}"

View File

@ -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}"