Skip to content

Instantly share code, notes, and snippets.

@alexef
Last active November 15, 2017 10:06
Show Gist options
  • Save alexef/d4e6e13144bab024a4b6e5279f690d21 to your computer and use it in GitHub Desktop.
Save alexef/d4e6e13144bab024a4b6e5279f690d21 to your computer and use it in GitHub Desktop.
Build mcrouter deb script for ubuntu 14.04
#!/bin/bash
set -e
export MCROUTER_VERSION="0.32.0"
export FOLLY_COMMIT="v2016.09.26.00"
# Install tools needed by install scripts below
echo 'debconf debconf/frontend select Noninteractive' | debconf-set-selections
apt-get -y update && apt-get -y install curl sudo wget build-essential
# Download mcrouter
cd /tmp
curl -L https://github.com/facebook/mcrouter/archive/v${MCROUTER_VERSION}.tar.gz | tar xvz
# Build mcrouter
cd /tmp/mcrouter-${MCROUTER_VERSION}/mcrouter
echo ${FOLLY_COMMIT} > ./FOLLY_COMMIT
export LDFLAGS="-Wl,-rpath=/usr/local/lib/mcrouter/"
export LD_LIBRARY_PATH="/usr/local/lib/mcrouter/"
rm -rf /tmp/mcrouter-build
mkdir /tmp/mcrouter-build && ./scripts/install_ubuntu_14.04.sh /tmp/mcrouter-build
# Install Ruby so we can install fpm for building the Debian package
echo "gem: --no-ri --no-rdoc" > ~/.gemrc
gem install fpm -v 1.5.0
# Copy all dependencies and build the Debian package
cd /tmp/mcrouter-build/install
cp /home/alexef/create_package.sh /tmp/mcrouter-build/install/create_package.sh
curl -L https://github.com/bmorton/futhark/raw/master/sh/cpld.bash -o /tmp/mcrouter-build/install/copy_deps.sh && chmod +x /tmp/mcrouter-build/install/copy_deps.sh
./create_package.sh ${MCROUTER_VERSION}
#!/bin/bash
# Author : Hemanth.HM
# Email : hemanth[dot]hm[at]gmail[dot]com
# License : GNU GPLv3
#
function useage()
{
cat << EOU
Useage: bash $0 <path to the binary> <path to copy the dependencies>
EOU
exit 1
}
#Validate the inputs
[[ $# < 2 ]] && useage
#Check if the paths are vaild
[[ ! -e $1 ]] && echo "Not a vaild input $1" && exit 1
[[ -d $2 ]] || echo "No such directory $2 creating..."&& mkdir -p "$2"
#Get the library dependencies
echo "Collecting the shared library dependencies for $1..."
deps=$(ldd $1 | awk 'BEGIN{ORS=" "}$1~/^\//{print $1}$3~/^\//{print $3}' | sed 's/,$/\n/')
echo "Copying the dependencies to $2"
#Copy the deps
for dep in $deps
do
echo "Copying $dep to $2"
cp "$dep" "$2"
done
echo "Done!"
#!/bin/bash
DIR=$(mktemp -d /tmp/mcrouter-packager.XXXXXXX)
LIB_DIR="$DIR/usr/local/lib/mcrouter"
BIN_DIR="$DIR/usr/local/bin"
mkdir -p $LIB_DIR $BIN_DIR
cp lib/* $LIB_DIR
cp bin/mcrouter $BIN_DIR
./copy_deps.sh bin/mcrouter $LIB_DIR
echo "Building package"
VERSION=$1
fpm -s dir -t deb -C "$DIR" -n mcrouter -v $VERSION -a amd64 --description "mcrouter" --maintainer "@getyourguide.com" -C $DIR .
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment