Magellan Linux

Contents of /smage/trunk/core/grub/grub-2.02-r3.smage2

Parent Directory Parent Directory | Revision Log Revision Log


Revision 14418 - (show annotations) (download)
Tue Jul 14 07:34:36 2020 UTC (3 years, 9 months ago) by niro
File size: 6247 byte(s)
-state disabled
1 # $Id$
2
3 PNAME="grub"
4 PVER="2.02"
5 PBUILD="r3"
6
7 STATE="disabled"
8 PCAT="sys-apps"
9
10 DESCRIPTION="GNU GRUB2 boot loader."
11 HOMEPAGE="http://www.gnu.org/software/grub/"
12
13 DEPEND=">= sys-apps/mage-release-1
14 >= sys-libs/ncurses-6.2
15 >= sys-libs/zlib-1.2
16 >= media-libs/freetype-2.9
17 >= sys-fs/device-mapper-2.03"
18
19 SDEPEND=">= sys-libs/ncurses-dev-6.2
20 >= sys-libs/zlib-dev-1.2
21 >= media-libs/freetype-dev-2.9"
22
23 SRCFILE="${PNAME}-${PVER/_/\~}.tar.gz"
24 SRCDIR="${BUILDDIR}/${PNAME}-${PVER/_/\~}"
25
26 ALX_PKG_KEEP="boot/grub
27 etc/conf.d
28 etc/grub.d
29 usr/sbin/grub-bios-setup
30 usr/sbin/grub-install
31 usr/sbin/grub-mkconfig
32 usr/sbin/grub-probe
33 usr/sbin/grub-reboot
34 usr/sbin/grub-set-default
35 usr/bin/grub-mkimage
36 usr/bin/grub-editenv
37 usr/bin/grub-mkrelpath
38 usr/bin/grub-script-check
39 usr/share/grub/grub-mkconfig_lib
40 usr/$(mlibdir)/grub/i386-pc"
41 sminclude mtools alx-split
42
43 # += to add injection files (alx.sminc)
44 SRC_URI+=(
45 gnu://${PNAME}/${SRCFILE}
46 mirror://${PNAME}/${SRCFILE}
47 mirror://${PNAME}/${PNAME}-2.02-confd-2.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.00-alx-add-includedir-function.patch
51 mirror://${PNAME}/${PNAME}-2.02-busybox-linux-install.patch
52 mirror://${PNAME}/${PNAME}-2.00-grub-mkconfig-fallback-to-blkid-instead-of-grub-probe-for-unknown-root-partition-types.patch
53 )
54
55 UP2DATE="updatecmd_gnu ${PNAME} gz"
56
57 # grub doesn't like CFLAG optimation,
58 # and do you really want that at your bootloader ??
59 unset CFLAGS
60 unset CXXFLAGS
61 unset CPPFLAGS
62 unset LDFLAGS
63 unset MAKEFLAGS
64
65 src_prepare()
66 {
67 munpack ${SRCFILE} || die
68 cd ${SRCDIR}
69
70 # use /etc/conf.d/grub instead of /etc/default/grub
71 mpatch ${PNAME}-2.02-confd-2.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 # grub-mkconfig: fallback to blkid instead of grub probe for unknown root partition types like f2fs
77 mpatch ${PNAME}-2.00-grub-mkconfig-fallback-to-blkid-instead-of-grub-probe-for-unknown-root-partition-types.patch || die
78
79 # fixes some issues with busybox
80 # not required anymore with busybox-1.26 and above, grep -vx|-qx is now supported
81 #mpatch ${PNAME}-${PVER}-busybox.patch || die
82 mpatch ${PNAME}-2.02-busybox-linux-install.patch || die
83
84 # add includedir() function to grub-mkconfig_lib
85 # includedir() includes all grub configuration snippets of given directory
86 mpatch ${PNAME}-2.00-alx-add-includedir-function.patch || die
87 }
88
89 src_compile()
90 {
91 cd ${SRCDIR}
92
93 local myarch
94 local myopts
95
96 # no efiemi on x86
97 case ${ARCH} in
98 x86_64) myopts+=" --enable-efiemu" ;;
99 i*86) myopts+=" --disable-efiemu" ;;
100 esac
101
102 # disable werror
103 myopts+=" --disable-werror"
104
105 # enable boot time statistics collection
106 myopts+=" --enable-boot-time"
107
108 # alx
109 myopts+=" --disable-nls"
110
111 # bios build, enforce i386
112 myarch="i386"
113 mconfigure --with-platform=pc --target="${myarch}" ${myopts} || die
114 make || die
115 }
116
117 alx_generic_src_install()
118 {
119 cd ${SRCDIR}
120
121 mmake DESTDIR=${BINDIR} install || die
122
123 # not required by pretty name patch anymore
124 # set distribution
125 #echo 'GRUB_DISTRIBUTOR="ALX Thinclient"' >> ${BINDIR}/usr/share/grub/grub-mkconfig_lib || die
126
127 # install only grub dir, no default config
128 minstalldir /boot/grub || die
129
130 # remove debugging related files
131 mdelete /usr/$(mlibdir)/grub/i386-pc/\*.module || die
132 mdelete /usr/$(mlibdir)/grub/i386-pc/\*.image || die
133 mdelete /usr/$(mlibdir)/grub/i386-pc/kernel.exec || die
134 mdelete /usr/$(mlibdir)/grub/i386-pc/gdb_grub || die
135 mdelete /usr/$(mlibdir)/grub/i386-pc/gmodule.pl || die
136
137 # docs
138 minstalldocs AUTHORS ChangeLog COPYING NEWS README THANKS TODO || die
139
140 # setup a proper grub default conf
141 minstalldir /etc/conf.d || die
142 mcinjectfile grub.confd /etc/conf.d/grub || die
143 # minstalldir /etc/conf.d/grub.d || die
144 # mcinjectfile grub-alx.confd /etc/conf.d/grub.d/10-alx || die
145
146 # # use custom creation scripts and delete the provided ones
147 # echo -e ${COLGREEN}" injecting custom grub-configs"${COLDEFAULT}
148 # local i
149 # for i in ${BINDIR}/etc/grub.d/10_linux \
150 # ${BINDIR}/etc/grub.d/20_linux_xen \
151 # ${BINDIR}/etc/grub.d/30_os-prober \
152 # ${BINDIR}/etc/grub.d/40_custom \
153 # ${BINDIR}/etc/grub.d/41_custom \
154 # ${BINDIR}/etc/grub.d/README
155 # do
156 # if [[ -f ${i} ]]
157 # then
158 # rm ${i} || die
159 # fi
160 # done
161 # mcinjectexec 05_alx_header /etc/grub.d/ || die
162 # mcinjectexec 10_alx /etc/grub.d/ || die
163
164 # only keep 10_linux script
165 for i in ${BINDIR}/etc/grub.d/20_linux_xen \
166 ${BINDIR}/etc/grub.d/30_os-prober \
167 ${BINDIR}/etc/grub.d/40_custom \
168 ${BINDIR}/etc/grub.d/41_custom \
169 ${BINDIR}/etc/grub.d/README
170 do
171 if [[ -f ${i} ]]
172 then
173 rm ${i} || die
174 fi
175 done
176 }
177
178 preinstall_grub()
179 {
180 mount /boot &> /dev/null
181
182 add_conf_prot_mask /etc/conf.d/grub /etc/grub.d /etc/conf.d/grub.d
183 }
184
185 postinstall_grub()
186 {
187 [ ! -d ${MROOT}/boot/grub ] && install -d ${MROOT}/boot/grub
188
189 # creates some essential links
190 [ ! -e ${MROOT}/boot/boot ] && ln -sf . ${MROOT}/boot/boot
191
192 # clean up old helpers, which are now consolidated to the '10_alx' script, and delete 10_alx too, we're using 10_linux now
193 local i
194 for i in 30_alx_hwdetect 40_alx_reset 10-alx
195 do
196 if [ -f ${MROOT}/etc/grub/${i} ]
197 then
198 rm ${MROOT}/etc/grub/${i}
199 fi
200 done
201 if [ -f ${MROOT}/etc/conf.d/grub.conf.d/10-alx ]
202 then
203 rm ${MROOT}/etc/conf.d/grub.conf.d/10-alx
204 fi
205
206 if [[ -z ${MROOT} ]] || [[ ${MROOT} = / ]] && [[ ${MAGE_BOOTSTRAP} != true ]]
207 then
208 # create a device.map
209 if [[ ! -f /boot/grub/device.map ]]
210 then
211 if [[ -x $(type -P grub-mkdevicemap) ]]
212 then
213 grub-mkdevicemap
214 fi
215 fi
216
217 # needed by grub-mkconfig on the first run
218 if [[ ! -f /boot/grub/video.lst ]]
219 then
220 install -m0644 /$(mlibdir)/grub/*/video.lst /boot/grub/video.lst
221 fi
222
223 # update grub.cfg
224 LC_ALL=C grub-mkconfig -o /boot/grub/grub.cfg
225
226 # install bootloader to disk
227 #local bootpartition="$(df -h /boot |(read; awk '{print $1; exit}'))"
228 local bootdisk
229 bootdisk="$(grub-probe --target=drive /boot | sed 's:(\(.*\),.*):(\1):')"
230
231 # Generate core.img, but don't let it be installed in boot sector
232 grub-install --no-floppy "${bootdisk}"
233 fi
234 }