本來這個blog是記錄開發輸入法的點滴的,後來越來越雜,現在什麼都記錄了。

2016年1月5日 星期二

Cross compile subversion server (svnserve) from scratch for openwrt:

Unfortunately svnserve is not likely to be availabe in the chaos calmer (15.05) version of of openwrt.
This article describes how to cross compile svnserve (with very basic funtionality) from scratch with the toolchain.
It assumed the "mvebu" toolchain for the router Linksys WRT1200AC / WRT1900AC, but the procedures are similar for other routers.
  1. Download the toolchain for WRT1200AC OpenWrt-Toolchain-mvebu_gcc-5.2.0_musl-1.1.11_eabi.Linux-x86_64.tar.bz2
  2. Download subversion-1.6.23.tar.gz.
  3. Download apr-1.2.12.tar.bz2
  4. Download apr-util-1.2.12.tar.bz2
  5. Download sqlite-amalgamation-3.6.13.tar.gz
  6. Download zlib-1.2.8.tar.gz
  7. Assume working directory is: /home/dev/svn_wrt1200ac.
    Put all source files above in /home/dev/svn_wrt1200ac/archive.
    cd /home/dev/svn_wrt1200ac
  8. Add cross compiler in PATH.
    tar xjvf archive/OpenWrt-Toolchain-mvebu_gcc-5.2.0_musl-1.1.11_eabi.Linux-x86_64.tar.bz2

    export PATH=$PATH:/home/dev/svn_wrt1200ac/OpenWrt-Toolchain-mvebu_gcc-5.2.0_musl-1.1.11_eabi.Linux-x86_64/toolchain-arm_cortex-a9+vfpv3_gcc-5.2.0_musl-1.1.11_eabi/bin/


    Run arm-openwrt-linux-gcc to see if you can run the executable

  9. Decompress the sources files in the right positions:
    tar xzvf archive/subversion-1.6.23.tar.gz
    tar xjvf archive/apr-1.2.12.tar.bz2
    tar xjvf archive/apr-util-1.2.12.tar.bz2
    tar xzvf archive/zlib-1.2.8.tar.gz
    tar xzvf archive/sqlite-amalgamation-3.6.13.tar.gz
    cd subversion-1.6.23
    ln -s ../sqlite-3.6.13/ sqlite-amalgamation
  10. Compile zlib first
    cd ../zlib-1.2.8
    CC=arm-openwrt-linux-gcc ./configure --prefix=/home/dev/svn_wrt1200ac/finalBins/usr
    make install


  11. Compile apr
    cd ../apr-1.2.12/
    ./configure --host=arm-openwrt-linux \
    ac_cv_file__dev_zero="yes" \
    ac_cv_func_setpgrp_void="yes" \
    apr_cv_process_shared_works="yes" \
    apr_cv_mutex_robust_shared="no" \
    apr_cv_tcp_nodelay_with_cork="no" \
    ac_cv_sizeof_struct_iovec="8" \
    apr_cv_mutex_recursive="yes" \
    --prefix=/home/dev/svn_wrt1200ac/finalBins/usr

    patch -p 0 include/apr.h

    Copy and paste the following, and then press Ctrl+D

    @@ -355,10 +355,10 @@
      * to find the logic for this definition search for "ssize_t_fmt" in
      * configure.in.
      */
    -#error Can not determine the proper size for ssize_t
    +#define APR_SSIZE_T_FMT "d"

     /* And APR_SIZE_T_FMT */
    -#error Can not determine the proper size for size_t
    +#define APR_SIZE_T_FMT "d"

     /* And APR_OFF_T_FMT */
     #define APR_OFF_T_FMT APR_INT64_T_FMT

    Start compile.
    make install

  12. Compile apr-util
    cd ../apr-util-1.2.12/
    cd xml/expat
    ./configure --host=arm-openwrt-linux --prefix=/home/dev/svn_wrt1200ac/finalBins/usr
    make install

    cd ../../
    ./configure --host=arm-openwrt-linux --with-apr=/home/dev/svn_wrt1200ac/finalBins/usr \
    --with-expat=/home/dev/svn_wrt1200ac/finalBins/usr \
    --prefix=/home/dev/svn_wrt1200ac/finalBins/usr
    make install

  13. Compile subversion
    cd ../subversion-1.6.23

    ./configure --host=arm-openwrt-linux \
    --with-zlib=/home/dev/svn_wrt1200ac/finalBins/usr \
    --with-apr=/home/dev/svn_wrt1200ac/finalBins/usr \
    --with-apr-util=/home/dev/svn_wrt1200ac/finalBins/usr \
    --prefix=/home/dev/svn_wrt1200ac/finalBins/usr \
    --without-berkeley-db

    make install

  14. Making tarball and transfer to router.
    cd ../finalBins
    tar -czvf svn1.6.23_wrt1200ac_finalBins.tar.gz usr/lib/lib*so* usr/bin

    Transfer the svn1.6.23_wrt1200ac_finalBins.tar.gz to router. Assume /tmp/svn_wrt1200ac_finalBins.tar.gz. e.g.:
    scp svn1.6.23_wrt1200ac_finalBins.tar.gz root@192.168.1.1:/tmp/

    In router, decompress:
    cd /
    tar -xzvf /tmp/svn1.6.23_wrt1200ac_finalBins.tar.gz
To setup svn server:
(Reference: https://forum.openwrt.org/viewtopic.php?id=11693)
mkdir /tmp/svn_repos
svnadmin create --fs-type fsfs /tmp/svn_repos

Added 3 lines to setup svn password:
In /tmp/svn_repos/conf/svnserve.conf, uncomment the folowing 3 lines
anon-access = read
auth-access = write
password-db = passwd

Add in /tmp/svn_repos/conf/passwd, password for "yylam"
To restart svn server is in /etc/rc.local
/usr/bin/svnserve -d -r /tmp/svn_repos

From OpenWrt forum: Looks like the same SVN package from the OpenWRT old_packages git repository. To reactivate the old_packages, add the following line to your feeds.conf file.
src-git old_packages git://git.openwrt.org/packages.git
hen, once you run scripts/feeds update old_packages; scripts/feeds install -a -p old_packages to update your OpenWRT, execute make menuconfig and enable the subversion package under Network --> Version Control Systems and then recompile your OpenWRT. If you don't like to add the old_packages, then either port the subversion package from the old_repository to OpenWRT GitHUB or wait for someone else to do this for you.