archrelease: copy trunk to extra-x86_64
[arch-packages.git] / grub / trunk / PKGBUILD
blobd40e82d3604e2effd19949cbb95004cf05337524
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='13.0.06'
24 _pkgver=2.06
25 pkgver=${_pkgver/-/}
26 pkgrel=2
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             '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#tag=${_tag}?signed"
61         "git+https://git.savannah.gnu.org/git/gnulib.git#commit=${_gnulib_commit}"
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         'grub.default')
67 sha256sums=('SKIP'
68             'SKIP'
69             'b7668a5d498972dc4981250c49f83601babce797be19b4fdd0f2f1c6cfbd0fc5'
70             'SKIP'
71             '5dee6628c48eef79812bb9e86ee772068d85e7fcebbd2b2b8d1e19d24eda9dab'
72             '8488aec30a93e8fe66c23ef8c23aefda39c38389530e9e73ba3fbcc8315d244d'
73             '791fadf182edf8d5bee4b45c008b08adce9689a9624971136527891a8f67d206')
75 _backports=(
76         # fs/xfs: Fix unreadable filesystem with v4 superblock
77         'a4b495520e4dc41a896a8b916a64eda9970c50ea'
80 _configure_options=(
81         FREETYPE="pkg-config freetype2"
82         BUILD_FREETYPE="pkg-config freetype2"
83         --enable-mm-debug
84         --enable-nls
85         --enable-device-mapper
86         --enable-cache-stats
87         --enable-grub-mkfont
88         --enable-grub-mount
89         --prefix="/usr"
90         --bindir="/usr/bin"
91         --sbindir="/usr/bin"
92         --mandir="/usr/share/man"
93         --infodir="/usr/share/info"
94         --datarootdir="/usr/share"
95         --sysconfdir="/etc"
96         --program-prefix=""
97         --with-bootdir="/boot"
98         --with-grubdir="grub"
99         --disable-silent-rules
100         --disable-werror
103 prepare() {
104         cd "${srcdir}/grub/"
106         echo "Apply backports..."
107         local _c
108         for _c in "${_backports[@]}"; do
109                 git log --oneline -1 "${_c}"
110                 git cherry-pick -n "${_c}"
111         done
113         echo "Patch to enable GRUB_COLOR_* variables in grub-mkconfig..."
114         ## Based on http://lists.gnu.org/archive/html/grub-devel/2012-02/msg00021.html
115         patch -Np1 -i "${srcdir}/0001-00_header-add-GRUB_COLOR_-variables.patch"
117         echo "Patch to detect of Arch Linux initramfs images by grub-mkconfig..."
118         patch -Np1 -i "${srcdir}/0002-10_linux-detect-archlinux-initramfs.patch"
120         echo "Fix DejaVuSans.ttf location so that grub-mkfont can create *.pf2 files for starfield theme..."
121         sed 's|/usr/share/fonts/dejavu|/usr/share/fonts/dejavu /usr/share/fonts/TTF|g' -i "configure.ac"
123         echo "Fix mkinitcpio 'rw' FS#36275..."
124         sed 's| ro | rw |g' -i "util/grub.d/10_linux.in"
126         echo "Fix OS naming FS#33393..."
127         sed 's|GNU/Linux|Linux|' -i "util/grub.d/10_linux.in"
129         echo "Pull in latest language files..."
130         ./linguas.sh
132         echo "Avoid problem with unifont during compile of grub..."
133         # http://savannah.gnu.org/bugs/?40330 and https://bugs.archlinux.org/task/37847
134         gzip -cd "${srcdir}/unifont-${_unifont_ver}.bdf.gz" > "unifont.bdf"
136         echo "Run bootstrap..."
137         ./bootstrap \
138                 --gnulib-srcdir="${srcdir}/gnulib/" \
139                 --no-git
141         echo "Make translations reproducible..."
142         sed -i '1i /^PO-Revision-Date:/ d' po/*.sed
145 _build_grub-common_and_bios() {
146         echo "Set ARCH dependent variables for bios build..."
147         if [[ "${CARCH}" == 'x86_64' ]]; then
148                 _EFIEMU="--enable-efiemu"
149         else
150                 _EFIEMU="--disable-efiemu"
151         fi
153         echo "Copy the source for building the bios part..."
154         cp -r "${srcdir}/grub/" "${srcdir}/grub-bios/"
155         cd "${srcdir}/grub-bios/"
157         echo "Unset all compiler FLAGS for bios build..."
158         unset CFLAGS
159         unset CPPFLAGS
160         unset CXXFLAGS
161         unset LDFLAGS
162         unset MAKEFLAGS
164         echo "Run ./configure for bios build..."
165         ./configure \
166                 --with-platform="pc" \
167                 --target="i386" \
168                 "${_EFIEMU}" \
169                 --enable-boot-time \
170                 "${_configure_options[@]}"
172         if [ ! -z "${SOURCE_DATE_EPOCH}" ]; then
173                 echo "Make info pages reproducible..."
174                 touch -d "@${SOURCE_DATE_EPOCH}" $(find -name '*.texi')
175         fi
177         echo "Run make for bios build..."
178         make
181 _build_grub-efi() {
182         echo "Copy the source for building the ${_EFI_ARCH} efi part..."
183         cp -r "${srcdir}/grub/" "${srcdir}/grub-efi-${_EFI_ARCH}/"
184         cd "${srcdir}/grub-efi-${_EFI_ARCH}/"
186         echo "Unset all compiler FLAGS for ${_EFI_ARCH} efi build..."
187         unset CFLAGS
188         unset CPPFLAGS
189         unset CXXFLAGS
190         unset LDFLAGS
191         unset MAKEFLAGS
193         echo "Run ./configure for ${_EFI_ARCH} efi build..."
194         ./configure \
195                 --with-platform="efi" \
196                 --target="${_EFI_ARCH}" \
197                 --disable-efiemu \
198                 --enable-boot-time \
199                 "${_configure_options[@]}"
201         echo "Run make for ${_EFI_ARCH} efi build..."
202         make
205 _build_grub-emu() {
206         echo "Copy the source for building the emu part..."
207         cp -r "${srcdir}/grub/" "${srcdir}/grub-emu/"
208         cd "${srcdir}/grub-emu/"
210         echo "Unset all compiler FLAGS for emu build..."
211         unset CFLAGS
212         unset CPPFLAGS
213         unset CXXFLAGS
214         unset LDFLAGS
215         unset MAKEFLAGS
217         echo "Run ./configure for emu build..."
218         ./configure \
219                 --with-platform="emu" \
220                 --target="${_EMU_ARCH}" \
221                 --enable-grub-emu-usb=no \
222                 --enable-grub-emu-sdl=no \
223                 --disable-grub-emu-pci \
224                 "${_configure_options[@]}"
226         echo "Run make for emu build..."
227         make
230 build() {
231         cd "${srcdir}/grub/"
233         echo "Build grub bios stuff..."
234         _build_grub-common_and_bios
236         echo "Build grub ${_EFI_ARCH} efi stuff..."
237         _build_grub-efi
239         if [[ "${CARCH}" == "x86_64" ]] && [[ "${_IA32_EFI_IN_ARCH_X64}" == "1" ]]; then
240                 echo "Build grub i386 efi stuff..."
241                 _EFI_ARCH="i386" _build_grub-efi
242         fi
244         if [[ "${_GRUB_EMU_BUILD}" == "1" ]]; then
245                 echo "Build grub emu stuff..."
246                 _build_grub-emu
247         fi
250 _package_grub-common_and_bios() {
251         cd "${srcdir}/grub-bios/"
253         echo "Run make install for bios build..."
254         make DESTDIR="${pkgdir}/" bashcompletiondir="/usr/share/bash-completion/completions" install
256         echo "Remove gdb debugging related files for bios build..."
257         rm -f "${pkgdir}/usr/lib/grub/i386-pc"/*.module || true
258         rm -f "${pkgdir}/usr/lib/grub/i386-pc"/*.image || true
259         rm -f "${pkgdir}/usr/lib/grub/i386-pc"/{kernel.exec,gdb_grub,gmodule.pl} || true
261         echo "Install /etc/default/grub (used by grub-mkconfig)..."
262         install -D -m0644 "${srcdir}/grub.default" "${pkgdir}/etc/default/grub"
265 _package_grub-efi() {
266         cd "${srcdir}/grub-efi-${_EFI_ARCH}/"
268         echo "Run make install for ${_EFI_ARCH} efi build..."
269         make DESTDIR="${pkgdir}/" bashcompletiondir="/usr/share/bash-completion/completions" install
271         echo "Remove gdb debugging related files for ${_EFI_ARCH} efi build..."
272         rm -f "${pkgdir}/usr/lib/grub/${_EFI_ARCH}-efi"/*.module || true
273         rm -f "${pkgdir}/usr/lib/grub/${_EFI_ARCH}-efi"/*.image || true
274         rm -f "${pkgdir}/usr/lib/grub/${_EFI_ARCH}-efi"/{kernel.exec,gdb_grub,gmodule.pl} || true
277 _package_grub-emu() {
278         cd "${srcdir}/grub-emu/"
280         echo "Run make install for emu build..."
281         make DESTDIR="${pkgdir}/" bashcompletiondir="/usr/share/bash-completion/completions" install
283         echo "Remove gdb debugging related files for emu build..."
284         rm -f "${pkgdir}/usr/lib/grub/${_EMU_ARCH}-emu"/*.module || true
285         rm -f "${pkgdir}/usr/lib/grub/${_EMU_ARCH}-emu"/*.image || true
286         rm -f "${pkgdir}/usr/lib/grub/${_EMU_ARCH}-emu"/{kernel.exec,gdb_grub,gmodule.pl} || true
289 package() {
290         cd "${srcdir}/grub/"
292         echo "Package grub ${_EFI_ARCH} efi stuff..."
293         _package_grub-efi
295         if [[ "${CARCH}" == "x86_64" ]] && [[ "${_IA32_EFI_IN_ARCH_X64}" == "1" ]]; then
296                 echo "Package grub i386 efi stuff..."
297                 _EFI_ARCH="i386" _package_grub-efi
298         fi
300         if [[ "${_GRUB_EMU_BUILD}" == "1" ]]; then
301                 echo "Package grub emu stuff..."
302                 _package_grub-emu
303         fi
305         echo "Package grub bios stuff..."
306         _package_grub-common_and_bios