| 1 | #!/bin/sh |
|---|
| 2 | |
|---|
| 3 | |
|---|
| 4 | |
|---|
| 5 | |
|---|
| 6 | |
|---|
| 7 | |
|---|
| 8 | |
|---|
| 9 | |
|---|
| 10 | set -e |
|---|
| 11 | verbose=0 |
|---|
| 12 | |
|---|
| 13 | verbose_msg () |
|---|
| 14 | { |
|---|
| 15 | if [ $verbose -ne 0 ]; then |
|---|
| 16 | echo "libtool-bundle: $@" |
|---|
| 17 | fi |
|---|
| 18 | } |
|---|
| 19 | |
|---|
| 20 | error_msg () |
|---|
| 21 | { |
|---|
| 22 | echo 1>&2 "libtool-bundle: $@" |
|---|
| 23 | } |
|---|
| 24 | |
|---|
| 25 | usage () |
|---|
| 26 | { |
|---|
| 27 | error_msg "Usage: $0 [-e extra XML data] [Mach-O bundle file] [destination directory] <bundle name>" |
|---|
| 28 | exit 1 |
|---|
| 29 | } |
|---|
| 30 | |
|---|
| 31 | case $1 in |
|---|
| 32 | -e) shift; if [ "$1" ]; then extradata=$1; shift; else usage; fi; ;; |
|---|
| 33 | esac |
|---|
| 34 | |
|---|
| 35 | [ $ |
|---|
| 36 | |
|---|
| 37 | sofile=$1 |
|---|
| 38 | [ ! -f $sofile ] && error_msg "Not a file or file not found: $sofile" && exit 1 |
|---|
| 39 | case "$sofile" in |
|---|
| 40 | *.so*) |
|---|
| 41 | |
|---|
| 42 | ;; |
|---|
| 43 | *) |
|---|
| 44 | error_msg "Invalid bundle: $sofile" |
|---|
| 45 | exit 1 |
|---|
| 46 | ;; |
|---|
| 47 | esac |
|---|
| 48 | |
|---|
| 49 | destdir=$2 |
|---|
| 50 | [ ! -d $destdir -o ! -w $destdir ] && error_msg "Not a directory or no write access: $destdir" && exit 1 |
|---|
| 51 | |
|---|
| 52 | name="$sofile" |
|---|
| 53 | [ $ |
|---|
| 54 | name=`echo $name | sed -e "s@.*/@@" -e "s@\.so.*@@"` |
|---|
| 55 | root="$destdir/${name}.bundle" |
|---|
| 56 | |
|---|
| 57 | verbose_msg "sofile: $sofile" |
|---|
| 58 | verbose_msg "destdir: $destdir" |
|---|
| 59 | verbose_msg "name: $name" |
|---|
| 60 | verbose_msg "root: $root" |
|---|
| 61 | |
|---|
| 62 | arch=`uname` |
|---|
| 63 | [ x$arch = xDarwin ] && arch=MacOS |
|---|
| 64 | type="BNDL" |
|---|
| 65 | creator="????" |
|---|
| 66 | |
|---|
| 67 | |
|---|
| 68 | [ -d "$root" ] && rm -rf "$root" |
|---|
| 69 | |
|---|
| 70 | mkdir -p "$root"/Contents/$arch |
|---|
| 71 | cp "$sofile" "$root"/Contents/$arch/"$name" |
|---|
| 72 | echo "$type$creator" > "$root"/Contents/PkgInfo |
|---|
| 73 | |
|---|
| 74 | create_info_plist () |
|---|
| 75 | { |
|---|
| 76 | echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" |
|---|
| 77 | echo "<!DOCTYPE plist PUBLIC \"-//Apple Computer//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">" |
|---|
| 78 | echo "<plist version=\"1.0\">" |
|---|
| 79 | echo "<dict>" |
|---|
| 80 | echo " <key>CFBundleDevelopmentRegion</key>" |
|---|
| 81 | echo " <string>English</string>" |
|---|
| 82 | echo " <key>CFBundleExecutable</key>" |
|---|
| 83 | echo " <string>$name</string>" |
|---|
| 84 | echo " <key>CFBundleInfoDictionaryVersion</key>" |
|---|
| 85 | echo " <string>6.0</string>" |
|---|
| 86 | echo " <key>CFBundleName</key>" |
|---|
| 87 | echo " <string>$name</string>" |
|---|
| 88 | echo " <key>CFBundlePackageType</key>" |
|---|
| 89 | echo " <string>$type</string>" |
|---|
| 90 | echo " <key>CFBundleSignature</key>" |
|---|
| 91 | echo " <string>$creator</string>" |
|---|
| 92 | echo " <key>CFBundleVersion</key>" |
|---|
| 93 | echo " <string>0.0.1d1</string>" |
|---|
| 94 | if [ "$extradata" ]; then |
|---|
| 95 | echo "" |
|---|
| 96 | [ -f "$extradata" ]; cat $extradata |
|---|
| 97 | fi |
|---|
| 98 | echo "</dict>" |
|---|
| 99 | echo "</plist>" |
|---|
| 100 | } |
|---|
| 101 | |
|---|
| 102 | create_info_plist > "$root"/Contents/Info.plist |
|---|
| 103 | |
|---|
| 104 | echo "Installed $sofile as $root" |
|---|