aboutsummaryrefslogtreecommitdiff
path: root/sample_images/generate_images.sh
diff options
context:
space:
mode:
authorAmin Hassani <ahassani@google.com>2017-08-23 14:29:40 -0700
committerchrome-bot <chrome-bot@chromium.org>2017-10-06 21:31:04 -0700
commitd7da8f4118c10d00d02b6274edd2f88971a6cb22 (patch)
tree25374d030530a3699705cf68dc4376d1ff2c611b /sample_images/generate_images.sh
parent3ba7a0819210d3e7d016f771c298865cae19efd4 (diff)
downloadupdate_engine-d7da8f4118c10d00d02b6274edd2f88971a6cb22.tar.gz
update_engine: Add Squashfs (phase 1)
Currently the Android container in CrOS is a Squashfs image (around 500MB) and the update engine treats it as one single file. This patch uses -map flag in 'unsquashfs' to get the location of files inside the Squashfs image. and creates a list of files that can be used in payload generator to create a delta. This patch adds support for both Squashfs file system and its appropriate unittests. However, we do not activate it in this patch, further patches will activate and use it in the payload generator. BUG=chromium:767120 TEST=cros_workon_make --board=amd64-generic --test update_engine; CQ-DEPEND=CL:650518,CL:686034 Change-Id: I02179727cd736661704d0ca2d9f881754b332b36 Reviewed-on: https://chromium-review.googlesource.com/636105 Commit-Ready: Amin Hassani <ahassani@chromium.org> Tested-by: Amin Hassani <ahassani@chromium.org> Reviewed-by: Ben Chan <benchan@chromium.org>
Diffstat (limited to 'sample_images/generate_images.sh')
-rwxr-xr-xsample_images/generate_images.sh45
1 files changed, 29 insertions, 16 deletions
diff --git a/sample_images/generate_images.sh b/sample_images/generate_images.sh
index 6a0d1ea0..8478682e 100755
--- a/sample_images/generate_images.sh
+++ b/sample_images/generate_images.sh
@@ -26,12 +26,15 @@ set -e
# cleanup <path>
# Unmount and remove the mountpoint <path>
cleanup() {
- if ! sudo umount "$1" 2>/dev/null; then
- if mountpoint -q "$1"; then
- sync && sudo umount "$1"
+ local path="$1"
+ if ! sudo umount "${path}" 2>/dev/null; then
+ if mountpoint -q "${path}"; then
+ sync && sudo umount "${path}"
fi
fi
- rmdir "$1"
+ if [ -n "${path}" ]; then
+ sudo rm -rf "${path}"
+ fi
}
# add_files_default <mntdir> <block_size>
@@ -203,10 +206,11 @@ EOF
# generate_fs <filename> <kind> <size> [block_size] [block_groups]
generate_fs() {
local filename="$1"
- local kind="$2"
- local size="$3"
- local block_size="${4:-4096}"
- local block_groups="${5:-}"
+ local type="$2"
+ local kind="$3"
+ local size="$4"
+ local block_size="${5:-4096}"
+ local block_groups="${6:-}"
local mkfs_opts=( -q -F -b "${block_size}" -L "ROOT-TEST" -t ext2 )
if [[ -n "${block_groups}" ]]; then
@@ -215,16 +219,17 @@ generate_fs() {
local mntdir=$(mktemp --tmpdir -d generate_ext2.XXXXXX)
trap 'cleanup "${mntdir}"; rm -f "${filename}"' INT TERM EXIT
-
# Cleanup old image.
if [[ -e "${filename}" ]]; then
rm -f "${filename}"
fi
- truncate --size="${size}" "${filename}"
- mkfs.ext2 "${mkfs_opts[@]}" "${filename}"
- sudo mount "${filename}" "${mntdir}" -o loop
+ if [[ "${type}" == "ext2" ]]; then
+ truncate --size="${size}" "${filename}"
+ mkfs.ext2 "${mkfs_opts[@]}" "${filename}"
+ sudo mount "${filename}" "${mntdir}" -o loop
+ fi
case "${kind}" in
unittest)
add_files_ue_settings "${mntdir}" "${block_size}"
@@ -237,6 +242,10 @@ generate_fs() {
;;
esac
+ if [[ "${type}" == "sqfs" ]]; then
+ mksquashfs "${mntdir}" "${filename}"
+ fi
+
cleanup "${mntdir}"
trap - INT TERM EXIT
}
@@ -253,10 +262,14 @@ generate_image() {
main() {
# Add more sample images here.
- generate_image disk_ext2_1k default $((1024 * 1024)) 1024
- generate_image disk_ext2_4k default $((1024 * 4096)) 4096
- generate_image disk_ext2_4k_empty empty $((1024 * 4096)) 4096
- generate_image disk_ext2_unittest unittest $((1024 * 4096)) 4096
+ generate_image disk_ext2_1k ext2 default $((1024 * 1024)) 1024
+ generate_image disk_ext2_4k ext2 default $((1024 * 4096)) 4096
+ generate_image disk_ext2_4k_empty ext2 empty $((1024 * 4096)) 4096
+ generate_image disk_ext2_unittest ext2 unittest $((1024 * 4096)) 4096
+
+ # Add squashfs sample images.
+ generate_image disk_sqfs_empty sqfs empty $((1024 * 4096)) 4096
+ generate_image disk_sqfs_default sqfs default $((1024 * 4096)) 4096
# Generate the tarball and delete temporary images.
echo "Packing tar file sample_images.tar.bz2"