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