[9d42c8e] | 1 | #!/bin/bash |
---|
| 2 | # Create macOS installation packages. |
---|
| 3 | # Based on bomutils tutorail: http://bomutils.dyndns.org/tutorial.html |
---|
| 4 | |
---|
| 5 | VERSION=1.1.0 |
---|
| 6 | AUTHOR="OpenGnsys Project" |
---|
| 7 | |
---|
| 8 | # Create directories. |
---|
[8db55ed] | 9 | mkdir -p build && cd build |
---|
[9d42c8e] | 10 | mkdir -p flat/base.pkg flat/Resources/en.lproj |
---|
| 11 | mkdir -p root/Applications |
---|
| 12 | |
---|
| 13 | # Copy application and script files. |
---|
| 14 | cp -r ../../src root/Applications/OGAgent.app |
---|
| 15 | cp -r ../scripts . |
---|
| 16 | |
---|
| 17 | # Create plist file. |
---|
| 18 | cat << EOT > root/Applications/OGAgent.app/OGAgent.plist |
---|
| 19 | <?xml version="1.0" encoding="UTF-8"?> |
---|
| 20 | <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> |
---|
| 21 | <plist version="1.0"> |
---|
| 22 | <dict> |
---|
| 23 | <key>BuildAliasOf</key> |
---|
| 24 | <string>OGAgent</string> |
---|
| 25 | <key>BuildVersion</key> |
---|
| 26 | <value>$VERSION</value> |
---|
| 27 | <author>$AUTHOR</author> |
---|
| 28 | </dict> |
---|
| 29 | </plist> |
---|
| 30 | EOT |
---|
| 31 | |
---|
| 32 | # Add files in the base package. |
---|
| 33 | ( cd root && find . | cpio -o --format odc --owner 0:80 | gzip -c ) > flat/base.pkg/Payload |
---|
| 34 | |
---|
| 35 | # Create PackageInfo file. |
---|
| 36 | cat << EOT > flat/base.pkg/PackageInfo |
---|
| 37 | <pkg-info format-version="2" identifier="es.opengnsys.ogagent.base.pkg" version="$VERSION" install-location="/" auth="root"> |
---|
| 38 | <payload installKBytes="$(du -k -s root)" numberOfFiles="$(find root | wc -l)"/> |
---|
| 39 | <scripts> |
---|
| 40 | <postinstall file="./postinstall"/> |
---|
| 41 | </scripts> |
---|
| 42 | <bundle-version> |
---|
| 43 | <bundle id="es.opengnsys.ogagent" CFBundleIdentifier="es.opengnsys.ogagent" path="./Applications/OGAgent.app" CFBundleVersion="$VERSION"/> |
---|
| 44 | </bundle-version> |
---|
| 45 | </pkg-info> |
---|
| 46 | EOT |
---|
| 47 | |
---|
| 48 | # Compress the scripts folder. |
---|
| 49 | ( cd scripts && find . | cpio -o --format odc --owner 0:80 | gzip -c ) > flat/base.pkg/Scripts |
---|
| 50 | |
---|
| 51 | # Create BOM file. |
---|
| 52 | mkbom -u 0 -g 80 root flat/base.pkg/Bom |
---|
| 53 | |
---|
| 54 | # Create Distribution file. |
---|
| 55 | cat << EOT > flat/Distribution |
---|
| 56 | <?xml version="1.0" encoding="utf-8"?> |
---|
| 57 | <installer-script minSpecVersion="1.000000" authoringTool="com.apple.PackageMaker" authoringToolVersion="3.0.3" authoringToolBuild="174"> |
---|
| 58 | <title>OGAgent 1.1.0</title> |
---|
| 59 | <options customize="never" allow-external-scripts="no"/> |
---|
| 60 | <domains enable_anywhere="true"/> |
---|
| 61 | <installation-check script="pm_install_check();"/> |
---|
| 62 | <script>function pm_install_check() { |
---|
| 63 | if(!(system.compareVersions(system.version.ProductVersion,'10.5') >= 0)) { |
---|
| 64 | my.result.title = 'Failure'; |
---|
| 65 | my.result.message = 'You need at least Mac OS X 10.5 to install OGAgent.'; |
---|
| 66 | my.result.type = 'Fatal'; |
---|
| 67 | return false; |
---|
| 68 | } |
---|
| 69 | return true; |
---|
| 70 | } |
---|
| 71 | </script> |
---|
| 72 | <choices-outline> |
---|
| 73 | <line choice="choice1"/> |
---|
| 74 | </choices-outline> |
---|
| 75 | <choice id="choice1" title="base"> |
---|
| 76 | <pkg-ref id="es.opengnsys.ogagent.base.pkg"/> |
---|
| 77 | </choice> |
---|
| 78 | <pkg-ref id="es.opengnsys.ogagent.base.pkg" installKBytes="$(du -k -s root)" version="$VERSION" auth="Root">#base.pkg</pkg-ref> |
---|
| 79 | </installer-script> |
---|
| 80 | EOT |
---|
| 81 | |
---|
[8db55ed] | 82 | # Create new Xar application archive. |
---|
| 83 | rm -f ../../../OGAgentInstaller-$VERSION.pkg |
---|
| 84 | ( cd flat && xar --compression none -cf "../../../OGAgentInstaller-$VERSION.pkg" * ) |
---|
[9d42c8e] | 85 | |
---|