Proper DMG support on macOS.

Previously `make install` on macOS created TuxPaint.dmg, but it was a
simple disk image.

Now TuxPaint.dmg is formatted as one would expect from any other macOS app,
with a Tux folder icon, symlink to the /Applications folder, and a
background image with an arrow.
This commit is contained in:
Mark K. Kim 2018-05-25 00:24:46 -04:00
parent 2aa7f4d2ae
commit b80393c11b
5 changed files with 53 additions and 5 deletions

1
.gitignore vendored
View file

@ -11,3 +11,4 @@ TuxPaint.app
TuxPaint.dmg
*.dylib
*.dylib.dSYM
.DS_Store

View file

@ -482,7 +482,8 @@ install: install-bin install-data install-man install-doc \
@echo
@if [ "x$(OS)" == "xosx" ]; then \
echo "All done! Now you can double click $(BUNDLE) to run the"; \
echo "program!!!"; \
echo "program!!! TuxPaint.dmg has also been created for"; \
echo "distribution."; \
echo; \
echo "For more information, see $(DOC_PREFIX)/README.txt"; \
else \
@ -591,7 +592,7 @@ clean:
@-rm -f templates/.thumbs/*.png
@if [ -d templates/.thumbs ]; then rmdir templates/.thumbs; fi
@-if [ "x$(BUNDLE)" != "x" ]; then rm -rf $(BUNDLE); fi
@-rm -f TuxPaint.dmg; rm -rf magic/*.dSYM
@-rm -f TuxPaint.dmg temp.dmg; rm -rf magic/*.dSYM
@echo
# "make uninstall" should remove the various parts from their
@ -1013,7 +1014,7 @@ install-man:
@chmod a+rx,g-w,o-w $(MAN_PREFIX)/man1/tp-magic-config.1.gz
# Install the support files for macOS application bundle
# Install the support files for macOS application bundle and create DMG
.PHONY: install-bundlefiles
install-bundlefiles:
@echo
@ -1026,8 +1027,9 @@ install-bundlefiles:
@install -m 644 macos/Info.plist $(BUNDLE)/Contents
@install -m 644 macos/tuxpaint.icns $(BUNDLE)/Contents/Resources
@custom/macos.sh
@echo "...Creating TuxPaint.dmg..."
@hdiutil create -volname "Tux Paint $(VER_VERSION)" -srcfolder $(BUNDLE) -ov -format UDBZ -o TuxPaint.dmg
@echo
@echo "...Creating DMG Distribution File..."
@custom/macos-mkdmg.sh
# Build the program!

45
custom/macos-mkdmg.sh Executable file
View file

@ -0,0 +1,45 @@
#!/bin/sh
BUNDLE=TuxPaint.app
TEMP_DMG=temp.dmg
TEMP_DMG_SIZE=`expr \`du -sm "$BUNDLE" | cut -f1\` \* 15 / 10`m
FINAL_DMG=TuxPaint.dmg
VOLNAME="Tux Paint"
ICON="macos/tuxpaint.icns"
BACKGROUND="macos/background.png"
echo " * Creating the temporary image..."
hdiutil create "$TEMP_DMG" -ov -fs HFS+ -size "$TEMP_DMG_SIZE" -volname "$VOLNAME" \
&& VOLUME=`hdiutil attach "$TEMP_DMG" -nobrowse -noverify -noautoopen | grep Apple_HFS | sed 's/^.*Apple_HFS[[:blank:]]*//'` \
|| exit 1
echo " * Adding the image background..."
mkdir "$VOLUME/.background" \
&& tiffutil -cathidpicheck "$BACKGROUND" -out "$VOLUME/.background/background.tiff" \
|| exit 1
echo " * Setting the folder icon..."
cp "$ICON" "$VOLUME/.VolumeIcon.icns" \
&& xattr -wx com.apple.FinderInfo '00 00 00 00 00 00 00 00 04 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00' "$VOLUME" \
|| exit 1
echo " * Copying the contents..."
ln -s "/Applications" "$VOLUME" \
&& cp -a "$BUNDLE" "$VOLUME" \
&& cp -a "macos/DS_Store" "$VOLUME/.DS_Store" \
|| exit 1
echo " * Configuring the folder to open upon mount..."
bless --folder "$VOLUME" --openfolder "$VOLUME" \
|| exit 1
echo " * Unmounting the temporary image..."
hdiutil detach "$VOLUME"
echo " * Creating the final image..."
hdiutil convert "$TEMP_DMG" -ov -format "UDBZ" -imagekey "zlib-level=9" -o "$FINAL_DMG"
echo " * Deleting the temporary image..."
rm -f "$TEMP_DMG"

BIN
macos/DS_Store Normal file

Binary file not shown.

BIN
macos/background.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB