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`
34 while [[ $# -gt 0 ]]; do
41 --nodebian) MakeDebian
=0
46 echo "$0 [--nosign] [--norpm] [--nodebian] [--nozip] version"
55 # Copy rEFInd source files to refind-$Version inside $TargetDir directory
56 # and create a tarball from refind-$Version. Both the tarball and the
57 # source directory are left in $TargetDir when this function finishes, and
58 # $TargetDir is the current directory at the end.
60 # Prepare a place and copy files there....
61 mkdir
-p $TargetDir/refind-
$Version/icons
/licenses
$TargetDir/refind-
$Version/icons
/svg
62 cp --preserve=timestamps icons
/*png icons
/README
$TargetDir/refind-
$Version/icons
/
63 cp --preserve=timestamps
-r icons
/licenses
/* $TargetDir/refind-
$Version/icons
/licenses
/
64 cp --preserve=timestamps
-r icons
/svg
/* $TargetDir/refind-
$Version/icons
/svg
/
65 cp -a debian docs images keys fonts banners include EfiLib libeg mok net refind filesystems \
66 gptsync refind.spec refind-install mkrlconf mvrefind mountesp CREDITS.txt NEWS.txt BUILDING.txt \
67 COPYING.txt LICENSE.txt README.txt refind.inf Make.tiano Make.common Make.aarch64 Makefile \
68 refind.conf-sample
$TargetDir/refind-
$Version
70 # Go there and prepare a souce code tarball....
72 rm -f refind-src-
$Version.
tar.gz
73 tar cvf refind-src-
$Version.
tar refind-
$Version
74 gzip -9 refind-src-
$Version.
tar
76 # Remove SVG files, since they aren't needed for binary packages....
77 rm -rf refind-
$Version/icons
/svg
80 # Create two .zip packages containing the full binary builds of rEFInd for three
81 # platforms -- IA32, X64, and AARCH64. One binary is the regular build and the
82 # second is the same as the first but substitutes refind_x64.efi build with
83 # GNU-EFI for the usual TianoCore build. (This is to provide an alternative for
84 # those rare cases when the TianoCore build fails.) The X64 binaries are signed
85 # with my key *IF* --nosign is not specified and if the key is available.
87 cd $TargetDir/refind-
$Version
88 # Build the ARM64 binaries
91 mkdir
-p refind-bin-
$Version/refind
/drivers_aa64
92 cp --preserve=timestamps drivers_aa64
/*_aa64.efi refind-bin-
$Version/refind
/drivers_aa64
/
93 cp --preserve=timestamps filesystems
/LICENSE
*txt refind-bin-
$Version/refind
/drivers_aa64
/
94 cp refind
/refind_aa64.efi refind-bin-
$Version/refind
/refind_aa64.efi
95 cp refind
/refind_aa64.efi
$StartDir/
96 mkdir
-p refind-bin-
$Version/refind
/tools_aa64
97 # Don't copy gptsync_aa64.efi because it won't build in cross-compile environment
98 # and because it's likely to be useless on ARM64.
100 # Build the IA32 binaries
104 mkdir
-p refind-bin-
$Version/refind
/drivers_ia32
105 cp --preserve=timestamps drivers_ia32
/*_ia32.efi refind-bin-
$Version/refind
/drivers_ia32
/
106 cp --preserve=timestamps filesystems
/LICENSE
*txt refind-bin-
$Version/refind
/drivers_ia32
/
107 cp refind
/refind_ia32.efi refind-bin-
$Version/refind
/refind_ia32.efi
108 cp refind
/refind_ia32.efi
$StartDir/
109 mkdir
-p refind-bin-
$Version/refind
/tools_ia32
110 cp --preserve=timestamps gptsync
/gptsync_ia32.efi refind-bin-
$Version/refind
/tools_ia32
/
112 # Build the X64 binaries
116 mkdir
-p refind-bin-
$Version/refind
/drivers_x64
117 cp -a icons refind-bin-
$Version/refind
/
118 if [[ $SignIt == 1 ]] ; then
119 for File
in `ls drivers_x64/*_x64.efi` ; do
120 $SBSign --key $KeysDir/refind.key
--cert $KeysDir/refind.crt
--output refind-bin-
$Version/refind
/$File $File
123 cp --preserve=timestamps drivers_x64
/*_x64.efi refind-bin-
$Version/refind
/drivers_x64
/
125 cp --preserve=timestamps filesystems
/LICENSE
*txt refind-bin-
$Version/refind
/drivers_x64
/
126 cp --preserve=timestamps refind.conf-sample refind-bin-
$Version/refind
/
127 if [[ $SignIt == 1 ]] ; then
128 $SBSign --key $KeysDir/refind.key
--cert $KeysDir/refind.crt
--output refind-bin-
$Version/refind
/refind_x64.efi refind
/refind_x64.efi
130 cp refind
/refind_x64.efi refind-bin-
$Version/refind
/refind_x64.efi
132 mkdir
-p refind-bin-
$Version/refind
/tools_x64
133 if [[ $SignIt == 1 ]] ; then
134 $SBSign --key $KeysDir/refind.key
--cert $KeysDir/refind.crt
--output refind-bin-
$Version/refind
/tools_x64
/gptsync_x64.efi gptsync
/gptsync_x64.efi
136 cp --preserve=timestamps gptsync
/gptsync_x64.efi refind-bin-
$Version/refind
/tools_x64
/
138 cp refind-bin-
$Version/refind
/refind_x64.efi
$StartDir
139 cp -a docs keys banners fonts COPYING.txt LICENSE.txt README.txt CREDITS.txt NEWS.txt refind-install mkrlconf mvrefind mountesp refind-bin-
$Version
141 # Prepare the final .zip file
142 zip -9r ..
/refind-bin-
$Version.
zip refind-bin-
$Version
144 # Prepare a variant with the x86-64 version built with GNU-EFI....
147 if [[ $SignIt == 1 ]] ; then
148 $SBSign --key $KeysDir/refind.key
--cert $KeysDir/refind.crt
--output refind-bin-
$Version/refind
/refind_x64.efi refind
/refind_x64.efi
150 cp refind
/refind_x64.efi refind-bin-
$Version/refind
/refind_x64.efi
152 zip -9r ..
/refind-bin-gnuefi-
$Version.
zip refind-bin-
$Version
155 rm -r refind-
$Version
158 # Make Debian packages using native Debian calls. Note that the Debian
159 # rules currently do NOT use a signing key, so these binaries will be
161 MakeDebianPackage
() {
166 tar xvfz ..
/refind-src-
$Version.
tar.gz
167 ln -sf ..
/refind-src-
$Version.
tar.gz refind_
$Version.orig.
tar.gz
169 debuild
-S -sa -rfakeroot -k'Rod Smith <rodsmith@rodsbooks.com>'
171 rm -rf ..
/debian-binary
172 mkdir ..
/debian-binary
173 mv refind-
$Version ..
/debian-binary
175 ln -sf ..
/refind-src-
$Version.
tar.gz refind_
$Version.orig.
tar.gz
177 dpkg-buildpackage
-us -uc
179 rm -rf refind-
$Version
181 } # MakeDebianPackage
183 # Make RPMs and then build Debian package from the RPM. Note that
184 # these files will be signed with my key, assuming --nosign was not
185 # passed as an option. (The RPM .spec file checks for the presence
189 cp refind-src-
$Version.
tar.gz ~
/rpmbuild
/SOURCES
/
190 rpmbuild
-ba $StartDir/refind.spec
191 mv ~
/rpmbuild
/RPMS
/*/refind-
$Version* .
/
192 mv ~
/rpmbuild
/SRPMS
/refind-
$Version* .
/
193 sudo alien
--to-deb -k -c refind-
$Version*x86_64.rpm
194 sudo chown rodsmith
: refind
*deb
195 rm ~
/rpmbuild
/SOURCES
/refind-src-
$Version.
tar.gz
196 rm -rf ~
/rpmbuild
/BUILD
/refind-
$Version
197 rm -rf ~
/rpmbuild
/BUILDROOT
/refind-
$Version-*
200 ###################################
202 # Main part of script begins here
204 ###################################
208 # From here on, if there's an error, abort immediately.
213 # Remove temporary files from the "debian" subdirectory
214 rm -rf debian
/refind debian
/*.log
216 # Convert man pages to HTML form
217 man2html docs
/man
/mkrlconf
.8 > docs
/refind
/mkrlconf.html
218 man2html docs
/man
/mvrefind
.8 > docs
/refind
/mvrefind.html
219 man2html docs
/man
/refind-install
.8 > docs
/refind
/refind-install.html
221 mkdir
-p ..
/snapshots
/$Version
222 TargetDir
=`cd -P ../snapshots/$Version && pwd`
225 if [[ ! -n $SBSign && $SignIt == 1 ]] ; then
226 echo "Can't find sbsign binary! Aborting!"
230 if [[ ! -n $KeysInfo && $SignIt == 1 ]] ; then
232 if [[ $?
-ne 0 ]] ; then
233 echo "Error mounting $KeysDir! Aborting!"
241 if [[ $MakeZip == 1 ]] ; then
245 if [[ $MakeDebian == 1 ]] ; then
249 if [[ $MakeRpm == 1 ]] ; then
254 if [[ $SignIt == 1 ]] ; then