aboutsummaryrefslogtreecommitdiffstats
path: root/extras/packethicn/install_macos.sh
blob: 7aa6413eff0ad6b5718d765598c21ab91fd37f66 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# Copyright (c) 2021 Cisco and/or its affiliates.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at:
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

#!/bin/bash

mkdir -p build
pushd build

cmake .. || exit 1
make || exit 1

echo "Installing..."
sudo make install || exit 1
popd

BUILD_DIR="build/build-root/lib"
SO_LIB="packethicn.so"

WS_LIB_PATH_LIST=$(otool -L $BUILD_DIR/$SO_LIB | grep wireshark | awk '{print $1}')

while IFS= read -r PATHL; do
  LIB=$(echo $PATHL | cut -d / -f 7)
  install_name_tool -change $PATHL @rpath/$LIB $BUILD_DIR/$SO_LIB
done <<< "$WS_LIB_PATH_LIST"

WS_GUI_PATH_LIST=$(find /usr/local -name Wireshark.app -print 2>/dev/null)
if [ $? == 0 ]; then
  while IFS= read -r PATHL; do
    EPAN_PATH=$(find ${PATHL}/Contents -name epan)
    cp $BUILD_DIR/$SO_LIB $EPAN_PATH
    echo "Installed $BUILD_DIR/$SO_LIB in $EPAN_PATH"
  done <<< "$WS_GUI_PATH_LIST"
else
  echo "Can't find the Wireshark GUI. Please copy $BUILD_DIR/$SO_LIB into the Wireshark plugin folder"
fi