Lines 142-147
src_install() {
Link Here
|
142 |
setup_boot_dir() { |
142 |
setup_boot_dir() { |
143 |
local boot_dir=$1 |
143 |
local boot_dir=$1 |
144 |
local dir=${boot_dir} |
144 |
local dir=${boot_dir} |
|
|
145 |
local instcfg="${ROOT}"/etc/grub.install |
145 |
|
146 |
|
146 |
[[ ! -e ${dir} ]] && die "${dir} does not exist!" |
147 |
[[ ! -e ${dir} ]] && die "${dir} does not exist!" |
147 |
[[ ! -L ${dir}/boot ]] && ln -s . "${dir}/boot" |
148 |
[[ ! -L ${dir}/boot ]] && ln -s . "${dir}/boot" |
Lines 154-171
setup_boot_dir() {
Link Here
|
154 |
if [[ ! -e ${dir}/grub.conf ]] && [[ -e ${dir}/menu.lst ]] ; then |
155 |
if [[ ! -e ${dir}/grub.conf ]] && [[ -e ${dir}/menu.lst ]] ; then |
155 |
mv -f "${dir}"/menu.lst "${dir}"/grub.conf |
156 |
mv -f "${dir}"/menu.lst "${dir}"/grub.conf |
156 |
ewarn |
157 |
ewarn |
157 |
ewarn "*** IMPORTANT NOTE: menu.lst has been renamed to grub.conf" |
158 |
ewarn "menu.lst has been renamed to grub.conf" |
158 |
ewarn |
159 |
ewarn |
159 |
fi |
160 |
fi |
160 |
|
161 |
|
161 |
if [[ -e ${dir}/stage2 ]] ; then |
162 |
if [[ -e ${dir}/stage2 ]] ; then |
162 |
mv "${dir}"/stage2{,.old} |
163 |
mv "${dir}"/stage2{,.old} |
163 |
ewarn "*** IMPORTANT NOTE: you must run grub and install" |
|
|
164 |
ewarn "the new version's stage1 to your MBR. Until you do," |
165 |
ewarn "stage1 and stage2 will still be the old version, but" |
166 |
ewarn "later stages will be the new version, which could" |
167 |
ewarn "cause problems such as an unbootable system." |
168 |
ebeep |
169 |
fi |
164 |
fi |
170 |
|
165 |
|
171 |
einfo "Copying files from /lib/grub and /usr/lib/grub to ${dir}" |
166 |
einfo "Copying files from /lib/grub and /usr/lib/grub to ${dir}" |
Lines 173-185
setup_boot_dir() {
Link Here
|
173 |
[[ -f ${x} ]] && cp -p "${x}" "${dir}"/ |
168 |
[[ -f ${x} ]] && cp -p "${x}" "${dir}"/ |
174 |
done |
169 |
done |
175 |
|
170 |
|
176 |
if [[ -e ${dir}/grub.conf ]] ; then |
171 |
if [[ ! -e ${instcfg} ]] ; then |
177 |
egrep \ |
172 |
cat > "${instcfg}" <<-EOF |
178 |
-v '^[[:space:]]*(#|$|default|fallback|initrd|password|splashimage|timeout|title)' \ |
173 |
# Commands to be used to install grub. |
179 |
"${dir}"/grub.conf | \ |
174 |
# These commands will be executed whenever grub is updated. |
|
|
175 |
# You can also run them manually using emerge --config grub. |
176 |
# See "info grub" or http://www.gnu.org/software/grub/ |
177 |
|
178 |
# Take the first partition on the first drive as the boot partition |
179 |
#root (hd0,0) |
180 |
|
181 |
# Install grub into the MBR of the first hard disk drive: |
182 |
#setup (hd0) |
183 |
|
184 |
# Install grub into the first partition of the first hard disk: |
185 |
#setup (hd0,0) |
186 |
EOF |
187 |
|
188 |
if [[ -e ${dir}/grub.conf ]] && \ |
189 |
egrep '^(setup|install)' "${dir}"/grub.conf >/dev/null; then |
190 |
echo >> ${instcfg} |
191 |
echo "# Entries automatically copied from your grub.conf:" >> ${instcfg} |
192 |
|
193 |
# from each menu entry containing either an install |
194 |
# or a setup command, take the title as a comment, |
195 |
# and include all commands between title and |
196 |
# install/setup. |
197 |
# No perl to keep dependencies down, sorry. |
198 |
sed -n '/^root\|^map/{x;/^# title/!{x;p;x};x}; |
199 |
H |
200 |
/^title/{s/^/# /;h;d} |
201 |
/^install\|^setup/{x;p;s/.*/# continued/;x}' \ |
202 |
"${dir}"/grub.conf >> "${instcfg}" |
203 |
elog |
204 |
elog "Commands for automatic installation of grub have been extracted from" |
205 |
elog "your grub.conf and saved in /etc/grub.install." |
206 |
elog "Please review that file." |
207 |
elog |
208 |
fi |
209 |
fi |
210 |
|
211 |
if egrep '^(setup|install)' "${instcfg}" >/dev/null; then |
212 |
einfo "Reinstalling grub with commands from ${instcfg}" |
213 |
egrep '^[^#]' "${instcfg}" | \ |
180 |
/sbin/grub --batch \ |
214 |
/sbin/grub --batch \ |
181 |
--device-map="${dir}"/device.map \ |
215 |
--device-map="${dir}"/device.map \ |
182 |
> /dev/null |
216 |
>"${T}"/grubinstall.out 2>&1 |
|
|
217 |
local grub_res=$? |
218 |
if [[ $grub_res != 0 ]] || egrep 'Error' "${T}"/grubinstall.out >/dev/null; then |
219 |
eerror |
220 |
eerror "Grub failed to install automatically!" |
221 |
eerror "Please instal it manually" |
222 |
eerror |
223 |
while read grub_res; do |
224 |
elog "${grub_res}" |
225 |
done < "${T}"/grubinstall.out |
226 |
else |
227 |
cat "${T}"/grubinstall.out |
228 |
fi |
229 |
echo |
230 |
else |
231 |
ewarn "There are no commands in ${instcfg} to install grub automatically." |
232 |
ewarn "Therefore you need to either install grub manually, or edit this" |
233 |
ewarn "file and run emerge --config =${PF} afterwards." |
234 |
if [[ -e ${dir}/stage2.old ]] ; then |
235 |
ewarn "" |
236 |
ewarn "*** IMPORTANT NOTE: you must install the new version" |
237 |
ewarn "to your system. Until you do, conflicting versions" |
238 |
ewarn "might cause problems such as an unbootable system." |
239 |
ebeep |
240 |
fi |
183 |
fi |
241 |
fi |
184 |
|
242 |
|
185 |
# the grub default commands silently piss themselves if |
243 |
# the grub default commands silently piss themselves if |
Lines 198-204
pkg_postinst() {
Link Here
|
198 |
|
256 |
|
199 |
pkg_config() { |
257 |
pkg_config() { |
200 |
local dir |
258 |
local dir |
201 |
einfo "Enter the directory where you want to setup grub:" |
259 |
read -p "Enter the directory where you want to setup grub [/boot]: " dir |
202 |
read dir |
260 |
[[ -z $dir ]] && dir=/boot |
203 |
setup_boot_dir "${dir}" |
261 |
setup_boot_dir "${dir}" |
204 |
} |
262 |
} |