4

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)

user732274
  • 1,069
  • 1
  • 12
  • 28

2 Answers2

5

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>
Michael Dautermann
  • 88,797
  • 17
  • 166
  • 215
  • The link is dead, and the author of that website has no corresponding code anywhere on GitHub or BitBucket. – Konrad Rudolph Mar 07 '19 at 17:33
  • @KonradRudolph His original post is on the Internet archive (archive.org) and I updated the links for you. The script has a copyright date of 2018 but the post is so old, I'm not 100% certain it's going to work. Let me know. – Michael Dautermann Mar 07 '19 at 18:52
  • @MichaelDautermann Wow, thanks. I had in the meantime found instructions to do this manually with Rez (around which this script is a wrapper). – Konrad Rudolph Mar 08 '19 at 10:09
  • 1
    Hi, It looks like since MacOS Big Sur (or Bug!) hdiutil unflatten and flatten options are no longer available. This means, we need to use uidfrez -xml ... I actually can add a license file to the dmg but after clicking on accept button the dmg cannot be opened and it is damaged. The source of the problem is the sla.xml file I prepared is extracted from a previous valid .dmg but is an plist file in xml format and I need to modify and remove parts that are damaging the dmg. I don't know jet which parts shall be removed and have no documentation... any help is welcome! Thanks! – IgnacioHR Nov 14 '20 at 11:31
  • It took me a couple of hours but now it is done. The xml file format is a plist file in xml format. The content of that file depends on what you have in the license files but the structure is the same as in the .r file. I need to generate a new answer in order to provide a file "template" for two languages, English and Spanish. – IgnacioHR Nov 14 '20 at 16:43
1

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.

IgnacioHR
  • 568
  • 4
  • 20