2022-05-30 23:57:09 +09:00
|
|
|
#!/bin/sh
|
|
|
|
# オーバーレイイメージファイルの生成
|
2022-06-01 01:07:38 +09:00
|
|
|
# Usage: bin/overlay-gen dist/overlay.img
|
2022-05-30 23:57:09 +09:00
|
|
|
# Required: fallocate losetup mkfs.ext4 gzip
|
|
|
|
cd -- "$(dirname -- "$0")/.."
|
|
|
|
set -eux
|
|
|
|
size=512m
|
2022-06-01 01:07:38 +09:00
|
|
|
image="$1"
|
|
|
|
fallocate -l "${size}" "${image}"
|
|
|
|
mkfs.ext4 "${image}"
|
2022-05-30 23:57:09 +09:00
|
|
|
dev="$(losetup -f)"
|
|
|
|
finally="losetup -d '${dev}'"
|
|
|
|
trap 'sh -c "${finally}"' EXIT
|
2022-06-01 01:07:38 +09:00
|
|
|
losetup "${dev}" "${image}"
|
2022-05-30 23:57:09 +09:00
|
|
|
tmp="$(mktemp -d)"
|
|
|
|
finally="rmdir '${tmp}'; ${finally}"
|
|
|
|
mount "${dev}" "${tmp}"
|
|
|
|
finally="umount '${tmp}'; ${finally}"
|
|
|
|
mkdir -p "${tmp}/work/usr"
|
|
|
|
mkdir -p "${tmp}/upper/usr"
|