macos - 使用 $HOME/Application 文件夹创建 dmg 安装程序

标签 macos installation packagemaker dmg home-directory

我已经在根应用程序文件夹 (/Application) 中创建了用于应用程序安装的脚本,但是我无法为用户主文件夹 $HOME/Application (~/Application) 创建相同的脚本。
这是我的脚本

#!/bin/sh
#http://stackoverflow.com/questions/96882/how-do-i-create-a-nice-looking-dmg-for-mac-os-x-using-command-line-tools

set -o verbose #echo onset +o verbose #echo off

# Note: this must run on a Mac

APP_NAME="XXX"
OUT_MAC=out/
DMG_PATH=${OUT_MAC}${APP_NAME}.dmg
DMG_CONTENT_PATH=${OUT_MAC}contents
BUNDLE_PATH=${DMG_CONTENT_PATH}/${APP_NAME}.app

#clean old dmg if exist
rm -rf ${DMG_PATH}

SetFile -a B "${BUNDLE_PATH}"

hdiutil create -srcfolder ${DMG_CONTENT_PATH} -volname ${APP_NAME} -fs HFS+ \
-fsargs "-c c=64,a=16,e=16" -format UDRW -size 550m ${DMG_PATH}.temp.dmg

device=$(hdiutil attach -readwrite -noverify -noautoopen "${DMG_PATH}".temp.dmg | \
egrep '^/dev/' | sed 1q | awk '{print $1}')

osascript <<EOT
tell application "Finder"
tell disk "${APP_NAME}"
open
set current view of container window to icon view
set toolbar visible of container window to false
set statusbar visible of container window to false
set the bounds of container window to {200, 100, 900, 530}
set theViewOptions to the icon view options of container window
set arrangement of theViewOptions to snap to grid
set icon size of theViewOptions to 96
set background picture of theViewOptions to file ".background:installer_dmg_bg.png"
make new alias file at container window to POSIX file "/Applications" with properties {name:"Applications"}
delay 1
set position of item "${APP_NAME}" of container window to {200, 200}
set position of item "Applications" of container window to {500, 200}
-- update without registering applications
delay 5
-- eject
end tell
end tell
EOT

chmod -Rf go-w "/Volumes/${APP_NAME}"
sync
sync
hdiutil detach ${device}
sync
hdiutil convert "${DMG_PATH}".temp.dmg -format UDZO -imagekey zlib-level=9 -o ${DMG_PATH}
rm -rf "${DMG_PATH}".temp.dmg

我试着改变

make new alias file at container window to POSIX file "/Applications" with properties {name:"Applications"}





make new alias file at container window to POSIX file "~/Applications" with properties {name:"Applications"}





make new alias file at container window to POSIX file "$HOME/Applications" with properties {name:"Applications"}



但没有运气!

最佳答案

如果您指定,则可以执行此操作:

path to applications folder from user domain

所以在你的脚本中它可能是这样的:
set appHome to path to applications folder from user domain
make new alias file at container window to appHome with properties {name:"Applications"}

*使用时 从用户域到应用程序文件夹的路径 POSIX file不需要。

关于macos - 使用 $HOME/Application 文件夹创建 dmg 安装程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21598009/

相关文章:

osx-snow-leopard - 在 Snow Leopard 上,带有预安装脚本的 PackageMaker 安装是否损坏?

macos - Applescript提取YouTube Livestream视频ID

python - 有哪些有用的 TextMate 功能?

ruby - 如何避免多个程序(git、ruby、python)和默认网络驱动器路径问题的持续问题?

installation - 更改 NSIS 中的默认安装文件夹

python - 从 setup.py 中检测 python 包安装路径

c - 在 Intel 机器上构建 Apple Silicon 二进制文件

android - 如何从 OSX 上的 Wireshark 中的 Android 模拟器获取 tcpdump 的实时 View ?

macos - 在 Mac OS X 上查找 .app/使用 XCode 4.3 运行 PackageMaker 的正确方法

macos - Mac OS X上的软件包卸载程序