archrelease: copy trunk to extra-x86_64
[arch-packages.git] / grub / trunk / PKGBUILD
blob10771f4c79a772cc0c39d2b8aff60ae43395f40f
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
10 _GRUB_EMU_BUILD="0"
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'
18 pkgname='grub'
19 pkgdesc='GNU GRand Unified Bootloader (2)'
20 epoch=2
21 _tag='53c5000739db114c229fe69ec3d4b76b92441098' # git rev-parse grub-${_pkgver}
22 _gnulib_commit='be584c56eb1311606e5ea1a36363b97bddb6eed3'
23 _unifont_ver='14.0.01'
24 _pkgver=2.06
25 pkgver=${_pkgver/-/}
26 pkgrel=4
27 url='https://www.gnu.org/software/grub/'
28 arch=('x86_64')
29 license=('GPL3')
30 backup=('etc/default/grub'
31         'etc/grub.d/40_custom')
32 install="${pkgname}.install"
33 options=('!makeflags')
35 conflicts=('grub-common' 'grub-bios' 'grub-emu' "grub-efi-${_EFI_ARCH}" 'grub-legacy')
36 replaces=('grub-common' 'grub-bios' 'grub-emu' "grub-efi-${_EFI_ARCH}")
37 provides=('grub-common' 'grub-bios' 'grub-emu' "grub-efi-${_EFI_ARCH}")
39 makedepends=('git' 'rsync' 'xz' 'freetype2' 'ttf-dejavu' 'python' 'autogen'
40              'texinfo' 'help2man' 'gettext' 'device-mapper' 'fuse2')
41 depends=('sh' 'xz' 'gettext' 'device-mapper')
42 optdepends=('freetype2: For grub-mkfont usage'
43             'fuse2: For grub-mount usage'
44             'dosfstools: For grub-mkrescue FAT FS and EFI support'
45             'lzop: For grub-mkrescue LZO support'
46             'efibootmgr: For grub-install EFI support'
47             'libisoburn: Provides xorriso for generating grub rescue iso using grub-mkrescue'
48             'os-prober: To detect other OSes when generating grub.cfg in BIOS systems'
49             'mtools: For grub-mkrescue FAT FS support')
51 if [[ "${_GRUB_EMU_BUILD}" == "1" ]]; then
52     makedepends+=('libusbx' 'sdl')
53     optdepends+=('libusbx: For grub-emu USB support'
54                  'sdl: For grub-emu SDL support')
57 validpgpkeys=('E53D497F3FA42AD8C9B4D1E835A93B74E82E4209'  # Vladimir 'phcoder' Serbinenko <phcoder@gmail.com>
58               'BE5C23209ACDDACEB20DB0A28C8189F1988C2166'  # Daniel Kiper <dkiper@net-space.pl>
59               '95D2E9AB8740D8046387FD151A09227B1F435A33') # Paul Hardy <unifoundry@unifoundry.com>
61 source=("git+https://git.savannah.gnu.org/git/grub.git#tag=${_tag}?signed"
62         "git+https://git.savannah.gnu.org/git/gnulib.git#commit=${_gnulib_commit}"
63         "https://ftp.gnu.org/gnu/unifont/unifont-${_unifont_ver}/unifont-${_unifont_ver}.bdf.gz"{,.sig}
64         '0001-00_header-add-GRUB_COLOR_-variables.patch'
65         '0002-10_linux-detect-archlinux-initramfs.patch'
66         'grub.default')
68 sha256sums=('SKIP'
69             'SKIP'
70             '391d194f6307fcd0915daafd360509a734e26f3e4013e63d47deb2530d59e66e'
71             'SKIP'
72             '5dee6628c48eef79812bb9e86ee772068d85e7fcebbd2b2b8d1e19d24eda9dab'
73             '8488aec30a93e8fe66c23ef8c23aefda39c38389530e9e73ba3fbcc8315d244d'
74             'c17bf255a41103f6b71a1710afc7e9addaebc578bcf51a48845e227b2f651682')
76 _backports=(
77         # fs/xfs: Fix unreadable filesystem with v4 superblock
78         'a4b495520e4dc41a896a8b916a64eda9970c50ea'
81 _configure_options=(
82         FREETYPE="pkg-config freetype2"
83         BUILD_FREETYPE="pkg-config freetype2"
84         --enable-mm-debug
85         --enable-nls
86         --enable-device-mapper
87         --enable-cache-stats
88         --enable-grub-mkfont
89         --enable-grub-mount
90         --prefix="/usr"
91         --bindir="/usr/bin"
92         --sbindir="/usr/bin"
93         --mandir="/usr/share/man"
94         --infodir="/usr/share/info"
95         --datarootdir="/usr/share"
96         --sysconfdir="/etc"
97         --program-prefix=""
98         --with-bootdir="/boot"
99         --with-grubdir="grub"
100         --disable-silent-rules
101         --disable-werror
104 prepare() {
105         cd "${srcdir}/grub/"
107         echo "Apply backports..."
108         local _c
109         for _c in "${_backports[@]}"; do
110                 git log --oneline -1 "${_c}"
111                 git cherry-pick -n "${_c}"
112         done
114         echo "Patch to enable GRUB_COLOR_* variables in grub-mkconfig..."
115         ## Based on http://lists.gnu.org/archive/html/grub-devel/2012-02/msg00021.html
116         patch -Np1 -i "${srcdir}/0001-00_header-add-GRUB_COLOR_-variables.patch"
118         echo "Patch to detect of Arch Linux initramfs images by grub-mkconfig..."
119         patch -Np1 -i "${srcdir}/0002-10_linux-detect-archlinux-initramfs.patch"
121         echo "Fix DejaVuSans.ttf location so that grub-mkfont can create *.pf2 files for starfield theme..."
122         sed 's|/usr/share/fonts/dejavu|/usr/share/fonts/dejavu /usr/share/fonts/TTF|g' -i "configure.ac"
124         echo "Fix mkinitcpio 'rw' FS#36275..."
125         sed 's| ro | rw |g' -i "util/grub.d/10_linux.in"
127         echo "Fix OS naming FS#33393..."
128         sed 's|GNU/Linux|Linux|' -i "util/grub.d/10_linux.in"
130         echo "Pull in latest language files..."
131         ./linguas.sh
133         echo "Avoid problem with unifont during compile of grub..."
134         # http://savannah.gnu.org/bugs/?40330 and https://bugs.archlinux.org/task/37847
135         gzip -cd "${srcdir}/unifont-${_unifont_ver}.bdf.gz" > "unifont.bdf"
137         echo "Run bootstrap..."
138         ./bootstrap \
139                 --gnulib-srcdir="${srcdir}/gnulib/" \
140                 --no-git
142         echo "Make translations reproducible..."
143         sed -i '1i /^PO-Revision-Date:/ d' po/*.sed
146 _build_grub-common_and_bios() {
147         echo "Set ARCH dependent variables for bios build..."
148         if [[ "${CARCH}" == 'x86_64' ]]; then
149                 _EFIEMU="--enable-efiemu"
150         else
151                 _EFIEMU="--disable-efiemu"
152         fi
154         echo "Copy the source for building the bios part..."
155         cp -r "${srcdir}/grub/" "${srcdir}/grub-bios/"
156         cd "${srcdir}/grub-bios/"
158         echo "Unset all compiler FLAGS for bios build..."
159         unset CFLAGS
160         unset CPPFLAGS
161         unset CXXFLAGS
162         unset LDFLAGS
163         unset MAKEFLAGS
165         echo "Run ./configure for bios build..."
166         ./configure \
167                 --with-platform="pc" \
168                 --target="i386" \
169                 "${_EFIEMU}" \
170                 --enable-boot-time \
171                 "${_configure_options[@]}"
173         if [ ! -z "${SOURCE_DATE_EPOCH}" ]; then
174                 echo "Make info pages reproducible..."
175                 touch -d "@${SOURCE_DATE_EPOCH}" $(find -name '*.texi')
176         fi
178         echo "Run make for bios build..."
179         make
182 _build_grub-efi() {
183         echo "Copy the source for building the ${_EFI_ARCH} efi part..."
184         cp -r "${srcdir}/grub/" "${srcdir}/grub-efi-${_EFI_ARCH}/"
185         cd "${srcdir}/grub-efi-${_EFI_ARCH}/"
187         echo "Unset all compiler FLAGS for ${_EFI_ARCH} efi build..."
188         unset CFLAGS
189         unset CPPFLAGS
190         unset CXXFLAGS
191         unset LDFLAGS
192         unset MAKEFLAGS
194         echo "Run ./configure for ${_EFI_ARCH} efi build..."
195         ./configure \
196                 --with-platform="efi" \
197                 --target="${_EFI_ARCH}" \
198                 --disable-efiemu \
199                 --enable-boot-time \
200                 "${_configure_options[@]}"
202         echo "Run make for ${_EFI_ARCH} efi build..."
203         make
206 _build_grub-emu() {
207         echo "Copy the source for building the emu part..."
208         cp -r "${srcdir}/grub/" "${srcdir}/grub-emu/"
209         cd "${srcdir}/grub-emu/"
211         echo "Unset all compiler FLAGS for emu build..."
212         unset CFLAGS
213         unset CPPFLAGS
214         unset CXXFLAGS
215         unset LDFLAGS
216         unset MAKEFLAGS
218         echo "Run ./configure for emu build..."
219         ./configure \
220                 --with-platform="emu" \
221                 --target="${_EMU_ARCH}" \
222                 --enable-grub-emu-usb=no \
223                 --enable-grub-emu-sdl=no \
224                 --disable-grub-emu-pci \
225                 "${_configure_options[@]}"
227         echo "Run make for emu build..."
228         make
231 build() {
232         cd "${srcdir}/grub/"
234         echo "Build grub bios stuff..."
235         _build_grub-common_and_bios
237         echo "Build grub ${_EFI_ARCH} efi stuff..."
238         _build_grub-efi
240         if [[ "${CARCH}" == "x86_64" ]] && [[ "${_IA32_EFI_IN_ARCH_X64}" == "1" ]]; then
241                 echo "Build grub i386 efi stuff..."
242                 _EFI_ARCH="i386" _build_grub-efi
243         fi
245         if [[ "${_GRUB_EMU_BUILD}" == "1" ]]; then
246                 echo "Build grub emu stuff..."
247                 _build_grub-emu
248         fi
251 _package_grub-common_and_bios() {
252         cd "${srcdir}/grub-bios/"
254         echo "Run make install for bios build..."
255         make DESTDIR="${pkgdir}/" bashcompletiondir="/usr/share/bash-completion/completions" install
257         echo "Remove gdb debugging related files for bios build..."
258         rm -f "${pkgdir}/usr/lib/grub/i386-pc"/*.module || true
259         rm -f "${pkgdir}/usr/lib/grub/i386-pc"/*.image || true
260         rm -f "${pkgdir}/usr/lib/grub/i386-pc"/{kernel.exec,gdb_grub,gmodule.pl} || true
262         echo "Install /etc/default/grub (used by grub-mkconfig)..."
263         install -D -m0644 "${srcdir}/grub.default" "${pkgdir}/etc/default/grub"
266 _package_grub-efi() {
267         cd "${srcdir}/grub-efi-${_EFI_ARCH}/"
269         echo "Run make install for ${_EFI_ARCH} efi build..."
270         make DESTDIR="${pkgdir}/" bashcompletiondir="/usr/share/bash-completion/completions" install
272         echo "Remove gdb debugging related files for ${_EFI_ARCH} efi build..."
273         rm -f "${pkgdir}/usr/lib/grub/${_EFI_ARCH}-efi"/*.module || true
274         rm -f "${pkgdir}/usr/lib/grub/${_EFI_ARCH}-efi"/*.image || true
275         rm -f "${pkgdir}/usr/lib/grub/${_EFI_ARCH}-efi"/{kernel.exec,gdb_grub,gmodule.pl} || true
277         _sbat_file="${pkgdir}/usr/share/grub/sbat.csv"
278         touch "${_sbat_file}"
279         echo "sbat,1,SBAT Version,sbat,1,https://github.com/rhboot/shim/blob/main/SBAT.md" >> "${_sbat_file}"
280         echo "grub,1,Free Software Foundation,grub,${_pkgver},https//www.gnu.org/software/grub/" >> "${_sbat_file}"
281         echo "grub.arch,1,Arch Linux,grub,${_pkgver},https://archlinux.org/packages/core/x86_64/grub/" >> "${_sbat_file}"
284 _package_grub-emu() {
285         cd "${srcdir}/grub-emu/"
287         echo "Run make install for emu build..."
288         make DESTDIR="${pkgdir}/" bashcompletiondir="/usr/share/bash-completion/completions" install
290         echo "Remove gdb debugging related files for emu build..."
291         rm -f "${pkgdir}/usr/lib/grub/${_EMU_ARCH}-emu"/*.module || true
292         rm -f "${pkgdir}/usr/lib/grub/${_EMU_ARCH}-emu"/*.image || true
293         rm -f "${pkgdir}/usr/lib/grub/${_EMU_ARCH}-emu"/{kernel.exec,gdb_grub,gmodule.pl} || true
296 package() {
297         cd "${srcdir}/grub/"
299         echo "Package grub ${_EFI_ARCH} efi stuff..."
300         _package_grub-efi
302         if [[ "${CARCH}" == "x86_64" ]] && [[ "${_IA32_EFI_IN_ARCH_X64}" == "1" ]]; then
303                 echo "Package grub i386 efi stuff..."
304                 _EFI_ARCH="i386" _package_grub-efi
305         fi
307         if [[ "${_GRUB_EMU_BUILD}" == "1" ]]; then
308                 echo "Package grub emu stuff..."
309                 _package_grub-emu
310         fi
312         echo "Package grub bios stuff..."
313         _package_grub-common_and_bios