This repository has been archived by the owner on Jun 15, 2023. It is now read-only.
forked from freebsd/freebsd-src
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmakedank.sh
executable file
·58 lines (45 loc) · 1.91 KB
/
makedank.sh
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
#!/bin/sh
. tools/boot/install-boot.sh
: "${HOSTPARENT:=ruunvald-nvme/vol}"
: "${OUTPUTDIR:=/tmp}"
: "${EXTRABYTES:=$((32 * 1024 * 1024))}"
: "${JOBS:=$(sysctl -n hw.ncpu)}"
: "${PRODUCT:=DankBSD}"
: "${PLATFORM:=$(uname -p)}"
: "${VERSION:=$(date '+%Y.%m.%d.%H.%M')}"
: "${PRODUCTID:=${PRODUCT}.${PLATFORM}}"
: "${IMAGENAME:=${PRODUCTID}.Live.${VERSION}}"
: "${EFIIMAGE:=${OUTPUTDIR}/${IMAGENAME}.ESP.img}"
: "${FSMNT:=${OUTPUTDIR}/${IMAGENAME}.mnt}"
: "${FSIMAGE:=${OUTPUTDIR}/${IMAGENAME}.ZFS.img}"
# : "${POOL:=${IMAGENAME}}"
: "${POOL:=danklive}"
: "${OUTPUTLIVE:=${OUTPUTDIR}/${IMAGENAME}.img}"
set -e
export RUST_BACKTRACE=1
DATASET=$(dankup new --kind system ${PRODUCTID}@0_${VERSION})
DSMNT=$(zfs get -H -o value mountpoint ${DATASET})
make -j${JOBS} installkernel installworld KERNCONF=DANK DESTDIR=${DSMNT}
make -j${JOBS} distribution KERNCONF=DANK DESTDIR=${DSMNT}
dankup commit ${PRODUCTID}@0_${VERSION}
DSUSED=$(zfs get -Hp -o value used ${DATASET})
make_esp_file ${EFIIMAGE} 1024 ${DSMNT}/boot/loader.efi
mkdir -p ${FSMNT}
truncate -s $((${DSUSED}*2+${EXTRABYTES})) ${FSIMAGE}
# don't create directly with the file - zfs remembers that, causing some msgs
mdconfig -u md69 -f ${FSIMAGE}
zpool create -R $FSMNT -o ashift=12 -O compression=zstd -O atime=off -O relatime=on -O xattr=sa -O mountpoint=none ${POOL} /dev/md69
# TODO: extract stuff from here into dankup
zfs create -o mountpoint=/home ${POOL}/home
zfs create -o dankbsd.uzers:gid=0 -o dankbsd.uzers:uid=0 -o dankbsd.uzers:name=root -o dankbsd.uzers:passwd= ${POOL}/home/root
zfs create -o mountpoint=/dank -o compression=zstd-12 ${POOL}/dankup-store
zfs send -pc ${DATASET}@S | zfs recv -d ${POOL}
zpool set bootfs=$(echo ${DATASET} | sed -e "s|^[^/]*|${POOL}|") ${POOL}
zpool export -f ${POOL}
mdconfig -du md69
mkimg -v -s gpt \
-p efi/dank-live-esp:=${EFIIMAGE} \
-p freebsd-zfs/dank-live-zfs:=${FSIMAGE} \
-o ${OUTPUTLIVE}
rm ${FSIMAGE} ${EFIIMAGE}
rm -r ${FSMNT}