1 # Maintainer : Christian Hesse <mail@eworm.de>
2 # Maintainer : Ronald van Haren <ronald.archlinux.org>
3 # Contributor: Tobias Powalowski <tpowa@archlinux.org>
4 # Contributor: Keshav Amburay <(the ddoott ridikulus ddoott rat) (aatt) (gemmaeiil) (ddoott) (ccoomm)>
6 ## "1" to enable IA32-EFI build in Arch x86_64, "0" to disable
7 _IA32_EFI_IN_ARCH_X64="1"
9 ## "1" to enable EMU build, "0" to disable
12 [[ "${CARCH}" == 'x86_64' ]] && _EFI_ARCH='x86_64'
13 [[ "${CARCH}" == 'i686' ]] && _EFI_ARCH='i386'
15 [[ "${CARCH}" == 'x86_64' ]] && _EMU_ARCH='x86_64'
16 [[ "${CARCH}" == 'i686' ]] && _EMU_ARCH='i386'
19 pkgdesc='GNU GRand Unified Bootloader (2)'
21 _commit='d9b4638c50b16d4722e66d334e2c1a674b4a45cc'
22 _pkgver=2.06.r322.gd9b4638c5
23 _unifont_ver='14.0.04'
26 url='https://www.gnu.org/software/grub/'
29 backup=('etc/default/grub'
30 'etc/grub.d/40_custom')
31 install="${pkgname}.install"
32 options=('!makeflags')
34 conflicts=('grub-common' 'grub-bios' 'grub-emu' "grub-efi-${_EFI_ARCH}" 'grub-legacy')
35 replaces=('grub-common' 'grub-bios' 'grub-emu' "grub-efi-${_EFI_ARCH}")
36 provides=('grub-common' 'grub-bios' 'grub-emu' "grub-efi-${_EFI_ARCH}")
38 makedepends=('git' 'rsync' 'xz' 'freetype2' 'ttf-dejavu' 'python' 'autogen'
39 'texinfo' 'help2man' 'gettext' 'device-mapper' 'fuse2')
40 depends=('sh' 'xz' 'gettext' 'device-mapper')
41 optdepends=('freetype2: For grub-mkfont usage'
42 'fuse2: For grub-mount usage'
43 'dosfstools: For grub-mkrescue FAT FS and EFI support'
44 'lzop: For grub-mkrescue LZO support'
45 'efibootmgr: For grub-install EFI support'
46 'libisoburn: Provides xorriso for generating grub rescue iso using grub-mkrescue'
47 'os-prober: To detect other OSes when generating grub.cfg in BIOS systems'
48 'mtools: For grub-mkrescue FAT FS support')
50 if [[ "${_GRUB_EMU_BUILD}" == "1" ]]; then
51 makedepends+=('libusbx' 'sdl')
52 optdepends+=('libusbx: For grub-emu USB support'
53 'sdl: For grub-emu SDL support')
56 validpgpkeys=('E53D497F3FA42AD8C9B4D1E835A93B74E82E4209' # Vladimir 'phcoder' Serbinenko <phcoder@gmail.com>
57 'BE5C23209ACDDACEB20DB0A28C8189F1988C2166' # Daniel Kiper <dkiper@net-space.pl>
58 '95D2E9AB8740D8046387FD151A09227B1F435A33') # Paul Hardy <unifoundry@unifoundry.com>
60 source=("git+https://git.savannah.gnu.org/git/grub.git#commit=${_commit}"
61 'git+https://git.savannah.gnu.org/git/gnulib.git'
62 "https://ftp.gnu.org/gnu/unifont/unifont-${_unifont_ver}/unifont-${_unifont_ver}.bdf.gz"{,.sig}
63 '0001-00_header-add-GRUB_COLOR_-variables.patch'
64 '0002-10_linux-detect-archlinux-initramfs.patch'
65 '0003-kern-efi-mm-increase-default-heap-size.patch'
71 '0bad2b8a46fcc4864c7b4cee4072653a58b9f36e2f54a5a395c7d6dc97766526'
73 '5dee6628c48eef79812bb9e86ee772068d85e7fcebbd2b2b8d1e19d24eda9dab'
74 '8488aec30a93e8fe66c23ef8c23aefda39c38389530e9e73ba3fbcc8315d244d'
75 '5529b5ef0cc735106b39b27329a6d1360323195cc2e75148d323ec0e681ed398'
76 'c17bf255a41103f6b71a1710afc7e9addaebc578bcf51a48845e227b2f651682'
77 '98b23d41e223bdc0a6e20bdcb3aa77e642f29b64081b1fd2f575314172fc89df')
86 PACKAGE_VERSION="${epoch}:${pkgver}-${pkgrel}"
87 FREETYPE="pkg-config freetype2"
88 BUILD_FREETYPE="pkg-config freetype2"
91 --enable-device-mapper
98 --mandir="/usr/share/man"
99 --infodir="/usr/share/info"
100 --datarootdir="/usr/share"
103 --with-bootdir="/boot"
104 --with-grubdir="grub"
105 --disable-silent-rules
112 echo "Apply backports..."
114 for _c in "${_backports[@]}"; do
115 git log --oneline -1 "${_c}"
116 git cherry-pick -n "${_c}"
119 echo "Apply reverts..."
121 for _c in "${_reverts[@]}"; do
122 git log --oneline -1 "${_c}"
123 git revert -n "${_c}"
126 echo "Patch to enable GRUB_COLOR_* variables in grub-mkconfig..."
127 ## Based on http://lists.gnu.org/archive/html/grub-devel/2012-02/msg00021.html
128 patch -Np1 -i "${srcdir}/0001-00_header-add-GRUB_COLOR_-variables.patch"
130 echo "Patch to detect of Arch Linux initramfs images by grub-mkconfig..."
131 patch -Np1 -i "${srcdir}/0002-10_linux-detect-archlinux-initramfs.patch"
133 echo "Patch to increase default heap size..."
134 patch -Np1 -i "${srcdir}/0003-kern-efi-mm-increase-default-heap-size.patch"
136 echo "Fix DejaVuSans.ttf location so that grub-mkfont can create *.pf2 files for starfield theme..."
137 sed 's|/usr/share/fonts/dejavu|/usr/share/fonts/dejavu /usr/share/fonts/TTF|g' -i "configure.ac"
139 echo "Fix mkinitcpio 'rw' FS#36275..."
140 sed 's| ro | rw |g' -i "util/grub.d/10_linux.in"
142 echo "Fix OS naming FS#33393..."
143 sed 's|GNU/Linux|Linux|' -i "util/grub.d/10_linux.in"
145 echo "Pull in latest language files..."
148 echo "Avoid problem with unifont during compile of grub..."
149 # http://savannah.gnu.org/bugs/?40330 and https://bugs.archlinux.org/task/37847
150 gzip -cd "${srcdir}/unifont-${_unifont_ver}.bdf.gz" > "unifont.bdf"
152 echo "Run bootstrap..."
154 --gnulib-srcdir="${srcdir}/gnulib/" \
157 echo "Make translations reproducible..."
158 sed -i '1i /^PO-Revision-Date:/ d' po/*.sed
161 _build_grub-common_and_bios() {
162 echo "Set ARCH dependent variables for bios build..."
163 if [[ "${CARCH}" == 'x86_64' ]]; then
164 _EFIEMU="--enable-efiemu"
166 _EFIEMU="--disable-efiemu"
169 echo "Copy the source for building the bios part..."
170 cp -r "${srcdir}/grub/" "${srcdir}/grub-bios/"
171 cd "${srcdir}/grub-bios/"
173 echo "Unset all compiler FLAGS for bios build..."
180 echo "Run ./configure for bios build..."
182 --with-platform="pc" \
186 "${_configure_options[@]}"
188 if [ ! -z "${SOURCE_DATE_EPOCH}" ]; then
189 echo "Make info pages reproducible..."
190 touch -d "@${SOURCE_DATE_EPOCH}" $(find -name '*.texi')
193 echo "Run make for bios build..."
198 echo "Copy the source for building the ${_EFI_ARCH} efi part..."
199 cp -r "${srcdir}/grub/" "${srcdir}/grub-efi-${_EFI_ARCH}/"
200 cd "${srcdir}/grub-efi-${_EFI_ARCH}/"
202 echo "Unset all compiler FLAGS for ${_EFI_ARCH} efi build..."
209 echo "Run ./configure for ${_EFI_ARCH} efi build..."
211 --with-platform="efi" \
212 --target="${_EFI_ARCH}" \
215 "${_configure_options[@]}"
217 echo "Run make for ${_EFI_ARCH} efi build..."
222 echo "Copy the source for building the emu part..."
223 cp -r "${srcdir}/grub/" "${srcdir}/grub-emu/"
224 cd "${srcdir}/grub-emu/"
226 echo "Unset all compiler FLAGS for emu build..."
233 echo "Run ./configure for emu build..."
235 --with-platform="emu" \
236 --target="${_EMU_ARCH}" \
237 --enable-grub-emu-usb=no \
238 --enable-grub-emu-sdl=no \
239 --disable-grub-emu-pci \
240 "${_configure_options[@]}"
242 echo "Run make for emu build..."
249 echo "Build grub bios stuff..."
250 _build_grub-common_and_bios
252 echo "Build grub ${_EFI_ARCH} efi stuff..."
255 if [[ "${CARCH}" == "x86_64" ]] && [[ "${_IA32_EFI_IN_ARCH_X64}" == "1" ]]; then
256 echo "Build grub i386 efi stuff..."
257 _EFI_ARCH="i386" _build_grub-efi
260 if [[ "${_GRUB_EMU_BUILD}" == "1" ]]; then
261 echo "Build grub emu stuff..."
266 _package_grub-common_and_bios() {
267 cd "${srcdir}/grub-bios/"
269 echo "Run make install for bios build..."
270 make DESTDIR="${pkgdir}/" bashcompletiondir="/usr/share/bash-completion/completions" install
272 echo "Remove gdb debugging related files for bios build..."
273 rm -f "${pkgdir}/usr/lib/grub/i386-pc"/*.module || true
274 rm -f "${pkgdir}/usr/lib/grub/i386-pc"/*.image || true
275 rm -f "${pkgdir}/usr/lib/grub/i386-pc"/{kernel.exec,gdb_grub,gmodule.pl} || true
277 echo "Install /etc/default/grub (used by grub-mkconfig)..."
278 install -D -m0644 "${srcdir}/grub.default" "${pkgdir}/etc/default/grub"
281 _package_grub-efi() {
282 cd "${srcdir}/grub-efi-${_EFI_ARCH}/"
284 echo "Run make install for ${_EFI_ARCH} efi build..."
285 make DESTDIR="${pkgdir}/" bashcompletiondir="/usr/share/bash-completion/completions" install
287 echo "Remove gdb debugging related files for ${_EFI_ARCH} efi build..."
288 rm -f "${pkgdir}/usr/lib/grub/${_EFI_ARCH}-efi"/*.module || true
289 rm -f "${pkgdir}/usr/lib/grub/${_EFI_ARCH}-efi"/*.image || true
290 rm -f "${pkgdir}/usr/lib/grub/${_EFI_ARCH}-efi"/{kernel.exec,gdb_grub,gmodule.pl} || true
292 sed -e "s/%PKGVER%/${epoch}:${pkgver}-${pkgrel}/" < "${srcdir}/sbat.csv" > "${pkgdir}/usr/share/grub/sbat.csv"
295 _package_grub-emu() {
296 cd "${srcdir}/grub-emu/"
298 echo "Run make install for emu build..."
299 make DESTDIR="${pkgdir}/" bashcompletiondir="/usr/share/bash-completion/completions" install
301 echo "Remove gdb debugging related files for emu build..."
302 rm -f "${pkgdir}/usr/lib/grub/${_EMU_ARCH}-emu"/*.module || true
303 rm -f "${pkgdir}/usr/lib/grub/${_EMU_ARCH}-emu"/*.image || true
304 rm -f "${pkgdir}/usr/lib/grub/${_EMU_ARCH}-emu"/{kernel.exec,gdb_grub,gmodule.pl} || true
310 echo "Package grub ${_EFI_ARCH} efi stuff..."
313 if [[ "${CARCH}" == "x86_64" ]] && [[ "${_IA32_EFI_IN_ARCH_X64}" == "1" ]]; then
314 echo "Package grub i386 efi stuff..."
315 _EFI_ARCH="i386" _package_grub-efi
318 if [[ "${_GRUB_EMU_BUILD}" == "1" ]]; then
319 echo "Package grub emu stuff..."
323 echo "Package grub bios stuff..."
324 _package_grub-common_and_bios