forked from Maccraft123/Cadmium
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild-all
executable file
·82 lines (60 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
78
79
80
81
82
#!/bin/bash
CADMIUMROOT=$(dirname $(realpath $0))
source $CADMIUMROOT/config
source $CADMIUMROOT/board/$TARGET/boardinfo
source $CADMIUMROOT/baseboard/$BASEBOARD/boardinfo
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
if [ -n "$2" ]; then
echo "Warning,"
echo "Running $0 like that is not recommended"
echo "Consider $0 /dev/sdX"
sleep 2
fi
umount $CADMIUMROOT/tmp 2>/dev/null || true
if [ $IN_RAM = true ]; then
mount -t tmpfs tmpfs $CADMIUMROOT/tmp
fi
# it deals with env vars
source $CADMIUMROOT/bootfw/$BOOTFW/prepare_parts
# build, package and write kernel
$CADMIUMROOT/kernel/build
# TODO: move to bootfw/prepare_parts
case "$FILESYSTEM" in
f2fs)
mkfs.f2fs -f $ROOTPART
;;
ext4)
mkfs.ext4 -F $ROOTPART
;;
esac
mkdir -p $CADMIUMROOT/tmp/root
mount $ROOTPART $CADMIUMROOT/tmp/root
# 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
if [ $BOOTFW = pmon ]; then
mkfs.ext4 ${DEVICE}1
mount ${DEVICE}1 $CADMIUMROOT/tmp/root/boot
# TODO
umount $CADMIUMROOT/tmp/root/boot
fi
# install modules
make -C $CADMIUMROOT/tmp/linux-$ARCH INSTALL_MOD_PATH=$CADMIUMROOT/tmp/root modules_install
# we don't umount it in fs/build
umount $CADMIUMROOT/tmp/root
# yes, this fails when device is pendrive or sth
losetup -d $DEVICE 2>/dev/null || true
sync
echo "Done!"
[ $IN_RAM = true ] && echo "Don't forget to umount $CADMIUMROOT/tmp"