From 985853297c6dcd91dd01b5026725ed85a5643617 Mon Sep 17 00:00:00 2001 From: Jess Frazelle Date: Mon, 6 Nov 2017 14:17:00 -0500 Subject: [PATCH] fix Signed-off-by: Jess Frazelle --- opensnitch/Dockerfile | 12 ++++++ opensnitchd/Dockerfile | 70 ++++++++++++++++++++++++++++++++++ opensnitchd/hook-opensnitch.py | 3 ++ opensnitchd/ldd | 13 +++++++ 4 files changed, 98 insertions(+) create mode 100644 opensnitch/Dockerfile create mode 100644 opensnitchd/Dockerfile create mode 100644 opensnitchd/hook-opensnitch.py create mode 100755 opensnitchd/ldd diff --git a/opensnitch/Dockerfile b/opensnitch/Dockerfile new file mode 100644 index 0000000..50eb195 --- /dev/null +++ b/opensnitch/Dockerfile @@ -0,0 +1,12 @@ +# Usage: +# docker run -d \ +# -v /etc/localtime:/etc/localtime:ro \ +# -v /tmp/.X11-unix:/tmp/.X11-unix \ +# -e "DISPLAY=unix${DISPLAY}" \ +# --net host \ +# --name opensnitch \ +# r.j3ss.co/opensnitch +# +FROM r.j3ss.co/opensnitchd:latest + +ENTRYPOINT ["/usr/bin/opensnitch-qt"] diff --git a/opensnitchd/Dockerfile b/opensnitchd/Dockerfile new file mode 100644 index 0000000..88602e4 --- /dev/null +++ b/opensnitchd/Dockerfile @@ -0,0 +1,70 @@ +# Usage: +# docker run -d \ +# --name=opensnitchd \ +# --net host \ +# r.j3ss.co/opensnitchd +# +FROM alpine:latest + +RUN apk add --no-cache \ + python3 + +ENV OPENSNITCH_VERSION master +ENV PYINSTALLER_TAG v3.3 + +COPY ldd /bin/ldd +COPY hook-opensnitch.py /tmp/hooks/hook-opensnitch.py +ENV PATH /bin:$PATH + +RUN buildDeps=' \ + build-base \ + git \ + libc-dev \ + libcap-dev \ + libnetfilter_queue-dev \ + libnfnetlink-dev \ + musl-dev \ + python3-dev \ + py3-gobject3 \ + py3-inotify \ + py3-qt5 \ + zlib-dev \ + ' \ + set -x \ + && apk --no-cache add $buildDeps \ + --repository https://dl-3.alpinelinux.org/alpine/edge/testing \ + && git clone --depth 1 --branch $PYINSTALLER_TAG https://github.com/pyinstaller/pyinstaller.git /tmp/pyinstaller \ + && ( \ + cd /tmp/pyinstaller/bootloader \ + && python3 ./waf configure --no-lsb all \ + && pip3 install .. \ + && rm -Rf /tmp/pyinstaller \ + ) \ + && git clone --depth 1 --branch ${OPENSNITCH_VERSION} https://github.com/evilsocket/opensnitch.git /usr/src/opensnitch \ + && ( \ + cd /usr/src/opensnitch \ + && python3 setup.py install \ + && pyinstaller \ + --exclude-module pycrypto \ + --exclude-module PyInstaller \ + --noconfirm \ + --onefile \ + --clean \ + --hidden-import=pkg_resources \ + --additional-hooks-dir=/tmp/hooks/ \ + $(which opensnitchd) \ + && mv dist/opensnitchd $(which opensnitchd) \ + && pyinstaller \ + --exclude-module pycrypto \ + --exclude-module PyInstaller \ + --noconfirm \ + --onefile \ + --clean \ + $(which opensnitch-qt) \ + && mv dist/opensnitch-qt $(which opensnitch-qt) \ + && rm -rf /usr/src/opensnitch \ + ) \ + && apk del $buildDeps \ + && echo "Build complete." + +CMD ["/usr/bin/opensnitchd"] diff --git a/opensnitchd/hook-opensnitch.py b/opensnitchd/hook-opensnitch.py new file mode 100644 index 0000000..bb02ef1 --- /dev/null +++ b/opensnitchd/hook-opensnitch.py @@ -0,0 +1,3 @@ +from PyInstaller.utils.hooks import copy_metadata + +datas = copy_metadata('opensnitch==0.0.2') diff --git a/opensnitchd/ldd b/opensnitchd/ldd new file mode 100755 index 0000000..d7d1f21 --- /dev/null +++ b/opensnitchd/ldd @@ -0,0 +1,13 @@ +#!/bin/sh + +# From http://wiki.musl-libc.org/wiki/FAQ#Q:_where_is_ldd_.3F +# +# Musl's dynlinker comes with ldd functionality built in. just create a +# symlink from ld-musl-$ARCH.so to /bin/ldd. If the dynlinker was started +# as "ldd", it will detect that and print the appropriate DSO information. +# +# Instead, this string replaced "ldd" with the package so that pyinstaller +# can find the actual lib. +exec /usr/bin/ldd "$@" | \ + sed -r 's/([^[:space:]]+) => ldd/\1 => \/lib\/\1/g' | \ + sed -r 's/ldd \(.*\)//g' \ No newline at end of file