attach license file to dmg under OSX

微笑、不失礼 提交于 2021-02-07 18:29:32

问题


guys! Is there any command line I can use to attach a license file to a dmg?

Thank you very much

(I'm experiencing problems with the editor, so forgive me if you see "strange things" in the text)


回答1:


I found a blog entry for you (linked here) where the guy has written a python script which you can call, from the command line, to attach a Software License Agreements to a Disk Image file.

Works on 10.6 & newer.

According to his original blog entry:

This script runs on Python 2.6 or 2.7. If the default locations of Rez and the FlatCarbon headers are different on your machine, you’ll need to specify the correct location using the command line options --rez and --flat-carbon.

His script (click this link to see it) can be invoked as easily as:

./licenseDMG.py <dmgFile> <licenseFile>



回答2:


I wrote this new answer because the hdiutil command no longer supports unflatten and flatten options. So I managed to do the same with the new udifrez command an preparing the slas in an xml file with plist format.

The structure of the template for two license files is this one

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>LPic</key>
    <array>
        <dict>
            <key>Attributes</key>
            <string>0x0000</string>
            <key>Data</key>
            <data>
            AAAAAgAAAAAAAAAIAAMAAA==
            </data>
            <key>ID</key>
            <string>5000</string>
            <key>Name</key>
            <string></string>
        </dict>
    </array>
    <key>RTF </key>
    <array>
        <dict>
            <key>Attributes</key>
            <string>0x0000</string>
            <key>Data</key>
            <data>

... here goes the English RTF file codified in base64

            </data>
            <key>ID</key>
            <string>5000</string>
            <key>Name</key>
            <string>English SLA</string>
        </dict>
        <dict>
            <key>Attributes</key>
            <string>0x0000</string>
            <key>Data</key>
            <data>

... here goes the Spanish RTF file codified in base64
                
            </data>
            <key>ID</key>
            <string>5003</string>
            <key>Name</key>
            <string>Spanish SLA</string>
        </dict>
    </array>
    <key>STR#</key>
    <array>
        <dict>
            <key>Attributes</key>
            <string>0x0000</string>
            <key>Data</key>
            <data>
            AAYNRW5nbGlzaCB0ZXN0MQVBZ3JlZQhEaXNhZ3JlZQVQcmludAdT
            YXZlLi4ueklmIHlvdSBhZ3JlZSB3aXRoIHRoZSB0ZXJtcyBvZiB0
            aGlzIGxpY2Vuc2UsIGNsaWNrICJBZ3JlZSIgdG8gYWNjZXNzIHRo
            ZSBzb2Z0d2FyZS4gIElmIHlvdSBkbyBub3QgYWdyZWUsIHByZXNz
            ICJEaXNhZ3JlZS4i
            </data>
            <key>ID</key>
            <string>5000</string>
            <key>Name</key>
            <string>English buttons</string>
        </dict>
        <dict>
            <key>Attributes</key>
            <string>0x0000</string>
            <key>Data</key>
            <data>
            AAYHRW5nbGlzaAVBZ3JlZQhEaXNhZ3JlZQVQcmludAdTYXZlLi4u
            e0lmIHlvdSBhZ3JlZSB3aXRoIHRoZSB0ZXJtcyBvZiB0aGlzIGxp
            Y2Vuc2UsIHByZXNzICJBZ3JlZSIgdG8gaW5zdGFsbCB0aGUgc29m
            dHdhcmUuICBJZiB5b3UgZG8gbm90IGFncmVlLCBwcmVzcyAiRGlz
            YWdyZWUiLg==
            </data>
            <key>ID</key>
            <string>5002</string>
            <key>Name</key>
            <string>English</string>
        </dict>
        <dict>
            <key>Attributes</key>
            <string>0x0000</string>
            <key>Data</key>
            <data>
            AAYHRXNwYZZvbAdBY2VwdGFyCk5vIGFjZXB0YXIISW1wcmltaXIK
            R3VhcmRhci4uLsBTaSBlc3SHIGRlIGFjdWVyZG8gY29uIGxvcyB0
            jnJtaW5vcyBkZSBlc3RhIGxpY2VuY2lhLCBwdWxzZSAiQWNlcHRh
            ciIgcGFyYSBpbnN0YWxhciBlbCBzb2Z0d2FyZS4gRW4gZWwgc3Vw
            dWVzdG8gZGUgcXVlIG5vIGVzdI4gZGUgYWN1ZXJkbyBjb24gbG9z
            IHSOcm1pbm9zIGRlIGVzdGEgbGljZW5jaWEsIHB1bHNlICJObyBh
            Y2VwdGFyLiI=
            </data>
            <key>ID</key>
            <string>5003</string>
            <key>Name</key>
            <string>Spanish</string>
        </dict>
    </array>
    <key>TMPL</key>
    <array>
        <dict>
            <key>Attributes</key>
            <string>0x0000</string>
            <key>Data</key>
            <data>
            E0RlZmF1bHQgTGFuZ3VhZ2UgSUREV1JEBUNvdW50T0NOVAQqKioq
            TFNUQwtzeXMgbGFuZyBJRERXUkQebG9jYWwgcmVzIElEIChvZmZz
            ZXQgZnJvbSA1MDAwRFdSRBAyLWJ5dGUgbGFuZ3VhZ2U/RFdSRAQq
            KioqTFNURQ==
            </data>
            <key>ID</key>
            <string>128</string>
            <key>Name</key>
            <string>LPic</string>
        </dict>
    </array>
    <key>styl</key>
    <array>
        <dict>
            <key>Attributes</key>
            <string>0x0000</string>
            <key>Data</key>
            <data>
            AAMAAAAAAAwACQAUAAAAAAAAAAAAAAAAACcADAAJABQBAAAAAAAA
            AAAAAAAAKgAMAAkAFAAAAAAAAAAAAAA=
            </data>
            <key>ID</key>
            <string>5000</string>
            <key>Name</key>
            <string>English SLA</string>
        </dict>
        <dict>
            <key>Attributes</key>
            <string>0x0000</string>
            <key>Data</key>
            <data>
            AAMAAAAAAAwACQAVAAAAAAAAAAAAAAAAACoADAAJABUBAAAAAAAA
            AAAAAAAALgAMAAkAFQAAAAAAAAAAAAA=
            </data>
            <key>ID</key>
            <string>5003</string>
            <key>Name</key>
            <string>Spanish SLA</string>
        </dict>
    </array>
</dict>
</plist>

I managed to base64 encode the two rtf files corresponding with the English sla and Spanish sla files in the right place.

Note, if you are using other languages, you need to carefully change some of the other content in the template file. But at least, I can give you something to start working from.



来源:https://stackoverflow.com/questions/8970981/attach-license-file-to-dmg-under-osx

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!