This repository has been archived by the owner on Aug 23, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 60
/
build-all
executable file
·77 lines (58 loc) · 1.71 KB
/
build-all
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
#!/bin/bash
CADMIUMROOT="$(dirname $(realpath $0))"
source "$CADMIUMROOT/config"
source "$CADMIUMROOT/flavor/$FLAV"
set -x
set -e
sleep 1 # let's give user time if they commit a typo
# Usage:
# build-all <device>
# build-all <file> <size>
[ -z "$1" ] && exit 1
[ $IN_RAM = true -a -z "$2" ] && exit 2
# This script is usually tested with a physical pendrive
if [ -n "$2" ]; then
echo "Warning,"
echo "Running $0 like that is not recommended"
echo "Consider $0 /dev/sdX"
sleep 2
fi
# Just in case we got lingering mounts
umount "$CADMIUMROOT/tmp" 2>/dev/null || true
if [ "$IN_RAM" = true ]; then
mount -t tmpfs tmpfs "$CADMIUMROOT/tmp"
fi
# it deals with env vars, TODO: make it not
source "$CADMIUMROOT/bootfw/$BOOTFW/prepare_parts"
"$CADMIUMROOT/kernel/build"
# TODO: move to bootfw/prepare_parts
case "$FILESYSTEM" in
f2fs)
mkfs.f2fs -f "$ROOTPART"
;;
ext4)
mkfs.ext4 -F "$ROOTPART"
;;
esac
function umount_root() {
echo "Cleaning up..."
umount "$CADMIUMROOT/tmp/root"
}
mkdir -p "$CADMIUMROOT/tmp/root"
mount "$ROOTPART" "$CADMIUMROOT/tmp/root"
trap umount_root EXIT
# write filesystem
"$CADMIUMROOT/fs/build" "$CADMIUMROOT/tmp/root"
"$CADMIUMROOT/bootfw/$BOOTFW/package" "$DEVICE" "$ROOTPART"
# TODO: move to bootfw/$BOOTFW/install
if [ "$BOOTFW" = depthcharge ]; then
dd if="$CADMIUMROOT/tmp/linux-$ARCH/vmlinux.kpart" of="$KERNPART"
cp "$CADMIUMROOT/tmp/oxide.kpart" "$CADMIUMROOT/tmp/root/"
fi
# install modules
make -C "$CADMIUMROOT/tmp/linux-$ARCH" INSTALL_MOD_PATH="$CADMIUMROOT/tmp/root" modules_install
# yes, this fails when device is pendrive or sth
losetup -d "$DEVICE" 2>/dev/null || true
sync # just to be sure
echo "Done!"
[ "$IN_RAM" = true ] && echo "Don't forget to umount $CADMIUMROOT/tmp"