summaryrefslogtreecommitdiffstats
path: root/build-release
blob: f395725fc51b493a8983c77e287b8d0c1e7635b5 (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
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
#!/bin/bash

#
#  build-release script: generates libreboot_bin and libreboot_src release archives
#
#	Copyright (C) 2014 Francis Rowe <info@gluglug.org.uk>
#
#    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/>.
#

set -u -e -v

arch="unknown"
if [ $(uname -i) = "i686" ] || [ $(uname -m) = "i686" ]
	then
		arch="i686"
		echo "Running on i686. ok."
		sleep 2
elif [ $(uname -i) = "x86_64" ] || [ $(uname -m) = "x86_64" ]
	then
		arch="x86_64"
		echo "Running on x86_64. ok."
		sleep 2
else
	echo "This script must be run on an i686 or x86_64 host. x86_64 is recommended."
	exit 1
fi

# MAKE SURE THAT YOU RAN "buildall" OR "builddeps" *AT LEAST ONCE*
# You should also run the 'build' script before running this 

# ### Delete old archives before continuing
# ----------------------------------------------------------------------------------------------------------------------------

echo "Deleting old release archives"

rm -f libreboot_src.tar.xz
rm -f libreboot_bin.tar.xz

# Get manifest which will be used to copy everything
find -maxdepth 1 > releasefilelist

# ### Prepare libreboot_src archive ready for release
# ----------------------------------------------------------------------------------------------------------------------------

echo "Preparing libreboot_src release archive"

mkdir libreboot_src

for resource in $(cat releasefilelist)
do
	if [ "$resource" != "." ]
		then
			cp -r $resource libreboot_src
	fi
done

cd libreboot_src/

# clean everything
./cleandeps

# back to main checkout directory
cd ../

# ### Further work in libreboot_src: delete *.git and *.svn
# ### To save space since they are not useful in the release archives
# ### Changes to these projects should be submitted upstream
# ----------------------------------------------------------------------------------------------------------------------------

cd libreboot_src/

# These instructions will also work even if .git or .svn are already deleted
# because "rm -rf" won't complain if they are missing. It is still useful on
# the release archives (non-git), for example if the user re-downloads these programmes.

# remove .git for libreboot project itself
rm -rf .git*

# # bucts needs .git to stay, otherwise it won't compile
# # We don't need .git* (please submit all upstreamable changes directly to bucts upstream)
# # removing them, to reduce the size of the archive
# cd bucts
# rm -rf .git
# rm -rf .gitignore
# cd ../
# # it was found to cause issues when deleting:
# # GIT_DISCOVERY_ACROSS_FILESYSTEM not set

# coreboot:
# the instructions for coreboot remain in getgb script
# they need to stay there, because otherwise "git diff"
# will show the blobs that were deleted (which means,
# that libreboot would be distributing blobs)

# Flashrom:
cd flashrom/
rm -rf .svn
cd ../

# GRUB:
cd grub/
rm -rf .git
rm -f .gitignore
cd ../

# SeaBIOS:
cd seabios/
rm -rf .git
rm -f .gitignore
cd ../

cd ../

# ### Prepare libreboot_bin archive ready for release
# ----------------------------------------------------------------------------------------------------------------------------

echo "Preparing libreboot_bin release archive"

mkdir libreboot_bin

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

# ---------------
# SeaBIOS related
# ---------------
# Include SeaBIOS and SeaVGABIOS option ROM in the binary archive
cp seabios/out/vgabios.bin libreboot_bin/
cp seabios/out/bios.bin.elf libreboot_bin/
# Add the script for it
cp addseabios libreboot_bin/
# Menu entry to be added to grub configs
cp resources/grub/config/seabios.cfg libreboot_bin/

# --------------
# BUC.TS related
# --------------
# X60/T60: BUC.TS utility is needed to flash libreboot while Lenovo BIOS is running
# Include it statically compiled
cp -r bucts bucts_
# make it statically compile
./builddeps-bucts static
mkdir libreboot_bin/bucts
mkdir libreboot_bin/bucts/"$arch"
mv bucts/bucts libreboot_bin/bucts/"$arch"
rm -rf bucts
mv bucts_ bucts

# ----------------
# Flashrom related
# ----------------
# Flashrom is used to install libreboot on supported targets
# Include it statically compiled
cp -r flashrom flashrom_
# make it statically compile
./builddeps-flashrom static
mkdir libreboot_bin/flashrom
cd flashrom/
mkdir ../libreboot_bin/flashrom/"$arch"
mv flashrom ../libreboot_bin/flashrom/"$arch"
mv flashrom_lenovobios_sst ../libreboot_bin/flashrom/"$arch"
mv flashrom_lenovobios_macronix ../libreboot_bin/flashrom/"$arch"
cd ../
rm -rf flashrom
mv flashrom_ flashrom

# ----------------
# cbfstool related
# ----------------
# build cbfstool, compiled (statically linked) and include the binary
cd coreboot/util/
cp -r cbfstool cbfstool_
cd cbfstool/
make clean
make SHARED=0 CC='gcc -static'
mkdir ../../../libreboot_bin/cbfstool

mkdir ../../../libreboot_bin/cbfstool/"$arch"
mv cbfstool ../../../libreboot_bin/cbfstool/"$arch"/
mv rmodtool ../../../libreboot_bin/cbfstool/"$arch"/

if [ "$arch" = "x86_64" ]
	then
		# Now build 32-bit binaries
		make clean
		make SHARED=0 CC='gcc -static -m32'
		mkdir ../../../libreboot_bin/cbfstool/i686
		mv cbfstool ../../../libreboot_bin/cbfstool/i686/
		mv rmodtool ../../../libreboot_bin/cbfstool/i686/
fi

# cross-compile for ARM
make clean
make SHARED=0 CC='arm-linux-gnueabi-gcc -static'
mkdir ../../../libreboot_bin/cbfstool/armv7l
mv cbfstool ../../../libreboot_bin/cbfstool/armv7l/
mv rmodtool ../../../libreboot_bin/cbfstool/armv7l/

cd ../
rm -rf cbfstool
mv cbfstool_ cbfstool
cd ../../

# ----------------
# ich9deblob related
# ----------------
# build ich9deblob, compiled (statically linked) and include the binary
cd resources/utilities/
cp -r ich9deblob ich9deblob_
cd ich9deblob/
make clean
make SHARED=0 CC='gcc -static'
mkdir ../../../libreboot_bin/ich9deblob

mkdir ../../../libreboot_bin/ich9deblob/"$arch"
mv ich9deblob ../../../libreboot_bin/ich9deblob/"$arch"/
mv ich9gen ../../../libreboot_bin/ich9deblob/"$arch"/

if [ "$arch" = "x86_64" ]
	then
		# Now build 32-bit binaries
		make clean
		make SHARED=0 CC='gcc -static -m32'
		mkdir ../../../libreboot_bin/ich9deblob/i686
		mv ich9deblob ../../../libreboot_bin/ich9deblob/i686/
		mv ich9gen ../../../libreboot_bin/ich9deblob/i686/
fi

# cross-compile for ARM
make clean
make SHARED=0 CC='arm-linux-gnueabi-gcc -static'
mkdir ../../../libreboot_bin/ich9deblob/armv7l
mv ich9deblob ../../../libreboot_bin/ich9deblob/armv7l/
mv ich9gen ../../../libreboot_bin/ich9deblob/armv7l/

cd ../
rm -rf ich9deblob
mv ich9deblob_ ich9deblob
cd ../../

# -----------------
# nvramtool related
# -----------------
# build nvramtool, compiled (statically linked) and include the binary
cd coreboot/util/
cp -r nvramtool nvramtool_
cd nvramtool/
make clean
make SHARED=0 CC='gcc -static'
mkdir ../../../libreboot_bin/nvramtool

mkdir ../../../libreboot_bin/nvramtool/"$arch"
mv nvramtool ../../../libreboot_bin/nvramtool/"$arch"/

if [ "$arch" = "x86_64" ]
	then
		# Now build 32-bit binaries
		make clean
		make SHARED=0 CC='gcc -static -m32'
		mkdir ../../../libreboot_bin/nvramtool/i686
		mv nvramtool ../../../libreboot_bin/nvramtool/i686/
fi

cd ../
rm -rf nvramtool
mv nvramtool_ nvramtool
cd ../../

# -----------------
# cbmem related
# -----------------
# build cbmem, compiled (statically linked) and include the binary
cd coreboot/util/
cp -r cbmem cbmem_
cd cbmem/
make clean
make SHARED=0 CC='gcc -static'
mkdir ../../../libreboot_bin/cbmem

mkdir ../../../libreboot_bin/cbmem/"$arch"
mv cbmem ../../../libreboot_bin/cbmem/"$arch"/

if [ "$arch" = "x86_64" ]
	then
		# Now build 32-bit binaries
		make clean
		make SHARED=0 CC='gcc -static -m32'
		mkdir ../../../libreboot_bin/cbmem/i686
		mv cbmem ../../../libreboot_bin/cbmem/i686/
fi
cd ../
rm -rf cbmem
mv cbmem_ cbmem
cd ../../

# ---------------------
# Include documentation
# ---------------------
cp -r docs 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/
cp powertop.trisquel7 libreboot_bin/
cp powertop.trisquel7.init libreboot_bin/

# -------------
# Miscellaneous
# -------------
# include X60 cmos.layout file
cp coreboot/src/mainboard/lenovo/x60/cmos.layout libreboot_bin/x60cmos.layout
cp coreboot/src/mainboard/lenovo/t60/cmos.layout libreboot_bin/t60cmos.layout
cp coreboot/src/mainboard/apple/macbook21/cmos.layout libreboot_bin/macbook21cmos.layout

# FLASHING SCRIPTS
# Flashrom script (makes flashing easier: ./flash path/to/libreboot.rom)
cp flash libreboot_bin/
# For those upgrading from libreboot 5th release (or lower) to latest, on the X60
cp x60flashfrom5 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/
# For initial flashing on macbook21/11
cp macbook21_firstflash libreboot_bin/

# ich9macchange script (change MAC address on X200 ROMs, using ich9gen)
cp ich9macchange libreboot_bin/

# ### Create the release tarballs
# ----------------------------------------------------------------------------------------------------------------------------

# Also delete the manifest
rm -f libreboot_src/releasefilelist
rm -f libreboot_bin/releasefilelist
rm -f releasefilelist

# We don't want to encourage development
# to happen on the release archives. 
# Development goes in git.
rm -f libreboot_src/build-release
rm -f libreboot_src/getall
rm -f libreboot_src/getbucts
rm -f libreboot_src/getcb
rm -f libreboot_src/getflashrom
rm -f libreboot_src/getgrub
rm -f libreboot_src/getgrubinvaders
rm -f libreboot_src/getmt86
rm -f libreboot_src/getseabios

# ich9deblob: there are certain files in there
# that the user most likely does not want to share
rm -f libreboot_src/resources/utilities/ich9deblob/deblobbed_descriptor.bin
rm -f libreboot_src/resources/utilities/ich9deblob/factory.rom
rm -f libreboot_src/resources/utilities/ich9deblob/libreboot.rom
rm -f libreboot_src/resources/utilities/ich9deblob/mkdescriptor.c
rm -f libreboot_src/resources/utilities/ich9deblob/mkdescriptor.h
rm -f libreboot_src/resources/utilities/ich9deblob/mkgbe.c
rm -f libreboot_src/resources/utilities/ich9deblob/mkgbe.h
rm -f libreboot_src/mkgbe.c
rm -f libreboot_src/mkgbe.h
rm -f libreboot_src/ich9fdgbe_8m.bin
rm -f libreboot_src/ich9fdgbe_4m.bin

# delete the "tobuild"
rm -rf libreboot_src/tobuild/
rm -f libreboot_src/tobuild.tar.xz

echo "Creating compressed libreboot_src release archive"

# create lzma compressed src archive
tar cfJ libreboot_src.tar.xz libreboot_src

echo "Creating compressed libreboot_bin release archive"

# create lzma compressed bin archive
tar cfJ libreboot_bin.tar.xz libreboot_bin

# ### Delete the uncompressed release directories
# ----------------------------------------------------------------------------------------------------------------------------

echo "Deleted the uncompressed release archives"

rm -rf libreboot_src
rm -rf libreboot_bin

# For those utilities that have to be built on the target
./mkextbuild

echo "DONE. See libreboot_src.tar.xz and libreboot_bin.tar.xz"
echo "NOTE FOR FCHMMR: don't forget to add ARM binaries for flashrom"
echo "NOTE FOR FCHMMR: don't forget to add i386 binaries for flashrom/bucts"
echo "The tarball tobuild.tar.xz has been created with everything needed to build these utilities"

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