This repository has been archived by the owner on Nov 10, 2017. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
create_package.sh
executable file
·60 lines (54 loc) · 1.79 KB
/
create_package.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/bin/bash
APPNAME="DAFGU Migration Status.app"
PKGSCRIPTS=installer_scripts
PKGVERSION=$(/usr/libexec/PlistBuddy -c "Print :CFBundleShortVersionString" "build/Release/$APPNAME/Contents/Info.plist")
PKGID="se.gu.it.DAFGU-Migration-Status"
PKGFILE="DAFGUMigrationStatus-$PKGVERSION.pkg"
PKGTARGET="10.5"
PKGTITLE="DAFGU Migration Status"
PACKAGEMAKER=""
if [ -e "/Developer/usr/bin/packagemaker" ]; then
PACKAGEMAKER="/Developer/usr/bin/packagemaker"
else
while read path; do
if [ -e "$path/Contents/MacOS/PackageMaker" ]; then
PACKAGEMAKER="$path/Contents/MacOS/PackageMaker"
break
fi
done < <(mdfind "(kMDItemCFBundleIdentifier == com.apple.PackageMaker)")
fi
if [ -z "$PACKAGEMAKER" ]; then
echo "packagemaker not found"
exit 1
fi
echo "Packaging $PKGTITLE as $PKGID $PKGVERSION"
rm -f "$PKGFILE"
pkgroot=`mktemp -d -t dafgumigrationstatus`
echo "Creating directory structure"
mkdir -p "$pkgroot/Library/LaunchAgents"
cp "LaunchAgents/se.gu.it.DAFGU-Migration-Status.plist" "$pkgroot/Library/LaunchAgents"
mkdir -p "$pkgroot/Applications/Utilities"
ditto --noqtn "build/Release/$APPNAME" "$pkgroot/Applications/Utilities/$APPNAME"
find "$pkgroot" -name .DS_Store -print0 | xargs -0 rm -f
xattr -d -r com.apple.FinderInfo "$pkgroot"
xattr -d -r com.macromates.caret "$pkgroot"
echo "Changing owner"
sudo chown -hR root:wheel "$pkgroot"
echo "Fixing permissions"
sudo ./copymodes / "$pkgroot"
sudo "$PACKAGEMAKER" \
--root "$pkgroot" \
--id "$PKGID" \
--title "$PKGTITLE" \
--scripts "$PKGSCRIPTS" \
--version "$PKGVERSION" \
--target $PKGTARGET \
--no-recommend \
--no-relocate \
--out "$PKGFILE"
# --info
# --resources
echo "Changing owner of $PKGFILE"
sudo chown $USER "$PKGFILE"
echo "Removing package root"
sudo rm -rf "$pkgroot"