diff --git a/bundle.sh b/bundle.sh index ca8cede..19fae62 100755 --- a/bundle.sh +++ b/bundle.sh @@ -4,17 +4,25 @@ err_ok=0 err_bad_arg=1 err_bad_run=2 -rm_if_dir() { - [[ -d $1 ]] && rm -rf "$1" && echo "removed $1" +rm_if() { + if [[ -d $1 ]]; + then + rm -rf "$1" && echo "removed dir $1" + elif [[ -f $1 ]] + then + rm -f "$1" && echo "removed file $1" + fi + return 0 } perish() { - rm_if_dir "${tmpdir}" + rm_if "${tmpdir}" exit "$1" } err() { echo "error, dropping build" - rm_if_dir "${appdir}" + rm_if "${appdir}" + rm_if "${dmg}" perish $1 } :() { @@ -49,16 +57,21 @@ exedir=$(dirname "${exe}") appdir=${exedir}/${app} tmpdir=$(mktemp -d) +diskdir=${tmpdir}/disk icondir=${tmpdir}/${name}.iconset + icon=${srcdir}/${icon_names[${name}]} +dmg=${exedir}/${name}.dmg -: rm_if_dir "${appdir}" +: rm_if "${appdir}" -: mkdir -p "${appdir}/Contents/"{Frameworks,MacOS,Resources} "${icondir}" +: mkdir -p "${appdir}/Contents/"{Frameworks,MacOS,Resources} : cp "${exe}" "${appdir}/Contents/MacOS" : cp "${srcdir}/resources/Info.plist" "${appdir}/Contents" +: mkdir -p "${icondir}" + : sips -z 16 16 "${icon}" --out "${icondir}/icon_16x16.png" : sips -z 32 32 "${icon}" --out "${icondir}/icon_32x32.png" : sips -z 64 64 "${icon}" --out "${icondir}/icon_64x64.png" @@ -81,6 +94,22 @@ do done < "${exedir}"/build/maraiah-tycho-*/out/etc/link.txt echo "success: bundle written to ${appdir}" + +if [[ ! "$NO_DMG" ]] +then + echo "creating the disk image..." + + : rm_if "${dmg}" + + : mkdir -p "${diskdir}" + : cp -r "${appdir}" "${diskdir}" + : cp "${srcdir}/resources/Image.DS_Store" "${diskdir}/.DS_Store" + : ln -s /Applications "${diskdir}" + : hdiutil create -volname "${name}" -srcfolder "${diskdir}" "${dmg}" + + echo "success: dmg written to ${dmg}" +fi + perish ${err_ok} ## EOF diff --git a/tycho/resources/Image.DS_Store b/tycho/resources/Image.DS_Store new file mode 100644 index 0000000..e52bf39 Binary files /dev/null and b/tycho/resources/Image.DS_Store differ