diff --git a/Scripts/install-dependencies.sh b/Scripts/install-dependencies.sh index 38ece54..eeb06b3 100644 --- a/Scripts/install-dependencies.sh +++ b/Scripts/install-dependencies.sh @@ -13,6 +13,8 @@ if [ $EUID -ne 0 ]; then exit 1 fi +testcmd() { command -v "$1" &> /dev/null; } + arch_name="$(uname -m)" osVariant="" @@ -28,20 +30,17 @@ if [ "${OSTYPE:0:6}" == "darwin" ]; then #brew analytics off #brew install git cmake mono-libgdiplus #brew install --cask dotnet -elif command -v apt-get &> /dev/null -then +elif testcmd apt-get; then osVariant="debian" apt-get update apt-get install -y libdc1394-22 libopenexr24 apt-get install -y libdc1394-25 libopenexr25 apt-get install -y libjpeg-dev libpng-dev libgeotiff-dev libgeotiff5 libavcodec-dev libavformat-dev libswscale-dev libtbb-dev libgl1-mesa-dev libgdiplus -elif command -v pacman &> /dev/null -then +elif testcmd pacman; then osVariant="arch" pacman -Syu pacman -S openjpeg2 libjpeg-turbo libpng libgeotiff libdc1394 ffmpeg openexr tbb libgdiplus -elif command -v yum &> /dev/null -then +elif testcmd yum; then osVariant="rhel" yum update -y yum install -y https://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-$(rpm -E %fedora).noarch.rpm diff --git a/Scripts/install-uvtools.sh b/Scripts/install-uvtools.sh index 494c0f3..ffc8f8d 100644 --- a/Scripts/install-uvtools.sh +++ b/Scripts/install-uvtools.sh @@ -13,7 +13,8 @@ api_url="https://api.github.com/repos/sn4k3/UVtools/releases/latest" dependencies_url="https://raw.githubusercontent.com/sn4k3/UVtools/master/Scripts/install-dependencies.sh" macOS_least_version=10.15 -function version { echo "$@" | awk -F. '{ printf("%d%03d%03d%03d\n", $1,$2,$3,$4); }'; } +version() { echo "$@" | awk -F. '{ printf("%d%03d%03d%03d\n", $1,$2,$3,$4); }'; } +testcmd() { command -v "$1" &> /dev/null; } if [ "$arch_name" != "x86_64" -a "$arch_name" != "arm64" ]; then echo "Error: Unsupported host arch $arch_name" @@ -36,7 +37,7 @@ if [ "${OSTYPE:0:6}" == "darwin" ]; then exit -1 fi - if [ -z "$(command -v brew)" ]; then + if ! testcmd brew; then bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" if [ -f "/opt/homebrew/bin/brew" -a -z "$(command -v brew)" ]; then echo '# Set PATH, MANPATH, etc., for Homebrew.' >> "$HOME/.zprofile" @@ -80,16 +81,13 @@ fi fi exit 1 -elif command -v apt-get &> /dev/null -then +elif testcmd apt-get; then osVariant="linux" [ -z "$(command -v curl)" ] && sudo apt-get install -y curl -elif command -v pacman &> /dev/null -then +elif testcmd pacman; then osVariant="arch" [ -z "$(command -v curl)" ] && sudo pacman -S curl -elif command -v yum &> /dev/null -then +elif testcmd yum; then osVariant="rhel" [ -z "$(command -v curl)" ] && sudo yum install -y curl fi diff --git a/build/createRelease.sh b/build/createRelease.sh index 8d89f72..88f98c0 100644 --- a/build/createRelease.sh +++ b/build/createRelease.sh @@ -12,6 +12,8 @@ cd "$(dirname "$0")" cd .. [ ! -d "UVtools.Core" ] && echo "UVtools.Core not found!" && exit -1 +testcmd() { command -v "$1" &> /dev/null; } + #runtime=$1 for runtime in $@; do :; done # Get last argument rootDir="$(pwd)" @@ -61,8 +63,7 @@ done #echo "Zip package: $zipPackage" # Checks -if ! command -v dotnet &> /dev/null -then +if ! testcmd dotnet; then echo "Error: dotnet not installed, please install .NET SDK $netVersion.x, dotnet-sdk or dotnet-sdk-$netVersion" exit fi