Skip to content

Commit

Permalink
Merge pull request #4 from siemens/feature/aur
Browse files Browse the repository at this point in the history
feat: Arch PKGBUILD and self-test
  • Loading branch information
thediveo authored Sep 22, 2023
2 parents cf66fd5 + 1b0d9e6 commit e28c0e8
Show file tree
Hide file tree
Showing 6 changed files with 136 additions and 13 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/dist
/packaging/aur/dist
*.syso
coverage.*
__debug_bin
47 changes: 34 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,19 +41,40 @@ Confirm and we're live capturing.

## Installation

Head over to our
[releases](https://github.com/siemens/cshargextcap/releases/latest) page.

- **Linux**: download the package matching your CPU architecture (amd64 or
arm64) and distro package format (Debian, Alpine, Fedora). Install the
downloaded package as usual.

- **Mac OS**: download the `.tar.gz` archive for Darwin arm64. Extract the contained `cshargextcap` plugin binary and copy/move it to `/Applications/Wireshark.app/Contents/MacOS/extcap`.

- **Windows**: download the ZIP archive for Windows amd64. Double click in file
explorer to open its contents, then double click on the installer `.exe`. You
don't need to extract the other files, as the installer perfectly works on its
own.
- **Linux**:
- **Alpine**, **Debian**, **Fedora**: head over to our
[releases](https://github.com/siemens/cshargextcap/releases/latest) page and
download the package matching your CPU architecture (amd64 or arm64) and
distro package format. Install the downloaded package as usual.
- **Arch**:
1. download `PKGBUILD` into a preferably clean directory:
```bash
wget https://raw.githubusercontent.com/siemens/cshargextcap/main/packaging/aur/PKGBUILD
```
2. `makepkg -s -r -c` in the directory you've downloaded `PKGBUILD` into.
3. either install only the excapt plugin, or additionally the Wireshark QT
desktop integration:
```bash
# plugin only for tshark usage, without desktop Wireshark dependency
pacman -U cshargextcap-git-cli*.zst
# with desktop integration
pacman -U cshargextcap-git-*.zst
```
4. You can later update to new releases without the need to download the
`PKGBUILD` file again, as it will automatically build and install from
the latest release.
- **Mac OS**: head over to our
[releases](https://github.com/siemens/cshargextcap/releases/latest) page and
download the `.tar.gz` archive for Darwin arm64. Extract the contained
`cshargextcap` plugin binary and copy/move it to
`/Applications/Wireshark.app/Contents/MacOS/extcap`.
- **Windows**: head over to our
[releases](https://github.com/siemens/cshargextcap/releases/latest) page and
download the ZIP archive for Windows amd64. Double click in file explorer to
open its contents, then double click on the installer `.exe`. You don't need
to extract the other files, as the installer perfectly works on its own.

See below for the [Quick Start](#quick-start).

Expand Down
10 changes: 10 additions & 0 deletions packaging/aur/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
FROM archlinux:base-devel

RUN useradd -m build && \
pacman -Syu --noconfirm && \
pacman -Sy --noconfirm git xdg-utils && \
echo "build ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/build
USER build
WORKDIR /pkg
COPY packagebuildandtest.sh /
CMD ["/bin/bash", "packagebuildandtest.sh"]
59 changes: 59 additions & 0 deletions packaging/aur/PKGBUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# Maintainer: Harald Albrecht <harald.albrecht@siemens.com>

# - https://wiki.archlinux.org/title/creating_packages
# - https://wiki.archlinux.org/title/Go_package_guidelines
# - https://wiki.archlinux.org/title/PKGBUILD
#
# Wireshark:
# - https://gitlab.archlinux.org/archlinux/packaging/packages/wireshark/-/blob/main/PKGBUILD?ref_type=heads

pkgbase='cshargextcap-git'
pkgname=('cshargextcap-git-cli' 'cshargextcap-git-desktop')
pkgver='0' # must be present, but will later be replaced by output of pkgver()
pkgrel='1'
pkgdesc='Wireshark extcap plugin for container traffic capture live streaming'
url='https://github.com/siemens/cshargextcap'
arch=('x86_64')
license=('MIT')
makedepends=('go' 'git')
# https://wiki.archlinux.org/title/VCS_package_guidelines
source=("git+https://github.com/siemens/cshargextcap")
md5sums=('SKIP')

pkgver() {
cd "${srcdir}/cshargextcap"
git describe --long --abbrev=7 | sed 's/^v//;s/\([^-]*-g\)/r\1/;s/-/./g'
}

prepare() {
cd "${srcdir}/cshargextcap"
mkdir -p build
}

build() {
cd "${srcdir}/cshargextcap"
go build \
-tags netgo,osusergo \
-trimpath \
-buildmode pie \
-mod=readonly \
-modcacherw \
-ldflags "-linkmode external -extldflags \"${LDFLAGS}\"" \
-o build/ \
./cmd/cshargextcap
}

package_cshargextcap-git-cli() {
depends=('wireshark-cli')

cd "${srcdir}/cshargextcap"
install -Dm 755 build/cshargextcap -t "${pkgdir}"/usr/lib/wireshark/extcap
}

package_cshargextcap-git-desktop() {
pkgdesk+=" - desktop integration"
depends=('cshargextcap-git-cli' 'wireshark-qt')

cd "${srcdir}/cshargextcap"
install -Dm 644 packaging/linux/com.github.siemens.packetflix.desktop -t "${pkgdir}"/usr/share/applications
}
5 changes: 5 additions & 0 deletions packaging/aur/makepackage.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash
set -e

docker build --pull -f Dockerfile -t archpkgbuilder .
docker run -it --rm --name archpkgbuilder -v .:/pkg archpkgbuilder && echo "SUCCESS" || echo "FAIL"
27 changes: 27 additions & 0 deletions packaging/aur/packagebuildandtest.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/bash
set -e

RED="\033[1;31m"
GREEN="\033[1;32m"
NOCOLOR="\033[0m"

cp -r /pkg /tmp/pkg
cd /tmp/pkg

makepkg --noconfirm --syncdeps --rmdeps --clean --install

# Pass back the PKGBUILD with checksum(s) included so that we can publish it as
# a release artefact from the release pipeline.
mkdir -p /pkg/dist
cp PKGBUILD /pkg/dist/

# Ask tshark to tell us the extcap interfaces it knows of: this must list the
# packetflix extcap so we know we've installed the plugin properly.
tshark -D | grep packetflix \
&& echo -e "${GREEN}OK:${NOCOLOR} tshark detects extcap plugin" \
|| (echo -e "${RED}FAIL:${NOCOLOR} tshark doesn't detect the packetflix extcap"; exit 1)

# Check that the default URL scheme handler registration is in place.
xdg-mime query default x-scheme-handler/packetflix | grep "packetflix.desktop" \
&& echo -e "${GREEN}OK:${NOCOLOR} packetflix URL scheme handler registered" \
|| (echo -e "${RED}FAIL:${NOCOLOR} packetflix URL scheme handler not detected"; exit 1)

0 comments on commit e28c0e8

Please sign in to comment.