Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Update the Mac installer to make a product archive package/installer #198

Merged
merged 1 commit into from
Oct 29, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
osx: update the Mac installer to make product archives
Update the macOS installer build to also create a distribution/product
archive package, that contains the flat component package we were
already building.

The product archive allows us to do things like set welcome and
conclusion messages, titles, and display a license (like the Windows
installers do).

In the new welcome and conclusion screens we include helpful links and
instructions on how to uninstall GCM Core, and how to configure it for
other users on the system.

The macOS installer continues to install in a global location, but only
configure the user's global Git configuration.
  • Loading branch information
mjcheetham committed Oct 28, 2020
commit 4514b0f9188ec928a1183594e623133ff08a8b74
10 changes: 7 additions & 3 deletions src/osx/Installer.Mac/build.sh
Original file line number Diff line number Diff line change
@@ -38,11 +38,15 @@ if [ -z "$VERSION" ]; then
die "--version was not set"
fi

PAYLOAD="$INSTALLER_OUT/pkg/$CONFIGURATION/payload"
PKGOUT="$INSTALLER_OUT/pkg/$CONFIGURATION/gcmcore-osx-$VERSION.pkg"
OUTDIR="$INSTALLER_OUT/pkg/$CONFIGURATION"
PAYLOAD="$OUTDIR/payload"
COMPONENTDIR="$OUTDIR/components"
COMPONENTOUT="$COMPONENTDIR/com.microsoft.gitcredentialmanager.component.pkg"
DISTOUT="$OUTDIR/gcmcore-osx-$VERSION.pkg"

# Layout and pack
"$INSTALLER_SRC/layout.sh" --configuration="$CONFIGURATION" --output="$PAYLOAD" || exit 1
"$INSTALLER_SRC/pack.sh" --payload="$PAYLOAD" --version="$VERSION" --output="$PKGOUT" || exit 1
"$INSTALLER_SRC/pack.sh" --payload="$PAYLOAD" --version="$VERSION" --output="$COMPONENTOUT" || exit 1
"$INSTALLER_SRC/dist.sh" --package-path="$COMPONENTDIR" --version="$VERSION" --output="$DISTOUT" || exit 1

echo "Build of Installer.Mac complete."
73 changes: 73 additions & 0 deletions src/osx/Installer.Mac/dist.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
#!/bin/bash
die () {
echo "$*" >&2
exit 1
}

# Directories
THISDIR="$( cd "$(dirname "$0")" ; pwd -P )"
ROOT="$( cd "$THISDIR"/../../.. ; pwd -P )"
SRC="$ROOT/src"
OUT="$ROOT/out"
INSTALLER_SRC="$SRC/osx/Installer.Mac"
RESXPATH="$INSTALLER_SRC/resources"
DISTPATH="$INSTALLER_SRC/distribution.xml"

# Product information
IDENTIFIER="com.microsoft.gitcredentialmanager.dist"

# Parse script arguments
for i in "$@"
do
case "$i" in
--version=*)
VERSION="${i#*=}"
shift # past argument=value
;;
--package-path=*)
PACKAGEPATH="${i#*=}"
shift # past argument=value
;;
--output=*)
DISTOUT="${i#*=}"
shift # past argument=value
;;
*)
# unknown option
;;
esac
done

# Perform pre-execution checks
if [ -z "$VERSION" ]; then
die "--version was not set"
fi
if [ -z "$PACKAGEPATH" ]; then
die "--package-path was not set"
elif [ ! -d "$PACKAGEPATH" ]; then
die "Could not find '$PACKAGEPATH'. Did you run pack.sh first?"
fi
if [ -z "$DISTOUT" ]; then
die "--output was not set"
fi

# Cleanup any old package
if [ -e "$DISTOUT" ]; then
echo "Deleteing old product package '$DISTOUT'..."
rm "$DISTOUT"
fi

# Ensure the parent directory for the package exists
mkdir -p "$(dirname "$DISTOUT")"

# Build product installer
echo "Building product package..."
/usr/bin/productbuild \
--package-path "$PACKAGEPATH" \
--resources "$RESXPATH" \
--distribution "$DISTPATH" \
--identifier "$IDENTIFIER" \
--version "$VERSION" \
"$DISTOUT" || exit 1

echo "Product build complete."
21 changes: 21 additions & 0 deletions src/osx/Installer.Mac/distribution.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<installer-gui-script minSpecVersion="1">
<title>Git Credential Manager Core</title>
<background file="background.png" mime-type="image/png" alignment="bottomleft" scaling="tofit" />
<options customize="never" />
<welcome file="welcome.html" mime-type="text/html" />
<conclusion file="conclusion.html" mime-type="text/html" />
<license file="LICENSE" />
<volume-check>
<allowed-os-versions>
<os-version min="10.13" />
</allowed-os-versions>
</volume-check>
<pkg-ref id="gcmcore" />
<choices-outline>
<line choice="default" />
</choices-outline>
<choice id="default" visible="true" enabled="false" title="Git Credential Manager Core" description="Git Credential Manager core application.">
<pkg-ref id="gcmcore">com.microsoft.gitcredentialmanager.component.pkg</pkg-ref>
</choice>
</installer-gui-script>
14 changes: 7 additions & 7 deletions src/osx/Installer.Mac/pack.sh
Original file line number Diff line number Diff line change
@@ -12,7 +12,7 @@ OUT="$ROOT/out"
INSTALLER_SRC="$SRC/osx/Installer.Mac"

# Product information
IDENTIFIER="com.microsoft.GitCredentialManager"
IDENTIFIER="com.microsoft.gitcredentialmanager"
INSTALL_LOCATION="/usr/local/share/gcm-core"

# Parse script arguments
@@ -50,13 +50,13 @@ if [ -z "$PKGOUT" ]; then
die "--output was not set"
fi

# Cleanup any old package file
# Cleanup any old component
if [ -e "$PKGOUT" ]; then
echo "Deleteing old package '$PKGOUT'..."
echo "Deleteing old component '$PKGOUT'..."
rm "$PKGOUT"
fi

# Ensure the parent directory for the package exists
# Ensure the parent directory for the component exists
mkdir -p "$(dirname "$PKGOUT")"

# Set full read, write, execute permissions for owner and just read and execute permissions for group and other
@@ -67,8 +67,8 @@ echo "Setting file permissions..."
echo "Removing extended attributes..."
/usr/bin/xattr -rc "$PAYLOAD" || exit 1

# Build installer package
echo "Building installer package..."
# Build component packages
echo "Building core component package..."
/usr/bin/pkgbuild \
--root "$PAYLOAD/" \
--install-location "$INSTALL_LOCATION" \
@@ -77,4 +77,4 @@ echo "Building installer package..."
--version "$VERSION" \
"$PKGOUT" || exit 1

echo "Pack complete."
echo "Component pack complete."
Binary file added src/osx/Installer.Mac/resources/background.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/osx/Installer.Mac/resources/en.lproj/LICENSE
41 changes: 41 additions & 0 deletions src/osx/Installer.Mac/resources/en.lproj/conclusion.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<style>
body { font-family: Helvetica; margin: 0 20px; }
h2 { font-weight: normal; }
.section { overflow: auto; }
.mono { font-family: monospace; }
</style>
</head>
<body>
<div class="section">
<p>Git Credential Manager Core was installed in <a href="file:///usr/local/share/gcm-core"><code>/usr/local/share/gcm-core</code></a> and configured for the current user.</p>
</div>
<div class="section">
<h2>Other users</h2>
<p>
GCM Core has already been automatically configured for use by the current user with Git.
If other users wish to use GCM Core, have them run the following command to update their global Git configuration (<code>~/.gitconfig</code>):
</p>
<p class="mono">$ git-credential-manager-core configure</p>
<p>
To configure GCM Core for all users, run the following command to update the system Git configuration:
</p>
<p class="mono">$ git-credential-manager-core configure --system</p>
</div>
<div class="section">
<h2>Uninstall</h2>
<p>If you wish to uninstall GCM Core, run the following script:</p>
<p class="mono">$ /usr/local/share/gcm-core/uninstall.sh</p>
</div>
<div class="section">
<h2>Resources</h3>
<ul>
<li><a href="https://aka.ms/gcmcore">Project homepage</a></li>
<li><a href="https://aka.ms/gcmcore-config">Configuration options</a></li>
</ul>
</div>
</body>
</html>
34 changes: 34 additions & 0 deletions src/osx/Installer.Mac/resources/en.lproj/welcome.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<style>
body { font-family: Helvetica; margin: 0 20px; }
h2 { font-weight: normal; }
.section { overflow: auto; }
</style>
</head>
<body>
<div class="section">
<h2>Git Credential Manager Core</h2>
<p>
Git Credential Manager Core is a secure, cross-platform Git credential helper with authentication support for GitHub, Azure Repos, and other popular Git hosting services.
</p>
</div>
<div class="section">
<h2>Installation notes</h2>
<p>
If you have the old Java-based <a href="https://github.com/microsoft/Git-Credential-Manager-for-Mac-and-Linux">Git Credential Manager for Mac & Linux</a> installed through Homebrew, it will be unlinked after installation.
</p>
<p>
Git Credential Manager Core will be configured as the Git credential helper for the system or user, depending on if it is installed for all users, or just the current user.
</p>
</div>
<div class="section">
<h2>Learn more</h2>
<ul>
<li><a href="https://aka.ms/gcmcore">Project homepage</a></li>
</ul>
</div>
</body>
</html>
7 changes: 5 additions & 2 deletions src/osx/Installer.Mac/scripts/postinstall
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
#!/bin/bash
set -e

PACKAGE=$1
INSTALL_DESTINATION=$2

function IsBrewPkgInstalled
{
# Check if Homebrew is installed
@@ -24,9 +27,9 @@ then
fi

# Create symlink to GCM in /usr/local/bin
/bin/ln -Fs /usr/local/share/gcm-core/git-credential-manager-core /usr/local/bin/git-credential-manager-core
/bin/ln -Fs "$INSTALL_DESTINATION/git-credential-manager-core" /usr/local/bin/git-credential-manager-core

# Configure GCM for the current user
/usr/local/share/gcm-core/git-credential-manager-core configure
"$INSTALL_DESTINATION/git-credential-manager-core" configure

exit 0
12 changes: 8 additions & 4 deletions src/osx/Installer.Mac/uninstall.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
#!/bin/bash

THISDIR="$( cd "$(dirname "$0")" ; pwd -P )"
GCMBIN="$THISDIR/git-credential-manager-core"

# Ensure we're running as root
if [ $(id -u) != "0" ]
then
@@ -9,7 +12,7 @@ fi

# Unconfigure
echo "Unconfiguring credential helper..."
/usr/local/share/gcm-core/git-credential-manager-core unconfigure
"$GCMBIN" unconfigure

# Remove symlink
if [ -L /usr/local/bin/git-credential-manager-core ]
@@ -21,13 +24,14 @@ else
fi

# Forget package installation/delete receipt
sudo pkgutil --forget com.microsoft.GitCredentialManager
echo "Removing installation receipt..."
pkgutil --forget com.microsoft.gitcredentialmanager

# Remove application files
if [ -d /usr/local/share/gcm-core/ ]
if [ -d "$THISDIR" ]
then
echo "Deleting application files..."
sudo rm -rf /usr/local/share/gcm-core/
rm -rf "$THISDIR"
else
echo "No application files found."
fi