forked from chinh4thepro/cadmium
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild-all
executable file
·135 lines (109 loc) · 2.76 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
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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
#!/bin/bash
CADMIUMROOT="$(dirname $(realpath $0))"
if [ "$ARCHITECTURE" == "" ];
then
echo "Which architecture would you like to build for?"
echo "1: arm"
echo "2: arm64"
arc=inv
until [ "$arc" != "inv" ]; do
read -p ": " arc
done
case $arc in
1) ARCHITECTURE="arm";;
2) ARCHITECTURE="arm64";;
esac
fi
case $ARCHITECTURE in
arm)
export ARCH="arm";
export FLAV="arm32-chromebook"
;;
arm64)
export ARCH="arm64";
export FLAV="arm64-chromebook"
;;
esac
source "$CADMIUMROOT/flavor/$FLAV"
if [ "$RFILESYSTEM" == "" ]
then
# Choose the filesystem
echo "Which RootFS would you like to build?"
echo "1: Arch"
echo "2: Debian"
echo "3: Void"
echo "4: Void-Musl"
rfs=inv
until [ "$rfs" != "inv" ]; do
read -p ": " rfs
done
case $rfs in
1) RFILESYSTEM="arch";;
2) RFILESYSTEM="debian";;
3) RFILESYSTEM="void";;
4) RFILESYSTEM="void-musl";;
esac
fi
case $RFILESYSTEM in
arch)
source $CADMIUMROOT/cadmium-configs/$ARCH/config-arch;
export RFILESYSTEM="arch"
;;
debian)
source $CADMIUMROOT/cadmium-configs/$ARCH/config-debian;
export RFILESYSTEM="debian"
;;
void)
source $CADMIUMROOT/cadmium-configs/$ARCH/config-void;
export RFILESYSTEM="void"
;;
void-musl)
source $CADMIUMROOT/cadmium-configs/$ARCH/config-void-musl;
export RFILESYSTEM="void-musl"
;;
esac
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"
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
[ "$IN_RAM" = true ] && echo "Don't forget to umount $CADMIUMROOT/tmp"
echo "Done!"