mirror of
https://github.com/bettercap/bettercap
synced 2025-08-14 10:46:57 -07:00
new: global (cross) compilation script
This commit is contained in:
parent
bb1d86fdd0
commit
7382cc7cce
6 changed files with 97 additions and 54 deletions
96
build.sh
Executable file
96
build.sh
Executable file
|
@ -0,0 +1,96 @@
|
|||
#!/bin/bash
|
||||
VERSION=$(cat core/banner.go | grep Version | cut -d '"' -f 2)
|
||||
|
||||
clean() {
|
||||
rm -rf build
|
||||
mkdir build
|
||||
}
|
||||
|
||||
bin_dep() {
|
||||
BIN=$1
|
||||
which $BIN > /dev/null || { echo "@ Dependency $BIN not found !"; exit 1; }
|
||||
}
|
||||
|
||||
vm_dep() {
|
||||
HOST=$1
|
||||
ping -c 1 $HOST > /dev/null || { echo "@ Virtual machine host $HOST not visible !"; exit 1; }
|
||||
}
|
||||
|
||||
build_linux_amd64() {
|
||||
OUTPUT=$1
|
||||
echo "@ Building $OUTPUT ..."
|
||||
go build -o "$OUTPUT" ..
|
||||
}
|
||||
|
||||
build_linux_arm7() {
|
||||
bin_dep 'arm-linux-gnueabi-gcc'
|
||||
|
||||
OUTPUT=$1
|
||||
OLD=$(pwd)
|
||||
echo "@ Building $OUTPUT ..."
|
||||
cd /tmp
|
||||
rm -rf libpcap-1.8.1
|
||||
if [ ! -f /tmp/libpcap-1.8.1.tar.gz ]; then
|
||||
echo "@ Downloading http://www.tcpdump.org/release/libpcap-1.8.1.tar.gz ..."
|
||||
wget -q http://www.tcpdump.org/release/libpcap-1.8.1.tar.gz -O /tmp/libpcap-1.8.1.tar.gz
|
||||
fi
|
||||
echo "@ Cross compiling libpcap for ARM ..."
|
||||
tar xf libpcap-1.8.1.tar.gz
|
||||
cd libpcap-1.8.1
|
||||
export CC=arm-linux-gnueabi-gcc
|
||||
./configure --host=arm-linux-gnueabi --with-pcap=linux > /dev/null
|
||||
make CFLAGS='-w' -j4 > /dev/null
|
||||
echo "@ Compiling $OUTPUT ..."
|
||||
cd "$OLD"
|
||||
env CC=arm-linux-gnueabi-gcc CGO_ENABLED=1 GOOS=linux GOARCH=arm GOARM=7 CGO_LDFLAGS="-L/tmp/libpcap-1.8.1" go build -o "$OUTPUT" ..
|
||||
rm -rf /tmp/libpcap-1.8.1
|
||||
}
|
||||
|
||||
build_macos_amd64() {
|
||||
vm_dep 'osxvm'
|
||||
|
||||
DIR=/Users/evilsocket/gocode/src/github.com/evilsocket/bettercap-ng
|
||||
OUTPUT=$1
|
||||
|
||||
echo "@ Updating repo on MacOS VM ..."
|
||||
ssh osxvm "cd $DIR && rm -rf '$OUTPUT' && git checkout . && git pull" > /dev/null
|
||||
|
||||
echo "@ Building $OUTPUT ..."
|
||||
ssh osxvm "export GOPATH=/Users/evilsocket/gocode && cd '$DIR' && PATH=$PATH:/usr/local/bin && go build -o $OUTPUT ." > /dev/null
|
||||
|
||||
echo "@ Downloading $OUTPUT ..."
|
||||
scp -C osxvm:$DIR/$OUTPUT . > /dev/null
|
||||
}
|
||||
|
||||
build_windows_amd64() {
|
||||
vm_dep 'winvm'
|
||||
|
||||
DIR=c:/Users/evilsocket/gopath/src/github.com/evilsocket/bettercap-ng
|
||||
OUTPUT=$1
|
||||
|
||||
echo "@ Updating repo on Windows VM ..."
|
||||
ssh winvm "cd $DIR && del *.exe && git pull" > /dev/null
|
||||
|
||||
echo "@ Building $OUTPUT ..."
|
||||
ssh winvm "cd $DIR && go build -o $OUTPUT ." > /dev/null
|
||||
|
||||
echo "@ Downloading $OUTPUT ..."
|
||||
scp -C winvm:$DIR/$OUTPUT . > /dev/null
|
||||
}
|
||||
|
||||
clean
|
||||
cd build
|
||||
|
||||
build_linux_amd64 bettercap-ng_linux_amd64_$VERSION
|
||||
build_linux_arm7 bettercap-ng_linux_arm7_$VERSION
|
||||
build_macos_amd64 bettercap-ng_macos_amd64_$VERSION
|
||||
build_windows_amd64 bettercap-ng_windows_amd64_$VERSION.exe
|
||||
|
||||
echo
|
||||
echo
|
||||
du -sh *
|
||||
|
||||
cd --
|
||||
|
||||
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue