xref: /aosp_15_r20/system/update_engine/sample_images/generate_test_erofs_images.sh (revision 5a9231315b4521097b8dc3750bc806fcafe0c72f)
1#!/bin/bash
2
3set -e
4
5sh_path=$0
6mkfs=$1
7output_image=$2
8delta_generator=$3
9compression_algo=$4
10
11if [ -z "$compression_algo" ]
12then
13  compression_algo="lz4hc,9"
14fi
15
16fs_root=$(mktemp -d -t erofs-XXXXXXXXXX)
17
18clean_up () {
19    ARG=$?
20    rm -rf $fs_root
21    echo "> clean_up"
22    exit $ARG
23}
24trap clean_up EXIT
25
26if [ ! -z "${delta_generator}" ]; then
27  mkdir -p ${fs_root}/dir1/dir2/dir123/nested_dir
28  mkdir -p ${fs_root}/etc/
29  cp ${sh_path} ${fs_root}/
30  truncate -s 1M ${fs_root}/file1
31  truncate -s 1M ${fs_root}/dir1/file2
32  truncate -s 1M ${fs_root}/dir1/file0
33  truncate -s 1M ${fs_root}/dir1/dir2/file0
34  truncate -s 1M ${fs_root}/dir1/dir2/file1
35  truncate -s 1M ${fs_root}/dir1/dir2/file2
36  truncate -s 1M ${fs_root}/dir1/dir2/file4
37  touch ${fs_root}/dir1/dir2/dir123/empty
38  cp ${delta_generator} ${fs_root}/delta_generator
39  truncate -s 1M ${fs_root}/delta_generator
40  echo "PAYLOAD_MINOR_VERSION=1234" > ${fs_root}/etc/update_engine.conf
41  truncate -s 16M ${fs_root}/dir1/dir2/dir123/chunks_of_zero
42fi
43
44${mkfs} -z $compression_algo -T 1656466080 -U BCF5939B-0930-A551-A548-E4BD99E783AC --ignore-mtime ${output_image} ${fs_root}
45