From ca4d7072d5d9d83366ed64cfa56b13845c9af119 Mon Sep 17 00:00:00 2001
From: Natanael Copa <ncopa@alpinelinux.org>
Date: Mon, 12 Jun 2017 14:11:08 +0000
Subject: [PATCH] main/grub: upgrade to 2.02

---
 main/grub/2.02_beta3-gcc6-ld-no-pie.patch | 57 -----------------------
 main/grub/APKBUILD                        | 13 ++----
 main/grub/fix-gcc-no-pie-specs.patch      | 11 +----
 3 files changed, 6 insertions(+), 75 deletions(-)
 delete mode 100644 main/grub/2.02_beta3-gcc6-ld-no-pie.patch

diff --git a/main/grub/2.02_beta3-gcc6-ld-no-pie.patch b/main/grub/2.02_beta3-gcc6-ld-no-pie.patch
deleted file mode 100644
index 0d8141544788..000000000000
--- a/main/grub/2.02_beta3-gcc6-ld-no-pie.patch
+++ /dev/null
@@ -1,57 +0,0 @@
-2016-05-21  Magnus Granberg  <zorry@gentoo.org>
-
-	#583042 sys-boot/grub-2.02_beta3-r1: building w/gcc-6[pie]: error:
-	x86_64-pc-linux-gnu/bin/ld: -r and -shared may not be used together
-
-	* acinclude.m4: Add -no-pie check.
-	* configure.ac: Add -no-pie to TARGET_LDFLAGS if needed.
-
---- a/acinclude.m4	2015-11-11 20:56:52.000000000 +0100
-+++ b/acinclude.m4	2016-05-17 00:08:22.000000000 +0200
-@@ -390,6 +390,24 @@ else
- [fi]
- ])
- 
-+dnl Check if the Linker supports `-no-pie'.
-+AC_DEFUN([grub_CHECK_NO_PIE],
-+[AC_MSG_CHECKING([whether linker accepts -no-pie])
-+AC_CACHE_VAL(grub_cv_cc_ld_nopie,
-+[save_LDFLAGS="$LDFLAGS"
-+LDFLAGS="$LDFLAGS -no-pie"
-+AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
-+	       [grub_cv_cc_ld_no_pie=yes],
-+	       [grub_cv_cc_ld_no_pie=no])
-+LDFLAGS="$save_LDFLAGS"
-+])
-+AC_MSG_RESULT([$grub_cv_cc_ld_no_pie])
-+nopie_possible=no
-+if test "x$grub_cv_cc_ld_no_pie" = xyes ; then
-+  nopie_possible=yes
-+fi
-+])
-+
- dnl Check if the C compiler supports `-fPIC'.
- AC_DEFUN([grub_CHECK_PIC],[
- [# Position independent executable.
---- a/configure.ac	2016-02-27 13:40:56.000000000 +0100
-+++ b/configure.ac	2016-05-17 00:57:29.471000000 +0200
-@@ -1184,13 +1184,18 @@ CFLAGS="$TARGET_CFLAGS"
- 
- # Position independent executable.
- grub_CHECK_PIE
-+grub_CHECK_NO_PIE
- [# Need that, because some distributions ship compilers that include
--# `-fPIE' in the default specs.
-+# `-fPIE' and '-pie' in the default specs.
- if [ x"$pie_possible" = xyes ]; then
-   TARGET_CFLAGS="$TARGET_CFLAGS -fno-PIE"
-+fi
-+if [ x"$nopie_possible" = xyes ] &&  [ x"$pie_possible" = xyes ]; then
-+  TARGET_LDFLAGS="$TARGET_LDFLAGS -no-pie"
- fi]
- 
- CFLAGS="$TARGET_CFLAGS"
-+LDFLAGS="$TARGET_LDFLAGS"
- 
- # Position independent executable.
- grub_CHECK_PIC
diff --git a/main/grub/APKBUILD b/main/grub/APKBUILD
index 004f3854963f..30cf7291a713 100644
--- a/main/grub/APKBUILD
+++ b/main/grub/APKBUILD
@@ -1,9 +1,8 @@
 # Contributor: Carlo Landmeter <clandmeter@gmail.com>
 # Maintainer:
 pkgname=grub
-_ver=2.02~beta3
 pkgver=2.02
-pkgrel=0
+pkgrel=1
 pkgdesc="Bootloader with support for Linux, Multiboot and more"
 url="https://www.gnu.org/software/grub/"
 arch="all !armhf !s390x"
@@ -27,14 +26,13 @@ ppc64le) subpackages="$subpackages $pkgname-ieee1275"
 s390x) subpackages="$subpackages $pkgname-emu" ;;
 esac
 
-source="ftp://alpha.gnu.org/gnu/grub/grub-$_ver.tar.xz
-	2.02_beta3-gcc6-ld-no-pie.patch
+source="https://ftp.gnu.org/gnu/grub/grub-$pkgver.tar.xz
 	fix-gcc-no-pie-specs.patch
 	grub2-accept-empty-module.patch
 	grub-xen-host_grub.cfg
 	2.02_beta3-mkconfig-alpine.patch
 	"
-builddir="$srcdir/grub-$_ver"
+builddir="$srcdir/grub-$pkgver"
 
 
 _build_bios() {
@@ -259,9 +257,8 @@ emu() {
 	mv $pkgdir/usr/lib/grub/*-emu $subpkgdir/usr/lib/grub/
 }
 
-sha512sums="4a530efef4dae45f4046cf3550563f14acb24d25cb88d5e06c93953ca5b1eec115118c6860233a9f627edcddae2571e5d6b867b70ff9dd5c184c9fef83ef7e11  grub-2.02~beta3.tar.xz
-fc15c95bf26b28eee3b5a0d8e5fac538445179cea19a8657cd360e37dd5a95010ea2b899d1e4f3692b778a71f79526539ad1c741f028186f0daf135ee1678da0  2.02_beta3-gcc6-ld-no-pie.patch
-b9eab870006ab7842e0af27171d3b66fea10835d3fd4e606f241a9898aa28bfc4c1cdf59cece8ad50d2e284a44cba74eb0f390ac29627518f86257a8d586976e  fix-gcc-no-pie-specs.patch
+sha512sums="cc6eb0a42b5c8df2f671cc128ff725afb3ff1f8832a196022e433cf0d3b75decfca2316d0aa5fabea75747d55e88f3d021dd93508563f8ca80fd7b9e7fe1f088  grub-2.02.tar.xz
+f2a7d9ab6c445f4e402e790db56378cecd6631b5c367451aa6ce5c01cd95b95c83c3dd24d6d4b857f8f42601eba82c855607513eb6ce5b2af6bd6c71f046e288  fix-gcc-no-pie-specs.patch
 098a1742aef131c85d63b934a9815879b991f2e73030cb90ac4b5dcd07d249fa0dd0a281e52ada0e10f05d59223493bd416eb47543242bf0ba336a0ebc9b2a1a  grub2-accept-empty-module.patch
 4e7394e0fff6772c89683039ccf81099ebbfe4f498e6df408977a1488fd59389b6e19afdbf0860ec271e2b2aea0df7216243dcc8235d1ca3af0e7f4d0a9d60a4  grub-xen-host_grub.cfg
 5de7c1cc11640a3892447f0daa1e3fd1f67b0c474c8aec555e4e6315b5e6c00491ba02c88b420cec221da0640c6961d639f148746df14a0b2c15bda7989cd25c  2.02_beta3-mkconfig-alpine.patch"
diff --git a/main/grub/fix-gcc-no-pie-specs.patch b/main/grub/fix-gcc-no-pie-specs.patch
index b14c0be3cc02..273c9dbe39f9 100644
--- a/main/grub/fix-gcc-no-pie-specs.patch
+++ b/main/grub/fix-gcc-no-pie-specs.patch
@@ -1,6 +1,6 @@
 --- ./configure.ac.orig
 +++ ./configure.ac
-@@ -1092,7 +1092,7 @@
+@@ -1100,7 +1100,7 @@
    if test x"$grub_cv_target_cc_efiemu64_link_format" = xunknown; then
      efiemu_excuse="no suitable link format for efiemu64 found"
    else
@@ -9,12 +9,3 @@
    fi
  fi
  if test x"$enable_efiemu" = xyes && test x"$efiemu_excuse" != x ; then
-@@ -1188,7 +1188,7 @@
- [# Need that, because some distributions ship compilers that include
- # `-fPIE' and '-pie' in the default specs.
- if [ x"$pie_possible" = xyes ]; then
--  TARGET_CFLAGS="$TARGET_CFLAGS -fno-PIE"
-+  TARGET_CFLAGS="$TARGET_CFLAGS -no-pie"
- fi
- if [ x"$nopie_possible" = xyes ] &&  [ x"$pie_possible" = xyes ]; then
-   TARGET_LDFLAGS="$TARGET_LDFLAGS -no-pie"
-- 
GitLab