Magellan Linux

Contents of /trunk/core/grub/grub-2.06-r5.smage2

Parent Directory Parent Directory | Revision Log Revision Log


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