mirror of
https://github.com/flatcar/scripts.git
synced 2025-09-23 14:41:31 +02:00
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:
parent
7c982f7398
commit
d44550272c
@ -106,10 +106,8 @@ if [ $FLAGS_test_mod -eq $FLAGS_TRUE ]
|
|||||||
then
|
then
|
||||||
echo "Modifying image for test"
|
echo "Modifying image for test"
|
||||||
SRC_IMAGE="${FLAGS_from}/chromiumos_image.bin"
|
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
|
./enter_chroot.sh -- ./mod_image_for_test.sh --board $FLAGS_board --yes
|
||||||
mv "$SRC_IMAGE" "${FLAGS_from}/chromiumos_test_image.bin"
|
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"
|
cd "${FLAGS_chroot}/build/${FLAGS_board}/usr/local"
|
||||||
echo "Archiving autotest build artifacts"
|
echo "Archiving autotest build artifacts"
|
||||||
tar cjf "${FLAGS_from}/autotest.tar.bz2" autotest
|
tar cjf "${FLAGS_from}/autotest.tar.bz2" autotest
|
||||||
|
@ -237,6 +237,7 @@ create_developer_image() {
|
|||||||
|
|
||||||
trap - EXIT
|
trap - EXIT
|
||||||
$SCRIPTS_DIR/mount_gpt_image.sh -u -r "$root_fs_dir" -s "$stateful_dir"
|
$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"
|
echo "Developer image built and stored at $output_img"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
20
common.sh
20
common.sh
@ -369,6 +369,26 @@ function safe_umount {
|
|||||||
fi
|
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
|
# 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
|
# usr and local since the developer root is mounted at /usr/local and
|
||||||
# applications expect to be installed under /usr/local/bin, etc.
|
# applications expect to be installed under /usr/local/bin, etc.
|
||||||
|
@ -30,6 +30,8 @@ DEFINE_boolean copy_kernel ${FLAGS_FALSE} \
|
|||||||
"Copy the kernel to the fourth partition."
|
"Copy the kernel to the fourth partition."
|
||||||
DEFINE_boolean test_image "${FLAGS_FALSE}" \
|
DEFINE_boolean test_image "${FLAGS_FALSE}" \
|
||||||
"Copies normal image to chromiumos_test_image.bin, modifies it for test."
|
"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" \
|
DEFINE_string build_root "/build" \
|
||||||
"The root location for board sysroots."
|
"The root location for board sysroots."
|
||||||
|
|
||||||
@ -88,7 +90,7 @@ FLAGS_from=`eval readlink -f ${FLAGS_from}`
|
|||||||
FLAGS_to=`eval readlink -f ${FLAGS_to}`
|
FLAGS_to=`eval readlink -f ${FLAGS_to}`
|
||||||
|
|
||||||
# Use this image as the source image to copy
|
# 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"
|
STATEFUL_DIR="${FLAGS_from}/stateful_partition"
|
||||||
mkdir -p "${STATEFUL_DIR}"
|
mkdir -p "${STATEFUL_DIR}"
|
||||||
|
@ -44,6 +44,7 @@ function unmount_image() {
|
|||||||
# Reset symlinks in /usr/local.
|
# Reset symlinks in /usr/local.
|
||||||
setup_symlinks_on_root "/usr/local" "/var" \
|
setup_symlinks_on_root "/usr/local" "/var" \
|
||||||
"${FLAGS_stateful_mountpt}"
|
"${FLAGS_stateful_mountpt}"
|
||||||
|
fix_broken_symlinks "${FLAGS_rootfs_mountpt}"
|
||||||
sudo umount "${FLAGS_rootfs_mountpt}/usr/local"
|
sudo umount "${FLAGS_rootfs_mountpt}/usr/local"
|
||||||
sudo umount "${FLAGS_rootfs_mountpt}/var"
|
sudo umount "${FLAGS_rootfs_mountpt}/var"
|
||||||
sudo umount -d "${FLAGS_stateful_mountpt}"
|
sudo umount -d "${FLAGS_stateful_mountpt}"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user