blob: a7a2f97469914d70edcfef95ecb39505d5a8a99f (
plain)
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
|
#!/bin/sh -e
output="$1"
rootfs_size="$2"
swap_size="$3"
rwfs_size="$4"
userfs_size="$5"
extra_size="$6"
totalsize=$(s6-expr ${rootfs_size} + ${swap_size} + ${rwfs_size} + ${userfs_size} + ${extra_size} + 4)
# prepare extlinux.conf
if s6-test ${KERNEL_GENERIC_ARCH} = x86 ; then
consolearg="console=ttyS0,115200n8"
if ${USE_GRAPHIC} ; then
consolearg=
fi
if ${USE_VIRTIO_DISK} ; then
bootpartition=/dev/vda1
elif s6-test ${KERNEL_ARCH} = x86_64 ; then
bootpartition=/dev/sda1
else
bootpartition=/dev/hda1
fi
s6-cat > ${output}/rootfs/boot/extlinux.conf <<EOF
serial 0 115200
console 0
prompt 0
default linux
totaltimeout 1200
say extlinux booting
label linux
linux /boot/vmlinuz
append ro root=$bootpartition rootfstype=ext4 loglevel=4 $consolearg
EOF
fi
s6-rmrf "$output/disk-image.raw"
setuidgid ${NORMALUSER} dd if=/dev/zero of=$output/disk-image.raw bs=1 count=0 seek=${totalsize}M
fdisk $output/disk-image.raw <<EOF
n
+${rootfs_size}M
n
+${swap_size}M
t
2
82
n
+${rwfs_size}M
n
n
+${userfs_size}M
n
a
1
w
EOF
loop=$(losetup -f)
losetup -P "$loop" "$output/disk-image.raw"
{
mkfs.ext4 -O ^huge_file ${loop}p1
mkswap ${loop}p2
mkfs.ext4 -O ^huge_file ${loop}p3
mkfs.ext4 -O ^huge_file ${loop}p5
mkfs.ext4 -O ^huge_file ${loop}p6
s6-mkdir -p "$output/tmp/rootfs" "$output/tmp/rwfs" "$output/tmp/userfs" "$output/tmp/stagingfs"
mount -t ext4 ${loop}p1 "$output/tmp/rootfs"
s6-hiercopy "$output/rootfs" "$output/tmp/rootfs"
if s6-test ${KERNEL_GENERIC_ARCH} = x86 ; then
dd if=${output}/build-build/opt/syslinux/usr/share/syslinux/mbr.bin of=${loop}
extlinux -i "$output/tmp/rootfs/boot"
fi
umount -l "$output/tmp/rootfs"
mount -t ext4 ${loop}p3 "$output/tmp/rwfs"
s6-hiercopy "$output/rwfs" "$output/tmp/rwfs"
umount -l "$output/tmp/rwfs"
mount -t ext4 ${loop}p5 "$output/tmp/userfs"
s6-hiercopy "$output/userfs" "$output/tmp/userfs"
umount -l "$output/tmp/userfs"
mount -t ext4 ${loop}p6 "$output/tmp/stagingfs"
s6-hiercopy "$output/stagingfs" "$output/tmp/stagingfs"
umount -l "$output/tmp/stagingfs"
} || { losetup -d "$loop" ; exit 1 ; }
losetup -d "$loop"
|