advancedTomato 3.4 v140 界面中文化 及乱搞 (Asus RT N16 / N66U / AC66U )

看到恩山有人分享v138的中文版固件,但是迟迟不出v140, 所以lz准备自己上了

tomato shibby也有不少人尝试汉化,但是都没有去翻译原repo里的文件,而是只翻译了编译过后的固件里的文件,这是费力不讨好的工作,而且不具有延续性,而此中文固件乃是将原repo中的文件汉化,从而达到不变应万变的目的,是乃正确之选。但lz有几点疑惑,猜测有两种可能性

  • 作者是城府极深的高手,从他恩山用马甲发帖, gayhub账号也是马甲可以看出,作者不希望被人肉,而且repo里也没有分branch。 可是这样一来,会造成协作者的困难,我猜作者是本地repo里有设置原repo为upstream, 从而可以减轻上游更新后merge的痛苦
  • 作者是小白,不会用git,每次出新版都彻底手动重新编辑,这样就可以解释为什么只有一个branch了,而且在固件里加入个人网站(顺带说一句,作者网站挂了,不知道是不是drink tea了)也是小白常见操作

lz觉得作者是上述第一种情况的高手,不管如何,lz决定在自己的N16上进行实验,lz科技实力不足,不想大改(比如port tomato raf里的translation module到这里),所以lz准备继续zhang-sir的工作,merge一下新版

尝试一(放弃)

lz本来想fork原作者的repo, 然后再添加修改

# 首先fork作者的repo,然后clone fork过的repo
git clone https://github.com/oglops/advancedtomato-gui-chinese.git

# 可以发现作者的commit和上游的commit混在了一起,所以先退后到最后一个上游的branch
git reset --hard 221d78b

# 彻底去除新的commit
git push -f origin master

# 添加 advancedTomato 官方界面repo作为上游repo
git remote add upstream https://github.com/Jackysi/advancedtomato-gui.git

# clone一下官方repo看是不是真的和上面的commit一模一样
git clone https://github.com/Jackysi/advancedtomato-gui.git
git reset --hard 221d78b
# 没看出有什么不同
meld ~/github/advancedtomato-gui-chinese ~/github/advancedtomato-gui

# 在fork的repo中创建chs分支
git checkout -b chs

# clone 汉化作者的repo到一个临时文件夹
cd ~/github
git clone https://github.com/Zhang-Sir/advancedtomato-gui-chinese.git advancedtomato-gui-chinese-zhang

# 把汉化后的文件复制到fork的repo中
# r 表示 recursive, p 表示 保持原有permission, v 表示 verbose
# 忽略.git文件夹 --ignore-times表示彻底覆盖,不管是否已经存在

# --exclude .git 可以换成 -C
rsync -rpv --ignore-times ~/github/advancedtomato-gui-chinese-zhang/* ~/github/advancedtomato-gui-chinese --exclude .git

# 把 chs branch push到repo
git commit -a -m "apply zhang-sir v138 chinese localization"
git push -u origin chs

# 可以这样看看到底汉化改了哪些地方,当然也可以把文件分别复制到两个文件夹,然后meld
git difftool HEAD^ HEAD admin-tomatoanon.asp

在上述测试中,没有遇到问题,只是查看了几个文件的翻译以后,有些不满意的地方,lz决定自行修改,问题出在,当lz切换回master分支,并fetch上游改变之后,想将这些变化merge到chs分支的时候,出现了一大堆conflicts, 经检查后发现上游作者不但空格和tab混用,而且在v140中略微改变了缩进风格 .. orz

lz最后决定还是直接fork上游的repo,然后把zhang-sir的汉化文件拷进去,这样历史比较清晰(上面那种方式会比较乱)

尝试二
# lz fork了上游repo
git clone git@github.com:oglops/advancedtomato-gui.git advancedtomato-gui-oglop

# 把汉化版的base commmit单独拿出来,放进chs branch
cd advancedtomato-gui-oglop
git checkout -b chs 221d78b

# 现在把汉化版文件拷过来, 覆盖原版
rsync -rpv --ignore-times ~/github/advancedtomato-gui-chinese-zhang/* ~/github/advancedtomato-gui-oglop --exclude .git

git commit -a -m "apply zhang-sir v138 chinese localization"

# 然后把英文版存到一个临时目录里
git checkout 221d78b
git checkout-index -a -f --prefix=$HOME/github/advancedtomato-gui-oglop-en/
git checkout chs
# 比较中文翻译,并添加lz的修改
meld . /home/oglop/github/advancedtomato-gui-oglop-en/

抱歉的是,lz删除了原作者的个人信息(请勿心寒),一则大部分工作据称是由bwq518完成,二来作者在里面加的个人网站挂了,github地址也不存在了,其次万一被请去drink tea这不是做死么,lz准备把这些信息放到repo说明里

各种错误们

  • 找不到systemd
    src/or/config.c:66:31: error: systemd/sd-daemon.h: No such file or directory
    src/or/config.c: In function 'options_act_reversible':
    src/or/config.c:1172: warning: implicit declaration of function 'sd_notifyf'
    src/or/config.c:1172: warning: nested extern declaration of 'sd_notifyf'
    make[6]: *** [src/or/config.o] Error 1
    Makefile:3579: recipe for target 'src/or/config.o' failed
    

    在tor的configure里禁用 systemd 见这里

  • restartable system calls conf test 出错
    checking for dlopen... yes
    checking for dlerror... yes
    checking for restartable system calls... configure: error: in `/home/oglop/advancedtomato/release/src/router/mysql':
    configure: error: cannot run test program while cross compiling
    See `config.log' for more details
    
    
    ...
    configure:22085: checking for restartable system calls
    configure:22091: error: in `/home/oglop/tomato/release/src/router/mysql':
    configure:22093: error: cannot run test program while cross compiling
    
    

    在configure.mipsel 里禁用check 不过好像本来就禁用了,也许这是意外

  • mipsel-uclibc-gcc -std=gnu99 -Os -Wall -DLINUX26 -DCONFIG_BCMWL5 -pipe -DBCMWPA2 -funit-at-a-time -Wno-pointer-sign -mtune=mips32 -mips32 -I/home/oglop/advancedtomato/release/src-rt/router/libncurses/staged/usr/include -ffunction-sections -fdata-sections -Wall -ffunction-sections -fdata-sections -Wl,--gc-sections -L/home/oglop/advancedtomato/release/src-rt/router/libncurses/staged/usr/lib -fPIC -o nano browser.o chars.o color.o cut.o files.o global.o help.o move.o nano.o prompt.o rcfile.o search.o text.o utils.o winio.o ../lib/libgnu.a -lncurses -ltinfo
    /home/oglop/tomato/tools/brcm/K26/hndtools-mipsel-uclibc-4.2.4/bin/../lib/gcc/mipsel-linux-uclibc/4.2.4/../../../../mipsel-linux-uclibc/bin/ld: cannot find -ltinfo
    collect2: ld returned 1 exit status
    make[7]: *** [nano] Error 1
    Makefile:1478: recipe for target 'nano' failed
    

    这是因为 lz 系统里的ncurses 版本导致,说明见 更新磊科q3和烽火hg320自定义版tomato shibby到v140

    $ pkg-config --libs ncurses
    -lncurses -ltinfo
    
  • make[4]: Leaving directory `/home/travis/builds/oglops/advancedtomato/release/src/btools'
    Creating Firmware for Netgear WNR3500L v2 ....
    mipsel-uclibc-objcopy -O binary -g /home/travis/builds/oglops/advancedtomato/release/src-rt/linux/linux-2.6/vmlinux image/vmlinux.bin
    /home/travis/builds/oglops/advancedtomato/release/src-rt/wnrtool/lzma e image/vmlinux.bin image/vmlinux.lzma
    make[3]: /home/travis/builds/oglops/advancedtomato/release/src-rt/wnrtool/lzma: Command not found
    

    这也许是因为缺少下述lib?

    sudo apt-get install lib32stdc++6 --fix-missing
    

    或者加到.travis.yml依赖里

测试编译

# lz修改过的适合F25的repo
git clone -b fedora https://github.com/oglops/advancedtomato.git

# 汉化文件
git clone -b v3.4-140 https://github.com/oglops/advancedtomato-gui.git

sudo ln -s ~/advancedtomato/tools/brcm /opt/brcm

cd ~/advancedtomato
export PATH=$PATH:/opt/brcm/hndtools-mipsel-linux/bin:/opt/brcm/hndtools-mipsel-uclibc/bin

# 把汉化版的www复制到 advancedTomato 源码中覆盖
rsync -rpv --ignore-times ~/advancedtomato-gui/* ~/advancedtomato/release/src-rt/router/www/ --exclude .git

cd release/src-rt

# AIO 版
make distclean ; rm ~/advancedTomato.txt; time make V1=RT-N5x-CN- V2=-140 r2z 2>&1 | tee ~/advancedTomato.txt
*********************** Tue Aug 1 23:53:58 PDT 2017 ************************
1.28.0000 MIPSR2-140 K26 USB AIO-64K
Creating little endian 3.0 filesystem on /home/oglop/advancedtomato/release/src-rt/router/mipsel-uclibc/target.image, block size 65536.

Little endian filesystem, data block size 65536, compressed data, compressed metadata, compressed fragments
Filesystem size 20355.70 Kbytes (19.88 Mbytes)
29.27% of uncompressed filesystem size (69544.45 Kbytes)
Inode table size 14132 bytes (13.80 Kbytes)
25.27% of uncompressed inode table size (55927 bytes)
Directory table size 13823 bytes (13.50 Kbytes)
52.34% of uncompressed directory table size (26412 bytes)
No duplicate files removed
Number of inodes 1643
Number of files 1334
Number of fragments 104
Number of symbolic links 218
Number of device nodes 0
Number of fifo nodes 0
Number of socket nodes 0
Number of directories 91
Number of uids 1
root (0)
Number of gids 0

Creating TRX: image/tomato-K26USB-1.28.RT-N5x-CN-MIPSR2-140-AIO-64K.trx

TRX Image:
Total Size .... : 21872640 (21360.0 KB) (20.9 MB)
Images ...... : 21869540 (0x014db3e4)
Padding ..... : 3072
Avail. for jffs :
4MB, 128K CFE : 0 EBs + 0
4MB, 256K CFE : 0 EBs + 0
8MB, 256K CFE : 0 EBs + 0
Note : Netgear routers have 6 EBs less available!
CRC-32 ........ : 4F036B38
128K Blocks ... : 167 (0x000000A7)
64K Blocks ... : 334 (0x0000014E)
Offsets:
0: 0x0000001C lzma-loader/loader.gz
1: 0x00000AD8 /home/oglop/advancedtomato/release/src-rt/linux/linux-2.6/arch/mips/brcm-boards
2: 0x000FA400 router/mipsel-uclibc/target.image

试编译 ac66u AIO 版

make distclean ; rm ~/advtt_ac66u.txt; time make V1=RT-N5x-CN- V2=-140 ac66z 2>&1 | tee ~/advtt_ac66u.txt
尝试在n16上测试

因为不想真刷进去测试,所以使用固件里设置webui位置的功能,虽然大部分次级菜单也许看不到,但主菜单是可以如此预览的

# 把汉化文件复制到 jffs去, lz事先设了测试用的n16 ip地址,然后把Lan口接到主路由的lan口,禁用了dhcp
scp ~/github/advancedtomato-gui-oglop/* root@192.168.1.3:/jffs/www/

ssh到路由器


# 设为/jffs/www
nvram set web_dir=jffs

# 恢复默认
nvram set web_dir=default

# 重启apache
service httpd restart

之后就可以根据页面显示来做相应的修正了,如果修改了文件,可以立即把修改过的文件用scp拷入,就可以预览效果了

# 当然也可以一次性把所有改动过的文件拷到路由器
git status --porcelain | awk '{print $2}' | xargs -I {} scp {} root@192.168.1.3:/jffs/www/

Notes:

  • 使用kdiff3的过程中发现没法输入中文?
    dnf install fcitx-table-chinese kcm-fcitx fcitx-libpinyin
    
    
    im-chooser
    
  • 给remote branch改名
    #rename the local branch to the new name
    git branch -m old_name new_name
    
    
    #delete the old branch on remote - where <remote> is eg. origin
    git push <remote> --delete old_name
    
    #push the new branch to remote
    git push <remote> new_name
    

n16 AIO 效果

edit:
04/08/2018 发现advanced-restrict-edit.asp页面上的星期和New Rule字符串不应该汉化,travis测试编译时发现总是提示

upnpevents.c:23:23: error: uuid/uuid.h: No such file or directory
upnpevents.c: In function 'newSubscriber':
upnpevents.c:119: error: 'uuid_t' undeclared (first use in this function)
upnpevents.c:119: error: (Each undeclared identifier is reported only once
upnpevents.c:119: error: for each function it appears in.)
upnpevents.c:119: error: expected ';' before 'uuid'
upnpevents.c:120: warning: implicit declaration of function 'uuid_generate'
upnpevents.c:120: error: 'uuid' undeclared (first use in this function)
upnpevents.c:122: warning: implicit declaration of function 'uuid_unparse'
make[5]: *** [upnpevents.o] Error 1
make[5]: *** Waiting for unfinished jobs....
make[4]: *** [miniupnpd] Error 2
make[3]: *** [all] Error 2
make[2]: *** [bin] Error 2

虽然系统里已经有uuid-dev了,最后的办法是把系统里的删了,然后自己安装uuid(cross compiled),并且修改miniupnpd的Makefile.Linux

下载链接:

https://oglopss.github.io/advancedTomato-ci-jekyll/

lz移除了之前dropbox的下载链接,因为lz后来把编译放到travis ci上,期间lz又数次更新了翻译repo,而没有在本机再次编译,在上面的连接里是最新版本

相关repo:

中文化 repo https://github.com/oglops/advancedtomato-gui
修改过的在Fedora 25上编译通过的repo https://github.com/oglops/advancedtom

参考:
AdvancedTomato汉化版
compilation error for mysql
How to rename a remote git branch name

advancedTomato 3.4 v140 界面中文化 及乱搞 (Asus RT N16 / N66U / AC66U )”的一个响应

    1. “测试编译”那一段就是教程,把”r2z”换成别的参数即可,别的参数见release/src-rt/Makefile,或者运行make help

      1. 你用的固件是从github pages下载的最新版么? 我晚上回去试试,无非是少打了引号之类的,你可以提交PR

      2. 谢谢大神!已经刷完,可以保存了。我现在想在 hg320 64K 版的tomato上安装下载软件 能否出个教程啊?

      3. 1.常用工具可以 插个优盘装entware,然后直接安装即可
        2. 对于自己想要的特殊工具如较新版本的ss libev,entware的repo里没有的话,基本上就是用crosstool-ng生成正确的适合工具链,然后用工具链编译想要的工具,最后拷到jffs上直接运行,这是linux使用问题,请自己Google吧,如果你是乐于助人的热血青年, 你也可以考虑成为package mainteiner,把ss libev提交到repo里,这样其他人就不用这样折腾了,很久之前看了下entware里的ss是2.x 版本的,不知道最近有没有更新了

留下评论