summaryrefslogtreecommitdiffstats
path: root/build
blob: 4ef6fa0cbad4dcb905309e550931aefd286f3367 (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
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
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
#!/bin/bash

#
#  build script: generates libreboot_bin and libreboot_meta
#
#	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/>.
#

# Build the ROM's

# MAKE SURE THAT YOU RAN "buildall" OR "builddeps" *AT LEAST ONCE*
# BEFORE RUNNING THIS!

echo "running 'make clean' in coreboot"

# run "make clean" in coreboot
cd coreboot
make clean
rm -rf grub.elf 
cd ..

echo "finished running 'make clean' in coreboot"

# Build the GRUB payload (ELF executable):
# ----------------------------------------------------------------------------------------------------------------------

echo "generating grub.elf payload"

cd grub
mv ../grub_memdisk_keymap .
# Build the GRUB2 payload (grub.elf)
./grub-mkstandalone --grub-mkimage=./grub-mkimage -O i386-coreboot -o grub.elf --modules='crypto cryptodisk ahci pata ehci uhci ohci usb_keyboard usbms part_msdos xfs ext2 fat at_keyboard part_gpt usbserial_usbdebug cbfs minix_be minix minix3_be minix3 minix2_be minix2 zfs ufs2 ufs1_be ufs1 udf squash4 romfs jfs reiserfs procfs odc ntfs nilfs2 newc iso9660 hfsplus cpio exfat cpio_be afs btrfs bfs hfs video_bochs password png jpeg keystatus sleep loopback gfxterm_background' --install-modules='syslinuxcfg bsd ls cat echo linux search configfile normal cbtime cbls memrw iorw minicmd lsmmap lspci halt reboot hexdump pcidump regexp setpci lsacpi chain test' --fonts= --themes= --locales= -d grub-core/ /boot/grub/grub.cfg=../resources/grub/config/grub_memdisk.cfg $(./grub_memdisk_keymap)
mv grub_memdisk_keymap ../

# move those into coreboot directory:
mv grub.elf ../coreboot

# come back into the main directory
cd ../

echo "finished generating grub.elf payload"

# Build the ROM's (for flashing)
# ----------------------------------------------------------------------------------------------------------------------

# ROM images for supported Thinkpads
# (x60 also means x60s)
for board in x60 t60 x60t
do
	# Build the ROM (with GRUB payload)
	./buildrom-withgrub $board

	# These are needed for the 'bucts' workarounds on X60/T60
	cd bin/$board
	for rom in $(find -type f)
	do
		dd if=$rom of=top64k.bin bs=1 skip=$[$(stat -c %s $rom) - 0x10000] count=64k
		dd if=$rom bs=1 skip=$[$(stat -c %s $rom) - 0x20000] count=64k | hexdump
		dd if=top64k.bin of=$rom bs=1 seek=$[$(stat -c %s $rom) - 0x20000] count=64k conv=notrunc
		rm -rf top64k.bin
	done
	cd ../../
done

# macbook21 doesn't need grub_serial, but the buildrom-withgrub script expects it
# (we will delete it later)
cp resources/grub/config/macbook21/grub_usqwerty.cfg resources/grub/config/macbook21/grub_serial_usqwerty.cfg
# build the ROM
./buildrom-withgrub macbook21
# delete the useless (nonsensical) files
rm -rf bin/macbook21/libreboot_serial*rom
rm -rf resources/grub/config/macbook21/grub_serial_usqwerty.cfg

# Now we prepare libreboot_bin archive ready for release
# ----------------------------------------------------------------------------------------------------------------------------

echo "generating ../libreboot_bin"

# delete the old one
rm -rf ../libreboot_bin

# create new directory
mkdir ../libreboot_bin

# Include the ROM's in the binary archive
cp -r bin ../libreboot_bin

# Include flashrom utility in binary archive
cp -r flashrom ../libreboot_bin

# For installing build dependencies
cp builddeb ../libreboot_bin
# For installing flashrom build dependencies
cp builddeb-flashrom ../libreboot_bin
# For installing bucts build dependencies
cp builddeb-bucts ../libreboot_bin

# Build scripts for flashrom and bucts
cp builddeps-flashrom ../libreboot_bin
cp builddeps-bucts ../libreboot_bin

# Useful information
cp README ../libreboot_bin
cp COPYING ../libreboot_bin

# Include the same documentation in binary archive
cp -r docs ../libreboot_bin

# X60/T60: BUC.TS utility is needed to flash libreboot while Lenovo BIOS is running
cp -r bucts ../libreboot_bin

# Include a copy of nvramtool in libreboot_bin
cp -r coreboot/util/nvramtool ../libreboot_bin

# X60/X60T/T60: Script for setting up powertop (kills high pitched noise)
cp powertop.trisquel6 ../libreboot_bin
cp powertop.trisquel6.init ../libreboot_bin

# (lazy hack) to make builddep-flashrom work in libreboot_bin:
cp -r resources ../libreboot_bin

# X60/T60: so that the user can use libreboot_bin to overwrite lenovo bios with libreboot
cp lenovobios_firstflash ../libreboot_bin
cp lenovobios_secondflash ../libreboot_bin

# Flashrom script (makes flashing easier: ./flash path/to/coreboot.rom)
cp flash ../libreboot_bin

# patch the version of cbfstool included in libreboot_bin,
# so that it can be built/executed standalone
# this modification is only suitable for the version included in libreboot_bin
# do not patch the one in libreboot_src with this
cp -r coreboot/util/cbfstool ../libreboot_bin/cbfstool_standalone
cp builddeps-cbfstool ../libreboot_bin
echo "Patching libreboot_bin/cbfstool_standalone to be buildable (and executable) without residing in coreboot source tree"
rm -rf ../libreboot_bin/cbfstool_standalone/rmodule.c
cp resources/cbfstool/patch/rmodule.c ../libreboot_bin/cbfstool_standalone
cp coreboot/src/include/rmodule-defs.h ../libreboot_bin/cbfstool_standalone
cd ../libreboot_bin
./builddeps-cbfstool
cd ../libreboot_src
echo "Done (cbfstool_standalone package created in libreboot_bin)"

echo "finished generating ../libreboot_bin"

# Create "libreboot_meta"
# -------------------------------------------------------------------------------------------------------------------------------

echo "generating ../libreboot_meta"

# delete old one
rm -rf ../libreboot_meta

# make new one
mkdir ../libreboot_meta

# MOVE unwanted parts to libreboot_meta (we'll move them back later)
mv bucts ../libreboot_meta
mv coreboot ../libreboot_meta
mv flashrom ../libreboot_meta
mv grub ../libreboot_meta
mv "memtest86+-5.01" ../libreboot_meta

# COPY wanted parts to libreboot_meta
cp -r * ../libreboot_meta
# DELETE unwanted ROM's from libreboot_meta
rm -rf ../libreboot_meta/bin/*

# MOVE BACK the unwanted (in meta) files back to src
mv ../libreboot_meta/bucts .
mv ../libreboot_meta/coreboot .
mv ../libreboot_meta/flashrom .
mv ../libreboot_meta/grub .
mv ../libreboot_meta/"memtest86+-5.01" .

echo "finished generating ../libreboot_meta"

# Create sha512sum manifest for bin, meta and src
# ------------------------------------------------------------------------------------------------------------------------------------

echo "creating sha512sum manifest in libreboot_bin"
cd ../libreboot_bin
rm -rf sha512sum.txt ../sha512sum.txt
touch ../sha512sum.txt
for i in $(find -type f); do sha512sum "$i" >> ../sha512sum.txt; done
mv ../sha512sum.txt .
echo "done"
cd ../libreboot_src

echo "creating sha512sum manifest in libreboot_meta"
cd ../libreboot_meta
rm -rf sha512sum.txt ../sha512sum.txt
touch ../sha512sum.txt
for i in $(find -type f); do sha512sum "$i" >> ../sha512sum.txt; done
mv ../sha512sum.txt .
echo "done"
cd ../libreboot_src

# # Doing this part is pointless
# # This should be done manually (after running 'cleandeps') before releasing the archive
# echo "creating sha512sum manifest in libreboot_src"
# # cd ../libreboot_bin
# rm -rf sha512sum.txt ../sha512sum.txt
# touch ../sha512sum.txt
# for i in $(find -type f); do sha512sum "$i" >> ../sha512sum.txt; done
# mv ../sha512sum.txt .
# echo "done"
# # cd ../libreboot_src

echo "BUILD COMPLETE. Check ../libreboot_bin and ../libreboot_meta"

# ------------------- DONE ----------------------