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

 

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.

Share this page:

16 Comment(s)