From 825afa90c82158b009ca6be980ad8c2c7f333787 Mon Sep 17 00:00:00 2001 From: cruisibesares Date: Tue, 30 Mar 2021 14:57:22 -0600 Subject: [PATCH 1/4] Setup AppImage packaging. This is a POC to show the ability to package pktvisor as an AppImage. If we want to build this out for other archs we probably should look into additional tooling. --- .dockerignore | 5 +++ .gitignore | 1 + appimage/Dockerfile.part | 18 ++++++++++ appimage/Makefile | 15 +++++++++ appimage/export.sh | 28 ++++++++++++++++ appimage/pktvisor/AppRun | 31 ++++++++++++++++++ .../pktvisor/TerminalEmulatorRequired.txt | 1 + appimage/pktvisor/pktvisor.desktop | 8 +++++ appimage/pktvisor/pktvisor.png | Bin 0 -> 15076 bytes docker/Dockerfile | 1 + 10 files changed, 108 insertions(+) create mode 100644 appimage/Dockerfile.part create mode 100644 appimage/Makefile create mode 100644 appimage/export.sh create mode 100644 appimage/pktvisor/AppRun create mode 100644 appimage/pktvisor/TerminalEmulatorRequired.txt create mode 100644 appimage/pktvisor/pktvisor.desktop create mode 100644 appimage/pktvisor/pktvisor.png diff --git a/.dockerignore b/.dockerignore index c4ab83c6e..919a15e1c 100644 --- a/.dockerignore +++ b/.dockerignore @@ -2,3 +2,8 @@ cmake-build* integration_tests/external* Dockerfile .dockerignore +.gitignore +.git +appimage/Dockerfile.part +appimage/export.sh +appimage/Makefile diff --git a/.gitignore b/.gitignore index c4fb154b5..82dd8837c 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ docs/html-documentation-generated* integration_tests/external golang/pkg/client/version.go docs/internals/html +appimage/*.AppImage \ No newline at end of file diff --git a/appimage/Dockerfile.part b/appimage/Dockerfile.part new file mode 100644 index 000000000..a162f194f --- /dev/null +++ b/appimage/Dockerfile.part @@ -0,0 +1,18 @@ +# file is needed for appimagetool when its run with --appimage-extract-and-run +# binutil is needed for strip +RUN apt-get update && apt-get install -yqq --no-install-recommends python3-pip binutils file dietlibc-dev gcc musl musl-tools \ + && pip3 install --user exodus-bundler --no-warn-script-location \ + && /root/.local/bin/exodus --verbose --tarball --output=/tmp/pktvisor.tgz $(which pktvisord) $(which pktvisor-pcap) \ + && mkdir pktvisor \ + && tar --strip=1 -xf /tmp/pktvisor.tgz -C pktvisor/ \ + && strip --verbose --strip-debug pktvisor/data/* \ + && cp $(which pktvisor-cli) /pktvisor/bin/pktvisor-cli + +# get latest appimagetool +ADD https://github.com/AppImage/AppImageKit/releases/download/continuous/appimagetool-x86_64.AppImage /bin/appimage-tool + +# add entrypoints and desktop things +COPY appimage/pktvisor /pktvisor + +# create appimage without fuse +RUN chmod +x /bin/appimage-tool /pktvisor/AppRun && appimage-tool --appimage-extract-and-run /pktvisor/ \ No newline at end of file diff --git a/appimage/Makefile b/appimage/Makefile new file mode 100644 index 000000000..6a9f449f6 --- /dev/null +++ b/appimage/Makefile @@ -0,0 +1,15 @@ +# in dev mode we just use the latest image +ifneq ($(strip $(DEV_MODE)),) +DEV_MODE := <(echo "FROM ns1labs/pktvisor:latest") appimage/Dockerfile.part +endif + +BUILD_FILES := docker/Dockerfile appimage/Dockerfile.part + +pktvisor-x86_64.AppImage: SHELL:=/bin/bash +pktvisor-x86_64.AppImage: + ID=$$(cd .. && cat $(if $(DEV_MODE),$(DEV_MODE),$(BUILD_FILES)) | docker build -q -f- .) ; \ + bash export.sh $$ID + +.PHONEY: clean +clean: + rm pktvisor-x86_64.AppImage \ No newline at end of file diff --git a/appimage/export.sh b/appimage/export.sh new file mode 100644 index 000000000..7bb01f5ab --- /dev/null +++ b/appimage/export.sh @@ -0,0 +1,28 @@ +#!/bin/bash + +FILES=(pktvisor-x86_64.AppImage) + +die () { + echo "$@" >&2 + exit 1 +} + +main () { + [[ $1 ]] || die "image name not specified" + + id= + cleanup() { + docker rm -v "$id" + } + + trap cleanup EXIT + + id=$(docker create $1) + [[ $? == 0 ]] || die "failed to create container for export" + + for file in "${FILES[@]}" ; do + docker cp "$id:$file" . + done +} + +main "$1" \ No newline at end of file diff --git a/appimage/pktvisor/AppRun b/appimage/pktvisor/AppRun new file mode 100644 index 000000000..9678a18a7 --- /dev/null +++ b/appimage/pktvisor/AppRun @@ -0,0 +1,31 @@ +#!/bin/sh +set -x + +# borrowed from appimage directly +SELF=$(readlink -f "$0") +HERE=${SELF%/*} +export PATH="${HERE}/usr/bin/:${HERE}/usr/sbin/:${HERE}/usr/games/:${HERE}/bin/:${HERE}/sbin/${PATH:+:$PATH}" +export LD_LIBRARY_PATH="${HERE}/usr/lib/:${HERE}/usr/lib/i386-linux-gnu/:${HERE}/usr/lib/x86_64-linux-gnu/:${HERE}/usr/lib32/:${HERE}/usr/lib64/:${HERE}/lib/:${HERE}/lib/i386-linux-gnu/:${HERE}/lib/x86_64-linux-gnu/:${HERE}/lib32/:${HERE}/lib64/${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}" +export PYTHONPATH="${HERE}/usr/share/pyshared/${PYTHONPATH:+:$PYTHONPATH}" +export XDG_DATA_DIRS="${HERE}/usr/share/${XDG_DATA_DIRS:+:$XDG_DATA_DIRS}" +export PERLLIB="${HERE}/usr/share/perl5/:${HERE}/usr/lib/perl5/${PERLLIB:+:$PERLLIB}" +export GSETTINGS_SCHEMA_DIR="${HERE}/usr/share/glib-2.0/schemas/${GSETTINGS_SCHEMA_DIR:+:$GSETTINGS_SCHEMA_DIR}" +export QT_PLUGIN_PATH="${HERE}/usr/lib/qt4/plugins/:${HERE}/usr/lib/i386-linux-gnu/qt4/plugins/:${HERE}/usr/lib/x86_64-linux-gnu/qt4/plugins/:${HERE}/usr/lib32/qt4/plugins/:${HERE}/usr/lib64/qt4/plugins/:${HERE}/usr/lib/qt5/plugins/:${HERE}/usr/lib/i386-linux-gnu/qt5/plugins/:${HERE}/usr/lib/x86_64-linux-gnu/qt5/plugins/:${HERE}/usr/lib32/qt5/plugins/:${HERE}/usr/lib64/qt5/plugins/${QT_PLUGIN_PATH:+:$QT_PLUGIN_PATH}" + +# begin entrypoint +# default to pktvisord but allow first arg to specify binary +BINARY="$1" +case "$BINARY" in + pktvisor-cli) shift ;; + pktvisor-pcap) shift ;; + pktvisord) shift ;; + *) BINARY=pktvisord ;; +esac + +# not a terminal +if [ ! -t 1 ] ; then + xdg-open "file://${HERE}/TerminalEmulatorRequired.txt" + exit 1 +else + exec "${HERE}/bin/${BINARY}" "$@" +fi \ No newline at end of file diff --git a/appimage/pktvisor/TerminalEmulatorRequired.txt b/appimage/pktvisor/TerminalEmulatorRequired.txt new file mode 100644 index 000000000..f463044a7 --- /dev/null +++ b/appimage/pktvisor/TerminalEmulatorRequired.txt @@ -0,0 +1 @@ +This app needs to be run from a terminal to function correctly. See the docs at https://github.com/ns1/pktvisor for more details. \ No newline at end of file diff --git a/appimage/pktvisor/pktvisor.desktop b/appimage/pktvisor/pktvisor.desktop new file mode 100644 index 000000000..346c67e78 --- /dev/null +++ b/appimage/pktvisor/pktvisor.desktop @@ -0,0 +1,8 @@ +[Desktop Entry] +Name=pktvisor +Terminal=true +Exec=AppRun +Comment=Test the terminal running a command inside it +Icon=pktvisor +Type=Application +Categories=Utility; \ No newline at end of file diff --git a/appimage/pktvisor/pktvisor.png b/appimage/pktvisor/pktvisor.png new file mode 100644 index 0000000000000000000000000000000000000000..b5a78ad089e9b5f83bd7eda7d67b023e5e2f2dbb GIT binary patch literal 15076 zcmeIZWmFwqvo1=2;O+$XpbLV#y9Rf6cXt8=cSwRmu!Xxjf#3vp39i9iPV??ha>xC3 z#`(LUVRiSKUNuXesu`iAAc>6d4gmrJ0$Ey0Oc??KvK_dug@Xb9f2#f-1bn=4QI-^e zs2C&M2OgBnG^Neuj&3Tl? zB>q($c;Y9wbai#)0f9U`JeWLKnH-!gKrGzc+#u!;pbsAyff9@^UiPj=o{aV`6#vu6 zzuOTrb1`wYa&)zFuqS2U9HUj+mpS^zorFD5cK*Dh=qw6 z^q;nYs(i0+c@&+k%z&O>+ZSNr`={jp=iR^h;RC&P{?}msXQuzW1*R&1zz6!zvI!u_ z_0VWRKya-{iwUcGzB$f>UzVGB8R$&TJR*&kA1$X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38-PrGTHFZY}z7Za5Vu<4RnvSV)Lm9ZJfWcY}gf+!`} z=$3jv67hM?I}WXJEOUgq0;wyQ7|YjT3OoHVI$Iax8tJI2ywOSPF}be$zm-dryZeNN0GpeI*xEXn3HttWLKGFR#dsgeAf-bTEmOcR3&U^e)4SO43I!rXxoP!E zeR?47oi>^tkgQTPMmf!<6DvwZ6Y$Ijsi)p1ll;DL#*w*N!FI83^zoQFbzsb;Wq>EK zVf%SRF&uFtCO2FEvoV!=vYfs?$1j{FNW*7?Ldo&M!cQtnr%v>iG^py#^2>|WBF1>Gd z-ez-XS#CCwdy<7~`?daXD&hWkLilF62=Lo%5g>rvbB@q;02qIFa|mDik-4qaNfN3w zWq)eTJWCN!`bHZW3RN<1dlk#-Haf{G(COS~ zD5}%Uf1RXaLl2B%Zu>Hg*>yra&39@{{zee(wCn~(u*-tv?^7C=uL3-r)rRb^LmH0p z0L%=#QEUD8*^5^c{a|B6`|rwx0Aw*Id|USIzsI+vgirzP=FL@$^LJ%f0JC&M6DXzr ztCtDDTdgD>D+~Rra+fe*J`jBx2mgJ*<9~MHKgOw@AK2s=umFyhi#srprG6Rk@26plv4kxcA?*tpiNEQe<}e|C~7jPI@>-0_<1x yvsVA_UhDw&vlbnV{G0tU$N~2I{|zzd1=hmxnb(z!A@cRisI<6(ScQmT@c#kfjQM&1 literal 0 HcmV?d00001 diff --git a/docker/Dockerfile b/docker/Dockerfile index fb84acdd8..d7a210456 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -21,6 +21,7 @@ RUN \ FROM golang:latest AS gobuild COPY golang/ /src/ WORKDIR /src/ +COPY --from=cppbuild /pktvisor-src/golang/pkg/client/version.go /src/pkg/client/version.go RUN go build -o pktvisor-cli cmd/pktvisor-cli/main.go FROM debian:bullseye-slim AS runtime From 46a62e3fbe1b550622b443e6df20b0d5a7d767bd Mon Sep 17 00:00:00 2001 From: cruisibesares Date: Tue, 30 Mar 2021 17:15:55 -0600 Subject: [PATCH 2/4] Adding Readme to AppImage --- appimage/Readme.md | 24 ++++++++++++++++++++++++ appimage/pktvisor/AppRun | 2 +- 2 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 appimage/Readme.md diff --git a/appimage/Readme.md b/appimage/Readme.md new file mode 100644 index 000000000..0f7f06db4 --- /dev/null +++ b/appimage/Readme.md @@ -0,0 +1,24 @@ +AppImage Packaging +================== + +Creates an AppImage that contains `pktvisord` `pktvisor-pcap` and `pktvisor-cli`. This implementation builds the AppImage in a docker using the assets generated by the docker [build](../docker). Because not all of the assets are statically complied we use [Exodus](https://github.com/intoli/exodus) to capture a minimal set of decencies for the AppImage + + +## Build: +`make pktvisor-x86_64.AppImage` + +## Development: +Because the build can take a while you may want to build the appimage from the latest docker image on docker hub. To do this you can set the `DEV_MODE=` environment to anything. Like so: + +`DEV_MODE=t make pktvisor-x86_64.AppImage` + + +## Usage: +To use the AppImage from the command line you can specify the binary you want to run as the first argument following the pattern: + +` +./pktvisor-x86_64.AppImage [pktvisord|pktvisor-pcap|pktvisor-cli] +` + +If you don't specify all args are passed to `pktvisord` by default. + diff --git a/appimage/pktvisor/AppRun b/appimage/pktvisor/AppRun index 9678a18a7..a08924b64 100644 --- a/appimage/pktvisor/AppRun +++ b/appimage/pktvisor/AppRun @@ -22,7 +22,7 @@ case "$BINARY" in *) BINARY=pktvisord ;; esac -# not a terminal +# not a terminal try to alert the user if [ ! -t 1 ] ; then xdg-open "file://${HERE}/TerminalEmulatorRequired.txt" exit 1 From 7d1b6107784fedeb06ca144c940e0415cdad7c98 Mon Sep 17 00:00:00 2001 From: cruisibesares Date: Tue, 30 Mar 2021 17:37:12 -0600 Subject: [PATCH 3/4] Final cleanup and comments. --- appimage/Makefile | 12 ++++++------ appimage/export.sh | 8 ++++++++ appimage/pktvisor/pktvisor.desktop | 1 - 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/appimage/Makefile b/appimage/Makefile index 6a9f449f6..7ad89cb8f 100644 --- a/appimage/Makefile +++ b/appimage/Makefile @@ -1,13 +1,13 @@ -# in dev mode we just use the latest image +# in dev mode we just use the latest image as the start point ifneq ($(strip $(DEV_MODE)),) -DEV_MODE := <(echo "FROM ns1labs/pktvisor:latest") appimage/Dockerfile.part +DOCKERFILE_HEAD = <(echo "FROM ns1labs/pktvisor:latest") +else +DOCKERFILE_HEAD = docker/Dockerfile endif -BUILD_FILES := docker/Dockerfile appimage/Dockerfile.part - -pktvisor-x86_64.AppImage: SHELL:=/bin/bash +pktvisor-x86_64.AppImage: SHELL:=/bin/bash #needed for the fd when DOCKERFILE_HEAD is in DEV_MODE pktvisor-x86_64.AppImage: - ID=$$(cd .. && cat $(if $(DEV_MODE),$(DEV_MODE),$(BUILD_FILES)) | docker build -q -f- .) ; \ + ID=$$(cd .. && cat $(DOCKERFILE_HEAD) appimage/Dockerfile.part | docker build -q -f- .) ; \ bash export.sh $$ID .PHONEY: clean diff --git a/appimage/export.sh b/appimage/export.sh index 7bb01f5ab..00c27ff24 100644 --- a/appimage/export.sh +++ b/appimage/export.sh @@ -1,5 +1,9 @@ #!/bin/bash +## +# Try to extract files from docker image as atomically as possible +# + FILES=(pktvisor-x86_64.AppImage) die () { @@ -7,9 +11,11 @@ die () { exit 1 } +# pass in image id as $1 main () { [[ $1 ]] || die "image name not specified" + # make a trap that see the var id= cleanup() { docker rm -v "$id" @@ -17,9 +23,11 @@ main () { trap cleanup EXIT + # make it id=$(docker create $1) [[ $? == 0 ]] || die "failed to create container for export" + # take it for file in "${FILES[@]}" ; do docker cp "$id:$file" . done diff --git a/appimage/pktvisor/pktvisor.desktop b/appimage/pktvisor/pktvisor.desktop index 346c67e78..35a4e20b4 100644 --- a/appimage/pktvisor/pktvisor.desktop +++ b/appimage/pktvisor/pktvisor.desktop @@ -2,7 +2,6 @@ Name=pktvisor Terminal=true Exec=AppRun -Comment=Test the terminal running a command inside it Icon=pktvisor Type=Application Categories=Utility; \ No newline at end of file From b6a34869d5c1f6348a3481641e77c502902b9f67 Mon Sep 17 00:00:00 2001 From: cruisibesares Date: Thu, 8 Apr 2021 10:58:52 -0600 Subject: [PATCH 4/4] Appimage README clarification. Updating some wording and adding the `DEV_IMAGE` env var to the appimage build for ease of development. --- appimage/Makefile | 4 +++- appimage/{Readme.md => README.md} | 8 ++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) rename appimage/{Readme.md => README.md} (62%) diff --git a/appimage/Makefile b/appimage/Makefile index 7ad89cb8f..085a7079c 100644 --- a/appimage/Makefile +++ b/appimage/Makefile @@ -1,6 +1,8 @@ +DEV_IMAGE ?= ns1labs/pktvisor:latest + # in dev mode we just use the latest image as the start point ifneq ($(strip $(DEV_MODE)),) -DOCKERFILE_HEAD = <(echo "FROM ns1labs/pktvisor:latest") +DOCKERFILE_HEAD = <(echo "FROM $(DEV_IMAGE)") else DOCKERFILE_HEAD = docker/Dockerfile endif diff --git a/appimage/Readme.md b/appimage/README.md similarity index 62% rename from appimage/Readme.md rename to appimage/README.md index 0f7f06db4..126ca1711 100644 --- a/appimage/Readme.md +++ b/appimage/README.md @@ -1,7 +1,7 @@ AppImage Packaging ================== -Creates an AppImage that contains `pktvisord` `pktvisor-pcap` and `pktvisor-cli`. This implementation builds the AppImage in a docker using the assets generated by the docker [build](../docker). Because not all of the assets are statically complied we use [Exodus](https://github.com/intoli/exodus) to capture a minimal set of decencies for the AppImage +Creates an AppImage that contains `pktvisord` `pktvisor-pcap` and `pktvisor-cli`. This implementation builds the AppImage in a docker using the assets generated by the docker [build](../docker). Because not all of the assets are statically linked we use [Exodus](https://github.com/intoli/exodus) to capture a minimal set of dependencies for the AppImage ## Build: @@ -12,6 +12,10 @@ Because the build can take a while you may want to build the appimage from the l `DEV_MODE=t make pktvisor-x86_64.AppImage` +You may also specify a custom image in dev mode by setting the env file `DEV_IMAGE=` to the image you wish to build on. Example: + +`DEV_IMAGE="ns1labs/pktvisor:develop" DEV_MODE=t make pktvisor-x86_64.AppImage` + ## Usage: To use the AppImage from the command line you can specify the binary you want to run as the first argument following the pattern: @@ -20,5 +24,5 @@ To use the AppImage from the command line you can specify the binary you want to ./pktvisor-x86_64.AppImage [pktvisord|pktvisor-pcap|pktvisor-cli] ` -If you don't specify all args are passed to `pktvisord` by default. +If you don't specify a binary, all args are passed to pktvisord by default.