mirror of
https://github.com/flatcar/scripts.git
synced 2025-08-08 13:36:58 +02:00
use helper info/die funcs rather than raw echo
We have helper funcs already for displaying messages, so convert some raw `echo` calls to them. BUG=None TEST=build_image still works and boots Change-Id: Ie66cc59d0362ef6aa19011fa6cb0bc64a6a4fce8 Reviewed-on: https://gerrit.chromium.org/gerrit/14478 Reviewed-by: Richard Barnette <jrbarnette@chromium.org> Commit-Ready: Mike Frysinger <vapier@chromium.org> Tested-by: Mike Frysinger <vapier@chromium.org>
This commit is contained in:
parent
48df416640
commit
84f66f5864
@ -73,8 +73,7 @@ create_base_image() {
|
|||||||
|
|
||||||
ROOT_LOOP_DEV=$(sudo losetup --show -f "${ROOT_FS_IMG}")
|
ROOT_LOOP_DEV=$(sudo losetup --show -f "${ROOT_FS_IMG}")
|
||||||
if [ -z "${ROOT_LOOP_DEV}" ] ; then
|
if [ -z "${ROOT_LOOP_DEV}" ] ; then
|
||||||
echo "No free loop device. Free up a loop device or reboot. exiting. "
|
die "No free loop device. Free up a loop device or reboot. exiting. "
|
||||||
exit 1
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Specify a block size and block count to avoid using the hash pad.
|
# Specify a block size and block count to avoid using the hash pad.
|
||||||
@ -106,8 +105,7 @@ create_base_image() {
|
|||||||
DISK_LABEL="C-STATE"
|
DISK_LABEL="C-STATE"
|
||||||
STATEFUL_LOOP_DEV=$(sudo losetup --show -f "${STATEFUL_FS_IMG}")
|
STATEFUL_LOOP_DEV=$(sudo losetup --show -f "${STATEFUL_FS_IMG}")
|
||||||
if [ -z "${STATEFUL_LOOP_DEV}" ] ; then
|
if [ -z "${STATEFUL_LOOP_DEV}" ] ; then
|
||||||
echo "No free loop device. Free up a loop device or reboot. exiting. "
|
die "No free loop device. Free up a loop device or reboot. exiting. "
|
||||||
exit 1
|
|
||||||
fi
|
fi
|
||||||
sudo mkfs.ext4 "${STATEFUL_LOOP_DEV}"
|
sudo mkfs.ext4 "${STATEFUL_LOOP_DEV}"
|
||||||
sudo tune2fs -L "${DISK_LABEL}" -U "${UUID}" -c 0 -i 0 "${STATEFUL_LOOP_DEV}"
|
sudo tune2fs -L "${DISK_LABEL}" -U "${UUID}" -c 0 -i 0 "${STATEFUL_LOOP_DEV}"
|
||||||
@ -126,7 +124,7 @@ create_base_image() {
|
|||||||
|
|
||||||
# Perform binding rather than symlinking because directories must exist
|
# Perform binding rather than symlinking because directories must exist
|
||||||
# on rootfs so that we can bind at run-time since rootfs is read-only.
|
# on rootfs so that we can bind at run-time since rootfs is read-only.
|
||||||
echo "Binding directories from stateful partition onto the rootfs"
|
info "Binding directories from stateful partition onto the rootfs"
|
||||||
sudo mkdir -p "${ROOT_FS_DIR}/usr/local"
|
sudo mkdir -p "${ROOT_FS_DIR}/usr/local"
|
||||||
sudo mount --bind "${DEV_IMAGE_ROOT}" "${ROOT_FS_DIR}/usr/local"
|
sudo mount --bind "${DEV_IMAGE_ROOT}" "${ROOT_FS_DIR}/usr/local"
|
||||||
sudo mkdir -p "${ROOT_FS_DIR}/var"
|
sudo mkdir -p "${ROOT_FS_DIR}/var"
|
||||||
|
@ -67,15 +67,15 @@ build_gpt() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Now populate the partitions.
|
# Now populate the partitions.
|
||||||
echo "Copying stateful partition..."
|
info "Copying stateful partition..."
|
||||||
$sudo dd if="$stateful_img" of="$outdev" conv=notrunc bs=512 \
|
$sudo dd if="$stateful_img" of="$outdev" conv=notrunc bs=512 \
|
||||||
seek=$START_STATEFUL
|
seek=$START_STATEFUL
|
||||||
|
|
||||||
echo "Copying rootfs..."
|
info "Copying rootfs..."
|
||||||
$sudo dd if="$rootfs_img" of="$outdev" conv=notrunc bs=512 \
|
$sudo dd if="$rootfs_img" of="$outdev" conv=notrunc bs=512 \
|
||||||
seek=$START_ROOTFS_A
|
seek=$START_ROOTFS_A
|
||||||
|
|
||||||
echo "Copying EFI system partition..."
|
info "Copying EFI system partition..."
|
||||||
$sudo dd if="$esp_img" of="$outdev" conv=notrunc bs=512 \
|
$sudo dd if="$esp_img" of="$outdev" conv=notrunc bs=512 \
|
||||||
seek=$START_ESP
|
seek=$START_ESP
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
install_dev_packages() {
|
install_dev_packages() {
|
||||||
local image_name=$1
|
local image_name=$1
|
||||||
|
|
||||||
echo "Adding developer packages to ${image_name}"
|
info "Adding developer packages to ${image_name}"
|
||||||
|
|
||||||
trap "unmount_image ; delete_prompt" EXIT
|
trap "unmount_image ; delete_prompt" EXIT
|
||||||
|
|
||||||
@ -88,7 +88,7 @@ install_dev_packages() {
|
|||||||
if [ ${FLAGS_factory_install} -eq ${FLAGS_FALSE} ]; then
|
if [ ${FLAGS_factory_install} -eq ${FLAGS_FALSE} ]; then
|
||||||
test_image_content "$ROOT_FS_DIR"
|
test_image_content "$ROOT_FS_DIR"
|
||||||
fi
|
fi
|
||||||
echo "Developer image built and stored at ${image_name}"
|
info "Developer image built and stored at ${image_name}"
|
||||||
|
|
||||||
unmount_image
|
unmount_image
|
||||||
trap - EXIT
|
trap - EXIT
|
||||||
|
@ -73,7 +73,7 @@ fi
|
|||||||
|
|
||||||
# Common unmounts for either a device or directory
|
# Common unmounts for either a device or directory
|
||||||
function unmount_image() {
|
function unmount_image() {
|
||||||
echo "Unmounting image from ${FLAGS_stateful_mountpt}" \
|
info "Unmounting image from ${FLAGS_stateful_mountpt}" \
|
||||||
"and ${FLAGS_rootfs_mountpt}"
|
"and ${FLAGS_rootfs_mountpt}"
|
||||||
# Don't die on error to force cleanup
|
# Don't die on error to force cleanup
|
||||||
set +e
|
set +e
|
||||||
@ -185,7 +185,7 @@ function mount_image() {
|
|||||||
setup_symlinks_on_root "${FLAGS_stateful_mountpt}/dev_image" \
|
setup_symlinks_on_root "${FLAGS_stateful_mountpt}/dev_image" \
|
||||||
"${FLAGS_stateful_mountpt}/var" "${FLAGS_stateful_mountpt}"
|
"${FLAGS_stateful_mountpt}/var" "${FLAGS_stateful_mountpt}"
|
||||||
fi
|
fi
|
||||||
echo "Image specified by ${FLAGS_from} mounted at"\
|
info "Image specified by ${FLAGS_from} mounted at"\
|
||||||
"${FLAGS_rootfs_mountpt} successfully."
|
"${FLAGS_rootfs_mountpt} successfully."
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user