Contents of /trunk/core/grub/grub-2.06-r6.smage2
Parent Directory | Revision Log
Revision 33589 -
(show annotations)
(download)
Thu Aug 10 11:23:42 2023 UTC (9 months ago) by niro
File size: 7846 byte(s)
Thu Aug 10 11:23:42 2023 UTC (9 months ago) by niro
File size: 7846 byte(s)
-make build from git sources and x64-ia32 builds optional, added missing efibootmgr dependency
1 | # $Id$ |
2 | |
3 | PNAME="grub" |
4 | PVER="2.06" |
5 | PBUILD="r6" |
6 | |
7 | PCAT="sys-apps" |
8 | |
9 | DESCRIPTION="GNU GRUB2 boot loader." |
10 | HOMEPAGE="http://www.gnu.org/software/grub/" |
11 | |
12 | DEPEND=">= sys-apps/mage-release-1 |
13 | >= sys-libs/ncurses-6.4 |
14 | >= sys-dev/gettext-0.22 |
15 | >= sys-libs/zlib-1.2 |
16 | >= media-libs/freetype-2.13 |
17 | >= virtual/xz-utils |
18 | >= sys-apps/os-prober-1.56 |
19 | >= sys-fs/device-mapper-2.02 |
20 | >= sys-fs/dosfstools-4.2 |
21 | >= sys-apps/efibootmgr-18" |
22 | |
23 | SDEPEND=">= virtual/pkgconfig |
24 | >= net-misc/rsync-3 |
25 | >= app-text/help2man-1 |
26 | >= sys-dev/autogen-5 |
27 | >= sys-dev/autoconf-10 |
28 | >= sys-dev/automake-10" |
29 | |
30 | SRCFILE="${PNAME}-${PVER}.tar.gz" |
31 | SRCDIR="${BUILDDIR}/${PNAME}-${PVER}" |
32 | |
33 | UNIFONT_PVER=15.0.06 |
34 | UNIFONT_SRCFILE="unifont-${UNIFONT_PVER}.pcf.gz" |
35 | |
36 | if [[ ${GRUB_GIT_SOURCE} = 1 ]] |
37 | then |
38 | GNULIB_SRCFILE="gnulib-20230809.tar.bz2" |
39 | GNULIB_SRCDIR="${BUILDDIR}/gnulib" |
40 | fi |
41 | |
42 | sminclude mtools |
43 | |
44 | # grub.confd revision |
45 | CONF_REV=1.4 |
46 | |
47 | # grub sources from git |
48 | # 1=yes; 0=no |
49 | GRUB_GIT_SOURCE=0 |
50 | |
51 | # build ia32 on x64 platforms |
52 | # 1=yes; 0=no |
53 | BUILD_X64_IA32=1 |
54 | |
55 | msetfeature "!strip static !ccache !distcc" |
56 | |
57 | SRC_URI=( |
58 | gnu://${PNAME}/${SRCFILE} |
59 | https://unifoundry.com/pub/unifont/unifont-${UNIFONT_PVER}/font-builds/${UNIFONT_SRCFILE} |
60 | mirror://${PNAME}/${SRCFILE} |
61 | mirror://${PNAME}/${UNIFONT_SRCFILE} |
62 | mirror://${PNAME}/${PNAME}-2.06-confd.patch |
63 | mirror://${PNAME}/${PNAME}-2.02-cosmetic.patch |
64 | mirror://${PNAME}/${PNAME}-2.00-10_linux-pretty-names-from-etc-os-release.patch |
65 | mirror://${PNAME}/${PNAME}-2.06-e2fsprogs-1.47-fixes.patch |
66 | mirror://${PNAME}/grub.confd-${CONF_REV} |
67 | ) |
68 | |
69 | if [[ ${GRUB_GIT_SOURCE} = 1 ]] |
70 | then |
71 | SRC_URI+=( mirror://${PNAME}/${GNULIB_SRCFILE} ) |
72 | fi |
73 | |
74 | UP2DATE="updatecmd_gnu ${PNAME} gz" |
75 | |
76 | # grub doesn't like CFLAG optimation, |
77 | # and do you really want that at your bootloader ?? |
78 | unset CFLAGS |
79 | unset CXXFLAGS |
80 | unset LTOFLAGS |
81 | |
82 | src_prepare() |
83 | { |
84 | munpack ${SRCFILE} || die |
85 | if [[ ${GRUB_GIT_SOURCE} = 1 ]] |
86 | then |
87 | munpack ${GNULIB_SRCFILE} || die |
88 | fi |
89 | cd ${SRCDIR} |
90 | |
91 | # upstream fixes |
92 | mpatch -Np1 ${PNAME}-2.06-e2fsprogs-1.47-fixes.patch || die |
93 | |
94 | # use /etc/conf.d/grub instead of /etc/default/grub |
95 | mpatch ${PNAME}-2.06-confd.patch || die |
96 | # cosmetic fixes |
97 | mpatch ${PNAME}-2.02-cosmetic.patch || die |
98 | # generate pretty names from os-release if GRUB_DISTRIBUTOR is not set |
99 | mpatch ${PNAME}-2.00-10_linux-pretty-names-from-etc-os-release.patch |
100 | |
101 | # http://savannah.gnu.org/bugs/?40330 and https://bugs.archlinux.org/task/37847 |
102 | gzip -cd ${SOURCEDIR}/${PNAME}/${UNIFONT_SRCFILE} > unifont.bdf || die |
103 | |
104 | if [[ ${GRUB_GIT_SOURCE} = 1 ]] |
105 | then |
106 | # run bootstrap (only required for versions from git) |
107 | ./bootstrap --gnulib-srcdir=${GNULIB_SRCDIR} --no-git || die |
108 | fi |
109 | |
110 | # regen aclocal with automake 1.16 |
111 | WANT_AUTOMAKE=1.16 ./autogen.sh || die |
112 | |
113 | # setup build dirs |
114 | cp -r ${SRCDIR} ${BUILDDIR}/build_bios || die |
115 | cp -r ${SRCDIR} ${BUILDDIR}/build_efi || die |
116 | if [[ ${ARCH} = x86_64 ]] && [[ ${BUILD_X64_IA32} = 1 ]] |
117 | then |
118 | cp -r ${SRCDIR} ${BUILDDIR}/build_efi_ia32 || die |
119 | fi |
120 | } |
121 | |
122 | src_compile() |
123 | { |
124 | local myconf |
125 | local myarch |
126 | local efiemu |
127 | |
128 | # common configure options |
129 | # grub-mount requires fuse3 |
130 | # grub-mkfont requires freetype2 |
131 | myconf="--prefix=/usr |
132 | --mandir=/usr/share/man |
133 | --infodir=/usr/share/info |
134 | --datarootdir=/usr/share |
135 | --sysconfdir=/etc |
136 | --localstatedir=/var/lib |
137 | --libdir=/usr/$(mlibdir) |
138 | --disable-static |
139 | --enable-shared |
140 | --enable-nls |
141 | --disable-werror |
142 | --disable-silent-rules |
143 | --enable-device-mapper |
144 | --enable-cache-stats |
145 | --enable-boot-time |
146 | --enable-grub-mkfont |
147 | --disable-grub-mount |
148 | --with-bootdir=/boot |
149 | --with-grubdir=grub" |
150 | |
151 | # fix freetype build issues |
152 | export FREETYPE="pkg-config freetype2" |
153 | export BUILD_FREETYPE="pkg-config freetype2" |
154 | |
155 | # set version |
156 | export PACKAGE_VERSION="${PVER}-${PBUILD}" |
157 | |
158 | # unset all build flags |
159 | unset CFLAGS |
160 | unset CPPFLAGS |
161 | unset CXXFLAGS |
162 | unset LDFLAGS |
163 | unset LTOFLAGS |
164 | unset MAKEFLAGS |
165 | unset MAKEOPTS |
166 | |
167 | # build bios version |
168 | cd ${BUILDDIR}/build_bios |
169 | myarch="i386" |
170 | |
171 | if [[ ${ARCH} = x86_64 ]] |
172 | then |
173 | efiemu="--enable-efiemu" |
174 | else |
175 | efiemu="--disable-efiemu" |
176 | fi |
177 | |
178 | ./configure --with-platform=pc --target="${myarch}" ${myconf} ${efiemu} || die |
179 | make || die |
180 | |
181 | # build efi version |
182 | cd ${BUILDDIR}/build_efi |
183 | case ${ARCH} in |
184 | x86_64) myarch="${ARCH}" ;; |
185 | i*86) myarch="i386" ;; |
186 | esac |
187 | |
188 | efiemu="--disable-efiemu" |
189 | |
190 | ./configure --with-platform=efi --target="${myarch}" ${myconf} ${efiemu} || die |
191 | make || die |
192 | |
193 | # build ia32 efi version on x86_64 |
194 | if [[ ${ARCH} = x86_64 ]] && [[ ${BUILD_X64_IA32} = 1 ]] |
195 | then |
196 | cd ${BUILDDIR}/build_efi_ia32 |
197 | myarch="i386" |
198 | efiemu="--disable-efiemu" |
199 | |
200 | ./configure --with-platform=efi --target="${myarch}" ${myconf} ${efiemu} || die |
201 | make || die |
202 | fi |
203 | } |
204 | |
205 | src_install() |
206 | { |
207 | local myarch |
208 | |
209 | # install efi version first |
210 | cd ${BUILDDIR}/build_efi |
211 | case ${ARCH} in |
212 | x86_64) myarch="${ARCH}" ;; |
213 | i*86) myarch="i386" ;; |
214 | esac |
215 | make DESTDIR=${BINDIR} install || die |
216 | # remove debugging related files |
217 | mdelete /usr/$(mlibdir)/grub/${myarch}-efi/\*.module || die |
218 | #mdelete -f /usr/$(mlibdir)/grub/${myarch}-efi/\*.image || die # may or may not exist |
219 | mdelete /usr/$(mlibdir)/grub/${myarch}-efi/kernel.exec || die |
220 | mdelete /usr/$(mlibdir)/grub/${myarch}-efi/gdb_grub || die |
221 | mdelete /usr/$(mlibdir)/grub/${myarch}-efi/gmodule.pl || die |
222 | |
223 | # install efi_ia32 version |
224 | if [[ ${ARCH} = x86_64 ]] && [[ ${BUILD_X64_IA32} = 1 ]] |
225 | then |
226 | cd ${BUILDDIR}/build_efi_ia32 |
227 | myarch="i386" |
228 | |
229 | make DESTDIR=${BINDIR} install || die |
230 | # remove debugging related files |
231 | mdelete /usr/$(mlibdir)/grub/${myarch}-efi/\*.module || die |
232 | #mdelete -f /usr/$(mlibdir)/grub/${myarch}-efi/\*.image || die # may or may not exist |
233 | mdelete /usr/$(mlibdir)/grub/${myarch}-efi/kernel.exec || die |
234 | mdelete /usr/$(mlibdir)/grub/${myarch}-efi/gdb_grub || die |
235 | mdelete /usr/$(mlibdir)/grub/${myarch}-efi/gmodule.pl || die |
236 | fi |
237 | |
238 | # install bios version last |
239 | cd ${BUILDDIR}/build_bios |
240 | make DESTDIR=${BINDIR} install || die |
241 | # remove debugging related files |
242 | mdelete /usr/$(mlibdir)/grub/i386-pc/\*.module || die |
243 | mdelete /usr/$(mlibdir)/grub/i386-pc/\*.image || die |
244 | mdelete /usr/$(mlibdir)/grub/i386-pc/kernel.exec || die |
245 | mdelete /usr/$(mlibdir)/grub/i386-pc/gdb_grub || die |
246 | mdelete /usr/$(mlibdir)/grub/i386-pc/gmodule.pl || die |
247 | |
248 | # not required by pretty name patch anymore |
249 | # set distribution |
250 | #echo 'GRUB_DISTRIBUTOR="Magellan-Linux"' >> ${BINDIR}/usr/share/grub/grub-mkconfig_lib || die |
251 | |
252 | # setup a proper grub default conf |
253 | minstallconf grub.confd-${CONF_REV} grub || die |
254 | |
255 | # enable a splash screen by default |
256 | sed -i '/^GRUB_CMDLINE_LINUX_DEFAULT=/s:\"\(.*\)\":\"\1 splash\":' ${BINDIR}/etc/conf.d/grub || die |
257 | |
258 | # needed dir |
259 | minstalldir /boot/grub || die |
260 | |
261 | # install unifont |
262 | minstalldir /usr/share/fonts/unifont || die |
263 | gunzip -c ${SOURCEDIR}/${PNAME}/${UNIFONT_SRCFILE} > ${BINDIR}/usr/share/fonts/unifont/unifont.pcf || die |
264 | |
265 | # docs |
266 | cd ${SRCDIR} |
267 | minstalldocs AUTHORS ChangeLog COPYING NEWS README THANKS TODO || die |
268 | } |
269 | |
270 | preinstall() |
271 | { |
272 | mount /boot &> /dev/null |
273 | } |
274 | |
275 | postinstall() |
276 | { |
277 | [ ! -d ${MROOT}/boot/grub ] && install -d ${MROOT}/boot/grub |
278 | |
279 | # creates some essential links |
280 | [ ! -e ${MROOT}/boot/boot ] && ln -sf . ${MROOT}/boot/boot |
281 | |
282 | if [[ -z ${MROOT} ]] || [[ ${MROOT} = / ]] && [[ ${MAGE_BOOTSTRAP} != true ]] |
283 | then |
284 | # create a device.map |
285 | if [[ ! -f /boot/grub/device.map ]] |
286 | then |
287 | if [[ -x $(type -P grub-mkdevicemap) ]] |
288 | then |
289 | grub-mkdevicemap |
290 | fi |
291 | fi |
292 | |
293 | # needed by grub-mkconfig on the first run |
294 | if [[ ! -f /boot/grub/video.lst ]] |
295 | then |
296 | install -m0644 /$(mlibdir)/grub/*/video.lst /boot/grub/video.lst |
297 | fi |
298 | |
299 | # update grub.cfg |
300 | LC_ALL=C grub-mkconfig -o /boot/grub/grub.cfg |
301 | |
302 | # install bootloader to disk |
303 | #local bootpartition="$(df -h /boot |(read; awk '{print $1; exit}'))" |
304 | local bootdisk |
305 | bootdisk="$(grub-probe --target=drive /boot | sed 's:(\(.*\),.*):(\1):')" |
306 | |
307 | # Generate core.img, but don't let it be installed in boot sector |
308 | grub-install --no-floppy "${bootdisk}" |
309 | fi |
310 | } |