View | Details | Raw Unified
Collapse All | Expand All

(-) /usr/portage/sys-boot/grub/grub-0.97-r5.ebuild (-14 / +72 lines)
 Lines 142-147   src_install() { Link Here 
setup_boot_dir() {
setup_boot_dir() {
	local boot_dir=$1
	local boot_dir=$1
	local dir=${boot_dir}
	local dir=${boot_dir}
	local instcfg="${ROOT}"/etc/grub.install
	[[ ! -e ${dir} ]] && die "${dir} does not exist!"
	[[ ! -e ${dir} ]] && die "${dir} does not exist!"
	[[ ! -L ${dir}/boot ]] && ln -s . "${dir}/boot"
	[[ ! -L ${dir}/boot ]] && ln -s . "${dir}/boot"
 Lines 154-171   setup_boot_dir() { Link Here 
	if [[ ! -e ${dir}/grub.conf ]] && [[ -e ${dir}/menu.lst ]] ; then
	if [[ ! -e ${dir}/grub.conf ]] && [[ -e ${dir}/menu.lst ]] ; then
		mv -f "${dir}"/menu.lst "${dir}"/grub.conf
		mv -f "${dir}"/menu.lst "${dir}"/grub.conf
		ewarn
		ewarn
		ewarn "*** IMPORTANT NOTE: menu.lst has been renamed to grub.conf"
		ewarn "menu.lst has been renamed to grub.conf"
		ewarn
		ewarn
	fi
	fi
	if [[ -e ${dir}/stage2 ]] ; then
	if [[ -e ${dir}/stage2 ]] ; then
		mv "${dir}"/stage2{,.old}
		mv "${dir}"/stage2{,.old}
		ewarn "*** IMPORTANT NOTE: you must run grub and install"
		ewarn "the new version's stage1 to your MBR.  Until you do,"
		ewarn "stage1 and stage2 will still be the old version, but"
		ewarn "later stages will be the new version, which could"
		ewarn "cause problems such as an unbootable system."
		ebeep
	fi
	fi
	einfo "Copying files from /lib/grub and /usr/lib/grub to ${dir}"
	einfo "Copying files from /lib/grub and /usr/lib/grub to ${dir}"
 Lines 173-185   setup_boot_dir() { Link Here 
		[[ -f ${x} ]] && cp -p "${x}" "${dir}"/
		[[ -f ${x} ]] && cp -p "${x}" "${dir}"/
	done
	done
	if [[ -e ${dir}/grub.conf ]] ; then
	if [[ ! -e ${instcfg} ]] ; then
		egrep \
		cat > "${instcfg}" <<-EOF
			-v '^[[:space:]]*(#|$|default|fallback|initrd|password|splashimage|timeout|title)' \
			# Commands to be used to install grub.
			"${dir}"/grub.conf | \
			# These commands will be executed whenever grub is updated.
			# You can also run them manually using emerge --config grub.
			# See "info grub" or http://www.gnu.org/software/grub/
			# Take the first partition on the first drive as the boot partition
			#root (hd0,0) 
			# Install grub into the MBR of the first hard disk drive:
			#setup (hd0)
			# Install grub into the first partition of the first hard disk:
			#setup (hd0,0)
		EOF
		if [[ -e ${dir}/grub.conf ]] && \
				egrep '^(setup|install)' "${dir}"/grub.conf >/dev/null; then
			echo >> ${instcfg}
			echo "# Entries automatically copied from your grub.conf:" >> ${instcfg}
			# from each menu entry containing either an install
			# or a setup command, take the title as a comment,
			# and include all commands between title and
			# install/setup.
			# No perl to keep dependencies down, sorry.
			sed -n '/^root\|^map/{x;/^# title/!{x;p;x};x};
				H
				/^title/{s/^/# /;h;d}
				/^install\|^setup/{x;p;s/.*/# continued/;x}' \
				"${dir}"/grub.conf >> "${instcfg}"
			elog
			elog "Commands for automatic installation of grub have been extracted from"
			elog "your grub.conf and saved in /etc/grub.install."
			elog "Please review that file."
			elog
		fi
	fi
	if egrep '^(setup|install)' "${instcfg}" >/dev/null; then
		einfo "Reinstalling grub with commands from ${instcfg}"
		egrep '^[^#]' "${instcfg}" | \
		/sbin/grub --batch \
		/sbin/grub --batch \
			--device-map="${dir}"/device.map \
			--device-map="${dir}"/device.map \
			> /dev/null
			>"${T}"/grubinstall.out 2>&1
		local grub_res=$?
		if [[ $grub_res != 0 ]] || egrep 'Error' "${T}"/grubinstall.out >/dev/null; then
			eerror
			eerror "Grub failed to install automatically!"
			eerror "Please instal it manually"
			eerror
			while read grub_res; do
				elog "${grub_res}"
			done < "${T}"/grubinstall.out
		else
			cat "${T}"/grubinstall.out
		fi
		echo
	else
		ewarn "There are no commands in ${instcfg} to install grub automatically."
		ewarn "Therefore you need to either install grub manually, or edit this"
		ewarn "file and run emerge --config =${PF} afterwards."
		if [[ -e ${dir}/stage2.old ]] ; then
			ewarn ""
			ewarn "*** IMPORTANT NOTE: you must install the new version"
			ewarn "to your system.  Until you do, conflicting versions"
			ewarn "might cause problems such as an unbootable system."
			ebeep
		fi
	fi
	fi
	# the grub default commands silently piss themselves if
	# the grub default commands silently piss themselves if
 Lines 198-204   pkg_postinst() { Link Here 
pkg_config() {
pkg_config() {
	local dir
	local dir
	einfo "Enter the directory where you want to setup grub:"
	read -p "Enter the directory where you want to setup grub [/boot]: " dir
	read dir
	[[ -z $dir ]] && dir=/boot
	setup_boot_dir "${dir}"
	setup_boot_dir "${dir}"
}
}