在蘋果用命令掛載 .dmg 並遠端安裝 .pkg
在遠端管理mac的時候就需要這樣的技巧.
第一個步驟. 要先知道如何掛載 dmg 映像檔.
# hdiutil attach foo.dmg
Checksumming Driver Descriptor Map (DDM : 0)…
Driver Descriptor Map (DDM : 0): verified CRC32 $FEF30ABC
Checksumming (Apple_Free : 1)…
(Apple_Free : 1): verified CRC32 $00000000
Checksumming Apple (Apple_partition_map : 2)…
Apple (Apple_partition_map : 2): verified CRC32 $759BB202
Checksumming Macintosh (Apple_Driver_ATAPI : 3)…
Macintosh (Apple_Driver_ATAPI : 3): verified CRC32 $F1E8BA9E
Checksumming (Apple_Free : 4)…
(Apple_Free : 4): verified CRC32 $00000000
Checksumming disk image (Apple_HFS : 5)…
………………………………………………………………
disk image (Apple_HFS : 5): verified CRC32 $02C572A3
Checksumming (Apple_Free : 6)…
(Apple_Free : 6): verified CRC32 $00000000
verified CRC32 $31655A51
/dev/disk1 Apple_partition_scheme
/dev/disk1s1 Apple_partition_map
/dev/disk1s2 Apple_Driver_ATAPI
/dev/disk1s3 Apple_HFS /Volumes/foo Update
第二個步驟, 用 installer 指令安裝 . pkg 檔案
# sudo installer -pkg /Volumes/foo/bar.pkg -target “/”
installer: Package name is foo-bar
installer: Upgrading at base path /
installer: The upgrade was successful.
最後個步驟就是, 反掛載 .dmg 檔案
# hdiutil detach /Volumes/foo/
“disk1” unmounted.
“disk1” ejected.
如此一來就可以偷偷幫使用者背景更新程式. 不為人知..搞得好像行善不為人知. Orz