Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rTorrent: Refactor source code #1014

Draft
wants to merge 4 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions scripts/remove/rtorrent.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ for u in ${users}; do
rm -f /home/${u}/.rtorrent.rc
done

# We need to run our own script to ensure xmlrpc and libtorrent is removed properly. We can't relay on apt remove.
. /etc/swizzin/sources/functions/rtorrent
isdeb=$(dpkg -l | grep rtorrent)
echo_progress_start "Removing old rTorrent binaries and libraries ... "
if [[ -z $isdeb ]]; then
remove_rtorrent_legacy
else
if [[ -n $isdeb ]]; then
remove_rtorrent
fi
remove_rtorrent_legacy
echo_progress_done

for a in rutorrent flood; do
Expand Down
10 changes: 5 additions & 5 deletions scripts/upgrade/rtorrent.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@ if [[ -n $noexec ]]; then
mount -o remount,exec /tmp
noexec=1
fi

# Upgrade script will automatically remove left over binares, we only need to remove apt packages ourselves
isdeb=$(dpkg -l | grep rtorrent)
echo_progress_start "Removing old rTorrent binaries and libraries ... "
if [[ -z $isdeb ]]; then
remove_rtorrent_legacy
else
if [[ -n $isdeb ]]; then
echo_progress_start "Removing old rTorrent binaries and libraries ... "
remove_rtorrent
echo_progress_done
fi
echo_progress_done

echo_progress_start "Checking rTorrent Dependencies ... "
depends_rtorrent
Expand Down
18 changes: 18 additions & 0 deletions sources/build/libudns.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/usr/bin/bash
# libudns Builder

udnslog=$1

source /etc/swizzin/sources/functions/utils
rm_if_exists $udnslog
touch $udnslog

rm_if_exists "/tmp/udns"
git clone -q https://github.com/shadowsocks/libudns /tmp/udns >> $udnslog 2>&1
cd /tmp/udns
./autogen.sh >> $udnslog 2>&1
./configure --prefix=/usr >> $udnslog 2>&1
make CFLAGS="-w -flto -O2 -fPIC" >> $udnslog 2>&1
make -s install >> $udnslog 2>&1
cd /tmp
rm -rf udns*
18 changes: 18 additions & 0 deletions sources/build/mktorrent.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/usr/bin/bash
# mktorrent Builder

mklog=$1

source /etc/swizzin/sources/functions/utils
rm_if_exists $mklog
touch $mklog

cd /tmp
curl -sL https://github.com/Rudde/mktorrent/archive/v1.1.zip -o mktorrent.zip >> $mklog 2>&1
rm_if_exists "/tmp/mktorrent"
unzip -d mktorrent -j mktorrent.zip >> $mklog 2>&1
cd mktorrent
make >> $mklog 2>&1
make install PREFIX=/usr >> $mklog 2>&1
cd /tmp
rm -rf mktorrent*
66 changes: 66 additions & 0 deletions sources/build/prepare_lt_rakshasa.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
#!/usr/bin/bash
# libtorrent rakshasa source file preperation

llog=$1
elog=$2
tpath=$3
version=$4
udns=$5
libtorrentloc="https://github.com/rakshasa/libtorrent/archive/refs/tags/v${version}.tar.gz"

source /etc/swizzin/sources/functions/utils
rm_if_exists $llog
rm_if_exists $elog
rm_if_exists $tpath
touch $llog
touch $elog
mkdir $tpath

# Retreive libtorrent then extract and remove tar.gz file
curl -sL $libtorrentloc -o "$tpath-$version.tar.gz"
tar -xf "$tpath-$version.tar.gz" -C $tpath --strip-components=1 >> $llog 2>&1
rm_if_exists "$tpath-$version.tar.gz"
# Change directory to libtorrent temp path
cd $tpath >> $llog 2>&1
# Look for custom source file patches based on the libtorrent version
if [[ -f /root/libtorrent-rakshasa-$version.patch ]]; then
patch -p1 < /root/libtorrent-rakshasa-$version.patch >> $llog 2>&1 || {
echo "Something went wrong when patching libtorrent-rakshasa" >> $elog 2>&1
rm_if_exists $tpath
exit 1
}
echo "Libtorrent-rakshasa patch found and applied!" >> $llog 2>&1
else
echo "No libtorrent-rakshasa patch found at /root/libtorrent-rakshasa-$version.patch" >> $llog 2>&1
fi
# Apply source file patches based on the libtorrent version
case $version in
0.13.6)
patch -p1 < /etc/swizzin/sources/patches/rtorrent/openssl.patch >> $llog 2>&1
if pkg-config --atleast-version=1.14 cppunit; then
patch -p1 < /etc/swizzin/sources/patches/rtorrent/cppunit-libtorrent.patch >> $llog 2>&1
fi
patch -p1 < /etc/swizzin/sources/patches/rtorrent/bencode-libtorrent.patch >> $llog 2>&1
patch -p1 < /etc/swizzin/sources/patches/rtorrent/throttle-fix-0.13.6.patch >> $llog 2>&1
;;

0.13.7)
patch -p1 < /etc/swizzin/sources/patches/rtorrent/throttle-fix-0.13.7-8.patch >> $llog 2>&1
patch -p1 < /etc/swizzin/sources/patches/rtorrent/openssl.patch >> $llog 2>&1
;;

0.13.8)
if [[ $udns == "true" ]]; then
patch -p1 < /etc/swizzin/sources/patches/rtorrent/libtorrent-udns-0.13.8.patch >> $llog 2>&1
patch -p1 < /etc/swizzin/sources/patches/rtorrent/libtorrent-scanf-0.13.8.patch >> $llog 2>&1
fi
patch -p1 < /etc/swizzin/sources/patches/rtorrent/throttle-fix-0.13.7-8.patch >> $llog 2>&1
;;
esac
# Generate source files for compile
./autogen.sh >> $llog 2>&1
# Whipe any existing libtorrent binaries
./configure --prefix=/usr >> $llog 2>&1
make uninstall >> $llog 2>&1
# Echo PASSED to elog if we make it this far
echo "PASSED" >> $elog 2>&1
52 changes: 52 additions & 0 deletions sources/build/prepare_rtorrent.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#!/usr/bin/bash
# rtorrent source file preperation

rlog=$1
elog=$2
tpath=$3
version=$4
udns=$5
rtorrentloc="https://github.com/rakshasa/rtorrent/archive/refs/tags/v$version.tar.gz"

source /etc/swizzin/sources/functions/utils
rm_if_exists $rlog
rm_if_exists $elog
rm_if_exists $tpath
touch $rlog
touch $elog
mkdir $tpath

curl -sL $rtorrentloc -o "$tpath-$version.tar.gz"
tar -xf "$tpath-$version.tar.gz" -C $tpath --strip-components=1 >> $rlog 2>&1
rm_if_exists "$tpath-$version.tar.gz"

cd $tpath >> $rlog 2>&1
# Look for custom source file patches based on the rtorrent version
if [[ -f /root/rtorrent-$version.patch ]]; then
patch -p1 < /root/rtorrent-$version.patch >> $rlog 2>&1 || {
echo "Something went wrong when patching rTorrent" >> $elog 2>&1
rm_if_exists $tpath
exit 1
}
echo "rTorrent patch found and applied!" >> $rlog 2>&1
else
echo "No rTorrent patch found at /root/rtorrent-$version.patch" >> $rlog 2>&1
fi
# Apply tracker scape patch for rTorrent if udns is enabled
if [[ $udns == "true" ]]; then
patch -p1 < /etc/swizzin/sources/patches/rtorrent/rtorrent-scrape-0.9.8.patch >> $rlog 2>&1
fi
# Apply lockfile-fix to all rtorrents
patch -p1 < /etc/swizzin/sources/patches/rtorrent/lockfile-fix.patch >> $rlog 2>&1
# Apply xmlrpc-fix to all rtorrents
patch -p1 < /etc/swizzin/sources/patches/rtorrent/xmlrpc-fix.patch >> $rlog 2>&1
# Use pkgconfig for cppunit if 0.9.6
if [[ $version == "0.9.6" ]]; then
patch -p1 < /etc/swizzin/sources/patches/rtorrent/rtorrent-0.9.6.patch >> $rlog 2>&1
fi
# Generate source files for compile
./autogen.sh >> $rlog 2>&1
# Remove any existing rtorrent binaries
rm -rf /usr/bin/rtorrent >> $rlog 2>&1
# Echo PASSED to elog if we make it this far
echo "PASSED" >> $elog 2>&1
25 changes: 25 additions & 0 deletions sources/build/prepare_xmlrpc.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/usr/bin/bash
# xmlrpc-c source file preperation

xlog=$1
tpath=$2
XMLRPC_REV=2954

source /etc/swizzin/sources/functions/utils
rm_if_exists $xlog
rm_if_exists $tpath
touch $xlog
mkdir $tpath

# Retreive xmlrpc source code
svn co http://svn.code.sf.net/p/xmlrpc-c/code/advanced@$XMLRPC_REV $tpath >> $xlog 2>&1 || {
svn co https://github.com/mirror/xmlrpc-c/trunk/advanced@$XMLRPC_REV $tpath >> $xlog 2>&1
}
# Change directory to xmlrpc temp path
cd $tpath >> $xlog 2>&1
# Patch latest CPU architectures, so configure works properly on ARM64
cp -rf /etc/swizzin/sources/patches/rtorrent/xmlrpc-config.guess config.guess >> $xlog 2>&1
cp -rf /etc/swizzin/sources/patches/rtorrent/xmlrpc-config.sub config.sub >> $xlog 2>&1
# Whipe any existing xmlrpc binaries
./configure >> $xlog 2>&1
make uninstall >> $xlog 2>&1