summaryrefslogtreecommitdiffstats
path: root/buildrom-withgrub
blob: c7eb2802286622056ecbae4fd817567984b7fb1d (plain)
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

#  buildrom-withgrub script: this generically builds the ROM images.
#  The ROM images built by this script will use the GRUB payload.
#
#	Copyright (C) 2014 Francis Rowe
#
#    This program is free software: you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation, either version 3 of the License, or
#    (at your option) any later version.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
#

# DO NOT RUN THIS DIRECTLY!
# Use "build"

# base ROM's: coreboot_usqwerty.rom and coreboot_serial_usqwerty.rom
# All other ROM's will be based on one of these.

if (( $# != 1 )); then
	echo "Usage: ./buildrom-withgrub boardname"
	echo "Example: ./buildrom-withgrub x60"
	echo "You need to specify exactly 1 argument"
	exit
fi

# Build the ROM images:
# ----------------------------------------------------------------------------------------------------------------------

cd coreboot
rm -rf .config

# cbfstool will be used quite heavily here.
mv util/cbfstool/cbfstool .

# prepare libreboot configuration and build it
cp ../resources/libreboot/config/$1/config .config

# coreboot.rom will appear under ./coreboot/build
make

# move it out (we'll be cleaning the build)
# also rename it to libreboot_usqwerty.rom
mv build/coreboot.rom libreboot_usqwerty.rom

# clean the build
make clean
rm -rf .config

# Insert files/configurations and perform operations that are common on all ROM images
# ---------------------------------------------------------------------------------------------------------------

# Add background image and font
./cbfstool libreboot_usqwerty.rom add -f ../resources/grub/background/background.jpg -n background.jpg -t raw
./cbfstool libreboot_usqwerty.rom add -f ../resources/grub/background/gnulove.jpg -n gnulove.jpg -t raw
./cbfstool libreboot_usqwerty.rom add -f ../resources/grub/font/dejavusansmono.pf2 -n dejavusansmono.pf2 -t raw

# Insert files/configurations and perform operations that are common on *serial* ROM images
# ---------------------------------------------------------------------------------------------------------------

# ROM's based on this will have MemTest86+ included inside.
cp libreboot_usqwerty.rom libreboot_serial_usqwerty.rom

# Add memtest86+ to libreboot_serial_usqwerty.rom
./cbfstool libreboot_serial_usqwerty.rom add -f ../memtest86+-5.01/memtest -n memtest -t raw

# Prepare ROM's (based on libreboot_usqwerty.rom and libreboot_serial_usqwerty.rom) with
# alternative keyboard layout configurations inside GRUB
# ---------------------------------------------------------------------------------------------------------------

# The for loops MUST be separate. Do NOT re-factor them!

# default configs
cp ../resources/grub/config/$1/grub_usqwerty.cfg .
cp ../resources/grub/config/$1/grub_serial_usqwerty.cfg .

for keymap in $(ls ../resources/grub/keymap/original)
do
	# copy the ROM based on the keymap
	cp libreboot_usqwerty.rom libreboot_"$keymap".rom
	cp libreboot_serial_usqwerty.rom libreboot_serial_"$keymap".rom
done

for keymap in $(ls ../resources/grub/keymap/original)
do
	# copy the config based on the keymap:
	cp grub_usqwerty.cfg grub_"$keymap".cfg
	cp grub_serial_usqwerty.cfg grub_serial_"$keymap".cfg
done

for keymap in $(ls ../resources/grub/keymap/original)
do
	# Insert GRUB keymap instructions into the config
	echo "keymap $keymap" >> grub_"$keymap".cfg
	echo "keymap $keymap" >> grub_serial_"$keymap".cfg
done

for keymap in $(ls ../resources/grub/keymap/original)
do
	# Set the GRUB keymap for the given ROM image
	./cbfstool libreboot_"$keymap".rom add -f grub_"$keymap".cfg -n grub.cfg -t raw
	./cbfstool libreboot_serial_"$keymap".rom add -f grub_serial_"$keymap".cfg -n grub.cfg -t raw
done

# we don't need the grub.cfg's anymore
rm -rf grub*cfg

# Now we clean up and prepare the binary archive ready for release.
# ----------------------------------------------------------------------------------------------------------------------------

# prepare directory for new ROM images
rm -rf $1
mkdir $1
# move the ROM's into the newly created directory
mv libreboot*rom $1

# delete the old ROM's from ../bin
rm -rf ../bin/$1
# now put the new ROM's in ./bin
mv $1 ../bin

# cbfstool no longer needed here, so put it back
mv cbfstool util/cbfstool/

# go back to main source directory
cd ../