Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Tudor Golubenco committed Aug 4, 2015
0 parents commit 598b85f
Show file tree
Hide file tree
Showing 6 changed files with 87 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*.swp
/build/
15 changes: 15 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@

.PHONY: image
image:
docker build -t tudorg/beats-builder xgo-image/

.PHONY: packetbeat
packetbeat: image
cd build && xgo -image=tudorg/beats-builder -static \
-before-build=../xgo-scripts/before_build.sh \
github.com/elastic/packetbeat

.PHONY: run-interactive
run-interactive:
docker run -t -i -v $(shell pwd):/build -v $(shell pwd)/xgo-scripts/:/scripts --entrypoint=bash tudorg/beats-builder

28 changes: 28 additions & 0 deletions xgo-image/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
FROM tudorg/xgo-latest

This comment has been minimized.

Copy link
@andrewkroh

andrewkroh Sep 6, 2015

Member

@tsg Where does this image come from? I don't see it on docker hub. I suspect it needs to be built and tagged locally from https://github.com/tsg/xgo?

This comment has been minimized.

Copy link
@tsg

tsg Sep 7, 2015

Contributor

@andrewkroh Yes, that was from tsg/xgo. But with PR #1 I moved the Docker files into this repository because they drifted too much from the upstream xgo. PR #1 is not currently merged, but should be soon.


MAINTAINER Tudor Golubenco <tudor@elastic.co>

# Get libpcap binaries for linux
RUN \
dpkg --add-architecture i386 && \
apt-get update && \
apt-get install -y libpcap0.8-dev

RUN \
mkdir -p /libpcap && \
apt-get download libpcap0.8-dev:i386 && \
dpkg -x libpcap0.8-dev_*_i386.deb /libpcap/i386 && \
apt-get download libpcap0.8-dev && \
dpkg -x libpcap0.8-dev_*_amd64.deb /libpcap/amd64 && \
rm libpcap0.8-dev*.deb


# Get libpcap binaries for win
ENV WPDPACK_URL https://www.winpcap.org/install/bin/WpdPack_4_1_2.zip
RUN \
./fetch.sh $WPDPACK_URL f5c80885bd48f07f41833d0f65bf85da1ef1727a && \
unzip `basename $WPDPACK_URL` -d /libpcap/win && \
rm `basename $WPDPACK_URL`

# add patch for gopacket
ADD gopacket_pcap.patch /gopacket_pcap.patch
22 changes: 22 additions & 0 deletions xgo-image/gopacket_pcap.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
diff --git a/Godeps/_workspace/src/github.com/tsg/gopacket/pcap/pcap.go b/Godeps/_workspace/src/github.
index d2465bb..7b23b84 100644
--- a/Godeps/_workspace/src/github.com/tsg/gopacket/pcap/pcap.go
+++ b/Godeps/_workspace/src/github.com/tsg/gopacket/pcap/pcap.go
@@ -8,12 +8,13 @@
package pcap

/*
-#cgo linux LDFLAGS: -lpcap
+#cgo linux,386 LDFLAGS: /libpcap/i386/usr/lib/i386-linux-gnu/libpcap.a
+#cgo linux,amd64 LDFLAGS: /libpcap/amd64/usr/lib/x86_64-linux-gnu/libpcap.a
#cgo freebsd LDFLAGS: -lpcap
#cgo darwin LDFLAGS: -lpcap
-#cgo windows CFLAGS: -I C:/WpdPack/Include
-#cgo windows,386 LDFLAGS: -L C:/WpdPack/Lib -lwpcap
-#cgo windows,amd64 LDFLAGS: -L C:/WpdPack/Lib/x64 -lwpcap
+#cgo windows CFLAGS: -I /libpcap/win/WpdPack/Include
+#cgo windows,386 LDFLAGS: -L /libpcap/win/WpdPack/Lib -lwpcap
+#cgo windows,amd64 LDFLAGS: -L /libpcap/win/WpdPack/Lib/x64 -lwpcap
#include <stdlib.h>
#include <pcap.h>

8 changes: 8 additions & 0 deletions xgo-scripts/before_build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/sh

PB_PATH=/go/src/github.com/elastic/packetbeat

if [ -d $PB_PATH ]; then
cd $PB_PATH
patch -p1 < /gopacket_pcap.patch
fi
12 changes: 12 additions & 0 deletions xgo-scripts/before_tsg_build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/sh

PB_PATH=/go/src/github.com/elastic/packetbeat
PB_TSG_PATH=/go/src/github.com/tsg/packetbeat

mkdir -p `dirname $PB_PATH`
ln -s $PB_TSG_PATH $PB_PATH

if [ -d $PB_PATH ]; then
cd $PB_PATH
patch -p1 < /gopacket_pcap.patch
fi

0 comments on commit 598b85f

Please sign in to comment.