From 242d73489efb28562dc679526ae4d69588db6db3 Mon Sep 17 00:00:00 2001 From: Winford Date: Fri, 3 Nov 2023 22:34:53 -0700 Subject: [PATCH] Fix some small bugs in install.sh Fixes bashism in the `args` test in `install.sh` that don't work with POSIX `sh`, or `bash` in `sh` mode. Since location of `sh` can vary by operating system the use of `/usr/bin/env` to find the installed `sh` is a safe cross-platform way of launching this script as described in the `README`. Modified the pre-installation check to test if the currently installed version is the same rather than just for the presence of the `atomvm_packbeam` directory so that upgrading to other versions will be possible with future releases. Signed-off-by: Winford --- install.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/install.sh b/install.sh index a38e033..264233a 100755 --- a/install.sh +++ b/install.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/usr/bin/env sh # # This file is part of AtomVM. # @@ -48,7 +48,7 @@ set -e readonly root_dir="$(cd $(dirname $0) && pwd)" readonly nargs=$# -if [[ ${nargs} -lt 2 ]]; then +if [ ${nargs} -lt 2 ]; then echo echo "Syntax: $0 " echo " where is the prefix location for the install" @@ -84,8 +84,8 @@ echo_run cp "${src_tar}" "${tmp_dir}/." echo_run gunzip "${tmp_dir}/atomvm_packbeam-${version}.tar.gz" readonly dest_dir="${prefix}/atomvm_packbeam" -if [ -e "${dest_dir}" ]; then - echo "ERROR! It looks like ${dest_dir} already exists!" +if [ $(${dest_dir}/bin/packbeam version) = ${version} ]; then + echo "ERROR! It looks like ${version} is already installed!" exit 1 fi