小米路由器mini折腾之Python篇
上回老高写了翻墙篇,寻思着这openwrt下能不能跑个python,继续折腾!
准备
刷了Pandorabox的小米路由器一个,原生系统没有测试,估计没有什么问题,但是需要开启SSH。
配置opkg源
# 备份初始conf
mv /etc/opkg.conf /etc/opkg.conf.bak
# 新建配置
vim /etc/opkg.conf
# 添加如下内容
dest root /
dest ram /tmp
lists_dir ext /var/opkg-lists
option overlay_root /overlay
# notice
dest usb /mnt/sdb1/opkg
arch all 100
arch ramips_24kec 200
arch ramips 300
arch mips 400
arch unkown 500
src/gz barrier_breaker_base http://downloads.openwrt.org/barrier_breaker/14.07/ramips/mt7620a/packages/base
src/gz barrier_breaker_luci http://downloads.openwrt.org/barrier_breaker/14.07/ramips/mt7620a/packages/luci
src/gz barrier_breaker_management http://downloads.openwrt.org/barrier_breaker/14.07/ramips/mt7620a/packages/management
src/gz barrier_breaker_oldpackages http://downloads.openwrt.org/barrier_breaker/14.07/ramips/mt7620a/packages/oldpackages
src/gz barrier_breaker_packages http://downloads.openwrt.org/barrier_breaker/14.07/ramips/mt7620a/packages/packages
src/gz barrier_breaker_routing http://downloads.openwrt.org/barrier_breaker/14.07/ramips/mt7620a/packages/routing
src/gz barrier_breaker_telephony http://downloads.openwrt.org/barrier_breaker/14.07/ramips/mt7620a/packages/telephony
# wq保存
# 执行升级
opkg update
安装Python
需要注意的是,小米路由器的可用空间不多,但Python的安装会占用挺大的空间,所以我们指定opkg将程序安装在U盘或硬盘上。
这时我们回到刚才的配置文件里,找到notice,这里的dest usb /mnt/sdb1/opkg
就是指定变量usb
为外置存储路径/mnt/sdb1/opkg
。外置存储的路径可以用df -h
查看。
以后我们使用opkg -d usb install xxx
即可将程序安装至/mnt/sdb1/opkg
。
# 先需要安装libc,需要下载下来安装
## 建立文件夹
mkdir -p /mnt/sdb1/opkg/src
cd /mnt/sdb1/opkg/src
wget http://downloads.openwrt.org/barrier_breaker/14.07/ramips/mt7620a/packages/base/libc_0.9.33.2-1_ramips_24kec.ipk
## 安装libc,最好安装到根下
opkg install libc_0.9.33.2-1_ramips_24kec.ipk
# 接着安装Python
opkg -d usb install libreadline
opkg -d usb install python
opkg -d usb install python-json
opkg -d usb install python-curl
opkg -d usb install python-openssl
# 路径
export PATH=$PATH:/mnt/sdb1/opkg/usr/bin
echo 'export PATH=$PATH:/mnt/sdb1/opkg/usr/bin' >> /etc/profile
# 别名
echo "alias opintall='opkg -d usb install'" >> /etc/profile
问题
目前已知的bug:
Python方向键乱码,无法使用。
References:
python解释器方向键乱码应该是缺少组件支持,安装完readline-devel之后,重新安装python应该就可以了
感谢,回头试试
运行xx-net.sh时报错import time包错误
8G U盘自动mount为/mnt/sda1,安装的时候提示以下错误。 [root@PandoraBox:/mnt/sda1/opkg]#opkg -d usb install libreadline Installing libreadline (6.2-1) to usb... Downloading http://downloads.openwrt.org/barrier_breaker/14.07/ramips/mt7620a/packages/base/libreadline_6.2-1_ramips_24kec.ipk. Configuring libreadline. Collected errors: * extract_archive: Cannot create symlink from ./usr/lib/libhistory.so.6 to 'libhistory.so.6.2': Operation not permitted. * extract_archive: Cannot create symlink from ./usr/lib/libreadline.so to 'libreadline.so.6': Operation not permitted. * extract_archive: Cannot create symlink from ./usr/lib/libreadline.so.6 to 'libreadline.so.6.2': Operation not permitted. * extract_archive: Cannot create symlink from ./usr/lib/libhistory.so to 'libhistory.so.6': Operation not permitted. 最开始安装libc的时候也出现了类似的错误,后通过省略-d参数成功安装在root下 opkg install libc_0.9.33.2-1_ramips_24kec.ipk 貌似和路径有关,opkg.conf基本上和站长的一致,只修改了/sdb1为/sda1(df查询得到)。主要内容如下 dest root / dest ram /tmp lists_dir ext /var/opkg-lists option overlay_root /overlay # notice dest usb /mnt/sda1/opkg (后略) 请指点迷津,多谢
安装libc时出问题了 * deb_extract: libc_0.9.33.2-1_ramips_24kec.ipk: invalid magic * pkg_init_from_file: Failed to extract control file from libc_0.9.33.2-1_ramips_24kec.ipk.
小白求救, [root@PandoraBox:/root]#opkg update Package iptables-mod-chaos version 2.3-1 has no valid architecture, ignoring. Package kmod-usb-storage version 3.14.36-1 has no valid architecture, ignoring. Package terminfo version 5.9-1 has no valid architecture, ignoring. Package kmod-sched-connmark version 3.14.36-1 has no valid architecture, ignorin g. …………………… 几十个 has no valid architecture,
PandoraBox 14.09 r601
正常
和这个没联系吗 ………… Package kmod-usb-cm109 version 3.14.36-1 has no valid architecture, ignoring. Installing curl (7.38.0-1) to root... Downloading http://downloads.openwrt.org/barrier_breaker/14.07/ramips/mt7620a/packages/base/curl_7.38.0-1_ramips_24kec.ipk. Collected errors: * satisfy_dependencies_for: Cannot satisfy the following dependencies for curl: * libc * libc * libc * * opkg_install_cmd: Cannot install package curl.
怎么解决的
,, 看到了libc那句话了,之前没仔细看,解决了 麻烦了
看你的错误是权限不足,你的U盘是什么格式的?
多谢!问题得到完美解决。在openwrt上将U盘格式化成ext分区可参考:http://blog.csdn.net/yufei_email/article/details/8805682
8G Sandisk 酷豆, Fat 32
哈哈,我就是猜的,没想到还猜对了!
回头我再折腾一下,试试看NTFS格式能不能支持。如果能在NTFS格式的U盘上正常工作就最好了。
格式化成Linux下的ext或者ntfs试试