基于ubuntu 18.04,安装依赖:
apt install build-essential libncurses5-dev zlib1g-dev gawk git libssl-dev wget unzip python ocaml-nox help2man texinfo yui-compressor
下载最新版本18.10的ImageBuilder:
https://downloads.pangubox.com/pandorabox/18.10/targets/ralink/mt7621/PandoraBox-ImageBuilder-ralink-mt7621.Linux-x86_64.tar.xz
tar Jxf PandoraBox-ImageBuilder-ralink-mt7621.Linux-x86_64.tar.xz
cd PandoraBox-ImageBuilder-ralink-mt7621.Linux-x86_64
查看可编译的固件型号及其包含的软件包:
make info
制作固件:
#info显示的所有机型固件
make image
#仅制作k2p固件
make image PROFILE="k2p"
#安装额外的软件包,自编译软件先把软件放到packages/目录下
make image PROFILE="k2p" PACKAGES="wget"
#添加files目录内文件到固件内,如files/etc/config/network网络配置文件
make image PROFILE="k2p" FILES="files"
#查看更多选项
make help
默认的软件包在以下两个文件内:
include/target.mk
.profiles.mk
开始使用默认配置制作k2p固件:
make image PROFILE="k2p"
遇到以下错误:
regexp could be something like 'pkgname*' '*file*' or similar
e.g. opkg info 'libstd*' or opkg search '*libop*' or opkg remove 'libncur*'
Makefile:140: recipe for target 'package_install' failed
make[2]: *** [package_install] Error 1
make[2]: Leaving directory '/tmp/PandoraBox-ImageBuilder-ralink-mt7621.Linux-x86_64'
Makefile:110: recipe for target '_call_image' failed
make[1]: *** [_call_image] Error 2
make[1]: Leaving directory '/tmp/PandoraBox-ImageBuilder-ralink-mt7621.Linux-x86_64'
Makefile:196: recipe for target 'image' failed
make: *** [image] Error 2
因为在Makerfile 144行要预先安装kernel文件,而package没kernel软件包,下载kernel:
wget https://downloads.pangubox.com/pandorabox/18.10/targets/ralink/mt7621/packages/kernel_3.14.79-1_mipsel_1004kc_dsp.ipk -P packages/
再次执行又出现错误:
Collected errors:
* opkg_install_cmd: Cannot install package dosfsck.
* opkg_install_cmd: Cannot install package fkmod-leds-gpio.
* opkg_install_cmd: Cannot install package kmod-ipt-nathelper.
* opkg_install_cmd: Cannot install package mkdosfs.
* satisfy_dependencies_for: Cannot satisfy the following dependencies for ralink-utils:
* kmod-ipt-nathelper-extra *
Makefile:140: recipe for target 'package_install' failed
make[2]: *** [package_install] Error 255
make[2]: Leaving directory '/tmp/PandoraBox-ImageBuilder-ralink-mt7621.Linux-x86_64'
Makefile:110: recipe for target '_call_image' failed
make[1]: *** [_call_image] Error 2
make[1]: Leaving directory '/tmp/PandoraBox-ImageBuilder-ralink-mt7621.Linux-x86_64'
Makefile:196: recipe for target 'image' failed
make: *** [image] Error 2
因为新版的openwrt将kmod-ipt-nathelper-extra 更改为kmod-nf-nathelper-extra,而潘多拉的源package没修改依赖,使用以下脚本在制作时更新源后修改软件依赖项kmod-ipt-nathelper-extra为kmod-nf-nathelper-extra:
#!/bin/bash
for file in `ls dl/18.10*`;do
echo $file;
mv $file $file.gz
gunzip $file.gz
sed -i 's/kmod-ipt-nathelper-extra/kmod-nf-nathelper-extra/g' $file
gzip -9 $file
mv $file.gz $file
done
sed -i 's/kmod-ipt-nathelper/kmod-nf-nathelper/g' include/target.mk
将以上保存为fix.sh到image build目录加可执行权限,并修改Makefile文件在122行$(MAKE) package_install前插入:
$(TOPDIR)/fix.sh
再次执行又遇到以下错误:
Collected errors:
* opkg_install_cmd: Cannot install package dosfsck.
* opkg_install_cmd: Cannot install package fkmod-leds-gpio.
* opkg_install_cmd: Cannot install package mkdosfs.
因为上面这3个软件有的改名,有的名字写错,修复下:
sed -i 's/fkmod-leds-gpio/kmod-leds-gpio/g' .profiles.mk
sed -i 's/mkdosfs dosfsck/dosfstools/g' .profiles.mk
````
再次执行终于制作完成k2p固件,将制作的固件scp到路由/tmp/目录开始刷机:
scp bin/targets/ralink/mt7621/PandoraBox-ralink-mt7621-k2p-2018-10-26-git-85c67caa2-squashfs-sysupgrade.bin 192.168.168.1:/tmp/
k2p路由内使用[sysupgrade命令刷机][1]:
sysupgrade -n -v /tmp/PandoraBox-ralink-mt7621-k2p-2018-10-26-git-85c67caa2-squashfs-sysupgrade.bin
标签:openwrt, k2p, pandorabox, 潘多拉
fix.sh放哪个目录里?我怎么不成功?
文中有脚本内容复制保存为fix.sh文件
用了fix.还是出现这个错误:
Updated list of available packages in /media/rxy/625C93155C92E359/PandoraBox-ImageBuilder-ralink-mt7621.Linux-x86_64/build_dir/target-mipsel_1004kc+dsp_uClibc-1.0.x/root-ralink/../../../../../../../media/rxy/625C93155C92E359/PandoraBox-ImageBuilder-ralink-mt7621.Linux-x86_64/dl/imagebuilder
/media/rxy/625C93155C92E359/PandoraBox-ImageBuilder-ralink-mt7621.Linux-x86_64/fix.sh
bash: /media/rxy/625C93155C92E359/PandoraBox-ImageBuilder-ralink-mt7621.Linux-x86_64/fix.sh: /usr/bin/bash: bad interpreter: No such file or directory
Makefile:110: recipe for target '_call_image' failed
make[1]: *** [_call_image] Error 126
make[1]: Leaving directory '/media/rxy/625C93155C92E359/PandoraBox-ImageBuilder-ralink-mt7621.Linux-x86_64'
Makefile:197: recipe for target 'image' failed
make: *** [image] Error 2
我是用18.07的编译的,把脚本里的18.10换成了18.07
我用18.07试了下,制作成功,fix.sh保存在image build目录,并加执行权限。
不会是ubuntu版本不同的原因吧?我的是ubuntu16.04
将fix.sh第一行更改为#!/bin/bash
18.07编译成功了,不过编译18.10的失败了,提示安装yui-compressor,事实上是安装了的
软件版本的问题吧,用ubuntu18.04试试。