UBuntu 编译 Openwrt x86固件

By | 2018-11-27

官方教程: http://wiki.openwrt.org/zh-cn/doc/howto/buildroot.exigence
1)更新源和安装编译支持软件包

sudo apt-get update
sudo apt-get install git-core build-essential libssl-dev libncurses5-dev unzip
sudo apt-get install subversion mercurial

2)通过源代码进行编译,下载过程非常慢
git clone git://git.openwrt.org/openwrt.git openwrt
cd openwrt
./scripts/feeds update -a
./scripts/feeds install -a
make defconfig
make prereq
make menuconfig

1)首先安装ubuntu ,不管版本,不管是server还是desktop版本,反正都是用命令行编译

2) 安装编译环境支持软件包
apt-get -y install curl wget tree grep gcj texinfo sharutils subversion ncurses-term libtool autoconf automake gcc-multilib bison screen gcc g++ binutils patch bzip2 flex make gettext unzip libc6 git-core build-essential libncurses5-dev zlib1g-dev gawk quilt asciidoc libz-dev

64位系统编译需要以下软件包:
apt-get install build-essential subversion libncurses5-dev zlib1g-dev gawk gcc-multilib flex git-core gettext libssl-dev

3)下载Openwrt x86源码,可能用git方式
git clone git://git.openwrt.org/openwrt.git

———————————————————-

以下是ubuntu 16.04 LTS 编译环境:
apt-get update
apt-get upgrade
apt-get install subversion build-essential git-core libncurses5-dev zlib1g-dev gawk flex quilt libssl-dev xsltproc libxml-parser-perl unzip
以编译LEDE为例:
git clone http://github.com/lede-project/source lede
cd lede
./scripts/feeds update -a
./scripts/feeds install -a
make menuconfig
TargetSystem (x86) —> (*) x86
Subtarget选中x86_64
 
配目标文件系统为 EXT4
Target Images —>

  • ext4
    取消选中ext4之外的其他镜像格式。

    Seconds to wait before booting the default entry
    改为0,每次启动时等待0秒。

    用web界面要加 luci,
    LuCI–>Collection选中luci。这个是通过网页访问软路由所必须的组建,建议选中;否则就只能使用虚拟化串口或ssh访问软路由了。

    LuCI->Applications中选中
    luci-app-ddns
    luci-app-qos
    luci-app-statistics
    luci-app-upnp
    luci-app-vnstat

    这是几个常见应用,根据个人喜好随便选。

    Base system
    取消选中dnsmasq
    选中dnsmasq-full
    因为dnsmasq-full支持ipset功能,对于基于域名的xx很有用。

    Network->File Transfer中选中
    curl
    wget
    顺手选中两个下载工具。

    Network->IP Addresses and Names中选中
    bind-dig
    ddns-scripts_No-IP_com。(用来支持no-ip.com的ddns服务)
    一个是测试工具;
    另一个是某个ddns支持,还有其他ddns支持,也可以酌情选中。

    Network->Routing and Rediction中选中
    ip-full
    这个很关键。

    Network中选中
    iperf3
    ipset
    一个是测试工具;
    另一个是ipset,用于支持基于域名的xx。

    Network->Web Servers/Proxies选中那些SS,如果您需要使用SS的话。

    Utilities->Editors中选中
    nano
    也可以选中vim,无所谓,反正都是文本编辑器,选个顺手的就好。

    Utilities->Shells中选中
    bash
    如果您喜欢自己写脚本,可以选中bash,比默认的ash强大一些。

    点击Save,保存为.config。
    一路Exit退出。

    最后:

  • make defconfig
  • make prereq
     make menuconfig
  • 这是交叉编译,首次编译时会自动下载很多编译工具的源代码,先编译得到编译工具;
    然后才是软路由和软件包的编译过程,期间也要下载所有的源代码。
    只要您的网速足够快,XX足够给力足够稳,一般40分钟左右可以完成编译。
    定量的说,网速也不用太快,只需要通过VXN测速,下行速率为100Mbps就够了,40分钟应该可以搞定。

    之后再次编译时,除非手动指定,否则很多工具不会重新编译,源代码也不会重新下载,编译速度会大大加快。

發佈留言