Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/sh
- # Build Transmission-Daemon for Windows
- # Download Cygwin installer http://cygwin.com/setup.exe and install to C:\Cygwin
- # If you prefer a batch to auto install Cygwin http://pastebin.com/DrZ6N2wm
- # Additionally install the following packages:
- # bison
- # flex
- # gettext-devel
- # libtool
- # make
- # gcc-g++ (4)
- # patch
- # pkg-config
- # wget
- # If you edit this script in windows run this command to modifie newline characters
- # dos2unix build-transmission-cygwin.sh
- # Then to run script in Cygwin Terminal
- # ./build-transmission-cygwin.sh
- ############################################################################################################
- # SCRIPT START HERE #
- # TO ENSURE SMOOTH COMPILATION #
- export CC='/usr/bin/gcc.exe -I/usr/include'
- export CXX=/usr/bin/g++.exe
- export CFLAGS='-mtune=pentium-mmx -mthreads -mms-bitfields -O3 -static-libgcc'
- export CXXFLAGS='-mtune=pentium-mmx -mthreads -mms-bitfields -O3 -static-libstdc++'
- export PATH=/usr/bin:/bin
- # CREAT WORKING DIR #
- mkdir -p ~/source
- cd ~/source
- rm -rf transmission-win32
- ############################################################################################################
- # CHECK IF PACKAGES HAVE ALREADY BEEN DOWNLOADED #
- PACK=$(ls -p | grep "/" | cut -c 1 | tr -d '\n')
- if [ "$PACK" != "cgillotz" ] ; then
- # DOWNLOAD PACKAGES AND UNTAR #
- wget -O - http://zlib.net/zlib-1.2.8.tar.gz | tar -zxvf -
- wget -O - http://acelnmp.googlecode.com/files/libiconv-1.14.tar.gz | tar -zxvf -
- wget -O - http://mirrors.nfsi.pt/gnu/gettext/gettext-0.18.2.1.tar.gz | tar -zxvf -
- wget -O - http://ftp.gnome.org/pub/gnome/sources/intltool/0.40/intltool-0.40.6.tar.bz2 | tar -jxvf -
- wget -O - http://www.openssl.org/source/openssl-1.0.1e.tar.gz | tar -zxvf -
- wget -O - http://curl.haxx.se/download/curl-7.29.0.tar.bz2 | tar -jxvf -
- wget -O - http://downloads.sourceforge.net/project/levent/libevent/libevent-2.0/libevent-2.0.21-stable.tar.gz | tar -zxvf -
- wget -O - http://download.transmissionbt.com/files/transmission-2.81.tar.xz | tar -xJf -
- wget -q -P /usr/include/sys ftp://sam.hps.iu.edu/custom/torque-4.1.3/src/resmom/cygwin/quota.h
- else
- echo -e '\n\e[01;31mPACKAGES HAVE ALREADY BEEN DOWNLOADED\e[00m\n'
- fi
- ############################################################################################################
- # COMPILE PACKAGES#
- # read -p "Press [Enter] to compile ZLIB"
- cd ~/source/zlib-1.2.8
- ./configure --prefix=/usr --static
- make
- cp -f zconf.h zlib.h /usr/include
- cp -f libz.a /usr/lib
- # read -p "Press [Enter] to compile LIBICONV"
- cd ~/source/libiconv-1.14
- ./configure --prefix=/usr --disable-shared
- make
- make install
- rm -f /usr/lib/libintl.*
- # read -p "Press [Enter] to compile GETTEXT"
- cd ~/source/gettext-0.18.2.1
- ./configure --prefix=/usr --enable-relocatable --disable-shared
- cd gettext-runtime
- make install
- # read -p "Press [Enter] to compile INTLTOOL"
- cd ~/source/intltool-0.40.6
- ./configure --prefix=/usr
- make install
- # read -p "Press [Enter] to compile OPENSSL"
- cd ~/source/openssl-1.0.1e
- ./Configure -L/usr/lib -lz -lpthread --prefix=/usr threads zlib Cygwin
- make
- make install
- # read -p "Press [Enter] to compile CURL"
- cd ~/source/curl-7.29.0
- ./configure --prefix=/usr --disable-shared
- make
- make install
- # read -p "Press [Enter] to compile LIBEVENT"
- cd ~/source/libevent-2.0.21-stable
- ./configure --prefix=/usr --disable-shared
- make
- make install
- # read -p "Press [Enter] to compile TRANSMISSION"
- cd ~/source/transmission-2.81
- if [ ! -f third-party/libutp/utp.cpp.bak ]; then
- sed -i.bak '/snprintf/ i\\t\textern int snprintf(char *, size_t, const char *, ...);' third-party/libutp/utp.cpp
- sed -i.bak 's/_LINUX/defined(_LINUX_QUOTA_VERSION) \&\& &/' libtransmission/platform-quota.c
- fi
- ./configure --prefix=/usr --disable-shared --enable-static --without-gtk
- make
- make install
- cd ~/source
- ############################################################################################################
- # CREAT TRANSMISSION-WIN32 DIR#
- # read -p "Press [Enter] to creat transmission-win32 dir"
- mkdir -p transmission-win32/app transmission-win32/data
- # CYGWIN1.DLL #
- cp /usr/bin/cygwin1.dll transmission-win32/app
- # CA-BUNDLE.CRT #
- perl curl-7.29.0/lib/mk-ca-bundle.pl
- mv ca-bundle.crt transmission-win32/app/
- rm certdata.txt
- # COPY EXEs AND STRIP #
- find . -type f -name "transmission*.exe" -exec cp {} transmission-win32/app \;
- strip transmission-win32/app/*.exe
- # COPY RCP #
- find -type d -name "web" -exec cp -r {} transmission-win32 \;
- # GET DATA FILES #
- cd transmission-win32
- /usr/bin/transmission-daemon -g data -w /cygdrive/d/Downloads -e log.txt -x td.pid
- sleep 5
- kill -TERM $(cat td.pid)
- rm td.pid
- # CLEANUP #
- find . -type f -name "Makefile*" -exec rm -rf {} \;
- ############################################################################################################
- # START.BAT #
- echo '@ECHO OFF' >> Start.bat
- echo 'set CURL_CA_BUNDLE=app\ca-bundle.crt' >> Start.bat
- echo 'set TRANSMISSION_WEB_HOME=%cd%\web' >> Start.bat
- echo 'app\transmission-daemon.exe -g data -x app/transmission-daemon.pid' >> Start.bat
- echo 'EXIT' >> Start.bat
- # STOP.BAT #
- echo '@ECHO OFF' >> Stop.bat
- echo 'set /p PID=<app\transmission-daemon.pid' >> Stop.bat
- echo 'taskkill /f /pid %PID%' >> Stop.bat
- echo 'del app\transmission-daemon.pid' >> Stop.bat
- echo 'EXIT' >> Stop.bat
- ############################################################################################################
- # CONFIG FILE: data\settings.json #
- echo -e '\n\e[01;33mCONFIG FILE:\e[00m data\settings.json'
- # DOWNLOAD DIR: /cygdrive/d/Downloads = D:\Downloads #
- echo -e '\n\e[01;33mDOWNLOAD DIR:\e[00m /cygdrive/d/Downloads = D:\Downloads'
- # RCP: http://localhost:9091/transmission/web/ #
- echo -e '\n\e[01;33mWebUI:\e[00m http://localhost:9091/transmission/web/'
- # TRANSMISSION GUI: http://gdriv.es/lapin/transmission/TransmissionRemoteGUI_4.1.7z#
- echo -e '\n\e[01;33mTRANSMISSION GUI:\e[00m http://gdriv.es/lapin/transmission/TransmissionRemoteGUI_4.1.7z'
- ############################################################################################################
- # If you get snprintf error with libutp, insert the following line into third-party/libutp/utp.cpp
- # just before the line containing snprintf:
- # extern int snprintf(char *, size_t, const char *, ...);
- # find . -name "utp.cpp" -print | xargs sed -i.bak '/snprintf/ i\\t\textern int snprintf(char *, size_t, const char *, ...);'
- ############################################################################################################
- # Version 2.80 breaks building on Cygwin (libtransmission/platform.c and quotas,
- # adding this file https://github.com/adaptivecomputing/torque/blob/master/src/resmom/cygwin/quota.h
- # to Cygwins /usr/include/sys solves the problem).
- ############################################################################################################
- # Version 2.81 with the above workaround needs a one line patch:
- # libtransmission/platform-quota.c
- # FIND #elif defined(__sun) || (_LINUX_QUOTA_VERSION < 2)
- # REPLACE #elif defined(__sun) || (defined(_LINUX_QUOTA_VERSION) && _LINUX_QUOTA_VERSION < 2)
Advertisement
Add Comment
Please, Sign In to add comment