Magellan Linux

Annotation of /trunk/core/grub/grub-2.02-r2.smage2

Parent Directory Parent Directory | Revision Log Revision Log


Revision 32047 - (hide annotations) (download)
Mon Mar 11 15:43:32 2019 UTC (5 years, 3 months ago) by niro
File size: 4846 byte(s)
-enabled efi grub build
1 niro 32047 # $Id$
2    
3     PNAME="grub"
4     PVER="2.02"
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-5.9
14     >= sys-dev/gettext-0.19
15     >= sys-libs/zlib-1.2.5
16     >= media-libs/freetype-2.5
17     >= app-arch/xz-utils-5
18     >= sys-apps/os-prober-1.56
19     >= sys-fs/device-mapper-2.02
20     >= sys-fs/dosfstools-4.1"
21    
22     SRCFILE="${PNAME}-${PVER}.tar.gz"
23     SRCDIR="${BUILDDIR}/${PNAME}-${PVER}"
24    
25     sminclude mtools
26    
27     # grub.confd revision
28     CONF_REV=1.4
29    
30     SRC_URI=(
31     gnu://${PNAME}/${SRCFILE}
32     mirror://${PNAME}/${SRCFILE}
33     mirror://${PNAME}/${PNAME}-2.02-confd-2.patch
34     mirror://${PNAME}/${PNAME}-2.02-cosmetic.patch
35     mirror://${PNAME}/${PNAME}-2.00-10_linux-pretty-names-from-etc-os-release.patch
36     mirror://${PNAME}/grub.confd-${CONF_REV}
37     )
38    
39     UP2DATE="updatecmd_gnu ${PNAME} gz"
40    
41     # grub doesn't like CFLAG optimation,
42     # and do you really want that at your bootloader ??
43     unset CFLAGS
44     unset CXXFLAGS
45    
46     src_prepare()
47     {
48     munpack ${SRCFILE} || die
49     cd ${SRCDIR}
50    
51     # use /etc/conf.d/grub instead of /etc/default/grub
52     mpatch ${PNAME}-2.02-confd-2.patch || die
53     # cosmetic fixes
54     mpatch ${PNAME}-2.02-cosmetic.patch || die
55     # generate pretty names from os-release if GRUB_DISTRIBUTOR is not set
56     mpatch ${PNAME}-2.00-10_linux-pretty-names-from-etc-os-release.patch
57    
58     # setup build dirs
59     install -d ${SRCDIR}/build_bios || die
60     install -d ${SRCDIR}/build_efi || die
61     }
62    
63     src_compile()
64     {
65     local myconf
66     local myarch
67    
68     # common configure options
69     # grub-mount requires fuse2
70     # grub-mkfont requires freetype2
71     myconf="--prefix=/usr
72     --host=${CHOST}
73     --build=${CHOST}
74     --mandir=/usr/share/man
75     --infodir=/usr/share/info
76     --datadir=/usr/share
77     --sysconfdir=/etc
78     --localstatedir=/var/lib
79     --libdir=/usr/$(mlibdir)
80     --disable-static
81     --enable-shared
82     --disable-efiemu
83     --disable-werror
84     --enable-device-mapper
85     --enable-grub-mkfont
86     --disable-grub-mount"
87    
88     # fix freetype build issues
89     FREETYPE="pkg-config freetype2"
90     BUILD_FREETYPE="pkg-config freetype2"
91    
92     # build bios version
93     cd ${SRCDIR}/build_bios
94     myarch="i386"
95     ../configure --with-platform=pc --target="${myarch}" ${myconf} || die
96     mmake || die
97    
98     # build efi version
99     cd ${SRCDIR}/build_efi
100     case ${ARCH} in
101     x86_64) myarch="${ARCH}" ;;
102     i*86) myarch="i386" ;;
103     esac
104     ../configure --with-platform=efi --target="${myarch}" ${myconf} || die
105     mmake || die
106     }
107    
108     src_install()
109     {
110     local myarch
111    
112     # install bios version
113     cd ${SRCDIR}/build_bios
114     mmake DESTDIR=${BINDIR} install || die
115     # remove debugging related files
116     mdelete /usr/$(mlibdir)/grub/i386-pc/\*.module || die
117     mdelete /usr/$(mlibdir)/grub/i386-pc/\*.image || die
118     mdelete /usr/$(mlibdir)/grub/i386-pc/kernel.exec || die
119     mdelete /usr/$(mlibdir)/grub/i386-pc/gdb_grub || die
120     mdelete /usr/$(mlibdir)/grub/i386-pc/gmodule.pl || die
121    
122     # install efi version
123     cd ${SRCDIR}/build_efi
124     case ${ARCH} in
125     x86_64) myarch="${ARCH}" ;;
126     i*86) myarch="i386" ;;
127     esac
128     mmake DESTDIR=${BINDIR} install || die
129     # remove debugging related files
130     mdelete /usr/$(mlibdir)/grub/${myarch}-efi/\*.module || die
131     mdelete /usr/$(mlibdir)/grub/${myarch}-efi/\*.image || die
132     mdelete /usr/$(mlibdir)/grub/${myarch}-efi/kernel.exec || die
133     mdelete /usr/$(mlibdir)/grub/${myarch}-efi/gdb_grub || die
134     mdelete /usr/$(mlibdir)/grub/${myarch}-efi/gmodule.pl || die
135    
136     # not required by pretty name patch anymore
137     # set distribution
138     #echo 'GRUB_DISTRIBUTOR="Magellan-Linux"' >> ${BINDIR}/usr/share/grub/grub-mkconfig_lib || die
139    
140     # setup a proper grub default conf
141     minstallconf grub.confd-${CONF_REV} grub || die
142    
143     # enable a splash screen by default
144     sed -i '/^GRUB_CMDLINE_LINUX_DEFAULT=/s:\"\(.*\)\":\"\1 splash\":' ${BINDIR}/etc/conf.d/grub || die
145    
146     # needed dir
147     minstalldir /boot/grub || die
148    
149     # docs
150     cd ${SRCDIR}
151     minstalldocs AUTHORS ChangeLog COPYING NEWS README THANKS TODO || die
152     }
153    
154     preinstall()
155     {
156     mount /boot &> /dev/null
157     }
158    
159     postinstall()
160     {
161     [ ! -d ${MROOT}/boot/grub ] && install -d ${MROOT}/boot/grub
162    
163     # creates some essential links
164     [ ! -e ${MROOT}/boot/boot ] && ln -sf . ${MROOT}/boot/boot
165    
166     if [[ -z ${MROOT} ]] || [[ ${MROOT} = / ]] && [[ ${MAGE_BOOTSTRAP} != true ]]
167     then
168     # create a device.map
169     if [[ ! -f /boot/grub/device.map ]]
170     then
171     if [[ -x $(type -P grub-mkdevicemap) ]]
172     then
173     grub-mkdevicemap
174     fi
175     fi
176    
177     # needed by grub-mkconfig on the first run
178     if [[ ! -f /boot/grub/video.lst ]]
179     then
180     install -m0644 /$(mlibdir)/grub/*/video.lst /boot/grub/video.lst
181     fi
182    
183     # update grub.cfg
184     LC_ALL=C grub-mkconfig -o /boot/grub/grub.cfg
185    
186     # install bootloader to disk
187     #local bootpartition="$(df -h /boot |(read; awk '{print $1; exit}'))"
188     local bootdisk
189     bootdisk="$(grub-probe --target=drive /boot | sed 's:(\(.*\),.*):(\1):')"
190    
191     # Generate core.img, but don't let it be installed in boot sector
192     grub-install --no-floppy "${bootdisk}"
193     fi
194     }