18b339582a65502f5755d6dde1235b7fe1b62759
[refind] / mkdistrib
1 #!/bin/bash
2 #
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 #
8 # Usage: ./mkdistrib version [--nosign]
9 # where "version" is a version number
10 # MUST be run from an x86-64 system, on which the TianoCore build
11 # includes both X64 and IA32 build support ("TARGET_ARCH = IA32 X64"
12 # in Conf/target.txt). The MOK files must be available from a disk
13 # partition to be mounted via /etc/fstab at /mnt/refind.
14
15
16 if [[ $2 == "--nosign" ]] ; then
17 SignIt=0
18 else
19 SignIt=1
20 fi
21
22 StartDir=`pwd`
23 SBSign=`which sbsign 2> /dev/null`
24 KeysDir=/mnt/refind
25
26 KeysInfo=`df $KeysDir 2> /dev/null | grep $KeysDir`
27
28 if [[ ! -n $SBSign && $SignIt == 1 ]] ; then
29 echo "Can't find sbsign binary! Aborting!"
30 exit 1
31 fi
32
33 if [[ ! -n $KeysInfo && $SignIt == 1 ]] ; then
34 mount /mnt/refind
35 if [[ $? -ne 0 ]] ; then
36 echo "Error mounting $KeysDir! Aborting!"
37 echo ""
38 exit 1
39 fi
40 fi
41
42 # From here on, if there's an error, abort immediately.
43 set -e
44
45 make clean
46
47 # Remove temporary files from the "debian" subdirectory
48 rm -rf debian/refind debian/*.log
49
50 # Convert man pages to HTML form
51 man2html docs/man/mkrlconf.8 > docs/refind/mkrlconf.html
52 man2html docs/man/mvrefind.8 > docs/refind/mvrefind.html
53 man2html docs/man/refind-install.8 > docs/refind/refind-install.html
54
55 # Prepare a place and copy files there....
56 mkdir -p ../snapshots/$1/refind-$1/icons/licenses ../snapshots/$1/refind-$1/icons/svg
57 cp --preserve=timestamps icons/*png icons/README ../snapshots/$1/refind-$1/icons/
58 cp --preserve=timestamps -r icons/licenses/* ../snapshots/$1/refind-$1/icons/licenses/
59 cp --preserve=timestamps -r icons/svg/* ../snapshots/$1/refind-$1/icons/svg/
60 cp -a debian docs images keys fonts banners include EfiLib libeg mok net refind filesystems gptsync refind.spec refind-install mkrlconf mvrefind mountesp CREDITS.txt NEWS.txt BUILDING.txt COPYING.txt LICENSE.txt README.txt refind.inf Make.tiano Make.common Makefile refind.conf-sample ../snapshots/$1/refind-$1
61
62 # Go there and prepare a souce code tarball....
63 cd ../snapshots/$1/
64 rm -f refind-src-$1.tar.gz
65 tar cvf refind-src-$1.tar refind-$1
66 gzip -9 refind-src-$1.tar
67
68 # Remove SVG files, since they aren't needed for binary packages....
69 rm -rf refind-$1/icons/svg
70
71 # Build the IA32 binaries
72 cd refind-$1
73 ARCH=ia32 make -j1
74 ARCH=ia32 make fs
75 mkdir -p refind-bin-$1/refind/drivers_ia32
76 cp --preserve=timestamps drivers_ia32/*_ia32.efi refind-bin-$1/refind/drivers_ia32/
77 cp --preserve=timestamps filesystems/LICENSE*txt refind-bin-$1/refind/drivers_ia32/
78 cp refind/refind_ia32.efi refind-bin-$1/refind/refind_ia32.efi
79 cp refind/refind_ia32.efi $StartDir/
80 mkdir -p refind-bin-$1/refind/tools_ia32
81 cp --preserve=timestamps gptsync/gptsync_ia32.efi refind-bin-$1/refind/tools_ia32/
82
83 # Build the X64 binaries
84 make clean
85 make -j1
86 make fs
87 mkdir -p refind-bin-$1/refind/drivers_x64
88 cp -a icons refind-bin-$1/refind/
89 if [[ $SignIt == 1 ]] ; then
90 for File in `ls drivers_x64/*_x64.efi` ; do
91 $SBSign --key $KeysDir/refind.key --cert $KeysDir/refind.crt --output refind-bin-$1/refind/$File $File
92 done
93 else
94 cp --preserve=timestamps drivers_x64/*_x64.efi refind-bin-$1/refind/drivers_x64/
95 fi
96 cp --preserve=timestamps filesystems/LICENSE*txt refind-bin-$1/refind/drivers_x64/
97 cp --preserve=timestamps refind.conf-sample refind-bin-$1/refind/
98 if [[ $SignIt == 1 ]] ; then
99 $SBSign --key $KeysDir/refind.key --cert $KeysDir/refind.crt --output refind-bin-$1/refind/refind_x64.efi refind/refind_x64.efi
100 else
101 cp refind/refind_x64.efi refind-bin-$1/refind/refind_x64.efi
102 fi
103 mkdir -p refind-bin-$1/refind/tools_x64
104 if [[ $SignIt == 1 ]] ; then
105 $SBSign --key $KeysDir/refind.key --cert $KeysDir/refind.crt --output refind-bin-$1/refind/tools_x64/gptsync_x64.efi gptsync/gptsync_x64.efi
106 else
107 cp --preserve=timestamps gptsync/gptsync_x64.efi refind-bin-$1/refind/tools_x64/
108 fi
109 cp refind-bin-$1/refind/refind_x64.efi $StartDir
110 cp -a docs keys banners fonts COPYING.txt LICENSE.txt README.txt CREDITS.txt NEWS.txt refind-install mkrlconf mvrefind mountesp refind-bin-$1
111
112 # Prepare the final .zip file
113 zip -9r ../refind-bin-$1.zip refind-bin-$1
114
115 # Prepare a variant with the x86-64 version built with GNU-EFI....
116 make clean
117 make -j1 gnuefi
118 if [[ $SignIt == 1 ]] ; then
119 $SBSign --key $KeysDir/refind.key --cert $KeysDir/refind.crt --output refind-bin-$1/refind/refind_x64.efi refind/refind_x64.efi
120 else
121 cp refind/refind_x64.efi refind-bin-$1/refind/refind_x64.efi
122 fi
123 zip -9r ../refind-bin-gnuefi-$1.zip refind-bin-$1
124
125 # Clean up....
126 cd ..
127 rm -r refind-$1
128
129 # Prepare the RPM & Debian package files
130 cp refind-src-$1.tar.gz ~/rpmbuild/SOURCES/
131 rpmbuild -ba $StartDir/refind.spec
132 mv ~/rpmbuild/RPMS/*/refind-$1* ./
133 mv ~/rpmbuild/SRPMS/refind-$1* ./
134 sudo alien --to-deb -k -c refind-$1*x86_64.rpm
135 sudo chown rodsmith: refind*deb
136 rm ~/rpmbuild/SOURCES/refind-src-$1.tar.gz
137
138 # Clean up
139 if [[ $SignIt == 1 ]] ; then
140 umount $KeysDir
141 fi
142
143 # Finish
144 cd $StartDir