⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 compile

📁 grub for dos ,people can use it in dos for calling linux
💻
字号:
#!/bin/sh## Script for patch and build. See notes below.## Usage:#		sh compile# or#		./compileif [ "$2" != "" ] || [ "$1" != "" -a "$1" != patchonly -a "$1" != untaronly -a "$1" != makedist ]; then	echo "Usage:"	echo "        [ chinese=1 ] [ scdrom=1 ] [ bioscdrom=1 ] $0"	echo "        [ chinese=1 ] [ scdrom=1 ] [ bioscdrom=1 ] $0  untaronly"	echo "        [ chinese=1 ] [ scdrom=1 ] [ bioscdrom=1 ] $0  patchonly"	echo "        [ chinese=1 ] [ scdrom=1 ] [ bioscdrom=1 ] $0  makedist"	exit 1fiGRUB_ver=grub-0.97	while read w1 w2 w3 w4; do		[ "$w1" = "Current" ] && [ "$w2" = "Version:" ] && break	done < README.txt	if [ "$w1" != "Current" -o "$w2" != "Version:" ]; then		echo "Error: README.txt has no \"Current Version:\" line."		exit 1	fi	# strip the trailing CR	w3=${w3%%[^0-9a-zA-Z_.+-]*}GRUB4DOS_ver=$w3	if [ "$chinese" = 1 ]; then	COMPILE_WITH_chinese=1else	COMPILE_WITH_chinese=0fiif [ "$scdrom" = 1 ]; then	COMPILE_WITH_scdrom=1else	COMPILE_WITH_scdrom=0fiif [ "$bioscdrom" = 1 ]; then	COMPILE_WITH_bioscdrom=1else	COMPILE_WITH_bioscdrom=0fifunction untar_gnu_grub(){	if [ -f ${GRUB_ver}.tar.gz ]; then		tar -xzf ${GRUB_ver}.tar.gz || exit $?	elif [ -f ../${GRUB_ver}.tar.gz ]; then		tar -xzf ../${GRUB_ver}.tar.gz || exit $?	elif [ -f ~/${GRUB_ver}.tar.gz ]; then		tar -xzf ~/${GRUB_ver}.tar.gz || exit $?	else		echo file not found: ${GRUB_ver}.tar.gz		echo You may download it from GNU GRUB site and place it in your home dir.		exit 1	fi	echo "#define GRUB4DOS_VERSION \"$GRUB4DOS_ver ($(date --utc --iso-8601))\"" > ${GRUB_ver}/stage2/grub4dos_version.h}function apply_patches(){	echo	echo Applying patch ${GRUB_ver}-patch1-startups	echo	patch -p1 < ../${GRUB_ver}-patch1-startups  || exit $?	echo	echo Applying patch ${GRUB_ver}-patch2-findroot	echo	patch -p1 < ../${GRUB_ver}-patch2-findroot  || exit $?	echo	echo Applying patch ${GRUB_ver}-patch3-ntfs	echo	patch -p1 < ../${GRUB_ver}-patch3-ntfs      || exit $?	echo	echo Applying patch ${GRUB_ver}-patch4-emulation	echo	patch -p1 < ../${GRUB_ver}-patch4-emulation || exit $?	echo	echo Applying patch ${GRUB_ver}-patch5-splash	echo	patch -p1 < ../${GRUB_ver}-patch5-splash    || exit $?	if [ "$COMPILE_WITH_chinese" = 1 -o "$COMPILE_WITH_scdrom" = 1 -o "$COMPILE_WITH_bioscdrom" = 1 ]; then		echo		echo Applying patch ${GRUB_ver}-patch6-chinese		echo		patch -p1 < ../${GRUB_ver}-patch6-chinese    || exit $?	fi		if [ "$COMPILE_WITH_scdrom" = 1 -o "$COMPILE_WITH_bioscdrom" = 1 ]; then		echo		echo Applying patch ${GRUB_ver}-patch7-scdrom		echo		patch -p1 < ../${GRUB_ver}-patch7-scdrom    || exit $?	fi	if [ "$COMPILE_WITH_bioscdrom" = 1 ]; then 		echo		echo Applying patch ${GRUB_ver}-patch8-bioscdrom		echo		patch -p1 < ../${GRUB_ver}-patch8-bioscdrom || exit $?	fi}if [ "$1" = "" ] && [ -e ${GRUB_ver} ]; then	set makedistfiif [ "$1" != makedist ]; then[ -f ${GRUB_ver}-patch1-startups  ] || exit $?[ -f ${GRUB_ver}-patch2-findroot  ] || exit $?[ -f ${GRUB_ver}-patch3-ntfs      ] || exit $?[ -f ${GRUB_ver}-patch4-emulation ] || exit $?[ -f ${GRUB_ver}-patch5-splash    ] || exit $?[ -f ${GRUB_ver}-patch6-chinese   ] || exit $?[ -f ${GRUB_ver}-patch7-scdrom    ] || exit $?[ -f ${GRUB_ver}-patch8-bioscdrom ] || exit $?if [ -e ${GRUB_ver} ]; then	echo $GRUB_ver already exists. Please remove it first. exit...	exit 1fiuntar_gnu_grub[ "$1" = untaronly ] && exitcd ${GRUB_ver} || exit $?apply_patches[ "$1" = patchonly ] && exitechoecho Running aclocal ...echoaclocal  || exit $?echoecho Running autoconf ...echoautoconf || exit $?echoecho Running automake ...echoautomake || exit $?echoecho Running ./configure ...echo## patch2-findroot now includes a preset menu (by Chris Semler. Thanks!)# FINDROOT has merged into FIND. Example:##	find --set-root /boot/grub/menu.lst## This command will set the device which contains /boot/grub/menu.lst# as the new root device.#./configure --enable-preset-menu=preset_menu.lst || ./configure || exit $?echoecho Running make ...echomake || exit $?echoecho make succeeded.echo# echo# echo Now copying stage1, stage1.5 and stage2 files to boot/grub ...# echo## if ! cmp stage1/stage1 ../boot/grub/stage1 >&- 2>&- ; then#	cp -f stage1/stage1 ../boot/grub/stage1# fi## cp -f stage2/*1_5 stage2/stage2 ../boot/grub/echoecho Copying grub.exe, grldr, grldr.mbr, bootlace.com hmload.com to the top dir ...echocp -f stage2/grub.exe stage2/grldr stage2/grldr.mbr stage2/bootlace.com stage2/hmload.com ../echoecho Make a static grub utility for Linux ...echoif cd grub; then	if gcc --static -O2 -g -o grub main.o asmstub.o ../stage2/libgrub.a  ../lib/libcommon.a -lncurses ; then		echo		echo Successful compilation of static grub.		echo		echo		echo Now try to strip grub ...		echo		if strip grub; then			echo			echo grub stripped successfully			echo			echo			echo Now copy grub to the top dir ...			echo			if cp -f grub ../../ ; then				echo				echo Grub copied OK.				echo			else				echo Failure when copying grub.			fi		else			echo Failed in stripping grub.		fi	else		echo "Failure: error occurred while compiling static grub."	fi		cd ..	else	echo "Failure: The subdir \"grub\" does not exist."fiechoecho "Now apply the \"chinese\" patch..."echoif [ "$COMPILE_WITH_scdrom" = 1 -o "$COMPILE_WITH_bioscdrom" = 1 ]; then	echo	echo "The chinese and scdrom patches already applied."	echo	#	if ! cmp stage1/stage1 ../chinese/boot/grub/stage1 >&- 2>&- ; then#		cp -f stage1/stage1 ../chinese/boot/grub/stage1#	fi#	#	cp -f stage2/*1_5 stage2/stage2 ../chinese/boot/grub/	cp -f stage2/grub.exe stage2/grldr ../chinese/	echo	echo All done.	echo		exitficd ..rm -rf ${GRUB_ver}_tmpcp -a ${GRUB_ver} ${GRUB_ver}_tmpcd ${GRUB_ver}_tmpif [ "$COMPILE_WITH_chinese" != 1 ]; then	if ! patch -p1 < ../${GRUB_ver}-patch6-chinese ; then		echo "failed patch ${GRUB_ver}-patch6-chinese"		exit 1	fifi# if ! patch -p1 < ../${GRUB_ver}-patch7-scdrom ; then#	echo "failed patch ${GRUB_ver}-patch7-scdrom"#	exit 1# fimake || exit $?# if ! cmp stage1/stage1 ../chinese/boot/grub/stage1 >&- 2>&- ; then#	cp -f stage1/stage1 ../chinese/boot/grub/stage1# fi## cp -f stage2/*1_5 stage2/stage2 ../chinese/boot/grub/cp -f stage2/grub.exe stage2/grldr ../chinese/echoecho All done.echoexitelse	# makedist	if [ ! -d ${GRUB_ver} ]; then		echo "The dir ${GRUB_ver} does not exist. Cannot compile with makedist. exit"		exit 1	fi	rm -rf new1.diff new2.diff	rm -rf ${GRUB_ver}.old	rm -rf *.old *~	mv ${GRUB_ver} ${GRUB_ver}.old || exit $?	untar_gnu_grub	cd ${GRUB_ver} || exit $?	apply_patches	cd ..	cp -a ${GRUB_ver} ${GRUB_ver}.new1	cp -a ${GRUB_ver} ${GRUB_ver}.new2	new1=0	new2=0	for f in dosstart.S grldrstart.S start_eltorito.S start.S mbrstart.S bootlacestart.S hmloadstart.S edd.S video.S bootlace.inc a20.inc linux/autoconf.h linux/compile.h linux/config.h linux/edd.h linux/linkage.h linux/version.h asm/boot.h asm/e820.h asm/linkage.h asm/page.h asm/segment.h asm/setup.h; do		if ! cmp ${GRUB_ver}.old/stage2/$f ${GRUB_ver}.new1/stage2/$f; then			new1=1			cp -af ${GRUB_ver}.old/stage2/$f ${GRUB_ver}.new1/stage2/$f || exit $?		fi	done		for f in asm.S apm.S nbloader.S pxeloader.S setjmp.S; do		if ! cmp ${GRUB_ver}.old/stage2/$f ${GRUB_ver}.new2/stage2/$f; then			new2=1			cp -af ${GRUB_ver}.old/stage2/$f ${GRUB_ver}.new2/stage2/$f || exit $?		fi	done	cd ${GRUB_ver}.old/stage2/ || exit $?		for f in *.c *.h; do		[ "$f" == stage2_size.h ] && continue		[ "$f" == grub4dos_version.h ] && continue		cmp $f ../../${GRUB_ver}.new2/stage2/$f && continue	#if [ "$f" != stage2_size.h ] && [ "$f" != grub4dos_version.h ] && ! cmp $f ../../${GRUB_ver}.new2/stage2/$f; then		new2=1		cp -af $f ../../${GRUB_ver}.new2/stage2/$f || exit $?	#fi	done	cd ../../	cd ${GRUB_ver}.old/grub/ || exit $?		for f in *.c; do		if ! cmp $f ../../${GRUB_ver}.new2/grub/$f; then			new2=1			cp -af $f ../../${GRUB_ver}.new2/grub/$f || exit $?		fi	done	cd ../../	if [ "$new1" = 0 ] && [ "$new2" = 0 ]; then		rm -rf ${GRUB_ver} ${GRUB_ver}.new1 ${GRUB_ver}.new2		mv ${GRUB_ver}.old ${GRUB_ver}		echo no changes, exit normally		exit	fi	[ "$new1" != 0 ] && diff -Naur ${GRUB_ver} ${GRUB_ver}.new1 > new1.diff	[ "$new2" != 0 ] && diff -Naur ${GRUB_ver} ${GRUB_ver}.new2 > new2.diff		rm -rf ${GRUB_ver} ${GRUB_ver}.new1 ${GRUB_ver}.new2		untar_gnu_grub		s=${GRUB_ver}	for f in 1-startups 2-findroot 3-ntfs 4-emulation 5-splash 6-chinese 7-scdrom 8-bioscdrom ; do		rm -rf ${GRUB_ver}_${f#*-}		cp -a $s ${GRUB_ver}_${f#*-} || exit $?		cd ${GRUB_ver}_${f#*-}		echo		echo "Applying ${GRUB_ver}-patch$f :"		echo		patch -p1 < ../${GRUB_ver}-patch$f		if [ "$f" = "1-startups"  ]; then			[ -f ../new1.diff ] && patch -p1 < ../new1.diff		elif [ "$f" = "4-emulation"  ]; then			[ -f ../new2.diff ] && patch -p1 < ../new2.diff		fi		if ls */*.rej 2>&- ; then			echo			echo "The patch is rejected: " */*.rej			echo			exit 1		fi		rm -f */*.orig		cd ..				s=${GRUB_ver}_${f#*-}	done		rm -rf new1.diff new2.diff		s=${GRUB_ver}	for f in 1-startups 2-findroot 3-ntfs 4-emulation 5-splash 6-chinese 7-scdrom 8-bioscdrom ; do		mv -f ${GRUB_ver}-patch$f ${GRUB_ver}-patch$f.old || exit		diff -Naur $s ${GRUB_ver}_${f#*-} > ${GRUB_ver}-patch$f		rm -rf $s		s=${GRUB_ver}_${f#*-}	done	rm -rf $s		# Now ready to compile with the updated new patches		if ! sh compile; then		echo "Error occurred while compile."		exit 1	fi	rm -rf .old .grub_for_dos-$w3 old grub_for_dos-$w3* || exit 1	rm -rf new1.diff new2.diff	mkdir .old 2>&-	mv ${GRUB_ver}*/ .old/ || exit 1	mv -f tt* .old/ 2>&-	mv -f ${GRUB_ver}.tar.gz .old/ 2>&-	mv -f ${GRUB_ver}-patch*.old .old || exit 1	mkdir .grub_for_dos-$w3/	cp -a * .grub_for_dos-$w3/	mv -f .grub_for_dos-$w3 grub_for_dos-$w3	mv -f .old old	tar -czf grub_for_dos-$w3.tar.gz grub_for_dos-$w3	cp -f grub_for_dos-$w3.tar.gz ~/	zip -q -r grub_for_dos-$w3.zip grub_for_dos-$w3 2>&-	cp -f grub_for_dos-$w3.zip ~/ 2>&-	mv old/${GRUB_ver}*/ .	mv old/${GRUB_ver}.tar.gz . 2>&-	cp -f grub.exe grldr grldr.mbr bootlace.com ~/	fiexitpatch1 is for booting GRUB via DOS/NT/LILO/GRUB/KEXEC.patch2 is optional. It adds an option '--set-root' for FIND after patch1.patch3 is optional. It adds NTFS support after patch2.patch4 is optional. It adds disk emulation after patch3.patch5 is optional. It adds splash image support after patch4.patch6 is optional. It adds Chinese support after patch5.patch7 is experimental. It adds atapi cdrom support after patch6.patch8 is initiative. It adds bios cdrom routine support after patch7.This assumes autoconf-2.59(or later) and automake-1.9.4(or later) are installed on the system.Also gcc-3.4.3 or later must be installed on the system.Note: someone reports gcc-4.0.0 cannot compile grub4dos. Use 3.4.3 please.Note: gcc-4 is now ok by VirusCamp. Thanks!For more information on disk-emulation and DOS/NT/LILO/GRUB/KEXEC boot-method, go to GRUB for DOS pages athttp://newdos.yginfo.net/grubdos.htmhttp://grub4dos.sourceforge.net/http://sarovar.org/projects/grub4dos/http://grub4dos.jot.com/http://grub4dos.freespaces.com/

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -