openwrtx86安装docker_openwrt环境的搭建(以docker ubuntu18为例) - Go语言中文社区

openwrtx86安装docker_openwrt环境的搭建(以docker ubuntu18为例)


OpenWrt 可以被描述为一个嵌入式的 Linux 发行版,是路由器的固件,拥有强大的网络组件和扩展性,常常被用于工控设备、电话、小型机器人、智能家居、路由器以及VOIP设备中。 同时,它还提供了100多个已编译好的软件,而且数量还在不断增加,而OpenWrt SDK 更简化了开发软件的工序。官网

我这里使用的docker搭建开发环境,在普通ubuntu18里操作是一样的。docker的操作在这里

1、首先下载ubuntu18.04的镜像,换源,装基本编译环境

注意,docker下载的ubuntu镜像没有vi编辑器,需要用echo换源,这里以阿里云为例:

输入以下代码到命令行中换源

echo -e "deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse n

deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse n

deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse n

deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse n

deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse n

deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse n

deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse n

deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse n

deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse n

deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiversen" > /etc/apt/sources.list

我这里增加了一个lx的用户,一般用普通用户编译openwrt,

首先passwd root设置root 密码,然后安装apt install sudo 来安装sudo命令。之后用adduser lx 增加lx用户,passwd root 设置root 密码,我这里用户密码和root密码均为lx。

编译完成后生成镜像位置/home/lx/openwrt/bin/targets/ramips/mt76x8

我的docker镜像已经编译放到我的仓库中,

可以使用docker

首先安装开发的依赖包

apt-get install g++ libncurses5-dev libssl-dev zlib1g-dev bison flex unzip autoconf gawk make gettext gcc binutils patch bzip2 libz-dev python2.7 wget git subversion

安装完成后安装对应的openwrt 可以选择最新的主线,详情参考官方wiki

#最新的git clone git://github.com/openwrt/openwrt.git

#下载1806分支的代码

$git clone-bopenwrt-18.06https://github.com/openwrt/openwrt.gitopenwrt1806

$#下载19.07分支的代码

$git clone-bopenwrt-19.07https://github.com/openwrt/openwrt.gitopenwrt1907

我这里下载最新主干

git clone git://github.com/openwrt/openwrt.git

下载完成后

openwrt源码目录结构

tools和toolchain目录:包含了一些通用命令, 用来生成固件, 编译器, 和C库.

build dir/host目录:是一个临时目录, 用来储存不依赖于目标平台的工具.

build dir/toolchain-目录:用来储存依赖于指定平台的编译链. 只是编译文件存放目录无需修改.

build dir/target-目录:用来储存依赖于指定平台的软件包的编译文件, 其中包括linux内核, u-boot, packages, 只是编译文件存放目录无需修改.

staging_dir目录:是编译目标的最终安装位置, 其中包括rootfs, package, toolchain.

package目录:软件包的下载编译规则, 在OpenWrt固件中, 几乎所有东西都是.ipk, 这样就可以很方便的安装和卸载.

target目录:目标系统指嵌入式设备, 针对不同的平台有不同的特性, 针对这些特性, “target/linux”目录下按照平台进行目录划分, 里面包括了针对标准内核的补丁, 特殊配置等.

bin目录:编译完OpenWrt的二进制文件生成目录, 其中包括sdk, uImage, u-boot, dts, rootfs构建一个嵌入式系统完整的二进制文件.

config目录:存放着整个系统的的配置文件.

docs目录:里面不断包含了整个宿主机的文件源码的介绍, 里面还有Makefile为目标系统生成docs.

include目录:里面包括了整个系统的编译需要的头文件, 但是是以Make进行连接的.

feeds目录:扩展软件包索引目录.

scripts目录:组织编译整个OpenWrt的规则.

tmp目录:编译文件夹, 一般情况为空.

dl目录:所有软件的下载目录, 包括u-boot, kernel.

logs目录:如果编译出错, 可以在这里找到编译出错的log

执行feeds更新

./scripts/feeds update -a

./scripts/feeds install –a

过程中会报错,安装apt install rsync python3  ethtool解决

OpenWRT的feeds包括:

packages – 提供众多库, 工具等基本功能. 也是其他feed所依赖的软件源, 因此在安装其他feed前一定要先安装packages!

luci – OpenWrt默认的GUI(WEB管理界面).

xwrt – 另一种可替换LuCI的GUI

qpe – DreamBox维护的基于Qt的图形界面, 包含Qt2, Qt4, Qtopia, OPIE, SMPlayer等众多图形界面.

device – DreamBox维护与硬件密切相关的软件, 如uboot, qemu等.

dreambox_packages – DreamBox维护的国内常用网络工具, 如oh3c, njit8021xclient等.

desktop – OpenWrt用于桌面的一些软件包.

xfce – 基于Xorg的著名轻量级桌面环境. Xfce建基在GTK+2.x之上, 它使用Xfwm作为窗口管理器.

efl – 针对enlightenment.

phone -针对fso, paroli.

安装完成后,使用以下命令生成配置文件

make defconfig

然后make menuconfig 配置

这里我有一块mt7688的板子,所以这里我Target system 选择(MediaTek Ralink MIPS)联发科 mips架构  ,subtarget选择 MT76X8,如图所示

然后make V=s  -j4 进行编译。

编译完成后固件会放bin文件夹下。具体位置

/home/lx/openwrt/bin/targets/ramips/mt76x8

编译完成,做镜像。

docker commit -a:"lx" -m:"ubuntu18.04 add openwrt" 0c1 l308229423:openwrt

使用docker commit 制作,说明参考之前docker教程。

可以看到镜像还是比较大的,我已经将他推送到中央仓库,

可以直接使用docker pull l308229423/openwrt:openwrt来下载使用我的镜像,请耐心等待,但是也比编译配置openwrt要快了。

root密码,用户密码均为lx,有一个lx的用户。欢迎下载使用。

版权声明:本文来源CSDN,感谢博主原创文章,遵循 CC 4.0 by-sa 版权协议,转载请附上原文出处链接和本声明。
原文链接:https://blog.csdn.net/weixin_36336256/article/details/112886508
站方申明:本站部分内容来自社区用户分享,若涉及侵权,请联系站方删除。
  • 发表于 2021-06-14 09:56:22
  • 阅读 ( 1099 )
  • 分类:docker

0 条评论

请先 登录 后评论

官方社群

GO教程

猜你喜欢