|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +# Product information |
| 4 | +NAME="Git Credential Manager" |
| 5 | +IDENTIFIER="com.microsoft.GitCredentialManager" |
| 6 | +INSTALL_LOCATION="/usr/local/share/gcm-core" |
| 7 | + |
| 8 | +# Directories |
| 9 | +THISDIR="$( cd "$(dirname "$0")" ; pwd -P )" |
| 10 | +ROOT="$( cd $THISDIR/../.. ; pwd -P )" |
| 11 | +OUT=$ROOT/out |
| 12 | +PKGSCRIPTS=$ROOT/macos/installer/scripts |
| 13 | +MACOUT=$OUT/macos |
| 14 | +INSTALLEROUT=$MACOUT/installer/ |
| 15 | +PKGPAYLOAD=$INSTALLEROUT/payload |
| 16 | + |
| 17 | +# Parse script arguments |
| 18 | +for i in "$@" |
| 19 | +do |
| 20 | +case $i in |
| 21 | + -v=*|--version=*) |
| 22 | + VERSION="${i#*=}" |
| 23 | + shift # past argument=value |
| 24 | + ;; |
| 25 | + -c=*|--configuration=*) |
| 26 | + CONFIGURATION="${i#*=}" |
| 27 | + shift # past argument=value |
| 28 | + ;; |
| 29 | + *) |
| 30 | + # unknown option |
| 31 | + ;; |
| 32 | +esac |
| 33 | +done |
| 34 | + |
| 35 | +# Set default arguments |
| 36 | +VERSION=${VERSION:=1.0} |
| 37 | +CONFIGURATION=${CONFIGURATION:=Release} |
| 38 | + |
| 39 | +# Ensure output directories exist |
| 40 | +mkdir -p $MACOUT $PKGPAYLOAD |
| 41 | + |
| 42 | +# Publish the core product |
| 43 | +dotnet publish --runtime osx-x64 --configuration $CONFIGURATION --output $PKGPAYLOAD $ROOT/common/src/Git-Credential-Manager |
| 44 | + |
| 45 | +# Build the native credential helpers |
| 46 | +pod install --project-directory=$ROOT/macos/Microsoft.Authentication.Helper |
| 47 | +xcodebuild \ |
| 48 | + -workspace $ROOT/macos/Microsoft.Authentication.Helper/Microsoft.Authentication.Helper.xcworkspace \ |
| 49 | + -scheme Microsoft.Authentication.Helper \ |
| 50 | + -configuration $CONFIGURATION \ |
| 51 | + -derivedDataPath $MACOUT/Microsoft.Authentication.Helper |
| 52 | + |
| 53 | +# Copy helper executables to payload directory |
| 54 | +cp $MACOUT/Microsoft.Authentication.Helper/Build/Products/$CONFIGURATION/Microsoft.Authentication.Helper $PKGPAYLOAD |
| 55 | + |
| 56 | +# Copy uninstaller script |
| 57 | +cp $ROOT/macos/installer/uninstall-gcm.sh $PKGPAYLOAD |
| 58 | + |
| 59 | +# Remove any unwanted .DS_Store files |
| 60 | +find $PKGPAYLOAD -name '*.DS_Store' -type f -delete |
| 61 | + |
| 62 | +# Set full read, write, execute permissions for owner and just read and execute permissions for group and other |
| 63 | +/bin/chmod -R 755 $PKGPAYLOAD |
| 64 | + |
| 65 | +# Remove any extended attributes (ACEs) |
| 66 | +/usr/bin/xattr -rc $PKGPAYLOAD |
| 67 | + |
| 68 | +# Build installer package |
| 69 | +/usr/bin/pkgbuild \ |
| 70 | + --root $PKGPAYLOAD/ \ |
| 71 | + --install-location "$INSTALL_LOCATION" \ |
| 72 | + --scripts $PKGSCRIPTS/ \ |
| 73 | + --identifier "$IDENTIFIER" \ |
| 74 | + --version "$VERSION" \ |
| 75 | + "$INSTALLEROUT/$NAME.pkg" |
0 commit comments