-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathcreateimg
executable file
·115 lines (89 loc) · 2.98 KB
/
createimg
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
106
107
108
109
110
111
112
113
114
115
#!/bin/sh
# Copyright (C) 2004-2024 Soner Tari
#
# This file is part of UTMFW.
#
# UTMFW is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# UTMFW is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with UTMFW. If not, see <http://www.gnu.org/licenses/>.
ARCH=arm64
add_platform_site_files() {
if [ "$ARCH" = arm64 ]; then
cp -R -v $ROOT_PATH/openbsd/$INSTALL_SETS_PATH/firmware $ROOT_PATH/$SITE_DIR/etc/
echo "set tty fb0\nset timeout 5" > $ROOT_PATH/$SITE_DIR/etc/boot.conf
fi
}
EXCLUDE_FROM_SHA256="SHA256 SHA256.sig"
. ./meta/create
IMG_FILE=pffw${VMAJ}${VMIN}${SUBVERSION}_${ARCH}.img
echo "Creating image: $IMG_FILE"
cd $ROOT_PATH/$CD_PATH
# All sizes are in sectors
if [ "$ARCH" = arm64 ]; then
MSDOSSTART=32768
MSDOSSIZE=16384
fi
if [ "$ARCH" = amd64 ]; then
MSDOSSTART=0
MSDOSSIZE=960
fi
FFSSTART=$(($MSDOSSTART + $MSDOSSIZE))
# Size of cd/{arm64,amd64}, trim trailing white spaces by adding 0
CD_SIZE=$(($(du -L -s . | cut -d . -f 1) + 0))
echo "CD size $CD_SIZE sectors"
# Add overhead for ffs
FS_SIZE=$(($CD_SIZE + 8192))
echo "FS size $FS_SIZE sectors"
# Add end of msdos part
IMG_SIZE=$(($FS_SIZE + $FFSSTART))
echo "Image size $IMG_SIZE sectors"
cd $ROOT_PATH
rm $IMG_FILE
doas umount ./img_ffs
doas umount ./img_msdos
doas vnconfig -u vnd0
# 1 sector = 512 bytes
# SECURITY: Do not seek, write zeros
#dd if=/dev/zero of=$IMG_FILE bs=512 count=0 seek=$IMG_SIZE
dd if=/dev/zero of=$IMG_FILE bs=512 count=$IMG_SIZE
doas vnconfig vnd0 $IMG_FILE
if [ "$ARCH" = arm64 ]; then
#echo "reinit\ne 0\nC\nn\n$MSDOSSTART\n$MSDOSSIZE\nf 0\ne 3\nA6\nn\n$FFSSTART\n*\nw\nq\n" | doas fdisk -e vnd0 >/dev/null
doas fdisk -yi -b "${MSDOSSIZE}@${MSDOSSTART}:c" vnd0
fi
if [ "$ARCH" = amd64 ]; then
doas fdisk -yi -l $FS_SIZE -b $MSDOSSIZE -f /usr/mdec/mbr vnd0
fi
doas fdisk vnd0
echo '/ *' | doas disklabel -wAT- vnd0
doas disklabel vnd0
doas newfs -O 1 -m 0 -o space -i 524288 -c $CD_SIZE /dev/rvnd0a
if [ "$ARCH" = arm64 ]; then
doas newfs -t msdos -L boot -c 1 -F 16 /dev/rvnd0i
fi
if [ "$ARCH" = amd64 ]; then
doas newfs -t msdos /dev/rvnd0i
fi
mkdir ./img_ffs
doas mount /dev/vnd0a ./img_ffs
doas cp -R -L -v $ROOT_PATH/$CD_PATH/* ./img_ffs/
mkdir ./img_msdos
doas mount -o-l /dev/vnd0i ./img_msdos
doas cp -R -v openbsd/$INSTALL_SETS_PATH/BOOT/* ./img_msdos
if [ "$ARCH" = amd64 ]; then
doas objcopy -S -R .comment /usr/mdec/boot ./img_ffs/boot
doas installboot -v -r ./img_ffs vnd0 /usr/mdec/biosboot ./img_ffs/boot
fi
echo "$VOL_ID\n$SYS_ID\n$APP_ID\n$PUBLISH_ID\n$PREP_ID" > ./img_msdos/README.txt
doas umount ./img_ffs
doas umount ./img_msdos
doas vnconfig -u vnd0