Skip to content

Commit

Permalink
Merge pull request #260 from baconpaul/installer-mac-target-dir
Browse files Browse the repository at this point in the history
Have the output directory of the install be consistent
  • Loading branch information
baconpaul authored Jan 11, 2019
2 parents b0fa505 + 9530f94 commit 8dc86d3
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions installer_mac/make_installer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,11 @@ RSRCS="../resources/data"

OUTPUT_BASE_FILENAME="Surge-$VERSION-Setup"

TARGET_DIR="installer";

build_flavor()
{
TMPDIR=installer/tmp-pkg
TMPDIR=${TARGET_DIR}/tmp-pkg
flavor=$1
flavorprod=$2
ident=$3
Expand All @@ -52,7 +54,7 @@ build_flavor()
# The defaults only work if a component is a sole entry in a staging directory though, so synthesize that
# by moving the product to a tmp dir

mkdir $TMPDIR
mkdir -p $TMPDIR
mv $PRODUCTS/$flavorprod $TMPDIR

pkgbuild --root $TMPDIR --identifier $ident --version $VERSION --install-location $loc Surge_${flavor}.pkg || exit 1
Expand Down Expand Up @@ -142,19 +144,19 @@ XMLEND

# build installation bundle

if [[ ! -d installer ]]; then
mkdir installer
if [[ ! -d ${TARGET_DIR} ]]; then
mkdir ${TARGET_DIR}
fi
productbuild --distribution distribution.xml --package-path "./" --resources Resources "installer/$OUTPUT_BASE_FILENAME.pkg"
productbuild --distribution distribution.xml --package-path "./" --resources Resources "${TARGET_DIR}/$OUTPUT_BASE_FILENAME.pkg"

# create a DMG if required

if [[ $2 == "--dmg" ]]; then
if [[ -f "$OUTPUT_BASE_FILENAME.dmg" ]]; then
rm "$OUTPUT_BASE_FILENAME.dmg"
if [[ -f "${TARGET_DIR}/$OUTPUT_BASE_FILENAME.dmg" ]]; then
rm "${TARGET_DIR}/$OUTPUT_BASE_FILENAME.dmg"
fi
hdiutil create /tmp/tmp.dmg -ov -volname "$OUTPUT_BASE_FILENAME" -fs HFS+ -srcfolder "./installer/"
hdiutil convert /tmp/tmp.dmg -format UDZO -o "$OUTPUT_BASE_FILENAME.dmg"
hdiutil create /tmp/tmp.dmg -ov -volname "$OUTPUT_BASE_FILENAME" -fs HFS+ -srcfolder "./${TARGET_DIR}/"
hdiutil convert /tmp/tmp.dmg -format UDZO -o "${TARGET_DIR}/$OUTPUT_BASE_FILENAME.dmg"
fi

# clean up
Expand Down

0 comments on commit 8dc86d3

Please sign in to comment.