Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- function extract() {
- case "$1" in
- *.tar.xz )
- tar Jxf "$1"
- DECOMP=`echo "$1" | sed 's/.tar.xz//'`
- ;;
- *.tar.gz )
- tar zxf "$1"
- DECOMP=`echo "$1" | sed 's/.tar.gz//'`
- ;;
- *.tar.bz2 )
- tar jxf "$1"
- DECOMP=`echo "$1" | sed 's/.tar.bz2//'`
- ;;
- *.tar )
- tar xf "$1"
- DECOMP=`echo "$1" | sed 's/.tar//'`
- ;;
- *.zip )
- local destdir=`unzip -t "$1" | grep testing | head -n 1 | awk '{print $2}' | sed 's/\/$//'`
- unzip -qo "$1"
- if [ -d ${destdir} ]
- then
- unzip -qo "$1"
- DECOMP=$destdir
- else
- echo "Failed to decompress $1 . Unrecognized directory structure ${destdir}."
- unset DECOMP
- fi
- ;;
- esac
- }
- function fetch_file() {
- if [ -f "$1" ]
- then
- echo "Found local copy $1"
- else
- echo -n "Fetching $1 ..."
- wget -nv -O $1 $2 2> /dev/null
- echo " DONE"
- fi
- }
- function fetch_latest_fb_lib() {
- local lpath="$1.tar.gz"
- echo "Fetching $1 => $lpath"
- local relurl="https://github.com/facebook/$1/releases"
- local url=`wget -nv -O- $relurl 2> /dev/null | sed -n -r '/facebook\/.*archive\/.*tar.gz/ s/^.*(\/facebook\/.*\/archive\/)(.*\.tar\.gz).*/https:\/\/github.com\1\2/p' | head -n 1`
- fetch_file $lpath $url
- }
- function fetch_deps() {
- local libev=`wget -nv -O- https://github.com/libevent/libevent/releases 2> /dev/null | sed -n -r '/release-1.*\.tar\.gz/ s/^.*(\/libevent\/libevent\/archive\/release.*.tar.gz).*/https:\/\/github.com\1/p' | head -n 1`
- fetch_file libevent.tar.gz $libev
- local glogurl=`wget -nv -O- https://github.com/google/glog/releases 2> /dev/null | sed -n -r '/google\/glog\/archive\/.*\.tar\.gz/ s/^.*(\/google\/glog\/archive\/.*.tar.gz).*/https:\/\/github.com\1/p' | head -n 1`
- fetch_file libglog.tar.gz $glogurl
- local gflagsurl=`wget -nv -O- https://github.com/gflags/gflags/releases 2> /dev/null | sed -n -r '/gflags\/gflags\/archive\/.*\.tar\.gz/ s/^.*(\/gflags\/gflags\/archive\/.*.tar.gz).*/https:\/\/github.com\1/p' | head -n 1`
- fetch_file libgflags.tar.gz $gflagsurl
- git clone https://github.com/google/double-conversion double-conversion
- rm -rf double-conversion/.git
- }
- function fetch() {
- fetch_latest_fb_lib proxygen
- fetch_latest_fb_lib folly
- fetch_latest_fb_lib wangle
- fetch_deps
- }
- function recompress() {
- for f in *tar.gz;
- do
- gunzip $f
- done
- tar cf double-conversion.tar double-conversion
- echo -n "Recompressing into mega.tar ..."
- rm -f mega.tar
- tar cf mega *.tar
- mv mega mega.tar
- echo -n " compressing .. "
- xz -9 mega.tar
- echo " DONE"
- }
- function build() {
- # Libevent
- echo "========================== LIBEVENT ==========================="
- extract libevent.tar
- cd libevent-release-*
- sed --in-place -r '1s/python$/python2/' event_rpcgen.py
- ./autogen.sh
- ./configure --with-gnu-ld
- echo ">>>>>>>> Install LIBEVENT to /usr/local"
- sudo make install
- cd ..
- echo "========================== DOUBLE-CONVERSION ==========================="
- # Double conversion
- extract double-conversion.tar
- cd double-conversion
- sed --in-place -r '/CCFLAGS.append/ s/-O3/-O2 -march=westmere -mtune=westmere/' SConstruct
- echo ">>>>>>>> Compile and install double-conversion to /usr/local"
- sudo scons optimize=1 install
- cd ..
- echo "========================== GFLAGS ==========================="
- extract libgflags.tar
- cd gflags*
- cmake -D CMAKE_BUILD_TYPE=Release -D BUILD_SHARED_LIBS=ON -D BUILD_STATIC_LIBS=ON -D SITE=custom -D CMAKE_CXX_FLAGS="-O2 -march=westmere -mtune=westmere" -D CMAKE_C_FLAGS="-O2 -march=westmere -mtune=westmere" .
- make -j2
- echo ">>>>>>>> Install GFLAGS to /usr/local"
- sudo make install
- cd ..
- echo "========================== GLOG ==========================="
- extract libglog.tar
- cd glog*
- cmake -D CMAKE_BUILD_TYPE=Release -D BUILD_SHARED_LIBS=ON -D BUILD_STATIC_LIBS=ON -D CMAKE_RANLIB=/usr/bin/gcc-ranlib -D CMAKE_AR=/usr/bin/gcc-ar -D SITE=custom -D CMAKE_CXX_FLAGS="-O2 -march=westmere -mtune=westmere" -D CMAKE_C_FLAGS="-O2 -march=westmere -mtune=westmere" .
- ./configure --enable-static
- make -j2
- echo ">>>>>>>> Install GLOG to /usr/local"
- sudo make install
- sudo mkdir -p /usr/local/lib/cmake/glog; cp -a glog*cmake /usr/local/lib/cmake/glog
- echo "======================================================================================== "
- echo "WARN: Edit /usr/local/lib/cmake/glog/glog-targets.cmake to fix library/include locations"
- echo "======================================================================================== "
- cd ..
- echo "========================== FOLLY ==========================="
- export LD_LIBRARY_PATH=/usr/local/lib
- extract folly.tar
- cd folly*/folly
- mkdir _build; cd _build
- cmake -D CMAKE_BUILD_TYPE=Release -D FOLLY_USE_JEMALLOC=0 ..
- make -j2
- echo ">>>>>>>> Install FOLLY to /usr/local"
- sudo make install
- cd ../..
- echo "========================== WANGLE ==========================="
- extract wangle.tar
- cd wangle*/wangle
- cmake -D CMAKE_BUILD_TYPE=Release -D Boost_LIBRARY_DIR_RELEASE=/usr/lib -D BUILD_TESTS=OFF .
- make
- echo ">>>>>>>> Install WANGLE to /usr/local"
- sudo make install
- cd ../..
- echo "========================== PROXYGEN ==========================="
- extract proxygen.tar
- cd proxygen*/proxygen
- autoreconf -ivf
- ./configure
- make
- echo ">>>>>>>> Install PROXYGEN to /usr/local"
- sudo make install
- }
- function fetch_and_compress() {
- # Run remotely, if needed
- fetch
- recompress
- }
- function compile_locally() {
- # Local compile
- tar Jxf mega.tar.xz
- build
- }
- fetch_and_compress
- compile_locally
Add Comment
Please, Sign In to add comment