1
0
Fork 0
mirror of https://github.com/kou029w/yama.git synced 2025-01-18 16:08:11 +00:00
yama/bin/overlay-gen

21 lines
548 B
Text
Raw Normal View History

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"