Skip to content

Instantly share code, notes, and snippets.

@notsure2
Last active June 15, 2019 00:06
Show Gist options
  • Save notsure2/1bfd0082fe14f8f296cfe2255a48a5cb to your computer and use it in GitHub Desktop.
Save notsure2/1bfd0082fe14f8f296cfe2255a48a5cb to your computer and use it in GitHub Desktop.
Compile conntrack-tools for tomato statically using modern buildroot
#!/bin/sh
# Requires also checking out freshtomato-arm source code
# and adding in kernel/config_base: CONFIG_NF_CT_NETLINK=m
# and then compiling the kernel, then extracting nf_conntrack_netlink.ko
# and insmod before using conntrack utility.
BUILDROOT=/home/android/freshtomato/buildroot-2019.02.3
BUILDHOST=arm-buildroot-linux-uclibcgnueabi
BUILDROOT_BIN=$BUILDROOT/output/host/bin
DIR=$(dirname $(realpath $0))
WORKDIR=$DIR/src
DOWNLOADDIR=$DIR/download
rm -rf $WORKDIR
mkdir -p $DOWNLOADDIR
cd $DOWNLOADDIR
wget -N -c https://www.netfilter.org/projects/conntrack-tools/files/conntrack-tools-1.4.5.tar.bz2
wget -N -c https://www.netfilter.org/projects/libnfnetlink/files/libnfnetlink-1.0.1.tar.bz2
wget -N -c https://www.netfilter.org/projects/libmnl/files/libmnl-1.0.4.tar.bz2
wget -N -c https://www.netfilter.org/projects/libnetfilter_conntrack/files/libnetfilter_conntrack-1.0.7.tar.bz2
mkdir -p $WORKDIR
cd $WORKDIR
tar xvf $DOWNLOADDIR/conntrack-tools-1.4.5.tar.bz2
tar xvf $DOWNLOADDIR/libnfnetlink-1.0.1.tar.bz2
tar xvf $DOWNLOADDIR/libmnl-1.0.4.tar.bz2
tar xvf $DOWNLOADDIR/libnetfilter_conntrack-1.0.7.tar.bz2
export PATH=$BUILDROOT_BIN:$PATH
LIBNFNETLINK_DIR=$WORKDIR/libnfnetlink-1.0.1
LIBMNL_DIR=$WORKDIR/libmnl-1.0.4
LIBNETFILTER_CONNTRACK_DIR=$WORKDIR/libnetfilter_conntrack-1.0.7
CONNTRACK_TOOLS_DIR=$WORKDIR/conntrack-tools-1.4.5
cd $LIBNFNETLINK_DIR
./configure --host=$BUILDHOST --enable-static --disable-shared && make
[ $? -gt 0 ] && exit 1;
export LIBNFNETLINK_LIBS=" -L$LIBNFNETLINK_DIR/src/.libs -lnfnetlink "
export LIBNFNETLINK_CFLAGS=" -I$LIBNFNETLINK_DIR/include "
cd $LIBMNL_DIR
./configure --host=$BUILDHOST --enable-static --disable-shared && make
[ $? -gt 0 ] && exit 1;
export LIBMNL_LIBS=" -L$LIBMNL_DIR/src/.libs -lmnl "
export LIBMNL_CFLAGS=" -I$LIBMNL_DIR/include "
cd $LIBNETFILTER_CONNTRACK_DIR
./configure --host=$BUILDHOST --enable-static --disable-shared && make
[ $? -gt 0 ] && exit 1;
cd $CONNTRACK_TOOLS_DIR
export LIBNETFILTER_CONNTRACK_LIBS=" -L$LIBNETFILTER_CONNTRACK_DIR/src/.libs -lnetfilter_conntrack "
export LIBNETFILTER_CONNTRACK_CFLAGS=" -I$LIBNETFILTER_CONNTRACK_DIR/include "
LDFLAGS="-Wl,-static -static -static-libgcc" ./configure --host=$BUILDHOST --disable-cthelper --disable-cttimeout --enable-static --disable-shared
make V=s
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment