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