LAPINPT

Build Transmission-Daemon for Windows

Jul 12th, 2013
321
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 7.16 KB | None | 0 0
  1. #!/bin/sh
  2.  
  3. # Build Transmission-Daemon for Windows
  4.  
  5. # Download Cygwin installer http://cygwin.com/setup.exe and install to C:\Cygwin
  6.  
  7. # If you prefer a batch to auto install Cygwin  http://pastebin.com/DrZ6N2wm
  8.  
  9. # Additionally install the following packages:
  10. #   bison
  11. #   flex
  12. #   gettext-devel
  13. #   libtool
  14. #   make
  15. #   gcc-g++ (4)
  16. #   patch
  17. #   pkg-config
  18. #   wget
  19.  
  20. # If you edit this script in windows run this command to modifie newline characters
  21. # dos2unix build-transmission-cygwin.sh
  22.  
  23. # Then to run script in Cygwin Terminal
  24. # ./build-transmission-cygwin.sh
  25.  
  26. ############################################################################################################
  27.  
  28. # SCRIPT START HERE #
  29.  
  30. # TO ENSURE SMOOTH COMPILATION #
  31. export CC='/usr/bin/gcc.exe -I/usr/include'
  32. export CXX=/usr/bin/g++.exe
  33. export CFLAGS='-mtune=pentium-mmx -mthreads -mms-bitfields -O3 -static-libgcc'
  34. export CXXFLAGS='-mtune=pentium-mmx -mthreads -mms-bitfields -O3 -static-libstdc++'
  35. export PATH=/usr/bin:/bin
  36.  
  37. # CREAT WORKING DIR #
  38. mkdir -p ~/source
  39. cd ~/source
  40. rm -rf transmission-win32
  41.  
  42. ############################################################################################################
  43.  
  44. # CHECK IF PACKAGES HAVE ALREADY BEEN DOWNLOADED #
  45. PACK=$(ls -p | grep "/" | cut -c 1 | tr -d '\n')
  46. if [ "$PACK" != "cgillotz" ] ; then
  47.  
  48. # DOWNLOAD PACKAGES AND UNTAR #
  49.   wget -O - http://zlib.net/zlib-1.2.8.tar.gz | tar -zxvf -
  50.   wget -O - http://acelnmp.googlecode.com/files/libiconv-1.14.tar.gz | tar -zxvf -
  51.   wget -O - http://mirrors.nfsi.pt/gnu/gettext/gettext-0.18.2.1.tar.gz | tar -zxvf -
  52.   wget -O - http://ftp.gnome.org/pub/gnome/sources/intltool/0.40/intltool-0.40.6.tar.bz2 | tar -jxvf -
  53.   wget -O - http://www.openssl.org/source/openssl-1.0.1e.tar.gz | tar -zxvf -
  54.   wget -O - http://curl.haxx.se/download/curl-7.29.0.tar.bz2 | tar -jxvf -
  55.   wget -O - http://downloads.sourceforge.net/project/levent/libevent/libevent-2.0/libevent-2.0.21-stable.tar.gz | tar -zxvf -
  56.   wget -O - http://download.transmissionbt.com/files/transmission-2.81.tar.xz | tar -xJf -
  57.   wget -q -P /usr/include/sys ftp://sam.hps.iu.edu/custom/torque-4.1.3/src/resmom/cygwin/quota.h
  58. else
  59.   echo -e '\n\e[01;31mPACKAGES HAVE ALREADY BEEN DOWNLOADED\e[00m\n'
  60. fi
  61.  
  62. ############################################################################################################
  63.  
  64. # COMPILE PACKAGES#
  65.  
  66. # read -p "Press [Enter] to compile ZLIB"
  67. cd ~/source/zlib-1.2.8
  68. ./configure --prefix=/usr --static
  69. make
  70. cp -f zconf.h zlib.h /usr/include
  71. cp -f libz.a /usr/lib
  72.  
  73. # read -p "Press [Enter] to compile LIBICONV"
  74. cd ~/source/libiconv-1.14
  75. ./configure --prefix=/usr --disable-shared
  76. make
  77. make install
  78.  
  79. rm -f /usr/lib/libintl.*
  80.  
  81. # read -p "Press [Enter] to compile GETTEXT"
  82. cd ~/source/gettext-0.18.2.1
  83. ./configure --prefix=/usr --enable-relocatable --disable-shared
  84. cd gettext-runtime
  85. make install
  86.  
  87. # read -p "Press [Enter] to compile INTLTOOL"
  88. cd ~/source/intltool-0.40.6
  89. ./configure --prefix=/usr
  90. make install
  91.  
  92. # read -p "Press [Enter] to compile OPENSSL"
  93. cd ~/source/openssl-1.0.1e
  94. ./Configure -L/usr/lib -lz -lpthread --prefix=/usr threads zlib Cygwin
  95. make
  96. make install
  97.  
  98. # read -p "Press [Enter] to compile CURL"
  99. cd ~/source/curl-7.29.0
  100. ./configure --prefix=/usr --disable-shared
  101. make
  102. make install
  103.  
  104. # read -p "Press [Enter] to compile LIBEVENT"
  105. cd ~/source/libevent-2.0.21-stable
  106. ./configure --prefix=/usr --disable-shared
  107. make
  108. make install
  109.  
  110. # read -p "Press [Enter] to compile TRANSMISSION"
  111. cd ~/source/transmission-2.81
  112. if [ ! -f third-party/libutp/utp.cpp.bak ]; then
  113.   sed -i.bak '/snprintf/ i\\t\textern int snprintf(char *, size_t, const char *, ...);' third-party/libutp/utp.cpp
  114.   sed -i.bak 's/_LINUX/defined(_LINUX_QUOTA_VERSION) \&\& &/' libtransmission/platform-quota.c
  115. fi
  116. ./configure --prefix=/usr --disable-shared --enable-static --without-gtk
  117. make
  118. make install
  119. cd ~/source
  120.  
  121. ############################################################################################################
  122.  
  123. # CREAT TRANSMISSION-WIN32 DIR#
  124.  
  125. # read -p "Press [Enter] to creat transmission-win32 dir"
  126. mkdir -p transmission-win32/app transmission-win32/data
  127.  
  128. # CYGWIN1.DLL #
  129. cp /usr/bin/cygwin1.dll transmission-win32/app
  130.  
  131. # CA-BUNDLE.CRT #
  132. perl curl-7.29.0/lib/mk-ca-bundle.pl
  133. mv ca-bundle.crt transmission-win32/app/
  134. rm certdata.txt
  135.  
  136. # COPY EXEs AND STRIP #
  137. find . -type f -name "transmission*.exe" -exec cp {} transmission-win32/app \;
  138. strip transmission-win32/app/*.exe
  139.  
  140. # COPY RCP #
  141. find -type d -name "web" -exec cp -r {} transmission-win32 \;
  142.  
  143. # GET DATA FILES #
  144. cd transmission-win32
  145. /usr/bin/transmission-daemon -g data -w /cygdrive/d/Downloads -e log.txt -x td.pid
  146. sleep 5
  147. kill -TERM $(cat td.pid)
  148. rm td.pid
  149.  
  150. # CLEANUP #
  151. find . -type f -name "Makefile*" -exec rm -rf {} \;
  152.  
  153. ############################################################################################################
  154.  
  155. # START.BAT #
  156. echo '@ECHO OFF' >> Start.bat
  157. echo 'set CURL_CA_BUNDLE=app\ca-bundle.crt' >> Start.bat
  158. echo 'set TRANSMISSION_WEB_HOME=%cd%\web' >> Start.bat
  159. echo 'app\transmission-daemon.exe -g data -x app/transmission-daemon.pid' >> Start.bat
  160. echo 'EXIT' >> Start.bat
  161.  
  162. # STOP.BAT #
  163. echo '@ECHO OFF' >> Stop.bat
  164. echo 'set /p PID=<app\transmission-daemon.pid' >> Stop.bat
  165. echo 'taskkill /f /pid %PID%' >> Stop.bat
  166. echo 'del app\transmission-daemon.pid' >> Stop.bat
  167. echo 'EXIT' >> Stop.bat
  168.  
  169. ############################################################################################################
  170.  
  171. # CONFIG FILE: data\settings.json #
  172. echo -e '\n\e[01;33mCONFIG FILE:\e[00m  data\settings.json'
  173.  
  174. # DOWNLOAD DIR: /cygdrive/d/Downloads = D:\Downloads #
  175. echo -e '\n\e[01;33mDOWNLOAD DIR:\e[00m  /cygdrive/d/Downloads = D:\Downloads'
  176.  
  177. # RCP: http://localhost:9091/transmission/web/ #
  178. echo -e '\n\e[01;33mWebUI:\e[00m  http://localhost:9091/transmission/web/'
  179.  
  180. # TRANSMISSION GUI:  http://gdriv.es/lapin/transmission/TransmissionRemoteGUI_4.1.7z#
  181. echo -e '\n\e[01;33mTRANSMISSION GUI:\e[00m  http://gdriv.es/lapin/transmission/TransmissionRemoteGUI_4.1.7z'
  182.  
  183. ############################################################################################################
  184.  
  185. # If you get snprintf error with libutp, insert the following line into third-party/libutp/utp.cpp
  186. # just before the line containing snprintf:
  187.  
  188. # extern int snprintf(char *, size_t, const char *, ...);
  189.  
  190. # find . -name "utp.cpp" -print | xargs sed -i.bak '/snprintf/ i\\t\textern int snprintf(char *, size_t, const char *, ...);'
  191.  
  192. ############################################################################################################
  193.  
  194. # Version 2.80 breaks building on Cygwin (libtransmission/platform.c and quotas,
  195. # adding this file https://github.com/adaptivecomputing/torque/blob/master/src/resmom/cygwin/quota.h
  196. # to Cygwins /usr/include/sys solves the problem).
  197.  
  198. ############################################################################################################
  199.  
  200. # Version 2.81 with the above workaround needs a one line patch:
  201. # libtransmission/platform-quota.c
  202. # FIND #elif defined(__sun) || (_LINUX_QUOTA_VERSION < 2)
  203. # REPLACE #elif defined(__sun) || (defined(_LINUX_QUOTA_VERSION) && _LINUX_QUOTA_VERSION < 2)
Advertisement
Add Comment
Please, Sign In to add comment