#!/bin/sh echo "Don't forget to update this script with the change-log! Don't forget to uncomment the libtorrent and libxmlrpc library installation part! Press ENTER to start..." read NAME="rtorrent" VERSION="0.8.6" SOURCE="http://libtorrent.rakshasa.no/downloads/rtorrent-$VERSION.tar.gz" CONFIGURE="--prefix=/usr/local --disable-debug --with-xmlrpc-c" DATE=`date '+%Y/%m/%d'` export CFLAGS="-march=i486 -mtune=i686 -Os -pipe" export CXXFLAGS="-march=i486 -mtune=i686 -Os -pipe" export LDFLAGS="-Wl,-O1" echo "Downloading essential packages..." tce-load -wi compiletc squashfs-tools-4.x ncurses ncurses-dev curl curl-dev openssl-0.9.8 libsigc++ cd /tmp/ # Uncomment the one you would like to use: # # Install libtorrent and libxmlrpc from the repo: #tce-load -wi libtorrent-dev.tcz libxmlrpc-dev.tcz # # Install libtorrent and libxmlrpc from /tmp/ local directory (if you have just built these packages) #tce-load -i libtorrent-dev.tcz libxmlrpc-dev.tcz wget $SOURCE sudo rm -rf $NAME-$VERSION 2>/dev/null sudo rm /tmp/$NAME.tcz /tmp/$NAME.tcz.list /tmp/$NAME.tcz.md5.txt /tmp/$NAME.tcz.dep 2>/dev/null sudo rm -rf /tmp/$NAME 2>/dev/null sudo rm /tmp/$NAME-doc.tcz /tmp/$NAME-doc.tcz.list /tmp/$NAME-doc.tcz.md5.txt /tmp/$NAME-doc.tcz.dep 2>/dev/null sudo rm -rf /tmp/$NAME-doc 2>/dev/null tar xvfz $NAME-$VERSION.tar.gz cd $NAME-$VERSION wget http://ovh.ttdpatch.net/~jdrexler/rt/old/equal-operator.diff wget http://aur.archlinux.org/packages/rtorrent-color/rtorrent-color/rtorrent-0.8.6-canvas-fix.patch ################################ echo " Check source BEFORE equal-operator patch: (grep should NOT find any matches): " grep -c "apply_equal" ./src/command_ui.cc echo "Press ENTER to continue..." read patch -Np1 -i equal-operator.diff echo " Check source AFTER equal-operator patch: (grep should find 2 matches): " grep -c "apply_equal" ./src/command_ui.cc echo "Press ENTER to continue..." read ################################ echo " Check source BEFORE canvas patch: (grep should NOT find any matches): " grep -c "get_done_fg_color" ./src/ui/root.h grep -c "window_download_list.h" ./src/ui/root.cc grep -c "current_window_list();" ./src/ui/download_list.h grep -c "window() { return m_window; }" ./src/ui/element_download_list.h grep -c "DownloadList::current_window_list()" ./src/ui/download_list.cc grep -c "done_fg_color" ./src/command_network.cc grep -c "start_color()" ./src/display/canvas.cc echo "Press ENTER to continue..." read patch -Np1 -i rtorrent-0.8.6-canvas-fix.patch echo " Check source AFTER canvas patch: (grep should find 7 matches): " grep -c "get_done_fg_color" ./src/ui/root.h grep -c "window_download_list.h" ./src/ui/root.cc grep -c "current_window_list();" ./src/ui/download_list.h grep -c "window() { return m_window; }" ./src/ui/element_download_list.h grep -c "DownloadList::current_window_list()" ./src/ui/download_list.cc grep -c "done_fg_color" ./src/command_network.cc grep -c "start_color()" ./src/display/canvas.cc echo "Press ENTER to continue..." read ################################ echo " Starting ./configure $CONFIGURE" ./configure $CONFIGURE echo "Press ENTER to continue... " read make -j3 echo " Starting make install to: /tmp/$NAME" sudo make DESTDIR=/tmp/$NAME install-strip cd /tmp/$NAME sudo find . | xargs file | grep "executable" | grep ELF | grep "not stripped" | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null sudo find . | xargs file | grep "shared object" | grep ELF | grep "not stripped" | cut -f 1 -d : | xargs strip -g 2> /dev/null sudo mkdir -p /tmp/$NAME/usr/local/etc/ sudo echo "# Maximum and minimum number of peers to connect to per torrent. #min_peers = 40 max_peers = 75 # Same as above but for seeding completed torrents (-1 = same as downloading) #min_peers_seed = 10 max_peers_seed = 50 # Maximum number of simultanious uploads per torrent. max_uploads = 8 # Global upload and download rate in KiB. \"0\" for unlimited. download_rate = 0 upload_rate = 0 # Default directory to save the downloaded torrents. directory = /home/tc/torrents/ # Default session directory. Make sure you don't run multiple instance # of rtorrent using the same session directory. Perhaps using a relative path? session = /home/tc/.session/ # Color / Canvas patch done_fg_color = 2 #done_bg_color = 2 active_fg_color = 1 #active_bg_color = 4 # The rtorrent doesn't list the active tab properly by default. Add this fix: schedule = filter_active,30,30,\"view_filter = active,\\\"or={d.get_up_rate=,d.get_down_rate=}\\\"\" # Close torrents when diskspace is low. schedule = low_diskspace,5,60,close_low_diskspace=100M # Max number of files to keep open simultaniously. #max_open_files = 128 # Number of sockets to simultaneously keep open. #max_open_sockets = # IP and Port range to use for listening. #ip = 127.0.0.1 port_range = 49164-49164 # Alternative calls to bind and ip that should handle dynamic ip's. #schedule = ip_tick,0,1800,ip=rakshasa #schedule = bind_tick,0,1800,bind=rakshasa # Start opening ports at a random position within the port range. #port_random = no # Example of scheduling commands: Switch between two ip's every 5 seconds. #schedule = \"ip_tick1,5,10,ip=torretta\" #schedule = \"ip_tick2,10,10,ip=lampedusa\" # Remove a scheduled event. #schedule_remove = \"ip_tick1\" # If you want to use rtorrent with some web GUI's such as rutorrent you need to add the following to you config: #scgi_port = localhost:5000 # Set whetever the client should try to connect to UDP trackers. #use_udp_trackers = yes # Check hash for finished torrents. Might be usefull until the bug is # fixed that causes lack of diskspace not to be properly reported. check_hash = yes # Hash read-ahead controls how many MB to request the kernel to read # ahead. If the value is too low the disk may not be fully utilized, # while if too high the kernel might not be able to keep the read # pages in memory thus end up trashing. #hash_read_ahead = 10 # Interval between attempts to check the hash, in milliseconds. #hash_interval = 100 # Number of attempts to check the hash while using the mincore status, # before forcing. Overworked systems might need lower values to get a # decent hash checking rate. #hash_max_tries = 10 # Stop torrents when reaching upload ratio in percent, # when also reaching total upload in bytes, or when # reaching final upload ratio in percent. # example: stop at ratio 2.0 with at least 200 MB uploaded, or else ratio 20.0 #schedule = ratio,60,60,stop_on_ratio=200,200M,2000 # Encryption options, set to none (default) or any combination of the following: # allow_incoming, try_outgoing, require, require_RC4, enable_retry, prefer_plaintext # # The example value allows incoming encrypted connections, starts unencrypted # outgoing connections but retries with encryption if they fail, preferring # plaintext to RC4 encryption after the encrypted handshake # # encryption = allow_incoming,enable_retry,prefer_plaintext encryption = allow_incoming,try_outgoing,enable_retry # Enable DHT support for trackerless torrents or when all trackers are down. # May be set to \"disable\" (completely disable DHT), \"off\" (do not start DHT), # \"auto\" (start and stop DHT as needed), or \"on\" (start DHT immediately). # The default is \"off\". For DHT to work, a session directory must be defined. #dht = auto # UDP port to use for DHT. #dht_port = 6881 # Enable peer exchange (for torrents not marked private) #peer_exchange = yes # location where new torrent data is placed, and where you should place your # 'complete' data before you place your *.torrent file into the watch folder directory = /home/tc/torrents/incomplete # Watch directory_1 #schedule = watch_directory_1,5,5,\"load_start=/home/tc/torrents/watch/*.torrent,d.set_custom1=/home/tc/torrents/complete\" #system.method.insert=checkdirs1,simple,\"not=\\\"\$equal={d.get_custom1=,d.get_base_path=}\\\"\" #system.method.insert=movecheck1,simple,\"and={checkdirs1=,d.get_complete=,d.get_custom1=}\" #system.method.insert=movedir1,simple,\"d.set_directory=$d.get_custom1=;execute=mv,-u,$d.get_base_path=,$d.get_custom1=;d.set_custom1=;d.stop=;d.start=\" #system.method.set_key=event.download.hash_done,move_hashed1,\"branch={$movecheck1=,movedir1=}\" # Watch directory_2 #schedule = watch_directory_2,5,5,\"load_start=/home/tc/torrents/watch/iso/*.torrent,d.set_custom2=/home/tc/torrents/complete/iso\" #system.method.insert=checkdirs2,simple,\"not=\\\"\$equal={d.get_custom2=,d.get_base_path=}\\\"\" #system.method.insert=movecheck2,simple,\"and={checkdirs2=,d.get_complete=,d.get_custom2=}\" #system.method.insert=movedir2,simple,\"d.set_directory=$d.get_custom2=;execute=mv,-u,$d.get_base_path=,$d.get_custom2=;d.set_custom2=;d.stop=;d.start=\" #system.method.set_key=event.download.hash_done,move_hashed2,\"branch={$movecheck2=,movedir2=}\" # Watch directory_3 #schedule = watch_directory_3,5,5,\"load_start=/home/tc/torrents/watch/music/*.torrent,d.set_custom3=/home/tc/torrents/complete/music\" #system.method.insert=checkdirs3,simple,\"not=\\\"\$equal={d.get_custom3=,d.get_base_path=}\\\"\" #system.method.insert=movecheck3,simple,\"and={checkdirs3=,d.get_complete=,d.get_custom3=}\" #system.method.insert=movedir3,simple,\"d.set_directory=$d.get_custom3=;execute=mv,-u,$d.get_base_path=,$d.get_custom3=;d.set_custom3=;d.stop=;d.start=\" #system.method.set_key=event.download.hash_done,move_hashed3,\"branch={$movecheck3=,movedir3=}\" # schedule a timer event named 'watch_directory_1': # 1) triggers 10 seconds after rtorrent starts # 2) triggers at 10 second intervals thereafter # 3) Upon trigger, attempt to load (and start) new *.torrent files found in /home/tc/torrents/watch/ # 4) set a variable named 'custom1' with the value \"/home/tc/torrents/complete\" # NOTE: if you don't want it to automatically start the torrent, change 'load_start' to 'load' #schedule = watch_directory_1,10,10,\"load_start=/home/tc/torrents/watch/*.torrent,d.set_custom1=/home/tc/torrents/complete\" # insert a method with the alias 'checkdirs1' # 1) returns true if the current path of the torrent data is not equal to the value of custom1 # 2) otherwise, returns false #system.method.insert=checkdirs1,simple,\"not=\\\"\$equal={d.get_custom1=,d.get_base_path=}\\\"\" # insert a method with the alias 'movecheck1' # 1) returns true if all 3 commands return true ('result of checkdirs1' && 'torrent is 100% done', 'custom1 variable is set') # 2) otherwise, returns false #system.method.insert=movecheck1,simple,\"and={checkdirs1=,d.get_complete=,d.get_custom1=}\" # insert a method with the alias 'movedir1' # (a series of commands, separated by ';') # 1) \"set path of torrent to equal the value of custom1\"; # 2) \"mv -u \"; # 3) \"clear custom1\", \"stop the torrent\",\"resume the torrent\" # 4) stop the torrent # 5) start the torrent (to get the torrent to update the 'base path') #system.method.insert=movedir1,simple,\"d.set_directory=$d.get_custom1=;execute=mv,-u,$d.get_base_path=,$d.get_custom1=;d.set_custom1=;d.stop=;d.start=\" # set a key with the name 'move_hashed1' that is triggered by the hash_done event. # 1) When hashing of a torrent completes, this custom key will be triggered. # 2) when triggered, execute the 'movecheck1' method and check the return value. # 3) if the 'movecheck' method returns 'true', execute the 'movedir1' method we inserted above. # NOTE: 'branch' is an 'if' conditional statement: if(movecheck1){movedir1} #system.method.set_key=event.download.hash_done,move_hashed1,\"branch={$movecheck1=,movedir1=}\" # Watch a directory for new torrents, and stop those that have been deleted. #schedule = watch_directory,5,5,load_start=./watch/*.torrent #schedule = untied_directory,5,5,stop_untied= #schedule = watch_directory,5,5,load_start=/home/tc/watch/*.torrent #schedule = untied_directory,5,5,stop_untied= #schedule = tied_directory,5,5,start_tied=" > /tmp/rtorrent.rc sudo mv /tmp/rtorrent.rc /tmp/$NAME/usr/local/etc/.rtorrent.rc mkdir -p /tmp/$NAME-doc/usr/local/share cd /tmp/$NAME/usr/local/share sudo mv man /tmp/$NAME-doc/usr/local/share/ echo "Creating package..." cd /tmp/ sudo mksquashfs $NAME $NAME.tcz sudo md5sum $NAME.tcz > $NAME.tcz.md5.txt cd $NAME sudo find usr -not -type d > ../$NAME.tcz.list cd /tmp/ SIZE="`du -k $NAME.tcz|cut -f1`k" sudo echo "Title: $NAME.tcz Description: rTorrent + patches Version: $VERSION Author: Jari Sundell Original-site: http://libtorrent.rakshasa.no/ Copying-policy: GPL Size: $SIZE Extension_by: andriscom Comments: LibTorrent is a BitTorrent library written in C++ for *nix, with a focus on high performance and good code. The library differentiates itself from other implementations by transfering directly from file pages to the network stack. On high-bandwidth connections it is able to seed at 3 times the speed of the official client. The client uses ncurses and is ideal for use with screen or dtach. It supports saving of sessions and allows the user to add and remove torrents. The following patches were applied: Colored user interface patch: http://aur.archlinux.org/packages/rtorrent-color/rtorrent-color/rtorrent-0.8.6-canvas-fix.patch Equal operator patch: (needed for automatically Move Completed Torrent Data to 'Completed' Folders) http://ovh.ttdpatch.net/~jdrexler/rt/old/equal-operator.diff Built with CFLAGS: -march=i486 -mtune=i686 -Os -pipe Built with CXXFLAGS: -march=i486 -mtune=i686 -Os -pipe Built with LDFLAGS: -Wl,-O1 Built with the following options: ./configure $CONFIGURE You should move the /usr/local/etc/.rtorrent.rc config file to your home directory! Check the configuration and create the proper directories! (/home/tc/.session for example) If you would like to use a good WebUI: Download ruTorrent via svn: cd /usr/local/var/www/ svn co http://rutorrent.googlecode.com/svn/trunk/rutorrent cd /usr/local/var/www/rutorrent/ rmdir plugins svn co http://rutorrent.googlecode.com/svn/trunk/plugins/ Uncomment line: scgi_port = localhost:5000 in ~/.rtorrent.rc Configure your webserver to connect rTorrent via SCGI on port: 5000. http://code.google.com/p/rutorrent/wiki/WebSERVER For man entries you can install the rtorrent-doc.tcz package or visit: http://libtorrent.rakshasa.no/rtorrent/rtorrent.1.htm Source: $SOURCE Change-log: 2010/09/28 First version (0.8.6) $DATE Version: $VERSION - Added: CFLAGS, CXXFLAGS, LDFLAGS, canvas-fix.patch, equal-operator.patch Current: $DATE Version: $VERSION - Added: CFLAGS, CXXFLAGS, LDFLAGS, canvas-fix.patch, equal-operator.patch " > $NAME.tcz.info sudo echo "ncurses.tcz curl.tcz openssl-0.9.8.tcz libsigc++.tcz libtorrent.tcz libxmlrpc.tcz " > $NAME.tcz.dep echo "Creating package..." cd /tmp/ sudo mksquashfs $NAME-doc $NAME-doc.tcz sudo md5sum $NAME-doc.tcz > $NAME-doc.tcz.md5.txt cd $NAME-doc sudo find usr -not -type d > ../$NAME-doc.tcz.list cd /tmp/ SIZE="`du -k $NAME-doc.tcz|cut -f1`k" sudo echo "Title: $NAME-doc.tcz Description: rTorrent man pages Version: $VERSION Author: Jari Sundell Original-site: http://libtorrent.rakshasa.no/ Copying-policy: GPL Size: $SIZE Extension_by: andriscom Comments: Manual entry files for rTorrent $VERSION. Source: $SOURCE Change-log: 2010/09/28 First version (0.8.6) $DATE Version: $VERSION Current: $DATE Version: $VERSION " > $NAME-doc.tcz.info cd /tmp/ mkdir packages 2>/dev/null sudo rm packages/$NAME.tar.gz 2>/dev/null sudo rm packages/$NAME-doc.tar.gz 2>/dev/null tar zcf packages/$NAME.tar.gz $NAME.tcz* tar zcf packages/$NAME-doc.tar.gz $NAME-doc.tcz* echo " Run bcrypt on /tmp/packages/*.tar.gz... give password: tinycore" echo "Run the extension_audit.sh and reboot a clean system to try the packages!" echo "Send it to: tcesubmit@gmail.com"