bash 如何从命令行安装 DMG 文件?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/6357914/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-18 00:11:10  来源:igfitidea点击:

How do I install a DMG file from the command line?

pythonmacosbash

提问by sorin

I am looking for small bash or python script that will install a .dmgfile.

我正在寻找将安装.dmg文件的小型 bash 或 python 脚本。

We'll assume that the dmg contains one or more .appdirectories that have to be copied to /Applications, overriding any already existing directories.

我们假设 dmg 包含一个或多个.app必须复制到 的/Applications目录,覆盖任何已经存在的目录。

Files or directories not matching the *.apppattern are to be ignored.

*.app模式不匹配的文件或目录将被忽略。

回答by nimrodm

You can mount the disk image using

您可以使用挂载磁盘映像

hdiutil attach -mountpoint <path-to-desired-mountpoint> <filename.dmg>

The disk image will be mounted at the selected path (the argument following -mountpoint). Then, search for an .appfile and copy the file to /Applications.

磁盘映像将安装在选定的路径(后面的参数-mountpoint)。然后,搜索一个.app文件并将该文件复制到/Applications.

Once you have finished installation unmount the disk image:

完成安装后,卸载磁盘映像:

hdiutil detach <path-to-mountpoint>