How To Compile rTorrent From SVN In Ubuntu 9.10 Karmic Koala / Debian 5 Lenny With Magnet Link Support

Want to support HowtoForge? Become a subscriber!
 
Submitted by sjau (Contact Author) (Forums) on Fri, 2009-12-04 17:09. :: Debian | Ubuntu

How To Compile rTorrent From SVN In Ubuntu 9.10 Karmic Koala / Debian 5 Lenny With Magnet Link Support

Author: Stephan Jau
Revision: v1.2 
Last Change: February 16 2010

Introduction

rTorrent is a popular command line based bittorrent client. It provides very powerful features yet it is very light on the system - contrary to other bittorrent clients like Vuze. There are a couple of webinterfaces for it but they are not truly need. SSH access combined with the "screen" program provide you all the tools you need.

Recently a large bittorrent tracker announced, that they will in future only support magnet link. Magnet links are special URLs that contain a hash link that identifies the according .torrent file. By default, rtorrent does not support magnet links. However there is a patch for it provided by Josef. The patch itself is currently split up into 3 seperate patches. This howto provides a step-by-step guide on how to compile rtorrent from svn and applying the magnet link patches (as well as two other patches I am fond of).

This howto works for Ubuntu 9.10 Karmic Koala and for Debian 5 Lenny. The difference is that commands that contain sudo must be executed as root.

In this howto I assume you download and compile the sources from your ~/rtorrent resp. ~/rtorrent/trunk folder.

 

1. Remove current rtorrent installation

sudo apt-get remove rtorrent libtorrent*

 

2. Install necessary packages

sudo apt-get install subversion build-essential libtool automake openssl libsigc++-2.0-dev libncurses5-dev libcurl4-openssl-dev

 

3. Create rtorrent folder

mkdir ~/rtorrent

 

4. Go into the rtorrent folder

cd ~/rtorrent

Current location: /home/USER/rtorrent

 

5. Get the rtorrent sources by svn

svn co svn://rakshasa.no/libtorrent/trunk

Current rtorrent version is: rev. 1105.

 

6. Get into the trunk folder

cd trunk

Current location: /home/USER/rtorrent/trunk

 

7. Download the patches

For Magnet Link support:

wget http://ovh.ttdpatch.net/~jdrexler/rt/experimental/dht-pex-static_map.diff
wget http://ovh.ttdpatch.net/~jdrexler/rt/experimental/magnet-uri.diff
wget http://ovh.ttdpatch.net/~jdrexler/rt/experimental/object-sstr.diff

As mentioned before the magnet link patch was supplied by Josef. The magnet link patches are still in development but enough stable to use them already. For more info on the development go here: http://libtorrent.rakshasa.no/ticket/1382

Colour support for rtorrent:

wget http://www.simplylinux.ch/rtorrent/canvas-color.patch

If you're on rev. 1131 then use this patch here. I don't exactly know at what revision the original patch fails. If in doubt update your rtorrent version to the latest revision. Thx to the Italian_Plumber for supplying the updated patch.

wget http://www.simplylinux.ch/rtorrent/canvas-color_1131.patch

This patch enables you to colorize the rtorrent cli interfaces. It differentiaties between completed/uncompleted torrents and active/inactive ones. I first had to get used to it also but meanwhile I think it's really a good enhancement. The patch was originally supplied here: http://libtorrent.rakshasa.no/ticket/1382. However that patch does not work with the current rev. 1105. Because of that I fixed it and supply it also from my server.

Torrent Tracker Stats:

wget http://www.simplylinux.ch/rtorrent/trackerinfo.patch

This patch shows the number of seeders/leechers/completed as supplied by the tracker in the tracker view. Often it's not accurate however it's usefull for me to check if a tracker has any peers at all listed for a given torrent.

 

8. Apply the patches

Magnet link support:

patch -p0 < dht-pex-static_map.diff
patch -p0 < magnet-uri.diff
patch -p0 < object-sstr.diff

If the first patch gives an error like this:

patching file libtorrent/src/torrent/Makefile.am
Hunk #1 FAILED at 41.
Hunk #2 FAILED at 77.
2 out of 2 hunks FAILED -- saving rejects to file libtorrent/src/torrent/Makefile.am.rej

Then you'll have to download another custom patch also and apply it. The reason is, that the libtorrent Makefile.am has changed and the patch by Josef does not yet reflect that change. In time Josef will update his patch. So make sure that the above error message appears before running the patch below. My fix has been tested on revision 1117.

wget http://www.simplylinux.ch/rtorrent/dht-pex-static_map_rev1117.diff
patch -p0 < dht-pex-static_map_rev1117.diff

Colour support for rtorrent:

patch -p0 < canvas-color.patch

Torrent Tracker Stats:

patch -p0 < trackerinfo.patch

 

9. Get into the libtorrent folder

cd libtorrent

Current location: /home/USER/rtorrent/trunk/libtorrent

 

10. Run the autogen.sh script

./autogen.sh

 

11. Configure libtorrent

./configure

 

12. Compile libtorrent

make

 

13. Install libtorrent

sudo make install

 

14. Extend /etc/ld.so.conf

echo "include /usr/local/lib" | sudo tee -a /etc/ld.so.conf

 

15. Updated ld.so cache

sudo ldconfig

 

16. Get into the rtorrent folder

cd ../rtorrent

Current location: /home/USER/rtorrent/trunk/rtorrent

 

17. Run the autogen.sh script

./autogen.sh

 

18. Configure rtorrent

./configure

 

19. Compile rtorrent

make

 

20. Install rtorrent

sudo make install

 

21. Extend rtorrent configuration

Magnet Link support as provided by this howto requires a session folder. If there is no session folder defined yet in the ~/.rtorrent.rc config file or if that config file does not exist yet, then it has to be added. An example for an ~/.rtorrent.rc file can be found here: http://libtorrent.rakshasa.no/browser/trunk/rtorrent/doc/rtorrent.rc#latest. In addition I would also set the DHT option to "on".

You can also just copy the .rtorrent.rc config file from the trunk and then edit it:

cp ~/rtorrent/trunk/rtorrent/doc/rtorrent.rc ~/.rtorrent.rc

To make use of the colour patch, also the colour options need to be added to the ~/.rtorrent.rc config. I use this example below:

# Color / Canvas patch
done_fg_color = 2
#done_bg_color = 2
active_fg_color = 1
#active_bg_color = 4

With these options inactive completed torrents will be displayed as dark green, active ones as bright green, inactive incompleted torrents are displayed in dark red, active ones in bright red. To customize this further you can use those colours: 0 = black; 1 = red; 2 = green; 3 = yellow; 4 = blue; 5 = magenta; 6 = cyan; 7 = white

 

22. Run rtorrent

rtorrent

 

Howto use magnet links

The use is actually quite simple. In rtorrent press the backspace or enter key and then paste the magnet link url. The difference between the backspace and enter key is, that backspace auto-starts the magnet link and enter just add it but does not start it.

To make rtorrent auto-fetch magnet links that you click on you can use this bash script provided also by Josef:

#!/bin/bash
cd ~/watch    # set your watch directory here
[[ "$1" =~ xt=urn:btih:([^&/]+) ]] || exit;
echo "d10:magnet-uri${#1}:${1}e" > "meta-${BASH_REMATCH[1]}.torrent"

Save that script somewhere in your home folder e.g. ~/rtorrent_magnet.sh and make it executable. Then tell your browser that when a magnet link is clicked, that this script should be run (or the magnet link be opened by this script). I did not try it myself but I have faith in Josef's abilities as it was him who actually supplied the magnet link patch.


Please do not use the comment function to ask for help! If you need help, please use our forum.
Comments will be published after administrator approval.
Submitted by Anonymous (not registered) on Mon, 2011-01-03 13:23.
might think of adding libcppunit-dev to packages required to install if you run in to compilation problems of libtorrent
Submitted by M@ (not registered) on Thu, 2010-05-20 19:07.
I'm getting a 404 not found from wget when trying to download those patches, could they have been moved or renamed?
Submitted by Italian_Plumber (not registered) on Fri, 2010-03-26 21:26.
Very helpful.  Thanks!
Submitted by Petroffich (not registered) on Tue, 2010-03-23 12:13.
Thank a lot for your post! I used it myself and made translation for russian torrent tracker (http://rutracker.org/forum/viewtopic.php?t=2586225) rtorrent supports magnet url starting with r1144. Color patch is changed slightly, here it is for r1144-r1148 : http://garuda.newmail.ru/canvas-color_1146-1148.1.zip
Submitted by Anonymous (not registered) on Tue, 2010-02-23 01:10.
I had to install this too in step 2 (using ubuntu 9.10 server) sudo apt-get install libxmlrpc-c3-dev to get the --with-xmlrpc-c flag for ./configure to work for rtorrent.
Submitted by Anonymous (not registered) on Wed, 2010-01-20 04:20.

this is my first time trying to comile anything and install so i may have done something wrong outside of this guide. i followed all of teh steps exactly and everythign was working fine until i issued the make command on step 19. this is the output from the make command

aaron@aaron-server:~/rtorrent/trunk/rtorrent$ make
make  all-recursive
make[1]: Entering directory `/home/aaron/rtorrent/trunk/rtorrent'
Making all in doc
make[2]: Entering directory `/home/aaron/rtorrent/trunk/rtorrent/doc'
make[2]: Nothing to be done for `all'.
make[2]: Leaving directory `/home/aaron/rtorrent/trunk/rtorrent/doc'
Making all in src
make[2]: Entering directory `/home/aaron/rtorrent/trunk/rtorrent/src'
Making all in core
make[3]: Entering directory `/home/aaron/rtorrent/trunk/rtorrent/src/core'
g++ -DHAVE_CONFIG_H -I. -I../.. -I. -I./.. -I../..    -g -O2 -g -DDEBUG -I/usr/include/sigc++-2.0 -I/usr/lib/sigc++-2.0/include     -I/usr/local/include   -MT curl_socket.o -MD -MP -MF .deps/curl_socket.Tpo -c -o curl_socket.o curl_socket.cc
In file included from /usr/local/include/torrent/peer/peer_info.h:40,
                 from /usr/local/include/torrent/peer/peer.h:42,
                 from /usr/local/include/torrent/download.h:47,
                 from /usr/local/include/torrent/torrent.h:43,
                 from ./../control.h:44,
                 from curl_socket.cc:45:
/usr/local/include/torrent/hash_string.h:47:35: error: torrent/simple_string.h: No such file or directory
In file included from /usr/local/include/torrent/peer/peer_info.h:40,
                 from /usr/local/include/torrent/peer/peer.h:42,
                 from /usr/local/include/torrent/download.h:47,
                 from /usr/local/include/torrent/torrent.h:43,
                 from ./../control.h:44,
                 from curl_socket.cc:45:
/usr/local/include/torrent/hash_string.h:89: error: ‘SimpleString’ does not name a type
/usr/local/include/torrent/hash_string.h:102: error: expected ‘,’ or ‘...’ before ‘&’ token
/usr/local/include/torrent/hash_string.h: In static member function ‘static const torrent::HashString* torrent::HashString::cast_from(int)’:
/usr/local/include/torrent/hash_string.h:102: error: ‘src’ was not declared in this scope
make[3]: *** [curl_socket.o] Error 1
make[3]: Leaving directory `/home/aaron/rtorrent/trunk/rtorrent/src/core'
make[2]: *** [all-recursive] Error 1
make[2]: Leaving directory `/home/aaron/rtorrent/trunk/rtorrent/src'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/home/aaron/rtorrent/trunk/rtorrent'
make: *** [all] Error 2

im not sure what went wrong any help would be much appreciated. 

Submitted by sjau (registered user) on Fri, 2010-01-22 10:42.
Better to ask in the forum and hit me up with a PM when you do so.
Submitted by Anonymous (not registered) on Mon, 2012-02-20 08:30.

Als Is there any way by which my program (c program having inf_hash ) come to know that seeding of torrent against info_hash is started…….??
How to do this ?

 

Any Help would be aapretiated

Submitted by Anonymous (not registered) on Sun, 2010-01-17 16:41.
Looks like ovh.ttdpatch.net is down. Anyone have an alternate location for the patches. I did find magnet-hex-hash.diff in the google cache but none of the others.
Submitted by pconwell (not registered) on Thu, 2010-01-14 22:46.

At step 22 I got: "rtorrent: XMLRPC not supported."

I had to back up to step 18 and do "./configure --with-xmlrpc-c" to fix it.

Submitted by Anonymous (not registered) on Thu, 2009-12-31 19:46.

rtorrent with colors and magnet links support is great.

Thank you for this howto and the developers of rtorrent :)

Submitted by Simon Evans (not registered) on Tue, 2009-12-08 10:09.
That makes my favourite BitTorrent client even better.  Combined with rtGui (an rTorrent web interface), it's just awsome :)
Submitted by Anonymous (not registered) on Mon, 2009-12-07 10:56.

Great guide, thanks. You might want to update the svn checkout to manually specify revision 1105:

 svn co  svn://rakshasa.no/libtorrent/trunk --revision 1105

 as the latest SVN trunk is revision 1110 which will fail to compile.

Submitted by sjau (registered user) on Tue, 2009-12-22 17:56.
I just updated the howto. Added a custom patch that makes it work again in rev 1117 (and possibly older versions).
Submitted by dywany (not registered) on Sun, 2009-12-06 12:40.
Very good post, thanks a lot.
Submitted by dywany (not registered) on Thu, 2012-03-01 00:32.

Indeed, great post :)