This repository has been archived by the owner on Nov 11, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.sh
executable file
·166 lines (145 loc) · 3.76 KB
/
build.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
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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
#!/bin/bash
usage() {
echo "Usage : ./build.sh <distro> <options>"
echo "# Distros compatible :"
echo "Arch-based/ManJaro-based : arch"
echo "Debian-based/Ubuntu-based : debian"
echo "Fedora-based/RedHat-based/CentOS-based : fedora"
echo "# Options available :"
echo "Save logs (useful for reporting) : log"
echo "Do not use 'clear' : noclr"
}
if [ "$1" == "arch" ]; then
distro="arch"
elif [ "$1" == "debian" ]; then
distro="debian"
elif [ "$1" == "fedora" ]; then
distro="fedora"
elif [ "$1" == "help" ]; then
usage
elif [ "$1" != "arch" ]; then
usage
echo "SCRIPT NEEDS ARGUMENTS"
exit 1
elif [ $1 != "debian" ]; then
usage
echo "SCRIPT NEEDS ARGUMENTS"
exit 1
elif [ $1 != "fedora" ]; then
usage
echo "SCRIPT NEEDS ARGUMENTS"
exit 1
elif [ "$2" == "log" ]; then
log="true"
mkdir LOGS
echo "Logs enabled ! Logs are available in the 'LOGS/' directory"
elif [ "$2" == "noclr" ]; then
alias clear="echo"
fi
error() {
echo "FATAL ERROR, PLEASE REPORT : $1" && exit 1
}
welcome() {
echo "Welcome to "
echo "This coreboot fork adding features not available upstream, to the MacBook!"
sleep 2
}
dependencies() {
clear
echo "Before we start, we need to download dependencies for coreboot ..."
sleep 1
if [ "$log" == "true" ]; then
if [ "$distro" == "arch" ]; then
sudo pacman --sync --needed --noconfirm base-devel curl git gcc-ada ncurses zlib > LOGS/Dependencies.log
elif [ "$distro" == "debian" ]; then
sudo apt-get install -y bison build-essential curl flex git gnat libncurses5-dev m4 zlib1g-dev > LOGS/Dependencies.log
else
sudo dnf install git make gcc-gnat flex bison xz bzip2 gcc g++ ncurses-devel wget zlib-devel > LOGS/Dependencies.log
fi
else
if [ "$distro" == "arch" ]; then
sudo pacman --sync --needed --noconfirm base-devel curl git gcc-ada ncurses zlib
elif [ "$distro" == "debian" ]; then
sudo apt-get install -y bison build-essential curl flex git gnat libncurses5-dev m4 zlib1g-dev
else
sudo dnf install git make gcc-gnat flex bison xz bzip2 gcc g++ ncurses-devel wget zlib-devel
fi
fi
if [ "$?" != 1 ]; then
echo "done!"
else
error "Failed to install dependencies !"
fi
sleep 1
}
toolchain() {
clear
echo "Now, let's build the coreboot toolchain ... This is gonna take a while ..."
sleep 1
if [ $log == "true" ]; then
make crossgcc-i386 CPUS="$(nproc)" > LOGS/Toolchain.log
else
make crossgcc-i386 CPUS="$(nproc)"
fi
if [ "$?" != 1 ]; then
echo "done!"
else
error "Failed to build toolchain !"
fi
sleep 1
}
configure() {
clear
echo "Now, let's configure coreboot !"
echo "Before doing your own configuration, please, at least do the following :"
echo "-----------------------"
echo "Mainboard --->"
echo " Mainboard vendor --->"
echo " Apple"
echo " Mainboard model --->"
echo " MacBook1,1 or MacBook2,1 (choose the right one, should work with both but is only tested on MacBook2,1)"
echo "Devices --->"
echo " [*] Use native graphics initialization"
echo "Payload --->"
echo " Add a payload -->"
echo " SeaBIOS or GRUB (only tested with SeaBIOS)"
echo "Chipset --->"
echo " *** CPU ***"
echo " Include CPU microcode in CBFS --->"
echo " Do not include microcode updates"
echo "-----------------------"
sleep 10
echo "Starting menuconfig ..."
make menuconfig
if [ $? != 1 ]; then
echo "done!"
else
error "Failed to configure coreboot !"
fi
}
build() {
clear
echo "Now, everything is ready, now, let's build the actual rom !"
sleep 1
if [ "$log" == "true" ]; then
make > LOGS/Build.log
else
make
fi
if [ "$?" != 1 ]; then
echo "done!"
else
error "Failed to compile coreboot !"
fi
}
finish() {
echo "Your coreboot rom is now ready ! Enjoy your new firmware !"
echo "Exiting ..."
exit 0
}
# RUN ALL OF THIS
welcome
dependencies
toolchain
build
finish