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='e67a551a48192a04ab705fca832d82f850162b64'
22 _pkgver=2.06.r499.ge67a551a4
23 _unifont_ver='15.0.01'
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'
70 '1fddba900a36b8a067bf2177b05c4a2482a0f7ca1545cf531c03509f47ce1590'
72 '5dee6628c48eef79812bb9e86ee772068d85e7fcebbd2b2b8d1e19d24eda9dab'
73 '8488aec30a93e8fe66c23ef8c23aefda39c38389530e9e73ba3fbcc8315d244d'
74 '7df3f5cb5df7d2dfb17f4c9b5c5dedc9519ddce6f8d2c6cd43d1be17cecb65cb'
75 '98b23d41e223bdc0a6e20bdcb3aa77e642f29b64081b1fd2f575314172fc89df')
84 PACKAGE_VERSION="${epoch}:${pkgver}-${pkgrel}"
85 FREETYPE="pkg-config freetype2"
86 BUILD_FREETYPE="pkg-config freetype2"
88 --enable-device-mapper
95 --mandir="/usr/share/man"
96 --infodir="/usr/share/info"
97 --datarootdir="/usr/share"
100 --with-bootdir="/boot"
101 --with-grubdir="grub"
102 --disable-silent-rules
109 echo "Apply backports..."
111 for _c in "${_backports[@]}"; do
112 git log --oneline -1 "${_c}"
113 git cherry-pick -n "${_c}"
116 echo "Apply reverts..."
118 for _c in "${_reverts[@]}"; do
119 git log --oneline -1 "${_c}"
120 git revert -n "${_c}"
123 echo "Patch to enable GRUB_COLOR_* variables in grub-mkconfig..."
124 ## Based on http://lists.gnu.org/archive/html/grub-devel/2012-02/msg00021.html
125 patch -Np1 -i "${srcdir}/0001-00_header-add-GRUB_COLOR_-variables.patch"
127 echo "Patch to detect of Arch Linux initramfs images by grub-mkconfig..."
128 patch -Np1 -i "${srcdir}/0002-10_linux-detect-archlinux-initramfs.patch"
130 echo "Fix DejaVuSans.ttf location so that grub-mkfont can create *.pf2 files for starfield theme..."
131 sed 's|/usr/share/fonts/dejavu|/usr/share/fonts/dejavu /usr/share/fonts/TTF|g' -i "configure.ac"
133 echo "Fix mkinitcpio 'rw' FS#36275..."
134 sed 's| ro | rw |g' -i "util/grub.d/10_linux.in"
136 echo "Fix OS naming FS#33393..."
137 sed 's|GNU/Linux|Linux|' -i "util/grub.d/10_linux.in"
139 echo "Pull in latest language files..."
142 echo "Avoid problem with unifont during compile of grub..."
143 # http://savannah.gnu.org/bugs/?40330 and https://bugs.archlinux.org/task/37847
144 gzip -cd "${srcdir}/unifont-${_unifont_ver}.bdf.gz" > "unifont.bdf"
146 echo "Run bootstrap..."
148 --gnulib-srcdir="${srcdir}/gnulib/" \
151 echo "Make translations reproducible..."
152 sed -i '1i /^PO-Revision-Date:/ d' po/*.sed
155 _build_grub-common_and_bios() {
156 echo "Set ARCH dependent variables for bios build..."
157 if [[ "${CARCH}" == 'x86_64' ]]; then
158 _EFIEMU="--enable-efiemu"
160 _EFIEMU="--disable-efiemu"
163 echo "Copy the source for building the bios part..."
164 cp -r "${srcdir}/grub/" "${srcdir}/grub-bios/"
165 cd "${srcdir}/grub-bios/"
167 echo "Unset all compiler FLAGS for bios build..."
174 echo "Run ./configure for bios build..."
176 --with-platform="pc" \
180 "${_configure_options[@]}"
182 if [ ! -z "${SOURCE_DATE_EPOCH}" ]; then
183 echo "Make info pages reproducible..."
184 touch -d "@${SOURCE_DATE_EPOCH}" $(find -name '*.texi')
187 echo "Run make for bios build..."
192 echo "Copy the source for building the ${_EFI_ARCH} efi part..."
193 cp -r "${srcdir}/grub/" "${srcdir}/grub-efi-${_EFI_ARCH}/"
194 cd "${srcdir}/grub-efi-${_EFI_ARCH}/"
196 echo "Unset all compiler FLAGS for ${_EFI_ARCH} efi build..."
203 echo "Run ./configure for ${_EFI_ARCH} efi build..."
205 --with-platform="efi" \
206 --target="${_EFI_ARCH}" \
209 "${_configure_options[@]}"
211 echo "Run make for ${_EFI_ARCH} efi build..."
216 echo "Copy the source for building the emu part..."
217 cp -r "${srcdir}/grub/" "${srcdir}/grub-emu/"
218 cd "${srcdir}/grub-emu/"
220 echo "Unset all compiler FLAGS for emu build..."
227 echo "Run ./configure for emu build..."
229 --with-platform="emu" \
230 --target="${_EMU_ARCH}" \
231 --enable-grub-emu-usb=no \
232 --enable-grub-emu-sdl=no \
233 --disable-grub-emu-pci \
234 "${_configure_options[@]}"
236 echo "Run make for emu build..."
243 echo "Build grub bios stuff..."
244 _build_grub-common_and_bios
246 echo "Build grub ${_EFI_ARCH} efi stuff..."
249 if [[ "${CARCH}" == "x86_64" ]] && [[ "${_IA32_EFI_IN_ARCH_X64}" == "1" ]]; then
250 echo "Build grub i386 efi stuff..."
251 _EFI_ARCH="i386" _build_grub-efi
254 if [[ "${_GRUB_EMU_BUILD}" == "1" ]]; then
255 echo "Build grub emu stuff..."
260 _package_grub-common_and_bios() {
261 cd "${srcdir}/grub-bios/"
263 echo "Run make install for bios build..."
264 make DESTDIR="${pkgdir}/" bashcompletiondir="/usr/share/bash-completion/completions" install
266 echo "Remove gdb debugging related files for bios build..."
267 rm -f "${pkgdir}/usr/lib/grub/i386-pc"/*.module || true
268 rm -f "${pkgdir}/usr/lib/grub/i386-pc"/*.image || true
269 rm -f "${pkgdir}/usr/lib/grub/i386-pc"/{kernel.exec,gdb_grub,gmodule.pl} || true
271 echo "Install /etc/default/grub (used by grub-mkconfig)..."
272 install -D -m0644 "${srcdir}/grub.default" "${pkgdir}/etc/default/grub"
275 _package_grub-efi() {
276 cd "${srcdir}/grub-efi-${_EFI_ARCH}/"
278 echo "Run make install for ${_EFI_ARCH} efi build..."
279 make DESTDIR="${pkgdir}/" bashcompletiondir="/usr/share/bash-completion/completions" install
281 echo "Remove gdb debugging related files for ${_EFI_ARCH} efi build..."
282 rm -f "${pkgdir}/usr/lib/grub/${_EFI_ARCH}-efi"/*.module || true
283 rm -f "${pkgdir}/usr/lib/grub/${_EFI_ARCH}-efi"/*.image || true
284 rm -f "${pkgdir}/usr/lib/grub/${_EFI_ARCH}-efi"/{kernel.exec,gdb_grub,gmodule.pl} || true
286 sed -e "s/%PKGVER%/${epoch}:${pkgver}-${pkgrel}/" < "${srcdir}/sbat.csv" > "${pkgdir}/usr/share/grub/sbat.csv"
289 _package_grub-emu() {
290 cd "${srcdir}/grub-emu/"
292 echo "Run make install for emu build..."
293 make DESTDIR="${pkgdir}/" bashcompletiondir="/usr/share/bash-completion/completions" install
295 echo "Remove gdb debugging related files for emu build..."
296 rm -f "${pkgdir}/usr/lib/grub/${_EMU_ARCH}-emu"/*.module || true
297 rm -f "${pkgdir}/usr/lib/grub/${_EMU_ARCH}-emu"/*.image || true
298 rm -f "${pkgdir}/usr/lib/grub/${_EMU_ARCH}-emu"/{kernel.exec,gdb_grub,gmodule.pl} || true
304 echo "Package grub ${_EFI_ARCH} efi stuff..."
307 if [[ "${CARCH}" == "x86_64" ]] && [[ "${_IA32_EFI_IN_ARCH_X64}" == "1" ]]; then
308 echo "Package grub i386 efi stuff..."
309 _EFI_ARCH="i386" _package_grub-efi
312 if [[ "${_GRUB_EMU_BUILD}" == "1" ]]; then
313 echo "Package grub emu stuff..."
317 echo "Package grub bios stuff..."
318 _package_grub-common_and_bios