diff --git a/scripts/remove/rtorrent.sh b/scripts/remove/rtorrent.sh index 5e715cd3c..f2d3e2461 100755 --- a/scripts/remove/rtorrent.sh +++ b/scripts/remove/rtorrent.sh @@ -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 diff --git a/scripts/upgrade/rtorrent.sh b/scripts/upgrade/rtorrent.sh index 672f7f3b0..e950fc0f0 100755 --- a/scripts/upgrade/rtorrent.sh +++ b/scripts/upgrade/rtorrent.sh @@ -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 diff --git a/sources/build/prepare_lt_rakshasa.sh b/sources/build/prepare_lt_rakshasa.sh index 72cc60cdd..81055cfc3 100644 --- a/sources/build/prepare_lt_rakshasa.sh +++ b/sources/build/prepare_lt_rakshasa.sh @@ -16,12 +16,12 @@ 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 || { @@ -33,7 +33,6 @@ if [[ -f /root/libtorrent-rakshasa-$version.patch ]]; then 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) @@ -58,9 +57,10 @@ case $version in 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 diff --git a/sources/build/prepare_rtorrent.sh b/sources/build/prepare_rtorrent.sh index 778237319..e2882fbc3 100644 --- a/sources/build/prepare_rtorrent.sh +++ b/sources/build/prepare_rtorrent.sh @@ -44,9 +44,9 @@ patch -p1 < /etc/swizzin/sources/patches/rtorrent/xmlrpc-fix.patch >> $rlog 2>&1 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 diff --git a/sources/build/prepare_xmlrpc.sh b/sources/build/prepare_xmlrpc.sh index b1f3caff5..11960ba2c 100644 --- a/sources/build/prepare_xmlrpc.sh +++ b/sources/build/prepare_xmlrpc.sh @@ -11,10 +11,15 @@ 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 diff --git a/sources/functions/rtorrent b/sources/functions/rtorrent index 21e5b550b..52b867d90 100644 --- a/sources/functions/rtorrent +++ b/sources/functions/rtorrent @@ -118,20 +118,25 @@ function build_deps_rtorrent() { } function sources_rtorrent() { echo_info "Preparing source files" - # Prepare xmlrpc source files + # Create logging and temp paths for xmlrpc, libtorrent and rtorrent + rt_create_source_paths + # Prepare xmlrpc, libtorrent and rtorrent source files + bash "/etc/swizzin/sources/build/prepare_xmlrpc.sh" $xlog $xpath & + bash "/etc/swizzin/sources/build/prepare_lt_rakshasa.sh" $llog $lelog $lpath $libtorrentver $libudns & + bash "/etc/swizzin/sources/build/prepare_rtorrent.sh" $rlog $relog $rpath $rtorrentver $libudns & +} +function rt_create_source_paths() { + # XMLRPC-C xlog="/root/logs/xmlrpc.log" xpath="/tmp/xmlrpc-c" - bash "/etc/swizzin/sources/build/prepare_xmlrpc.sh" $xlog $xpath & - # Prepare libtorrent source files + # Libtorrent llog="/root/logs/lt_rakshasa.log" lelog="/root/logs/lt_rkshasa_errors.log" lpath="/tmp/libtorrent" - bash "/etc/swizzin/sources/build/prepare_lt_rakshasa.sh" $llog $lelog $lpath $libtorrentver $libudns & - # Prepare rtorrent source files + # rTorrent rlog="/root/logs/rtorrent.log" relog="/root/logs/rtorrent_errors.log" rpath="/tmp/rtorrent" - bash "/etc/swizzin/sources/build/prepare_rtorrent.sh" $rlog $relog $rpath $rtorrentver $libudns & } function log_deps_rtorrent() { # Append output to swizzin log file and remove log files @@ -142,9 +147,13 @@ function log_deps_rtorrent() { rt_log_append "xmlrc" $xlog "prepare" rt_log_append "libtorrent" $llog "prepare" rt_log_append "rtorrent" $rlog "prepare" - # Check for errors, remove error files and exit script on error + # Check for errors, remove error files rt_error_check $lelog rt_error_check $relog + # Exit script if error is found when checking + if [[ $rtinstallerror == "true" ]]; then + exit 1 + fi } function rt_log_append() { local binary=$1 @@ -158,18 +167,18 @@ function rt_log_append() { } function rt_error_check() { local file=$1 + rtinstallerror="false" . /etc/swizzin/sources/functions/utils if [[ $(grep -c "PASSED" $file) -lt 1 ]]; then local error=$(cat $file) echo_error $error - rm_if_exists $file - exit 1 + rtinstallerror="true" fi rm_if_exists $file } function build_xmlrpc-c() { - cd "/tmp/xmlrpc-c" + cd $xpath ./configure --prefix=/usr --disable-cplusplus --disable-wininet-client --disable-libwww-client >> $log 2>&1 || { echo_error "Something went wrong while configuring xmlrpc" exit 1 @@ -184,14 +193,13 @@ function build_xmlrpc-c() { mkdir -p /root/dist fpm -f -C /tmp/dist/xmlrpc-c -p /root/dist/xmlrpc-c_VERSION.deb -s dir -t deb -n xmlrpc-c --version ${VERSION} --description "xmlrpc-c compiled by swizzin" > /dev/null 2>&1 dpkg -i /root/dist/xmlrpc-c_${VERSION}.deb >> $log 2>&1 - cd /tmp - rm -rf xmlrpc-c + rm -rf $xpath rm -rf /tmp/dist/xmlrpc-c } function build_libtorrent_rakshasa() { VERSION=$libtorrentver - cd "/tmp/libtorrent" + cd $lpath ./configure --prefix=/usr >> $log 2>&1 || { echo_error "Something went wrong while configuring libtorrent" exit 1 @@ -205,13 +213,12 @@ function build_libtorrent_rakshasa() { mkdir -p /root/dist fpm -f -C /tmp/dist/libtorrent-rakshasa -p /root/dist/libtorrent-rakshasa_VERSION.deb -s dir -t deb -n libtorrent-rakshasa --version ${VERSION} --description "libtorrent-rakshasa compiled by swizzin" > /dev/null 2>&1 dpkg -i /root/dist/libtorrent-rakshasa_${VERSION}.deb >> $log 2>&1 - cd /tmp rm -rf /tmp/dist/libtorrent-rakshasa - rm -rf libtorrent* + rm -rf $lpath } function build_rtorrent() { - cd "/tmp/rtorrent" + cd $rpath VERSION=$rtorrentver stdc= if [[ ${rtorrentver} == "0.9.6" ]]; then @@ -230,9 +237,8 @@ function build_rtorrent() { mkdir -p /root/dist fpm -f -C /tmp/dist/rtorrent -p /root/dist/rtorrent_VERSION.deb -s dir -t deb -n rtorrent --version ${VERSION} --description "rtorrent compiled by swizzin" > /dev/null 2>&1 dpkg -i /root/dist/rtorrent_${VERSION}.deb >> $log 2>&1 - cd "/tmp" ldconfig >> $log 2>&1 - rm -rf rtorrent* >> $log 2>&1 + rm -rf $rpath >> $log 2>&1 rm -rf /tmp/dist/rtorrent rm_if_exists /root/dist rm_if_exists /tmp/dist @@ -249,20 +255,22 @@ function remove_rtorrent() { if [[ -n $repo ]]; then toclean+=($repo) fi - for c in ${toclean[@]}; do - # TODO add option to pass extra flags - apt-get remove -y -q --allow-change-held-packages $c >> $log 2>&1 - done + apt_remove --purge $toclean } function remove_rtorrent_legacy() { - rm -rf /usr/bin/rtorrent - cd /tmp - git clone https://github.com/rakshasa/libtorrent.git libtorrent >> /dev/null 2>&1 - cd libtorrent - ./autogen.sh >> $log 2>&1 - ./configure --prefix=/usr >> $log 2>&1 - make uninstall >> $log 2>&1 - cd - - rm -rf /tmp/libtorrent + # Create logging and temp paths for xmlrpc and libtorrent + rt_create_source_paths + # Run prepare script to remove xmlrpc and libtorrent using make uninstall + bash "/etc/swizzin/sources/build/prepare_xmlrpc.sh" $xlog $xpath & + bash "/etc/swizzin/sources/build/prepare_lt_rakshasa.sh" $llog "/dev/null" $lpath "0.13.8" "false" & + # Remove rtorrent from the bin file + rm -rf /usr/bin/rtorrent >> $log 2>&1 + # Wait for make uninstall to complete + wait + # Log our actions and remove temp files + rt_log_append "xmlrc" $xlog "remove" + rt_log_append "libtorrent" $llog "remove" + rm_if_exists $xpath + rm_if_exists $lpath }