Add to create file system with given file list

This patch will create a partition image with given file list in a file.

For example, suppose we have 'vendor.list' that contains files

  $ cat custom/templates/oem/vendor.list
  /etc/hostname

And give the file name 'vendor.list' to 'hooks/partition' with a certain
partition list.

  $ cat custom/templates/oem/hooks/partition
  oem_mkfs_ext4 5 vendor vendor.list
  oem_mkfs_ext4 6 app
  oem_mkfs_ext4 7 lib

The partition labeled by 'vendor' will contains the files as listed in
'vendor.list'.

Signed-off-by: Dongjin Kim <tobetter@gmail.com>
Change-Id: Ie4e80762f2d1c43c77dd941213f449dc3792fcbf
This commit is contained in:
Dongjin Kim
2021-04-23 17:07:07 +09:00
parent 258a4b1ea9
commit b0c52ac97c
5 changed files with 32 additions and 5 deletions

View File

@@ -1,3 +1,3 @@
oem_mkfs_ext4 5 app
oem_mkfs_ext4 6 lib
oem_mkfs_ext4 7 etc ${rootfs_mnt}/etc
oem_mkfs_ext4 5 vendor vendor.list
oem_mkfs_ext4 6 app
oem_mkfs_ext4 7 lib

View File

@@ -0,0 +1 @@
odroid-overlayroot

View File

@@ -1,4 +1,4 @@
TOTAL_SECTORS=15523840
TOTAL_SECTORS=15269888
PART[0]=500
PART[1]=500
PART[2]=50

View File

@@ -0,0 +1 @@
/etc/hostname

View File

@@ -145,9 +145,34 @@ oem_mkfs_ext4() {
local label=""
[ "x${2}" = "x" ] || label="-L ${2}"
[ "x${src}" = "x" ] && src=${TOPDIR}/custom/oem/part${1}
# Build image with the file list
if [ -f ${TOPDIR}/custom/${CUSTOMOS}/${src} ]; then
local overlayfs_dir=${build_dir}/overlayfs
rm -rf ${overlayfs_dir} && mkdir -p ${overlayfs_dir}
while read line; do
file=$(echo "${line}" | awk -F '#|;' '{print $1}')
if [ ! -z "${file}" ]; then
if ls ${rootfs_mnt}/${file} 1>/dev/null 2>&1; then
dir=$(dirname ${file} | uniq)
mkdir -p ${overlayfs_dir}/${dir}
mv ${rootfs_mnt}/${file} ${overlayfs_dir}/${dir}
fi
fi
done < ${TOPDIR}/custom/${CUSTOMOS}/${src}
src=${overlayfs_dir}
else
if [ "x${src}" = "x" ]; then
src=${TOPDIR}/custom/${CUSTOMOS}/part${1}
fi
fi
if [ -d ${src} ]; then
echo "* Creating ext4 file system to ${part} with ${src}"
sudo mkfs.ext4 -F ${label} -d ${src} ${part} 2>/dev/null \
|| panic "failed to create partition '${part}'"
fi