summaryrefslogtreecommitdiff
path: root/user/grub/APKBUILD
blob: 8b365fc0ba1f15dcd9b3351f98a93d783840fa58 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
# Contributor: Carlo Landmeter <clandmeter@gmail.com>
# Maintainer: A. Wilcox <awilfox@adelielinux.org>
pkgname=grub
pkgver=2.12_rc1
_pkgver=$(printf '%s' "$pkgver" | tr _ \~)
pkgrel=0
pkgdesc="Boot loader with support for Linux, Multiboot and more"
url="https://www.gnu.org/software/grub/"
arch="all"
# strip handled by grub Makefiles, abuild strip breaks xen pv-grub
options="!check !strip"  # Cannot test boot loader.
license="GPL-3.0+"
depends=""
makedepends="bison flex freetype-dev fuse-dev linux-headers lvm2-dev python3
	unifont xz"
# [22:02] <@awilfox> [[sroracle]]: grub breaks without its locale files present
# [22:02] <@awilfox> it cannot be split
subpackages="$pkgname-dev $pkgname-doc $pkgname-mount"

flavors=""
case "$CARCH" in
x86|pmmx)	flavors="efi bios";;
x86_64)		flavors="efi bios xenhost";;
aarch64)	flavors="efi";;
arm*)		flavors="efi uboot";;
ppc*)		flavors="ieee1275"; makedepends="$makedepends powerpc-utils" ;;
sparc*)		flavors="ieee1275";;
mips*)		flavors="arc";;
riscv*)		flavors="efi";;
esac
for f in $flavors; do
	subpackages="$subpackages $pkgname-$f"
done

install="$pkgname.post-upgrade"

source="https://alpha.gnu.org/gnu/$pkgname/$pkgname-$_pkgver.tar.xz
	adelie-branding.patch
	grub2-accept-empty-module.patch
	0001-unmerged-usr.patch
	0002-revert-gawk.patch
	0003-spcr-revision.patch
	0004-videoinfo-no-reinit.patch
	0005-vsnprintf.patch
	0006-cryptodisk-retval.patch
	0007-efi_gop-shadow.patch
	0008-efi-pure64.patch
	0009-linux-mixed-mode.patch
	0010-fix-gcc-no-pie-specs.patch
	grub-xen-host_grub.cfg
	default-grub
	update-grub
	quirk-01_radeon_agpmode
	"
builddir="$srcdir/$pkgname-$_pkgver"

_build_flavor() {
	flavor="$1"
	shift
	_configure="$@"
	case $CTARGET_ARCH in
		ppc64) export CFLAGS="${CFLAGS} -mno-altivec";;  # Workaround for http://savannah.gnu.org/bugs/?52629
	esac

	msg "Building grub for platform $flavor"
	mkdir -p "$srcdir"/build-$flavor
	cd "$srcdir"/build-$flavor
	$builddir/configure \
		--build=$CBUILD \
		--host=$CHOST \
		--target=$CTARGET \
		--prefix=/usr \
		--sysconfdir=/etc \
		--mandir=/usr/share/man \
		--localstatedir=/var \
		--disable-nls \
		--disable-werror \
		$_configure
	make
}

build() {
	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;;
		*)		_build_flavor $f --with-platform=$f;;
		esac
	done
}

_install_xen() {
	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"
	rm "$cfg" "$grub_memdisk"
}

_install_flavor() {
	flavor="$1"
	cd "$srcdir"/build-$flavor
	case $flavor in
	xenhost)	_install_xen;;
	*)	 	make DESTDIR="$pkgdir" install-strip;;
	esac
}

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

	rm -f "$pkgdir"/usr/lib/charset.alias
	install -D -m644 "$srcdir"/default-grub "$pkgdir"/etc/default/grub
	install -D -m755 "$srcdir"/update-grub "$pkgdir"/usr/sbin
	# remove grub-install warning of missing directory
	mkdir -p "$pkgdir"/usr/share/locale

	for i in "$srcdir"/quirk-*; do
		install -Dm755 "$i" \
			"$pkgdir"/etc/grub-quirks.d/"${i##"$srcdir"/quirk-}"
	done

	mkdir -p "$pkgdir"/etc/easy-boot.d
	ln -s ../../usr/sbin/update-grub \
		"$pkgdir"/etc/easy-boot.d/50-grub
}

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 efibootmgr efivar"
	mkdir -p "$subpkgdir"/usr/lib/grub
	mv "$pkgdir"/usr/lib/grub/*-efi "$subpkgdir"/usr/lib/grub/
}

xenhost() {
	pkgdesc="$pkgdesc (Xen host version)"
	mkdir -p "$subpkgdir"/usr/lib/grub-xen
	mv "$pkgdir"/*-xen.bin "$subpkgdir"/usr/lib/grub-xen/
}

ieee1275() {
	pkgdesc="$pkgdesc (IEEE-1275 OpenFirmware version)"
	case $CTARGETARCH in
		ppc*) depends="$pkgname powerpc-utils"
	esac
	mkdir -p "$subpkgdir"/usr/lib/grub
	mv "$pkgdir"/usr/lib/grub/*-ieee1275 "$subpkgdir"/usr/lib/grub/
}

mount() {
	pkgdesc="Utility to mount filesystems using GRUB modules"
	depends="$pkgname"
	mkdir -p "$subpkgdir"/usr/bin/
	mv "$pkgdir"/usr/bin/grub-mount "$subpkgdir"/usr/bin/
}

sha512sums="6f1fbce004b6dccf58e203bf6a6eeb771bac5ecc54b503265e56a97e9adce0221677bb3e64328144ec921f327a099f0345e7a9952be41cd8808f7635cded52cb  grub-2.12~rc1.tar.xz
4a6c909a1150b057fb0563f7a0646db33e16f84d6a8c443ef7db4003efd56c211a52f87699c5c95a6ccde65f6db46a8711a5b784f38479db804938dfe3115439  adelie-branding.patch
6e001762f7f562f2fafed56118079122e7602c731c70723241276f523e0882a3930d720fd847143d379ffd85626d2d7d3fa914590c0de1f0903a293695e71c41  grub2-accept-empty-module.patch
de798c8907ab5c3f00b42bf10a63a5666af2076932a46ec6e484c67303bef0509e7787910392f75b3e4ccb9aa17d67f2ef5f5fc1eed3dcdf96f598dc2400ade4  0001-unmerged-usr.patch
60e299ef0677dbd4e1e60623353be3dd8fbb1a795cbf24a9e1a2511f6a7322033254daf71116e95e93335d5e76a7a85488d66f357779a9f589f04119df8f0aea  0002-revert-gawk.patch
d7f22e5f02dfbebad5e9122a01a9d6e5fffd0bb4731790c97e5184c148a5e1e8f4d5d3d49b09b26a7768648b147b134c3b316649608d2ac8390ab63b7f278a07  0003-spcr-revision.patch
1daba1b4857c45f4e729d24cd800eb6f6b659ea5c8399394487f75817b4f7092e5972676fc8c28b6289e04f0fe41d4ca54dc4523db1393cdb65751d377a06d8a  0004-videoinfo-no-reinit.patch
0a69b2f9cb178b8ae4a7b96f1cb801ef6d6d7942a842346de5017b6fdb5a8bd6db1ad55fdd9cc41a6c4660be9985621008d1da1dc45510d6ffed425f0f4997d1  0005-vsnprintf.patch
9b444c596c3c7387c18f3d6747ce4000d8e1ac89a07d919f3c648b07a3492911a6b7a84764c7f953a8a7873f26dedf10549a46008bc23e38d1da3eeb6d1850e3  0006-cryptodisk-retval.patch
a16569a037b29a669d5bd68f6130b1c59870f8bb660bf98b318f0dac39bb9a0026d76e2d47298e2b22a91f75aa34c234785149b61e699dfdde27020210023e84  0007-efi_gop-shadow.patch
13a819813b82ed13752dff2bf2ddaf47e1c369f10148a988a2517d51f33c11ee187f3c6909c08a1b922440aebebe1f3178fe8f63f85055129b74893885e0db1f  0008-efi-pure64.patch
911a28fa28f966369039e14062deaf90c81818c06fb3f44add27c395a3074b8c1b858a47c1a97909e07b813a87633bf244e5ee4db23f9d429edd9a05f5b5d72a  0009-linux-mixed-mode.patch
1552f56c17c55aabae26c64beeb9ed507623331794d4b590721fa0f22b658831bbef3475dfb8c125ab05e8ec62939d5928416c32d2c968a4a2a98bee0744c1fd  0010-fix-gcc-no-pie-specs.patch
4e7394e0fff6772c89683039ccf81099ebbfe4f498e6df408977a1488fd59389b6e19afdbf0860ec271e2b2aea0df7216243dcc8235d1ca3af0e7f4d0a9d60a4  grub-xen-host_grub.cfg
1cb675fa0af9a1fd8d1a868e3e9de3bfef7eada66c5df0cfef23eca33e93e676eed6e1f67c679690f3e581565b350a9f3ba01aa9b89de66c970ea61ca21bcd65  default-grub
8e5f1cf91da9fd956695438509bb26e45f38170ca90d99a996e859053d72c82b7e4b02cb8979f047fc53498036f47b5400bf54687c390793995a05ded4216d55  update-grub
78b7ec141a364994c7de181e47fedca820add9960c56c7adf4c14ee11d5249a0887fd788ecd5d24b9bdd102b7c40395181e2f7c3fe5ab795dd7c0057ba1115c5  quirk-01_radeon_agpmode"