3 # Script to prepare source code and binary distribution files of rEFInd.
4 # By Rod Smith, 3/11/2012
5 # Updated 11/8/2012 to do more things automatically
6 # Updated 12/6/2012 to sign binaries with the rEFInd MOK
7 # Updated 12/3/2015 to independently compile .zip, RPM, and Debian packages
9 # Usage: ./mkdistrib [--nosign] [--norpm] [--nodebian] [--nozip] version
10 # where "version" is a version number.
13 # * Zip: x86-64 system with TianoCore configured for IA32, X64, and
14 # AARCH builds ("TARGET_ARCH = IA32 X64 AARCH64" in Conf/target.txt)
15 # * RPM: System with TianoCore or GNU-EFI of same CPU type as desired
16 # target architecture. (Tested only on X64/x86-64.)
17 # * Debian: System with GNU-EFI of same CPU type as desired target
19 # * MOK files: Used for zip and RPM builds; not used for building
20 # Debian packages. Must be mounted at /mnt/refind via /etc/fstab
21 # entry, unless --nosign is specified, in which case binaries are
22 # not signed. Only X64 binaries are signed.
29 KeysInfo
=`df $KeysDir 2> /dev/null | grep $KeysDir`
31 SBSign
=`which sbsign 2> /dev/null`
35 echo "$0 [--nosign] [--norpm] [--nodebian] [--nozip] version"
40 while [[ $# -gt 0 ]]; do
47 --nodebian) MakeDebian
=0
57 if [[ -z "$Version" ]] ; then
62 # Copy rEFInd source files to refind-$Version inside $TargetDir directory
63 # and create a tarball from refind-$Version. Both the tarball and the
64 # source directory are left in $TargetDir when this function finishes, and
65 # $TargetDir is the current directory at the end.
67 # Prepare a place and copy files there....
68 mkdir
-p $TargetDir/refind-
$Version/icons
/licenses
$TargetDir/refind-
$Version/icons
/svg
69 cp --preserve=timestamps icons
/*png icons
/README
$TargetDir/refind-
$Version/icons
/
70 cp --preserve=timestamps
-r icons
/licenses
/* $TargetDir/refind-
$Version/icons
/licenses
/
71 cp --preserve=timestamps
-r icons
/svg
/* $TargetDir/refind-
$Version/icons
/svg
/
72 cp -a debian docs images keys fonts banners include EfiLib libeg mok net refind filesystems \
73 gptsync refind.spec refind-install refind-mkdefault mkrlconf mvrefind mountesp CREDITS.txt \
74 NEWS.txt BUILDING.txt COPYING.txt LICENSE.txt README.txt refind.inf Make.common Makefile \
75 refind.conf-sample
$TargetDir/refind-
$Version
77 # Go there and prepare a souce code tarball....
79 rm -f refind-src-
$Version.
tar.gz
80 tar cvf refind-src-
$Version.
tar refind-
$Version
81 gzip -9 refind-src-
$Version.
tar
83 # Remove SVG files, since they aren't needed for binary packages....
84 rm -rf refind-
$Version/icons
/svg
87 # Create two .zip packages containing the full binary builds of rEFInd for three
88 # platforms -- IA32, X64, and AARCH64. One binary is the regular build and the
89 # second is the same as the first but substitutes refind_x64.efi build with
90 # GNU-EFI for the usual TianoCore build. (This is to provide an alternative for
91 # those rare cases when the TianoCore build fails.) The X64 binaries are signed
92 # with my key *IF* --nosign is not specified and if the key is available.
94 cd $TargetDir/refind-
$Version
95 # Build the ARM64 binaries
98 mkdir
-p refind-bin-
$Version/refind
/drivers_aa64
99 cp --preserve=timestamps drivers_aa64
/*_aa64.efi refind-bin-
$Version/refind
/drivers_aa64
/
100 cp --preserve=timestamps filesystems
/LICENSE
*txt refind-bin-
$Version/refind
/drivers_aa64
/
101 cp refind
/refind_aa64.efi refind-bin-
$Version/refind
/refind_aa64.efi
102 cp refind
/refind_aa64.efi
$StartDir/
103 mkdir
-p refind-bin-
$Version/refind
/tools_aa64
104 # Don't copy gptsync_aa64.efi because it won't build in cross-compile environment
105 # and because it's likely to be useless on ARM64.
107 # Build the IA32 binaries
111 mkdir
-p refind-bin-
$Version/refind
/drivers_ia32
112 cp --preserve=timestamps drivers_ia32
/*_ia32.efi refind-bin-
$Version/refind
/drivers_ia32
/
113 cp --preserve=timestamps filesystems
/LICENSE
*txt refind-bin-
$Version/refind
/drivers_ia32
/
114 cp refind
/refind_ia32.efi refind-bin-
$Version/refind
/refind_ia32.efi
115 cp refind
/refind_ia32.efi
$StartDir/
116 mkdir
-p refind-bin-
$Version/refind
/tools_ia32
117 cp --preserve=timestamps gptsync
/gptsync_ia32.efi refind-bin-
$Version/refind
/tools_ia32
/
119 # Build the X64 binaries
123 mkdir
-p refind-bin-
$Version/refind
/drivers_x64
124 cp -a icons refind-bin-
$Version/refind
/
125 if [[ $SignIt == 1 ]] ; then
126 for File
in `ls drivers_x64/*_x64.efi` ; do
127 $SBSign --key $KeysDir/refind.key
--cert $KeysDir/refind.crt
--output refind-bin-
$Version/refind
/$File $File
130 cp --preserve=timestamps drivers_x64
/*_x64.efi refind-bin-
$Version/refind
/drivers_x64
/
132 cp --preserve=timestamps filesystems
/LICENSE
*txt refind-bin-
$Version/refind
/drivers_x64
/
133 cp --preserve=timestamps refind.conf-sample refind-bin-
$Version/refind
/
134 if [[ $SignIt == 1 ]] ; then
135 $SBSign --key $KeysDir/refind.key
--cert $KeysDir/refind.crt
--output refind-bin-
$Version/refind
/refind_x64.efi refind
/refind_x64.efi
137 cp refind
/refind_x64.efi refind-bin-
$Version/refind
/refind_x64.efi
139 mkdir
-p refind-bin-
$Version/refind
/tools_x64
140 if [[ $SignIt == 1 ]] ; then
141 $SBSign --key $KeysDir/refind.key
--cert $KeysDir/refind.crt
--output refind-bin-
$Version/refind
/tools_x64
/gptsync_x64.efi gptsync
/gptsync_x64.efi
143 cp --preserve=timestamps gptsync
/gptsync_x64.efi refind-bin-
$Version/refind
/tools_x64
/
145 cp refind-bin-
$Version/refind
/refind_x64.efi
$StartDir
146 cp -a docs keys banners fonts COPYING.txt LICENSE.txt README.txt CREDITS.txt NEWS.txt refind-install refind-mkdefault mkrlconf mvrefind mountesp refind-bin-
$Version
148 # Prepare the final .zip file
149 zip -9r ..
/refind-bin-
$Version.
zip refind-bin-
$Version
151 # Prepare a variant with the x86-64 version built with GNU-EFI....
154 if [[ $SignIt == 1 ]] ; then
155 $SBSign --key $KeysDir/refind.key
--cert $KeysDir/refind.crt
--output refind-bin-
$Version/refind
/refind_x64.efi refind
/refind_x64.efi
157 cp refind
/refind_x64.efi refind-bin-
$Version/refind
/refind_x64.efi
159 zip -9r ..
/refind-bin-gnuefi-
$Version.
zip refind-bin-
$Version
162 rm -r refind-
$Version
165 # Make Debian packages using native Debian calls. Note that the Debian
166 # rules currently do NOT use a signing key, so these binaries will be
168 MakeDebianPackage
() {
173 tar xvfz ..
/refind-src-
$Version.
tar.gz
174 ln -sf ..
/refind-src-
$Version.
tar.gz refind_
$Version.orig.
tar.gz
176 debuild
-S -sa -rfakeroot -k'Rod Smith <rodsmith@rodsbooks.com>'
178 rm -rf ..
/debian-binary
179 mkdir ..
/debian-binary
180 mv refind-
$Version ..
/debian-binary
182 ln -sf ..
/refind-src-
$Version.
tar.gz refind_
$Version.orig.
tar.gz
184 dpkg-buildpackage
-us -uc
186 rm -rf refind-
$Version
188 } # MakeDebianPackage
190 # Make RPMs and then build Debian package from the RPM. Note that
191 # these files will be signed with my key, assuming --nosign was not
192 # passed as an option. (The RPM .spec file checks for the presence
196 cp refind-src-
$Version.
tar.gz ~
/rpmbuild
/SOURCES
/
197 rpmbuild
-ba $StartDir/refind.spec
198 mv ~
/rpmbuild
/RPMS
/*/refind-
$Version* .
/
199 mv ~
/rpmbuild
/SRPMS
/refind-
$Version* .
/
200 sudo alien
--to-deb -k -c refind-
$Version*x86_64.rpm
201 sudo chown rodsmith
: refind
*deb
202 rm ~
/rpmbuild
/SOURCES
/refind-src-
$Version.
tar.gz
203 rm -rf ~
/rpmbuild
/BUILD
/refind-
$Version
204 rm -rf ~
/rpmbuild
/BUILDROOT
/refind-
$Version-*
207 ###################################
209 # Main part of script begins here
211 ###################################
215 # From here on, if there's an error, abort immediately.
220 # Remove temporary files from the "debian" subdirectory
221 rm -rf debian
/refind debian
/*.log
223 # Convert man pages to HTML form
224 man2html docs
/man
/mkrlconf
.8 > docs
/refind
/mkrlconf.html
225 man2html docs
/man
/mvrefind
.8 > docs
/refind
/mvrefind.html
226 man2html docs
/man
/refind-mkdefault
.8 > docs
/refind
/refind-mkdefault.html
227 man2html docs
/man
/refind-install
.8 > docs
/refind
/refind-install.html
229 mkdir
-p ..
/snapshots
/$Version
230 TargetDir
=`cd -P ../snapshots/$Version && pwd`
233 if [[ ! -n $SBSign && $SignIt == 1 ]] ; then
234 echo "Can't find sbsign binary! Aborting!"
238 if [[ ! -n $KeysInfo && $SignIt == 1 ]] ; then
240 if [[ $?
-ne 0 ]] ; then
241 echo "Error mounting $KeysDir! Aborting!"
249 if [[ $MakeZip == 1 ]] ; then
253 if [[ $MakeDebian == 1 ]] ; then
257 if [[ $MakeRpm == 1 ]] ; then
262 if [[ $SignIt == 1 ]] ; then