Magellan Linux

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

Parent Directory Parent Directory | Revision Log Revision Log


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