#!/bin/sh echo "Don't forget to update this script with the change-log! Press ENTER to start..." read NAME="libtorrent" VERSION="0.12.6" SOURCE="http://libtorrent.rakshasa.no/downloads/libtorrent-$VERSION.tar.gz" CONFIGURE="--prefix=/usr/local --disable-debug" 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 openssl-0.9.8-dev libsigc++ cd /tmp/ 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 tar xvfz $NAME-$VERSION.tar.gz cd $NAME-$VERSION # http://www.ha-obsession.net/2010/02/rtorrent-patch-almost-linear.html echo "--- libtorrent-0.12.5/src/download/chunk_selector.cc 2009-05-13 15:10:13.000000000 +0200 +++ libtorrent-0.12.5.new/src/download/chunk_selector.cc 2009-12-22 16:38:50.000000000 +0100 @@ -79,13 +79,14 @@ m_sharedQueue.clear(); if (m_position == invalid_chunk) - m_position = random() % size(); + m_position = (random() % size()) / 10; advance_position(); } uint32_t ChunkSelector::find(PeerChunks* pc, __UNUSED bool highPriority) { + int tmp; // This needs to be re-enabled. if (m_position == invalid_chunk) return invalid_chunk; @@ -100,8 +101,28 @@ // Randomize position on average every 16 chunks to prevent // inefficient distribution with a slow seed and fast peers // all arriving at the same position. - if ((random() & 63) == 0) { - m_position = random() % size(); + + if ((random() & 31) == 0) { + + tmp = random(); + switch( tmp % 7 ) { + case 0: + case 1: + case 2: + case 3: + case 4: + m_position = 0; + break; + case 6: + m_position = size() - 20; + if (m_position > 0) { + break; + } + default: + m_position = tmp % size(); + break; + } + queue->clear(); } " > libtorrent-0.12.5-almost-linear-downloading.patch ################################ echo " Check source BEFORE almost-linear-downloading patch: (grep should NOT find any matches): " grep -c "int tmp;" ./src/download/chunk_selector.cc echo "Press ENTER to continue..." read patch -Np1 -i libtorrent-0.12.5-almost-linear-downloading.patch echo " Check source AFTER almost-linear-downloading patch: (grep should find 1 match): " grep -c "int tmp;" ./src/download/chunk_selector.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 cd /tmp/ sudo mv $NAME $NAME-dev mkdir -p /tmp/$NAME/usr/local/lib cd /tmp/$NAME-dev/usr/local/lib sudo mv *.so* /tmp/$NAME/usr/local/lib/ sudo mv *.la* /tmp/$NAME/usr/local/lib/ 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: libTorrent + patch 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 following patch was applied: http://www.ha-obsession.net/2010/02/rtorrent-patch-almost-linear.html 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 Source: $SOURCE Change-log: 2010/09/28 First version (0.12.6) $DATE Version: $VERSION - Added: CFLAGS, CXXFLAGS, LDFLAGS, file preallocation with posix-fallocate, almost-linear-downloading.patch Current: $DATE Version: $VERSION - Added: CFLAGS, CXXFLAGS, LDFLAGS, file preallocation with posix-fallocate, almost-linear-downloading.patch " > $NAME.tcz.info sudo echo "openssl-0.9.8.tcz libsigc++.tcz " > $NAME.tcz.dep echo "Creating package..." cd /tmp/ sudo mksquashfs $NAME-dev $NAME-dev.tcz sudo md5sum $NAME-dev.tcz > $NAME-dev.tcz.md5.txt cd $NAME-dev sudo find usr -not -type d > ../$NAME-dev.tcz.list cd /tmp/ SIZE="`du -k $NAME-dev.tcz|cut -f1`k" sudo echo "Title: $NAME-dev.tcz Description: libTorrent dev files 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 following patch was applied: http://www.ha-obsession.net/2010/02/rtorrent-patch-almost-linear.html 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 Source: $SOURCE Change-log: 2010/09/28 First version (0.12.6) $DATE Version: $VERSION - Added: CFLAGS, CXXFLAGS, LDFLAGS, almost-linear-downloading.patch Current: $DATE Version: $VERSION - Added: CFLAGS, CXXFLAGS, LDFLAGS, almost-linear-downloading.patch " > $NAME-dev.tcz.info sudo echo "$NAME.tcz " > $NAME-dev.tcz.dep cd /tmp/ mkdir packages 2>/dev/null sudo rm packages/$NAME.tar.gz 2>/dev/null sudo rm packages/$NAME-dev.tar.gz 2>/dev/null tar zcf packages/$NAME.tar.gz $NAME.tcz* tar zcf packages/$NAME-dev.tar.gz $NAME-dev.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"