From 492b37747d33eda310521370e08391b0639fd78a Mon Sep 17 00:00:00 2001 From: code liturgy Date: Sun, 6 Nov 2022 12:50:22 -0500 Subject: [PATCH] Add platform specific conditions --- Sharp.Augeas/Program.cs | 17 +++++++++++++++-- Sharp.Augeas/copyLibrary.sh | 9 ++++++--- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/Sharp.Augeas/Program.cs b/Sharp.Augeas/Program.cs index c37061b..25e785b 100644 --- a/Sharp.Augeas/Program.cs +++ b/Sharp.Augeas/Program.cs @@ -1,9 +1,22 @@ -using Sharp.Augeas; +using System.Runtime.InteropServices; +using Sharp.Augeas; using Sharp.Augeas.Test; var path = Environment.CurrentDirectory; var root = $"{path}/root/"; -AugSettings augSettings = new AugSettings(root, "/opt/homebrew/share/augeas/lenses/dist"); + +var lensPath = ""; + +if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) +{ + lensPath = "/usr/share/augeas/lenses/dist"; +} +if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) +{ + lensPath = "/opt/homebrew/share/augeas/lenses/dist"; +} + +AugSettings augSettings = new AugSettings(root, lensPath); var augeas = new Augeas(augSettings); // Calling extern functions diff --git a/Sharp.Augeas/copyLibrary.sh b/Sharp.Augeas/copyLibrary.sh index 6269a40..bd60c6d 100755 --- a/Sharp.Augeas/copyLibrary.sh +++ b/Sharp.Augeas/copyLibrary.sh @@ -1,6 +1,9 @@ #!/bin/bash - -LIB_FILE=libclAugeas.dylib +if [[ "$OSTYPE" == "linux-gnu"* ]]; then + LIB_FILE=libclAugeas.so +elif [[ "$OSTYPE" == "darwin"* ]]; then + LIB_FILE=libclAugeas.dylib +fi SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) DESTIN=$SCRIPT_DIR/bin/Debug/net6.0 @@ -9,7 +12,7 @@ DESTIN=$SCRIPT_DIR/bin/Debug/net6.0 if [[ -z "${CLAUG_LIB_PATH}" ]]; then echo "error: set the CLAUG_LIB_PATH in the ${LIB_FILE} location." echo - return + exit 2 fi BINARY=$CLAUG_LIB_PATH/$LIB_FILE