core/grub/PKGBUILD

248 lines
7.9 KiB
Bash
Raw Normal View History

2017-10-03 19:48:31 +08:00
_UNIFONT_VER="10.0.06"
2014-09-05 19:23:29 +08:00
_EFI_ARCH="x86_64"
pkgname="grub"
pkgdesc="GNU GRand Unified Bootloader (2)"
2017-10-03 19:48:31 +08:00
pkgver=2.02
pkgrel=1
2014-09-05 19:23:29 +08:00
url="https://www.gnu.org/software/grub/"
arch=('x86_64')
license=('GPL3')
backup=('boot/grub/grub.cfg' 'etc/default/grub' 'etc/grub.d/40_custom')
install="${pkgname}.install"
options=('!makeflags')
2014-11-09 22:13:50 +08:00
conflicts=('grub2-common' 'grub2-bios' 'grub2-efi64' 'grub2-efi32' "grub2-efi-${_EFI_ARCH}")
replaces=('grub2-common' 'grub2-bios' 'grub2-efi64' 'grub2-efi32' "grub2-efi-${_EFI_ARCH}")
provides=('grub2-common' 'grub2-bios' 'grub2-efi64' 'grub2-efi32' "grub2-efi-${_EFI_ARCH}")
2014-09-05 19:23:29 +08:00
makedepends=('git' 'rsync' 'xz' 'freetype2' 'ttf-dejavu' 'python3' 'autogen'
'texinfo' 'help2man' 'gettext' 'device-mapper' 'fuse')
depends=('sh' 'xz' 'gettext' 'device-mapper')
optdepends=('freetype2: For grub-mkfont usage'
'fuse: For grub-mount usage'
'dosfstools: For grub-mkrescue FAT FS and EFI support'
'efibootmgr: For grub-install EFI support'
'libisoburn: Provides xorriso for generating grub rescue iso using grub-mkrescue'
'os-prober: To detect other OSes when generating grub.cfg in BIOS systems'
'mtools: For grub-mkrescue FAT FS support')
2017-10-03 20:35:28 +08:00
source=("grub-$pkgver::git+git://git.sv.gnu.org/grub.git#tag=grub-$pkgver"
"grub-extras::git+git://git.sv.gnu.org/grub-extras.git#commit=f2a079441939eee7251bf141986cdd78946e1d20"
"https://ftp.gnu.org/gnu/unifont/unifont-${_UNIFONT_VER}/unifont-${_UNIFONT_VER}.bdf.gz"{,.sig}
2017-10-03 19:48:31 +08:00
'0002-intel-ucode.patch'
'0003-10_linux-detect-archlinux-initramfs.patch'
'0004-add-GRUB_COLOR_variables.patch'
'0005-Allow_GRUB_to_mount_ext234_filesystems_that_have_the_encryption_feature.patch'
'grub.default'
2014-09-05 19:23:29 +08:00
'update-grub')
2017-10-03 19:48:31 +08:00
md5sums=('8a4a2a95aac551fb0fba860ceabfa1d3'
'0dca61227c4fe0ab3f183f0cc428f15c'
'14d3e4d86b7134e39224848e582496ed'
'34cca1ad2da6db58823f17e04e6cdef9'
'ba9d27c44b677bf329e5b96933bdbde8'
2014-09-05 19:23:29 +08:00
'e506ae4a9f9f7d1b765febfa84e10d48'
2017-10-03 19:48:31 +08:00
'7d4aa743cfabe49158e970a97f7795f0'
2014-09-05 19:23:29 +08:00
'31e4c7414cef3db3fb26c40ac8da97f2'
'9910bdfd42fa7d3e21e6961bfcc977f9')
prepare() {
2017-10-03 19:48:31 +08:00
cd "${srcdir}/grub-${pkgver}/"
2015-08-31 22:52:39 +08:00
2017-10-03 19:48:31 +08:00
msg "Patch to load Intel microcode"
patch -Np1 -i "${srcdir}/0002-intel-ucode.patch"
2015-12-20 19:10:25 +08:00
2014-09-05 19:23:29 +08:00
msg "Patch to detect of Chakra Linux initramfs images by grub-mkconfig (same as Arch)"
2017-10-03 19:48:31 +08:00
patch -Np1 -i "${srcdir}/0003-10_linux-detect-archlinux-initramfs.patch"
2014-09-05 19:23:29 +08:00
msg "Patch to enable GRUB_COLOR_* variables in grub-mkconfig"
## Based on http://lists.gnu.org/archive/html/grub-devel/2012-02/msg00021.html
2017-10-03 19:48:31 +08:00
patch -Np1 -i "${srcdir}/0004-add-GRUB_COLOR_variables.patch"
2016-03-31 02:02:27 +08:00
2017-10-03 19:48:31 +08:00
msg "Patch to allow GRUB to mount ext2/3/4 filesystems that have the encryption feature"
patch -Np1 -i "${srcdir}/0005-Allow_GRUB_to_mount_ext234_filesystems_that_have_the_encryption_feature.patch"
2014-09-05 19:23:29 +08:00
msg "Fix DejaVuSans.ttf location so that grub-mkfont can create *.pf2 files for starfield theme"
2017-10-03 19:48:31 +08:00
sed 's|/usr/share/fonts/dejavu|/usr/share/fonts/dejavu /usr/share/fonts/TTF|g' -i "${srcdir}/grub-${pkgver}/configure.ac"
2014-09-05 19:23:29 +08:00
msg "Fix mkinitcpio 'rw' FS#36275"
2017-10-03 19:48:31 +08:00
sed 's| ro | rw |g' -i "${srcdir}/grub-${pkgver}/util/grub.d/10_linux.in"
2014-09-05 19:23:29 +08:00
msg "Fix OS naming FS#33393"
2017-10-03 19:48:31 +08:00
sed 's|GNU/Linux|Linux|' -i "${srcdir}/grub-${pkgver}/util/grub.d/10_linux.in"
2014-09-05 19:23:29 +08:00
2017-10-03 19:48:31 +08:00
msg "autogen.sh requires python (2/3). since bzr is in makedepends"
sed 's|python|python3|g' -i "${srcdir}/grub-${pkgver}/autogen.sh"
2014-09-05 19:23:29 +08:00
msg "Pull in latest language files"
./linguas.sh
msg "Remove not working langs which need LC_ALL=C.UTF-8"
2017-10-03 19:48:31 +08:00
sed -e 's#en@cyrillic en@greek##g' -i "${srcdir}/grub-${pkgver}/po/LINGUAS"
2014-09-05 19:23:29 +08:00
msg "Avoid problem with unifont during compile of grub, http://savannah.gnu.org/bugs/?40330 and https://bugs.archlinux.org/task/37847"
2017-10-03 19:48:31 +08:00
cp "${srcdir}/unifont-${_UNIFONT_VER}.bdf" "${srcdir}/grub-${pkgver}/unifont.bdf"
2014-09-05 19:23:29 +08:00
}
_build_grub-common_and_bios() {
msg "Copy the source for building the bios part"
2017-10-03 19:48:31 +08:00
cp -r "${srcdir}/grub-${pkgver}" "${srcdir}/grub-${pkgver}-bios"
cd "${srcdir}/grub-${pkgver}-bios/"
2014-09-05 19:23:29 +08:00
msg "Add the grub-extra sources for bios build"
2017-10-03 19:48:31 +08:00
install -d "${srcdir}/grub-${pkgver}-bios/grub-extras"
2017-10-03 20:35:28 +08:00
cp -r "${srcdir}/grub-extras/915resolution" "${srcdir}/grub-${pkgver}-bios/grub-extras/915resolution"
2017-10-03 19:48:31 +08:00
export GRUB_CONTRIB="${srcdir}/grub-${pkgver}-bios/grub-extras/"
2014-09-05 19:23:29 +08:00
msg "Unset all compiler FLAGS for bios build"
unset CFLAGS
unset CPPFLAGS
unset CXXFLAGS
unset LDFLAGS
unset MAKEFLAGS
2017-10-03 19:48:31 +08:00
cd "${srcdir}/grub-${pkgver}-bios/"
2014-09-05 19:23:29 +08:00
msg "Run autogen.sh for bios build"
./autogen.sh
msg "Run ./configure for bios build"
./configure \
--with-platform="pc" \
--target="i386" \
2017-10-03 19:48:31 +08:00
--enable-efiemu \
2014-09-05 19:23:29 +08:00
--enable-mm-debug \
--enable-nls \
--enable-device-mapper \
--enable-cache-stats \
--enable-boot-time \
--enable-grub-mkfont \
--enable-grub-mount \
--prefix="/usr" \
--bindir="/usr/bin" \
--sbindir="/usr/sbin" \
--mandir="/usr/share/man" \
--infodir="/usr/share/info" \
--datarootdir="/usr/share" \
--sysconfdir="/etc" \
2017-10-03 20:35:28 +08:00
--program-prefix="" \
2014-09-05 19:23:29 +08:00
--with-bootdir="/boot" \
--with-grubdir="grub" \
--disable-silent-rules \
--disable-werror
msg "Run make for bios build"
make
}
_build_grub-efi() {
msg "Copy the source for building the ${_EFI_ARCH} efi part"
2017-10-03 19:48:31 +08:00
cp -r "${srcdir}/grub-${pkgver}" "${srcdir}/grub-${pkgver}-efi-${_EFI_ARCH}"
cd "${srcdir}/grub-${pkgver}-efi-${_EFI_ARCH}/"
2014-09-05 19:23:29 +08:00
msg "Unset all compiler FLAGS for ${_EFI_ARCH} efi build"
unset CFLAGS
unset CPPFLAGS
unset CXXFLAGS
unset LDFLAGS
unset MAKEFLAGS
2017-10-03 19:48:31 +08:00
cd "${srcdir}/grub-${pkgver}-efi-${_EFI_ARCH}/"
2014-09-05 19:23:29 +08:00
msg "Run autogen.sh for ${_EFI_ARCH} efi build"
./autogen.sh
echo
msg "Run ./configure for ${_EFI_ARCH} efi build"
./configure \
--with-platform="efi" \
--target="${_EFI_ARCH}" \
--disable-efiemu \
--enable-mm-debug \
--enable-nls \
--enable-device-mapper \
--enable-cache-stats \
--enable-boot-time \
--enable-grub-mkfont \
--enable-grub-mount \
--prefix="/usr" \
--bindir="/usr/bin" \
--sbindir="/usr/sbin" \
--mandir="/usr/share/man" \
--infodir="/usr/share/info" \
--datarootdir="/usr/share" \
--sysconfdir="/etc" \
--program-prefix="" \
--with-bootdir="/boot" \
--with-grubdir="grub" \
--disable-silent-rules \
--disable-werror
msg "Run make for ${_EFI_ARCH} efi build"
make
}
build() {
2017-10-03 19:48:31 +08:00
cd "${srcdir}/grub-${pkgver}/"
2014-09-05 19:23:29 +08:00
2017-10-03 20:35:28 +08:00
msg 'Build grub bios stuff'
2014-09-05 19:23:29 +08:00
_build_grub-common_and_bios
msg "Build grub ${_EFI_ARCH} efi stuff"
_build_grub-efi
2017-10-03 19:48:31 +08:00
2017-10-03 20:35:28 +08:00
msg 'Build grub i386 efi stuff'
_EFI_ARCH='i386' _build_grub-efi
2014-09-05 19:23:29 +08:00
}
_package_grub-common_and_bios() {
2017-10-03 19:48:31 +08:00
cd "${srcdir}/grub-${pkgver}-bios/"
2014-09-05 19:23:29 +08:00
msg "Run make install for bios build"
make DESTDIR="${pkgdir}/" bashcompletiondir="/usr/share/bash-completion/completions" install
msg "Remove gdb debugging related files for bios build"
2017-10-03 19:48:31 +08:00
rm -f "${pkgdir}/usr/lib/grub/i386-pc"/*.module
rm -f "${pkgdir}/usr/lib/grub/i386-pc"/*.image
rm -f "${pkgdir}/usr/lib/grub/i386-pc"/{kernel.exec,gdb_grub,gmodule.pl}
2014-09-05 19:23:29 +08:00
msg "Install /etc/default/grub (used by grub-mkconfig)"
install -D -m0644 "${srcdir}/grub.default" "${pkgdir}/etc/default/grub"
msg "Install update-grub (Chakra helper script)"
install -D -m755 "${srcdir}/update-grub" "${pkgdir}/usr/sbin/update-grub"
}
_package_grub-efi() {
2017-10-03 19:48:31 +08:00
cd "${srcdir}/grub-${pkgver}-efi-${_EFI_ARCH}/"
2014-09-05 19:23:29 +08:00
msg "Run make install for ${_EFI_ARCH} efi build"
make DESTDIR="${pkgdir}/" bashcompletiondir="/usr/share/bash-completion/completions" install
msg "Remove gdb debugging related files for ${_EFI_ARCH} efi build"
2017-10-03 19:48:31 +08:00
rm -f "${pkgdir}/usr/lib/grub/${_EFI_ARCH}-efi"/*.module
rm -f "${pkgdir}/usr/lib/grub/${_EFI_ARCH}-efi"/*.image
rm -f "${pkgdir}/usr/lib/grub/${_EFI_ARCH}-efi"/{kernel.exec,gdb_grub,gmodule.pl}
2014-09-05 19:23:29 +08:00
}
2017-10-03 19:48:31 +08:00
package() {
cd "${srcdir}/grub-${pkgver}/"
2014-09-05 19:23:29 +08:00
msg "Package grub ${_EFI_ARCH} efi stuff"
_package_grub-efi
2017-10-03 19:48:31 +08:00
2017-10-03 20:35:28 +08:00
msg 'Package grub i386 efi stuff'
2017-10-03 19:48:31 +08:00
_EFI_ARCH="i386" _package_grub-efi
2014-09-05 19:23:29 +08:00
2017-10-03 20:35:28 +08:00
msg 'Package grub bios stuff'
2014-09-05 19:23:29 +08:00
_package_grub-common_and_bios
}