在docker上构建openwrt编译环境

Created: June 29, 2018, 3:21 a.m. Updated: June 29, 2018, 3:54 a.m.

去docker hub上查了下ubuntu能用的版本

https://hub.docker.com/_/ubuntu/

这次的openwrt sdk需要的是ubuntu 16.04版本

获取镜像

docker pull ubuntu:16.04

启动镜像挂在openwrt源码目录

docker run -it -v `pwd`/ap2502:/root/ap2502 ubuntu:16.04 /bin/bash

安装工具依赖

apt-get installgit-core build-essential gcc  g++ binutils patch bzip2 flex bison make autoconf gettext texinfo unzip sharutils subversion libncurses5-dev ncurses-term zlib1g-dev  gawk asciidoc libz-dev libssl-dev

make了一下可耻的挂了

bzcat /root/ap2502/dl/linux-3.3.8.tar.bz2 | /usr/bin/gtar -C /root/ap2502/build_dir/linux-ar71xx_generic -xf - bash: /usr/bin/gtar: No such file or directory Makefile:30: recipe for target '/root/ap2502/build_dir/linux-ar71xx_generic/linux-3.3.8/.prepared' failed make[4]: *** [/root/ap2502/build_dir/linux-ar71xx_generic/linux-3.3.8/.prepared] Error 127 make[4]: Leaving directory '/root/ap2502/target/linux/ar71xx' Makefile:13: recipe for target 'compile' failed

解决:

ln -s /bin/tar /usr/bin/gtar

继续 make

touch /root/ap2502/build_dir/linux-ar71xx_generic/linux-3.3.8/.quilt_used touch /root/ap2502/build_dir/linux-ar71xx_generic/linux-3.3.8/.prepared if [ -s "/root/ap2502/build_dir/linux-ar71xx_generic/linux-3.3.8/patches/series" ]; then (cd "/root/ap2502/build_dir/linux-ar71xx_generic/linux-3.3.8"; if quilt --quiltrc=- next >/dev/null 2>&1; then quilt --quiltrc=- push -a; else quilt --quiltrc=- top >/dev/null 2>&1; fi ); fi Makefile:30: recipe for target '/root/ap2502/build_dir/linux-ar71xx_generic/linux-3.3.8/.quilt_checked' failed make[4]: *** [/root/ap2502/build_dir/linux-ar71xx_generic/linux-3.3.8/.quilt_checked] Error 126 make[4]: Leaving directory '/root/ap2502/target/linux/ar71xx' Makefile:13: recipe for target 'compile' failed make[3]: *** [compile] Error 2

查了下没有安装quilt,而且还需要32位的支持

apt install quilt libc6:i386  lib32stdc++6 lib32z1 
make tools/quilt/install V=s

Package libc6:i386 is not available, but is referred to by another package. This may mean that the package is missing, has been obsoleted, or is only available from another source However the following packages replace it: libdb1-compat tzdata initscripts

ubuntu 16.04 下安装 libdb1-compat tzdata initscripts

继续 make

checking for ranlib... ranlib configure: error: cannot run /usr/bin/bash build-aux/config.sub Makefile:43: recipe for target '/root/ap2502/build_dir/host/sed-4.2.1/.configured' failed make[2]: [/root/ap2502/build_dir/host/sed-4.2.1/.configured] Error 1 make[2]: Leaving directory '/root/ap2502/tools/sed' tools/Makefile:142: recipe for target 'tools/sed/compile' failed make[1]: [tools/sed/compile] Error 2

给bash也做个软链

继续就可以了