0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

dmgに同梱できるドラッグ&ドロップ用のシンボリックリンクは限定されている話

Last updated at Posted at 2022-10-26

前提

  • App Store外でアプリケーションを配布する場合、dmgにアプリケーションに加えてApplicationsのシンボリックリンクを同梱してドラッグ&ドロップ(以下D&D)を促すようなものを見かけることがあります。
  • これを応用して、ファイルを特定のディレクトリにコピーさせる用途に使えないかと思いつきました。
  • 具体例としてはフォントファイルをLibrary/FontsにD&Dでコピーさせるようなdmgを作りたいです。

参考

作業例

前提

image

シンボリックリンクの作成

cd /Users/ikeh/Downloads/Test
ln -s /Library/Fonts/ Fonts
  • ちなみにユーザフォルダのエイリアス作成はできない?ようです。
ln -s ~/Library/Fonts/ UserFonts  <- 自分の環境のパスになってしまう
ln -s “~/Library/Fonts/” UserFonts  <- エイリアスの参照エラーとなる

dmgの作成

  • dmgを作成します。
create-dmg \
  --volname “SampleVolume” \
  --window-pos 200 120 \
  --window-size 812 542 \
  --icon-size 100 \
  --icon “対象フォント” 200 190 \
  --icon “Fonts” 600 185 \
  --app-drop-link 600 300 \
  --codesign “Developer ID Application: XXX (xxxxxxxxx)\
  “SymbolicFontsDemo.dmg” \
  “source_folder/”

dmgの動作確認

  • 現在のフォルダ構成は以下の通りなっているはずです。
  • 作成したdmgを開きます。

image

  • 下図のようになり、FontsApplicationsのそれぞれに対象フォントをD&Dでコピーできます。

dmgの動作確認(ダウンロード時)

  • 一見うまくいっているのですが、実際はdmgをダウンロードさせた場合にうまく動きません。

image

  • 具体的にはダウンロードしたときに付与される拡張属性com.apple.quarantineがついているとうまく動きません。
  • ApplicationsにはD&Dでコピーできますが、FontsにはD&Dできない状態となります。
ls -l@ *.dmg
-rw-r--r--@ 1 ikeh  staff  22152 10 27 00:29 SymbolicFontsDemo.dmg
	com.apple.macl	   72
	com.apple.quarantine	   56
  • 下記が拡張属性com.apple.quarantineがついている場合でも、D&Dでコピーができるディレクトリの一覧とのことです。

https://forum.juce.com/t/dmg-with-symlinks-to-library-audio-plug-ins/52161/28

Applications
Applications/Utilities
Desktop
Library/QuickLook
Library/Screen Savers
Library/PreferencePanes
Library/CloudStorage/iCloud Drive/Desktop
  • 実際に拡張属性を削除してみると、うまくコピーができることが確認できます。
xattr -d com.apple.quarantine SymbolicFontsDemo.dmg
  • 蛇足にはなるがzipの場合も同様にApplicationsにはコピーできるがLibrary/Fontsにはコピーできない動きとなった。

参考

Note that ~/Library isn’t an option, as the ~ is resolved at the time the symlink is made so it would be a symlink to /Users/sudara.

  • シンボリックリンクの作成に~は使えない

So, quarantine bit … how to disable …
xattr -d com.apple.quarantine testImage.dmg
… works.

  • 拡張属性com.apple.quarantineを取ると動作するという話。

I noted that it’s strange that I can have a notarized pkg installer that dumps all sorts of stuff everywhere — but a notarized dmg can’t do a drag and drop, even on user authentication.

  • signing/notarizationしてもD&Dはできない。

So, .pkg it is then?

  • .pkgが代替案になる…?

結論

  • dmgに同梱するD&Dでコピーさせるために使えるシンボリックリンクは以下に限られる。
    • 理由は拡張属性com.apple.quarantineによりセキュリティが働くため。
Applications
Applications/Utilities
Desktop
Library/QuickLook
Library/Screen Savers
Library/PreferencePanes
Library/CloudStorage/iCloud Drive/Desktop
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?