-
Notifications
You must be signed in to change notification settings - Fork 0
/
image
executable file
·40 lines (30 loc) · 1 KB
/
image
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/usr/bin/env bash
set -eufo pipefail
IFS=',' read -r -a features <<< "$BUILDER_FEATURES"
fstab="$(mktemp)"
for feature in "${features[@]}"; do
file="/builder/features/$feature/fstab"
if [ -e "$file" ]; then
[ ! -s "$fstab" ] || echo "warning: multiple fstabs, overwriting (consider using fstab.mod instead)"
printf 'using base fstab: %s\n' "$file"
sed 's/#.*$//;/^[[:space:]]*$/d' "$file" > "$fstab"
fi
done
fstab_tmp="$(mktemp)"
for feature in "${features[@]}"; do
file="/builder/features/$feature/fstab.mod"
if [ -e "$file" ]; then
printf 'modifying fstab with %s\n' "$file"
"$file" < "$fstab" > "$fstab_tmp"
sed 's/#.*$//;/^[[:space:]]*$/d' "$fstab_tmp" > "$fstab"
fi
done
rm "$fstab_tmp"
echo "---- fstab ----"
cat "$fstab"
echo "---------------"
mkdir /rootfs
mount -t tmpfs tmpfs /rootfs
tar --extract --xattrs --xattrs-include '*' --directory /rootfs < /input
(export PATH="/builder/image.d:$PATH"; makepart /rootfs < "$fstab" | makedisk /rootfs /image)
cp --sparse always /image /output