使用Ubuntu1404快速搭建Grub4Dos编译环境

分类:笔记 日期:2020-04-19 作者:caocaofff 浏览:1225

想对Grub4Dos进行修改后重新编译,于是记录下从无到有的搭建流程。

Grub4Dos对gcc编译器版本有要求,必须是4.6,所以我使用了Ubuntu14.04LTS

http://releases.ubuntu.com/trusty/ubuntu-14.04.6-server-amd64.iso

自行安装操作系统后,在任意目录新建执行脚本并运行:

#!/bin/bash
cp /etc/apt/sources.list /etc/apt/sources.list.bak
echo "deb http://mirrors.aliyun.com/ubuntu/ trusty main restricted universe multiverse" > /etc/apt/sources.list
echo "deb http://mirrors.aliyun.com/ubuntu/ trusty-security main restricted universe multiverse" >> /etc/apt/sources.list
echo "deb http://mirrors.aliyun.com/ubuntu/ trusty-updates main restricted universe multiverse" >> /etc/apt/sources.list
echo "deb http://mirrors.aliyun.com/ubuntu/ trusty-proposed main restricted universe multiverse" >> /etc/apt/sources.list
echo "deb http://mirrors.aliyun.com/ubuntu/ trusty-backports main restricted universe multiverse" >> /etc/apt/sources.list
echo "deb-src http://mirrors.aliyun.com/ubuntu/ trusty main restricted universe multiverse" >> /etc/apt/sources.list
echo "deb-src http://mirrors.aliyun.com/ubuntu/ trusty-security main restricted universe multiverse" >> /etc/apt/sources.list
echo "deb-src http://mirrors.aliyun.com/ubuntu/ trusty-updates main restricted universe multiverse" >> /etc/apt/sources.list
echo "deb-src http://mirrors.aliyun.com/ubuntu/ trusty-proposed main restricted universe multiverse" >> /etc/apt/sources.list
echo "deb-src http://mirrors.aliyun.com/ubuntu/ trusty-backports main restricted universe multiverse" >> /etc/apt/sources.list
apt-get update
mkdir /data
cd /data/
apt-get install unzip vim -y
apt-get install autoconf build-essential zlibc zlib1g-dev -y
add-apt-repository ppa:ubuntu-toolchain-r/test
apt-get install gcc-4.6 g++-4.6 -y
update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.6 20
update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.6 20
update-alternatives --config gcc
update-alternatives --config g++
apt-get install gcc-4.6-multilib -y
apt-get install nasm upx-ucl -y

这个时候,编译环境已经安装好了,可以去官网下载源码进行编译了。这里假设你已经把zip压缩包丢到了/data目录:

cd /data/
unzip grub4dos-5616d7fdec16473e4bb3ef096ee3d0d803926573.zip
cd grub4dos-5616d7fdec16473e4bb3ef096ee3d0d803926573/
./configure
make
#make执行完后,make install其实不需要执行了,因为你要的grldr已经编译在了stage2/grldr
#make install

#如果执行了make install,你要的编译好的文件在/usr/local/lib/grub/x86_64-unknown/

提示:

预设菜单文件:preset_menu.lst

CC版权: 本篇博文采用《CC 协议》,转载必须注明作者和本文链接

评论 (暂无评论)

发表评论

昵称:  
邮箱:  
网址: