Skip to content

Commit

Permalink
Build iprange and netdata statically on x86_64
Browse files Browse the repository at this point in the history
Uses an alpine linux docker image with musl + gcc to do the build.

No attempt is made to package/release the contents yet.
  • Loading branch information
philwhineray committed Feb 10, 2017
1 parent acacd9a commit 05f7bcb
Show file tree
Hide file tree
Showing 7 changed files with 98 additions and 2 deletions.
54 changes: 54 additions & 0 deletions build-x86_64-static.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#!/bin/sh

# https://twindb.com/building-rpm-on-travis-ci-in-docker-containers/
# https://lebkowski.name/docker-volumes/
#
# Clean up all existed images:
# sudo docker rm -v $(sudo docker ps -a -q -f status=exited)

set -e

. ./package.conf

IPRANGE_MD5=`cut -f1 -d' ' < build/iprange.md5`

mkdir -p build/x86_64-static
cd build/x86_64-static

cp -rp ../../x86_64-static/*.sh .

sudo rm -rf iprange netdata

tar xfj ../iprange-$IPRANGE_VERSION.tar.bz2
mv iprange-$IPRANGE_VERSION iprange
cp -rp ../../x86_64-static/iprange/*.sh iprange

tar xfj ../netdata-$NETDATA_VERSION.tar.bz2
mv netdata-$NETDATA_VERSION netdata
cp -rp ../../x86_64-static/netdata/*.sh netdata

if ! sudo docker inspect firehol-package-x86_64-static > /dev/null 2>&1
then
# To run interactively:
# sudo docker run -it firehol-package-x86_64-static /bin/sh
# (add -v host-dir:guest-dir:rw arguments to mount volumes)
# To remove images in order to re-create:
# sudo docker rm -v $(sudo docker ps -a -q -f status=exited)
# sudo docker rmi firehol-package-x86_64-static
sudo docker run -v `pwd`:/fh-build/x86_64-static:rw alpine:3.5 \
/bin/sh /fh-build/x86_64-static/docker-setup.sh
id=`sudo docker ps -l -q`
sudo docker commit $id firehol-package-x86_64-static
fi
sudo docker run -v `pwd`:/fh-build/x86_64-static:rw firehol-package-x86_64-static \
/bin/sh /fh-build/x86_64-static/iprange/docker-build.sh
sudo docker run -v `pwd`:/fh-build/x86_64-static:rw firehol-package-x86_64-static \
/bin/sh /fh-build/x86_64-static/netdata/docker-build.sh
cd ../..

if [ "$USER" ]
then
sudo chown -R "$USER" .
fi

# TODO: cp -p ??? output/packages
3 changes: 1 addition & 2 deletions clean.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#!/bin/sh

rm -rf build
rm -rf output
sudo rm -rf build output

exit 0
3 changes: 3 additions & 0 deletions package.conf
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,6 @@ FIREHOL_URL=https://github.com/firehol/firehol/releases/download/v$FIREHOL_VERSI

IPRANGE_VERSION=1.0.3
IPRANGE_URL=https://github.com/firehol/iprange/releases/download/v$IPRANGE_VERSION

NETDATA_VERSION=1.5.0
NETDATA_URL=https://github.com/firehol/netdata/releases/download/v$NETDATA_VERSION
7 changes: 7 additions & 0 deletions setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,15 @@ then
wget -O "iprange.md5" $IPRANGE_URL/iprange-$IPRANGE_VERSION.tar.bz2.md5
fi

if [ ! -f netdata.md5 ]
then
wget $NETDATA_URL/netdata-$NETDATA_VERSION.tar.bz2
wget -O "netdata.md5" $NETDATA_URL/netdata-$NETDATA_VERSION.tar.bz2.md5
fi

md5sum -c firehol.md5
md5sum -c iprange.md5
md5sum -c netdata.md5

cd ..
rm -rf output
Expand Down
10 changes: 10 additions & 0 deletions x86_64-static/docker-setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/sh

set -e

# Set up an alpine linux docker image so we can perform static builds in it
apk update
apk add --no-cache binutils make libgcc musl-dev gcc g++

# FireHOL/Netdata dependencies
apk add --no-cache ipset iptables tcpdump libuuid e2fsprogs-dev zlib-dev
11 changes: 11 additions & 0 deletions x86_64-static/iprange/docker-build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/sh

set -e

base=`dirname $0`
cd "$base"
echo "Running `basename $0` in $0"

LDFLAGS=-static export LDFLAGS
./configure
make
12 changes: 12 additions & 0 deletions x86_64-static/netdata/docker-build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/sh

set -e

base=`dirname $0`
cd "$base"
echo "Running `basename $0` in $0"

LDFLAGS=-static export LDFLAGS
./configure --prefix=/opt
make
make install DESTDIR=`pwd`

0 comments on commit 05f7bcb

Please sign in to comment.