Skip to content

Instantly share code, notes, and snippets.

@bioothod
Created September 17, 2014 01:50
Show Gist options
  • Save bioothod/8a03b381114d54d675b3 to your computer and use it in GitHub Desktop.
Save bioothod/8a03b381114d54d675b3 to your computer and use it in GitHub Desktop.
Vagrant file to build elliptics
#!/usr/bin/env bash
set -x
apt-get update
apt-get install -y git-core devscripts gcc g++ equivs gdb
BASE_DIR=`pwd`
ulimit -c unlimited
ulimit -u 100000
function hostname_setup {
name=`hostname -f`
hname=`host $name`
if test $? = 0; then
return
fi
if test x`grep $name /etc/hosts | wc -l` != x0; then
echo "Hostname is already set"
return
fi
echo "127.0.0.1 $name $name. $name.localdomain" >> /etc/hosts
}
function swap_setup {
swap_file="/var/tmp/swap.0"
if ! test -f $swap_file; then
dd if=/dev/zero of=$swap_file bs=10M count=400
mkswap $swap_file
fi
swapon $swap_file
}
function install {
pack=$1
while test x"$pack" != x; do
echo "Package: $pack"
if test x`dpkg -l | grep "ii $pack " | wc -l` = x0; then
dpkg -i ../$pack*.deb
if test $? != 0; then
return 1;
fi
fi
pack=`shift`
done
}
function update {
url=$1
version=$2
submodule=$3
cd $BASE_DIR
dir=`echo -n $url | awk -F "/" {'print $NF'} | awk -F "." {'print $1'}`
if ! test -d $dir; then
git clone $url -b $version
fi
cd $dir
git checkout $version
packages=`grep "Package: " debian/control | awk -F ":" {'print $2'}`
git remote update
LOCAL=$(git rev-parse @)
REMOTE=$(git rev-parse @{u})
BASE=$(git merge-base @ @{u})
if [ $LOCAL = $REMOTE ]; then
echo "Up-to-date"
install $packages && return 0
elif [ $LOCAL = $BASE ]; then
echo "Need to pull"
git pull
elif [ $REMOTE = $BASE ]; then
echo "Need to push"
exit 1
else
echo "Diverged"
exit 1
fi
mk-build-deps -i -r -t "apt-get --no-install-recommends -y"
if test x"$submodule" = x"submodule"; then
git submodule init
git submodule update
fi
# remove old package, we have to build a new one
for pack in $packages; do
rm -f ../$pack*.deb
done
debuild --no-tgz-check -i -us -uc -b
install $packages
}
swap_setup
hostname_setup
update http://github.com/3Hren/blackhole.git v0.2
update http://github.com/reverbrain/react.git master
update http://github.com/reverbrain/eblob.git master
update http://github.com/cocaine/cocaine-core.git v0.11 submodule
update http://github.com/cocaine/cocaine-framework-native.git v0.11
update http://github.com/reverbrain/elliptics.git master submodule
@shaitan
Copy link

shaitan commented Sep 29, 2014

git rev-parse and git merge-base do not accept @. May be it should be replaced by HEAD?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment