Thursday, June 7, 2012

[nslu2-linux] Re: rtorrent with magnet link & color ui support

 

I don't want this to be lost if either my free web hosting or free domain go belly up.

Setup the toolchain environment


  • Create a working directory and download master make file 1),

mkdir -p /mnt/jdata/builds/nslug/deb
cd /mnt/jdata/builds/nslug/
wget --cache=off http://www.nslu2-linux.org/Makefile


  • Install all the required libraries,

sudo make setup-host-debian

  • Download and install GCC-3.4 (not sure of GCC-4.4 works good for this) 2),

cd /mnt/jdata/builds/nslug/deb
 
wget http://ubuntu-mtc-a.evip.aol.com/pool/universe/g/gcc-3.4/cpp-3.4_3.4.6-6ubuntu5_i386.deb
wget http://ubuntu-mtc-a.evip.aol.com/pool/universe/g/gcc-3.4/g++-3.4_3.4.6-6ubuntu5_i386.deb
wget http://ubuntu-mtc-a.evip.aol.com/pool/universe/g/gcc-3.4/gcc-3.4_3.4.6-6ubuntu5_i386.deb
wget http://ubuntu-mtc-a.evip.aol.com/pool/universe/g/gcc-3.4/gcc-3.4-base_3.4.6-6ubuntu5_i386.deb
wget http://ubuntu-mtc-a.evip.aol.com/pool/universe/g/gcc-3.4/libstdc++6-dev_3.4.6-6ubuntu5_i386.deb
 
sudo dpkg -i *deb


  • Make the GCC-3.4 version the default one (in case v4.4 is already installed) 3),

sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-3.4 10
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.4 20
sudo update-alternatives --config gcc
 
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-3.4 10
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.4 20
sudo update-alternatives --config g++


  • Download bitbake recipes & patches,

cd /mnt/jdata/builds/nslug/
make setup-slugos-5.3-beta
export BASE=/mnt/jdata/builds/nslug/releases/slugos-5.3-beta
cd $BASE


  • Create some fixes for some buggy scripts 4) 5),

sed -i -e 's/^MACHINE[[:space:]]*=[[:space:]]*\".*\"/MACHINE = \"nslu2be\"/' conf/auto.conf
echo "TOPDIR='`pwd`'" >conf/topdir.conf. conf/topdir.conf && test "`pwd`" = "$TOPDIR" || \
echo "TOPDIR='`pwd`'" > conf/topdir.conf
 
sed -i 's/getline/getline2/' $BASE/openembedded/packages/unifdef/files/unifdef.c

  • Edit $BASE/openembedded/packages/fakeroot/fakeroot_1.9.6.bb, search and replace SRC_URI with the following,

SRC_URI = "http://pkgs.fedoraproject.org/repo/pkgs/fakeroot/fakeroot_1.9.6.tar.gz/9441c981bfd4e521abcd5d93385f71d8/fakeroot_${PV}.tar.gz \

  • Add below lines to $BASE/openembedded/conf/checksums.ini, the official repositories don't have v1.9.6 anymore. Note: fakeroot_1.9.6.tar.gz is used on slugos-5.3, other versions might use another version. Check the latest bb file.

[http://pkgs.fedoraproject.org/repo/pkgs/fakeroot/fakeroot_1.9.6.tar.gz/9441c981bfd4e521abcd5d93385f71d8/fakeroot_1.9.6.tar.gz]
md5=9441c981bfd4e521abcd5d93385f71d8
sha256=06c2772ae6e446227f6798ad8994fcdb1fe64385bc83a34f7e29fd8af2e4f5da


  • NOTE: if a checksum error appears while downloading a package (e.g. it no longer exists in the repository), do the 2 steps above, and remove the downloaded file in $BASE/downloads.

  • Replace symlink of sh to not point to dash 6),

sudo ln -sf /bin/bash /bin/sh

  • Create a small binary, this will force to create the toolchain using the GNU sources,

screen -S build bash --login # toolchain build takes a while
source setup-env
time bitbake tar


  • It looks like the above command fails the first time, so another patch needs to be applied and then run bitbake tar again,

sed -i 's/getline/getline2/' $BASE/slugos-nslu2be.tmp/work/armv5teb-linux-gnueabi/linux-libc-headers-2.6.23-r3/linux-2.6.23/scripts/unifdef.c

  • If everything goes well, the cross-compiler will be in $BASE/slugos-nslu2be.tmp/cross/armv5teb/bin/armeb-linux-gnueabi-gcc.
  • The patches & unpacking directories are respectively located at,

$BASE/openembedded/packages/<PACKAGE>/files/
$BASE/slugos-nslu2be.tmp/work/armv5teb-linux-gnueabi


  • To clean any build 7),

bitbake -c clean fakeroot


References
1) http://www.nslu2-linux.org/wiki/Development/MasterMakefile#ubuntu10.10
2) http://ubuntu-mtc-a.evip.aol.com/pool/universe/g/gcc-3.4/
3) http://askubuntu.com/questions/26498/choose-gcc-and-g-version
4) http://www.nslu2-linux.org/wiki/Optware/SlugosbeDevel
5) http://gumstix.8.n6.nabble.com/Openembedded-on-Ubuntu-9-10-td568010.html
6) http://www.nslu2-linux.org/wiki/Optware/AddAPackageToOptware
7) http://www.uv-ac.de/openembedded/openembedded-3.html



Compile rtorrent with magnet-link & color UI support

  • Add the checksums of the new versions to $BASE/openembedded/conf/checksums.ini (they can be anywhere in the file),

[http://libtorrent.rakshasa.no/downloads/libtorrent-0.12.6.tar.gz]
md5=037499ed708aaf72988cee60e5a8d96b
sha256=7b02f33164966a05261e83bad76eef537198fefe76eaf57dfd64bb27c7d77129
 
[http://libtorrent.rakshasa.no/downloads/rtorrent-0.8.6.tar.gz]
md5=b804c45c01c40312926bcea6b55bb084
sha256=8c96c68e1524162abd1fc4b612d0c3d924fccc25159c0b3f208e69281f0b32db


  • Download & edit the patches (to have magnet link & color UI support),

cd $BASE/openembedded/packages/libtorrent/files/
 
wget http://ovh.ttdpatch.net/~jdrexler/rt/old/dht-pex-static_map.diff
wget http://ovh.ttdpatch.net/~jdrexler/rt/old/magnet-uri.diff
wget http://ovh.ttdpatch.net/~jdrexler/rt/old/object-sstr.diff
wget http://www.simplylinux.ch/rtorrent/dht-pex-static_map_rev1117.diff
wget http://www.simplylinux.ch/rtorrent/canvas-color.patch
wget http://www.simplylinux.ch/rtorrent/trackerinfo.patch
 
mkdir libtorrent.tmp rtorrent.tmp
cp dht-pex-static_map.diff dht-pex-static_map_rev1117.diff magnet-uri.diff object-sstr.diff libtorrent.tmp
cp canvas-color.patch dht-pex-static_map.diff magnet-uri.diff trackerinfo.patch rtorrent.tmp
 
cd libtorrent.tmp
sed -i '4,15d' dht-pex-static_map.diff
sed -i '8,235d' magnet-uri.diff
sed -i '1999,2021d' dht-pex-static_map.diff # correct patch is on dht-pex-static_map_rev1117.diff
 
ls | while read f; do mv $f libtorrent.$f; done
mv * ..
 
cd ../rtorrent.tmp
sed -i '16,2369d' dht-pex-static_map.diff
sed -i '236,1889d' magnet-uri.diff
 
ls | while read f; do mv $f rtorrent.$f; done
mv * ..
 
cd ..
rmdir rtorrent.tmp libtorrent.tmp
rm canvas-color.patch dht-pex-static_map.diff dht-pex-static_map_rev1117.diff magnet-uri.diff object-sstr.diff trackerinfo.patch


  • Edit the recipes 5) 6),

cd $BASE/openembedded/packages/libtorrent
cp -p libtorrent_0.12.4.bb libtorrent_0.12.6.bb
cp -p rtorrent_0.8.4.bb rtorrent_0.8.6.bb


libtorrent_0.12.6.bb

SRC_URI = "http://libtorrent.rakshasa.no/downloads/libtorrent-${PV}.tar.gz \
           file://libtorrent.dht-pex-static_map.diff;patch=1 \
           file://libtorrent.dht-pex-static_map_rev1117.diff;patch=1 \
           file://libtorrent.magnet-uri.diff;patch=1 \
           file://libtorrent.object-sstr.diff;patch=1"

CXXFLAGS += "-mcpu=xscale -fno-inline"


rtorrent_0.8.6.bb

SRC_URI = "http://libtorrent.rakshasa.no/downloads/rtorrent-$.tar.gz \
           file://autoconf-cross-fix.patch;patch=1 \
           file://rtorrent.dht-pex-static_map.diff;patch=1 \
           file://rtorrent.magnet-uri.diff;patch=1 \
           file://rtorrent.canvas-color.patch;patch=1 \
           file://rtorrent.trackerinfo.patch;patch=1"

CXXFLAGS += "-mcpu=xscale -fno-inline"

  • This is where things get weird. Before starting the compilation, to avoid errors, run the following on another terminal 7),

cd $BASE/slugos-nslu2be.tmp/work/armv5teb-linux-gnueabi
watch -n1 rm libtorrent-0.12.6-r*/libtorrent-0.12.6/scripts/{libtool,lt*}.m4 rtorrent-0.8.6-r*/rtorrent-0.8.6/scripts/{libtool,lt*}.m4


  • Start the compilation,

screen -S build bash --login
cd $BASE
source setup-env
time bitbake rtorrent

  • If all goes well, the ipk files will be created,

cd $BASE/slugos-nslu2be.tmp/deploy/ipk/armv5teb
ls rtorrent_0.8.6-r0_armv5teb.ipk libtorrent11_0.12.6-r0_armv5teb.ipk


  • Go to the SlugOS box, and install rtorrent from the package manager (this is to avoid any dependencies or version errors),

sudo opkg install rtorrent


  • To fix errors that may have appeared about different versions, edit the status file and remove the appropiate entry 8),

sudo vi /usr/lib/opkg/status

Package: rtorrent
Version: 0.8.6-r0
Depends: ncurses (>= 5.4), libcurl4 (>= 7.19.0), libc6 (>= 2.6.1), libz1 (>= 1.2.3), libtorrent11 (>= 0.12.6), libcrypto0.9
Status: install prefer,user not-installed
Architecture: armv5teb


  • Copy the packages to the SlugOS box and uncompress them 9),

ar vx rtorrent_0.8.6-r0_armv5teb.ipk
gunzip -c data.tar.gz | tar -xf -
rm data.tar.gz control.tar.gz debian-binary
ar vx libtorrent11_0.12.6-r0_armv5teb.ipk
gunzip -c data.tar.gz | tar -tf -


  • Copy 2 binaries and replace a softlink,

sudo cp -p /usr/bin/rtorrent /usr/bin/rtorrent.0.8.4
sudo cp -p usr/bin/rtorrent /usr/bin
sudo cp -p usr/lib/libtorrent.so.11.0.6 /usr/lib/
sudo ln -sf /usr/lib/libtorrent.so.11.0.6 /usr/lib/libtorrent.so.11



References
1) http://www.howtoforge.com/how-to-compile-rtorrent-from-svn-in-ubuntu-9.10-karmic-koala-debian-5-lenny-with-magnet-link-support
2) http://www.howtoforge.com/how-to-compile-rtorrent-from-svn-in-ubuntu-10.04-lucid-lynx-debian-5-lenny-with-coloured-interface
3) http://libtorrent.rakshasa.no/downloads/
4) http://ovh.ttdpatch.net/~jdrexler/rt/old/
5) http://comments.gmane.org/gmane.comp.handhelds.openembedded/32366
6) http://libtorrent.rakshasa.no/wiki/LibTorrentKnownIssues#NSLU2routersandxscalebaseddevices
7) http://libtorrent.rakshasa.no/ticket/1852
8) http://lists.openmoko.org/nabble.html#nabble-td4054007
9) http://www.g-loaded.eu/2008/01/28/how-to-extract-rpm-or-deb-packages/

__._,_.___
Recent Activity:
.

__,_._,___

No comments:

Post a Comment