APKBUILD 12.5 KB
Newer Older
Carlo Landmeter's avatar
Carlo Landmeter committed
1
# Contributor: Carlo Landmeter <clandmeter@gmail.com>
2
# Maintainer: Timo Teräs <timo.teras@iki.fi>
Carlo Landmeter's avatar
Carlo Landmeter committed
3
pkgname=grub
Natanael Copa's avatar
Natanael Copa committed
4
pkgver=2.02
5
pkgrel=20
Carlo Landmeter's avatar
Carlo Landmeter committed
6 7
pkgdesc="Bootloader with support for Linux, Multiboot and more"
url="https://www.gnu.org/software/grub/"
8
arch="all !s390x"
9
license="GPL-3.0-or-later"
Natanael Copa's avatar
Natanael Copa committed
10
depends="mkinitfs"
11
triggers="grub.trigger=/boot"
Carlo Landmeter's avatar
Carlo Landmeter committed
12
depends_dev=""
13
makedepends="$depends_dev bison flex linux-headers xz-dev lvm2-dev
14
	automake autoconf libtool python3 freetype-dev unifont"
15
install="$pkgname.post-upgrade"
16
# strip handled by grub Makefiles, abuild strip breaks xen pv-grub
17
options="!check !strip"  # Cannot test boot loader.
18 19
subpackages="$pkgname-dev $pkgname-doc"

20
# currently grub only builds on x86*, aarch64 and ppc* systems
21
flavors=""
22
case "$CARCH" in
23
x86)		flavors="efi bios";;
Henrik Riomar's avatar
Henrik Riomar committed
24
x86_64)		flavors="efi bios xenhost xenhost_pvh";;
25
aarch64|arm*)	flavors="efi";;
26
mips*)		flavors="qemu_mips";;
27
ppc*)		flavors="ieee1275"; makedepends="$makedepends powerpc-utils" ;;
28
s390x)		flavors="emu" ;;
29
esac
30
for f in $flavors; do
Henrik Riomar's avatar
Henrik Riomar committed
31
	[ x"$f" = x"xenhost_pvh" ] && continue # xenhost_pvh shipped in the xenhost subpackage
32 33
	subpackages="$subpackages $pkgname-$f"
done
34

Natanael Copa's avatar
Natanael Copa committed
35
source="https://ftp.gnu.org/gnu/grub/grub-$pkgver.tar.xz
36
	fix-gcc-no-pie-specs.patch
37 38
	grub2-accept-empty-module.patch
	grub-xen-host_grub.cfg
39
	2.02_beta3-mkconfig-alpine.patch
Natanael Copa's avatar
Natanael Copa committed
40
	0008-Fix-packed-not-aligned-error-on-GCC-8.patch
Natanael Copa's avatar
Natanael Copa committed
41
	0009-xfs-Accept-filesystem-with-sparse-inodes.patch
42
	x86-64-Treat-R_X86_64_PLT32-as-R_X86_64_PC32.patch
43
	alpine-use-uuid.patch
44
	f2fs-support.patch
Henrik Riomar's avatar
Henrik Riomar committed
45
	alpine-intel-ucode.patch
46
	alpine-xen-initramfs.patch
47
	lang-C.UTF-8.patch
Henrik Riomar's avatar
Henrik Riomar committed
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68

	0001-xen-Add-some-Xen-headers.patch
	0002-loader-linux-Support-passing-RSDP-address-via-boot-p.patch
	0003-xen-Carve-out-grant-tab-initialization-into-dedicate.patch
	0004-xen-Prepare-common-code-for-Xen-PVH-support.patch
	0005-xen-Add-some-dummy-headers-for-PVH-mode.patch
	0006-xen-Rearrange-xen-init.c-to-prepare-it-for-Xen-PVH-m.patch
	0007-xen-Modify-grub_xen_ptr2mfn-for-Xen-PVH.patch
	0008-xen-Add-PVH-specific-defines-to-offset.h.patch
	0009-xen-Add-basic-hooks-for-PVH-in-current-code.patch
	0010-xen-Add-PVH-boot-entry-code.patch
	0011-xen-Setup-hypercall-page-for-PVH.patch
	0012-xen-Get-memory-map-from-hypervisor-for-PVH.patch
	0013-xen-Setup-Xen-specific-data-for-PVH.patch
	0014-xen-Init-memory-regions-for-PVH.patch
	0015-xen_pvh-Add-build-runes-for-grub-core.patch
	0016-grub-module-verifier-Ignore-all_video-for-xen_pvh.patch
	0017-xen-Use-elfnote-defines-instead-of-plain-numbers.patch
	0018-xen_pvh-Support-building-a-standalone-image.patch
	0019-xen_pvh-Support-grub-install-for-xen_pvh.patch
	0020-xen_pvh-Add-support-to-configure.patch
69 70 71 72

	0001-util-grub.d-20_linux_xen.in-Add-xen_boot-command-sup.patch
	0002-Fix-util-grub.d-20_linux_xen.in-Add-xen_boot-command.patch
	0003-Use-grub-file-to-figure-out-whether-multiboot2-shoul.patch
73
	"
Natanael Copa's avatar
Natanael Copa committed
74
builddir="$srcdir/grub-$pkgver"
Carlo Landmeter's avatar
Carlo Landmeter committed
75

76 77
prepare() {
	default_prepare
78
	PYTHON=python3 ./autogen.sh
79 80
}

81 82 83 84
_build_flavor() {
	local flavor="$1"
	shift
	local _configure="$@"
85

86 87 88 89
	msg "Building grub for platform $flavor"
	mkdir -p "$srcdir"/build-$flavor
	cd "$srcdir"/build-$flavor
	$builddir/configure \
Natanael Copa's avatar
Natanael Copa committed
90 91
		--build=$CBUILD \
		--host=$CHOST \
92
		--target=$CTARGET \
Natanael Copa's avatar
Natanael Copa committed
93 94 95 96 97 98
		--prefix=/usr \
		--sysconfdir=/etc \
		--mandir=/usr/share/man \
		--localstatedir=/var \
		--disable-nls \
		--disable-werror \
99 100
		$_configure
	make
Natanael Copa's avatar
Natanael Copa committed
101 102
}

103
build() {
104 105 106 107 108 109
	local f
	for f in $flavors; do
		case "$f" in
		bios)		_build_flavor $f --with-platform=pc;;
		efi)		_build_flavor $f --with-platform=efi --disable-efiemu;;
		xenhost)	_build_flavor $f --with-platform=xen;;
Henrik Riomar's avatar
Henrik Riomar committed
110
		xenhost_pvh)	_build_flavor $f --with-platform=xen_pvh --target=i386;;
111
		*)		_build_flavor $f --with-platform=$f;;
Henrik Riomar's avatar
Henrik Riomar committed
112

113 114
		esac
	done
115
}
116

117
_install_xen() {
118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136
	grub_dir=`mktemp -d`
	cfg=`mktemp`
	grub_memdisk=`mktemp`

	mkdir -p $grub_dir/boot/grub
	echo 'normal (memdisk)/grub.cfg' > $cfg
	sed -e "s/@@PVBOOT_ARCH@@/$CARCH/g" \
		$srcdir/grub-xen-host_grub.cfg \
			> $grub_dir/grub.cfg
	tar -cf - -C $grub_dir grub.cfg > $grub_memdisk

	./grub-mkimage \
		-O $CARCH-xen \
		-c $cfg \
		-d ./grub-core ./grub-core/*.mod \
		-m $grub_memdisk \
		-o $pkgdir/grub-$CARCH-xen.bin

	rm -r "$grub_dir"
137
	rm "$cfg" "$grub_memdisk"
138 139
}

Henrik Riomar's avatar
Henrik Riomar committed
140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164
_install_xenpvh() {
	grub_dir=`mktemp -d`
	cfg=`mktemp`
	grub_memdisk=`mktemp`

	mkdir -p $grub_dir/boot/grub
	echo 'normal (memdisk)/grub.cfg' > $cfg
	sed -e "s/@@PVBOOT_ARCH@@/$CARCH/g" \
		$srcdir/grub-xen-host_grub.cfg \
			> $grub_dir/grub.cfg
	tar -cf - -C $grub_dir grub.cfg > $grub_memdisk

	echo "About to run grub-mkimage in: $PWD"
	# Note: only i386-xen_pvh supported
	./grub-mkimage \
		-O i386-xen_pvh \
		-c $cfg \
		-d ./grub-core ./grub-core/*.mod \
		-m $grub_memdisk \
		-o $pkgdir/grub-i386-xen_pvh.bin

	rm -r "$grub_dir"
	rm "$cfg" "$grub_memdisk"
}

165 166 167 168 169
_install_flavor() {
	local flavor="$1"
	cd "$srcdir"/build-$flavor
	case $flavor in
	xenhost)	_install_xen;;
Henrik Riomar's avatar
Henrik Riomar committed
170
	xenhost_pvh)	_install_xenpvh;;
171 172
	*)	 	make DESTDIR="$pkgdir" install-strip;;
	esac
Natanael Copa's avatar
Natanael Copa committed
173 174
}

175 176 177
package() {
	# install BIOS & EFI version into the same directory
	# and overwrite similar files.
178 179 180
	for f in $flavors; do
		_install_flavor $f
	done
181

Carlo Landmeter's avatar
Carlo Landmeter committed
182
	rm -f "$pkgdir"/usr/lib/charset.alias
183 184
	# remove grub-install warning of missing directory
	mkdir -p "$pkgdir"/usr/share/locale
185 186 187 188 189 190 191 192

	mkdir -p "$pkgdir"/etc/default/
	cat >"$pkgdir"/etc/default/grub <<-EOF
	GRUB_DISTRIBUTOR="Alpine"
	GRUB_TIMEOUT=2
	GRUB_DISABLE_SUBMENU=y
	GRUB_DISABLE_RECOVERY=true
	EOF
Carlo Landmeter's avatar
Carlo Landmeter committed
193 194
}

195 196 197 198 199 200 201 202 203 204 205 206 207 208
bios() {
	pkgdesc="$pkgdesc (BIOS version)"
	depends="$pkgname"
	mkdir -p $subpkgdir/usr/lib/grub
	mv $pkgdir/usr/lib/grub/*-pc $subpkgdir/usr/lib/grub/
}

efi() {
	pkgdesc="$pkgdesc (EFI version)"
	depends="$pkgname"
	mkdir -p $subpkgdir/usr/lib/grub
	mv $pkgdir/usr/lib/grub/*-efi $subpkgdir/usr/lib/grub/
}

209 210 211 212
xenhost() {
	pkgdesc="$pkgdesc (XEN host version)"
	mkdir -p $subpkgdir/usr/lib/grub-xen
	mv $pkgdir/*-xen.bin $subpkgdir/usr/lib/grub-xen/
Henrik Riomar's avatar
Henrik Riomar committed
213 214 215

	# pick up result from xenhost_pvh build as well
	mv $pkgdir/*-xen_pvh.bin $subpkgdir/usr/lib/grub-xen/
216 217
}

218 219 220 221 222 223 224
qemu_mips() {
	pkgdesc="$pkgdesc (QEMU MIPS version)"
	depends="$pkgname"
	mkdir -p $subpkgdir/usr/lib/grub
	mv $pkgdir/usr/lib/grub/*-qemu_mips $subpkgdir/usr/lib/grub/
}

225 226
ieee1275() {
	pkgdesc="$pkgdesc (IEEE1275 version)"
227
	depends="$pkgname powerpc-utils"
228 229 230 231
	mkdir -p $subpkgdir/usr/lib/grub
	mv $pkgdir/usr/lib/grub/*-ieee1275 $subpkgdir/usr/lib/grub/
}

Natanael Copa's avatar
Natanael Copa committed
232 233 234 235 236 237 238
emu() {
	pkgdesc="$pkgdesc (EMU version)"
	depends="$pkgname"
	mkdir -p $subpkgdir/usr/lib/grub
	mv $pkgdir/usr/lib/grub/*-emu $subpkgdir/usr/lib/grub/
}

Natanael Copa's avatar
Natanael Copa committed
239 240
sha512sums="cc6eb0a42b5c8df2f671cc128ff725afb3ff1f8832a196022e433cf0d3b75decfca2316d0aa5fabea75747d55e88f3d021dd93508563f8ca80fd7b9e7fe1f088  grub-2.02.tar.xz
f2a7d9ab6c445f4e402e790db56378cecd6631b5c367451aa6ce5c01cd95b95c83c3dd24d6d4b857f8f42601eba82c855607513eb6ce5b2af6bd6c71f046e288  fix-gcc-no-pie-specs.patch
241
098a1742aef131c85d63b934a9815879b991f2e73030cb90ac4b5dcd07d249fa0dd0a281e52ada0e10f05d59223493bd416eb47543242bf0ba336a0ebc9b2a1a  grub2-accept-empty-module.patch
242
4e7394e0fff6772c89683039ccf81099ebbfe4f498e6df408977a1488fd59389b6e19afdbf0860ec271e2b2aea0df7216243dcc8235d1ca3af0e7f4d0a9d60a4  grub-xen-host_grub.cfg
243
065453d336d3c6a2943690faab7d05c09ac307bc360957976a08d88d6a57742dd068a6839bcb31c7dbb703d3ef19ae2f7f44844f1bef2a1a6c19a871544bddb5  2.02_beta3-mkconfig-alpine.patch
Natanael Copa's avatar
Natanael Copa committed
244
088455205f2f397d60e43eab19ed73994880ea1f442661f7975846cceaf2b112d92fd1341119d7dbfad3af2174dfd4d4721f31dead1ac35f4a3cb7c0d92f8a04  0008-Fix-packed-not-aligned-error-on-GCC-8.patch
245
4723c5dd9fd6e9b6c8677e32e4906c7995d695c7e85e834b1b29eb1d9a024678f8fa75846c7b929d1db9b5911b604c69c1b0379cb3b9adc98d5bb6d6719eb2c4  0009-xfs-Accept-filesystem-with-sparse-inodes.patch
246
e11f62b5012ecc8abf9d4912db12a263470887671b05ccb4de54981fb3b32a52d4557439a160e69e0654e35a57fdb0afd5fe801709b8037a6ea4a50d8b8455ec  x86-64-Treat-R_X86_64_PLT32-as-R_X86_64_PC32.patch
247
ce788fa909bb89a3ccabbc144bb46226373cf846ffe1f315b0bf8b02403220d95c8fe67baf3c37c4e12cb36f22d70f62bbd2d0c5ff6b7230f05e5964b5c548ac  alpine-use-uuid.patch
Henrik Riomar's avatar
Henrik Riomar committed
248
e4e7716cef9f183810eade57751617595c5d5fac740223a5ac3ed13e2215bbb38781328a3f8da3d4c71dd39ffec55d27d3e55b55c189dce55748e9a8512d4b41  f2fs-support.patch
Henrik Riomar's avatar
Henrik Riomar committed
249
ef30930acf817cb2d3721c78f89976a706b502419843ecbf938983a2076ee6a812fb914eb8d74014054b356325c0a72ae3f4416c4b22e5e86ebd8200304446d5  alpine-intel-ucode.patch
250
e683a647757956349c25e3c4e0be8d2e4f78287ba588c497f21942677b207f33a33fa4293cbe71665760dd31b752af02e1353896858cdb2f8d4368116878d5b1  alpine-xen-initramfs.patch
251
f23702741f2a37c83d0cbf16a000a6229dfd433cd583f3254d523ce35b3668c1db2d8a704a75013e74655ec4f9da5db6b630aa92e3ca5cc47df44cc9e41d1806  lang-C.UTF-8.patch
Henrik Riomar's avatar
Henrik Riomar committed
252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270
9daf00b36108852a7443ce4b5b1114d2e87cbfc72148b7847508965ff0dfab14b3f56980a0110c82170f5c2b75ef7a337a15398f59a4cb7e6404227499bffd9a  0001-xen-Add-some-Xen-headers.patch
33505273a8525aa4b44acba69f1b7f0dbee144809fb86626879895d44ce7eed889abf442644fc96536b4ebf86ab7c84a982749fc1181976e89e59a5cf7f7944e  0002-loader-linux-Support-passing-RSDP-address-via-boot-p.patch
1e446051930a96078e2b22831f53e939affdcee371e35e45d87efb8bdf02e2eea03247b7636525daf7d9306ec47cd4351e4d74abe357d19658b0b3fc884f9343  0003-xen-Carve-out-grant-tab-initialization-into-dedicate.patch
ceba427cdfc7e4566a0b9ba7ab1f7d52136510938a3789f0bddbabd45f7b3ccdd39e143d2b19a39ceae2348f08a0af92fd8297788828565571ec1a2491c11768  0004-xen-Prepare-common-code-for-Xen-PVH-support.patch
d185926d2e70cfa4d78a929d05932e2603cf9fa728c1afae7119bd26a9d60d9a769a560bab79b65b0733c7861e2907424542352019b3c6edf0a58be367573ba9  0005-xen-Add-some-dummy-headers-for-PVH-mode.patch
501cea14809a88ff11c81a325063b04c4f75efb490b7acaf6ca1435d98d24b3bcd8fd3b0df76a3e7200561c5020d299bb4ffb178f85f3e88bd18ba4ec656260f  0006-xen-Rearrange-xen-init.c-to-prepare-it-for-Xen-PVH-m.patch
8afefbecce41fb67a47c04fc3a068f3fae36f424746bd09298cbf774620dcf8493f366e66cd554c9112bbc18d31a09be5b5f6ed78d422d861873cf03755b7ddd  0007-xen-Modify-grub_xen_ptr2mfn-for-Xen-PVH.patch
e18e0e58ff325f2e50bf1625d4befe42e9e66d271563bbeabe7f0abacd3499b858ff2a827256cf0726f629d8a944a60dcd1d620a5f0823f44613d88f86cd41ed  0008-xen-Add-PVH-specific-defines-to-offset.h.patch
5337a029b5ae11d04a8c821baf15c360f35bf49892ff3c97e1c4b36775e4918feea6188850ecb99275ebf2cd4630ea887007e568a0743661f31663d5b9a4e3dd  0009-xen-Add-basic-hooks-for-PVH-in-current-code.patch
cc84a610e07180d732691163c08fc8de3252a6f23af4ec739ef18192c9bd8cdee60252bebcf2c224ef296f3accc86f9d57dde0f2069536ce1d4c203ab56166e2  0010-xen-Add-PVH-boot-entry-code.patch
0bc6becfd10c2948980e305268906d009729fb0795b9f7ef3a80ae169728461faa2582444cfad40f2c6063dd3a82ee5a030be092cba65833a7ab30feba147e43  0011-xen-Setup-hypercall-page-for-PVH.patch
49e146a955fb41e8dbb8cef9c1d321737d2646d0f4ac686a054a0e70db05879367e0110ee74690cff3357791397f1c86262311335a41fd81de15db722fe0f58d  0012-xen-Get-memory-map-from-hypervisor-for-PVH.patch
47b8572a1778ccf5221a5a0b7880e4f4bd86a03b5716b13444b5e8f7a4059c9b5cd6a01ddd29ca78fe89c0599d7ee018728979bce4771e7ca4420c14f8855dd7  0013-xen-Setup-Xen-specific-data-for-PVH.patch
e7f1311ed679dfd969225af91293a046fced7c046afcaa716f54b8cb18dbbe364d471e6b493d686cf8b63651e7e3a89b8c31ddc7457581117ebacafce3ceaea9  0014-xen-Init-memory-regions-for-PVH.patch
45d14b87a949ce5f1d63ba5cd0048205d94359d23d3f230017b7f6de6e5d25388b2d1af06b8f32fe187adfde2d3ef30e7100e6624f6201cb9d8365bd0a742ddb  0015-xen_pvh-Add-build-runes-for-grub-core.patch
fe7ea6eeab330c0fdfd0b2a858acdff88c68f69d80b9abb21b4c3cd1d18f8717ab7c47729e28857c564c4c1427d9b1ce6b9b93643507717a8f5ec2d99c843c70  0016-grub-module-verifier-Ignore-all_video-for-xen_pvh.patch
3e78cd3cd1c70236d8e9e3a536eb2f887283b5d257f60533d22d093df76c1c3c60e490acae4b738301c87edbac2e27398fce6ddbbeb9b2f193191c76afb9bd8b  0017-xen-Use-elfnote-defines-instead-of-plain-numbers.patch
c8a16db1224c9fb4a26ef39fbd8c36bf26ff68d45d88fb4e2530369c5bccadf0208551c34c0d16e9ee4a3102d67edad26a46e7b8388222f530310762246df8ef  0018-xen_pvh-Support-building-a-standalone-image.patch
b00cb9146cadc1f48586dcab31ac4605d9591d860283000accf709a489f136bf5c8fe3351dbefe51f9e27407ca3f1ce5dd7bc2ac64ac826f593183ef5d3a9759  0019-xen_pvh-Support-grub-install-for-xen_pvh.patch
271 272 273 274
78bc31b69cde95a29b365b43898caf69238c036683a26e5448d66cd48c7a4906d2a9eff065f082c5300b72616d6e63033891fd75d59ce724759dc998d9942a37  0020-xen_pvh-Add-support-to-configure.patch
9eb4d168824d863791040e7d288dfa2bd5314c34389adb92683b6335c5bd5426f74ec98257bcfde6ab89836ae33954ac1ad2e1caf451c2d6ab4540a4f394c985  0001-util-grub.d-20_linux_xen.in-Add-xen_boot-command-sup.patch
b0ab04fff0d998a78d5de7610544de14912dc5ac27f99d74e86df7ef59db02ad4a45620030d1ff640d7c09d1f3aecaf7506dfb21dc01377f6a1f3d5a95c2978b  0002-Fix-util-grub.d-20_linux_xen.in-Add-xen_boot-command.patch
34518e3917bd3fd8e5944fcb6d208515ff4f2ae2e74736eb451a532bc116a63232b8fed28ca91c2417e815d179d438795ccbf6735edcaed2c0760555635d595e  0003-Use-grub-file-to-figure-out-whether-multiboot2-shoul.patch"