mirror of
https://github.com/kou029w/yama.git
synced 2025-01-19 00:18:06 +00:00
21 lines
565 B
Text
21 lines
565 B
Text
|
#!/bin/sh
|
||
|
# オーバーレイイメージファイルの生成
|
||
|
# Usage: bin/overlay-gen
|
||
|
# Required: fallocate losetup mkfs.ext4 gzip
|
||
|
cd -- "$(dirname -- "$0")/.."
|
||
|
set -eux
|
||
|
size=512m
|
||
|
fallocate -l "${size}" overlay.img
|
||
|
mkfs.ext4 overlay.img
|
||
|
dev="$(losetup -f)"
|
||
|
finally="losetup -d '${dev}'"
|
||
|
trap 'sh -c "${finally}"' EXIT
|
||
|
losetup "${dev}" overlay.img
|
||
|
tmp="$(mktemp -d)"
|
||
|
finally="rmdir '${tmp}'; ${finally}"
|
||
|
mount "${dev}" "${tmp}"
|
||
|
finally="umount '${tmp}'; ${finally}"
|
||
|
mkdir -p "${tmp}/work/usr"
|
||
|
mkdir -p "${tmp}/upper/usr"
|
||
|
finally="${finally}; gzip -f overlay.img"
|