diff --git a/src/linux/Packaging.Linux/Packaging.Linux.csproj b/src/linux/Packaging.Linux/Packaging.Linux.csproj index b9fb5ccd5..362ffc230 100644 --- a/src/linux/Packaging.Linux/Packaging.Linux.csproj +++ b/src/linux/Packaging.Linux/Packaging.Linux.csproj @@ -9,6 +9,7 @@ false + /usr/local @@ -23,8 +24,8 @@ - - + + diff --git a/src/linux/Packaging.Linux/build.sh b/src/linux/Packaging.Linux/build.sh index 3b179e22d..6672857d2 100755 --- a/src/linux/Packaging.Linux/build.sh +++ b/src/linux/Packaging.Linux/build.sh @@ -30,12 +30,21 @@ case "$i" in INSTALL_FROM_SOURCE="${i#*=}" shift # past argument=value ;; + --install-prefix=*) + INSTALL_PREFIX="${i#*=}" + shift # past argument=value + ;; *) # unknown option ;; esac done +# Ensure install prefix exists +if [! -d "$INSTALL_PREFIX" ]; then + mkdir -p "$INSTALL_PREFIX" +fi + # Perform pre-execution checks CONFIGURATION="${CONFIGURATION:=Debug}" if [ -z "$VERSION" ]; then @@ -50,14 +59,11 @@ SYMBOLS="$OUTDIR/payload.sym" "$INSTALLER_SRC/layout.sh" --configuration="$CONFIGURATION" || exit 1 if [ $INSTALL_FROM_SOURCE = true ]; then - INSTALL_LOCATION="/usr/local" - mkdir -p "$INSTALL_LOCATION" - - echo "Installing..." + echo "Installing to $INSTALL_PREFIX" # Install directories - INSTALL_TO="$INSTALL_LOCATION/share/gcm-core/" - LINK_TO="$INSTALL_LOCATION/bin/" + INSTALL_TO="$INSTALL_PREFIX/share/gcm-core/" + LINK_TO="$INSTALL_PREFIX/bin/" mkdir -p "$INSTALL_TO" "$LINK_TO" diff --git a/src/linux/Packaging.Linux/install-from-source.sh b/src/linux/Packaging.Linux/install-from-source.sh index e379a55f5..98fe7bc4d 100755 --- a/src/linux/Packaging.Linux/install-from-source.sh +++ b/src/linux/Packaging.Linux/install-from-source.sh @@ -13,15 +13,30 @@ for i in "$@"; do is_ci=true shift # Past argument=value ;; + --install-prefix=*) + installPrefix="${i#*=}" + shift # past argument=value + ;; esac done +# If install-prefix is not passed, use default value +if [ -z "$installPrefix" ]; then + installPrefix=/usr/local +fi + +# Ensure install directory exists +if [! -d "$installPrefix" ]; then + echo "The folder $installPrefix does not exist" + exit +fi + # In non-ci scenarios, advertise what we will be doing and # give user the option to exit. if [ -z $is_ci ]; then echo "This script will download, compile, and install Git Credential Manager to: - /usr/local/bin + $installPrefix/bin Git Credential Manager is licensed under the MIT License: https://aka.ms/gcm/license" @@ -225,5 +240,5 @@ if [ -z "$DOTNET_ROOT" ]; then fi cd "$toplevel_path" -$sudo_cmd env "PATH=$PATH" $DOTNET_ROOT/dotnet build ./src/linux/Packaging.Linux/Packaging.Linux.csproj -c Release -p:InstallFromSource=true -add_to_PATH "/usr/local/bin" +$sudo_cmd env "PATH=$PATH" $DOTNET_ROOT/dotnet build ./src/linux/Packaging.Linux/Packaging.Linux.csproj -c Release -p:InstallFromSource=true -p:installPrefix=$installPrefix +add_to_PATH "$installPrefix/bin"