-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild_package.sh
executable file
·43 lines (32 loc) · 1.01 KB
/
build_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
#!/bin/sh
ORGID=com.github.sijk
PROJECT=`xcodebuild -showBuildSettings | awk '/PROJECT =/ {print $3}'`
PACKROOT=build/package
EXECROOT=$PACKROOT/exec
SCRIPTDIR=$PACKROOT/scripts
DISTDIR=dist
mkdir -p $EXECROOT
mkdir -p $SCRIPTDIR
mkdir -p $DISTDIR
xcodebuild DSTROOT=$EXECROOT install
AGENT_PLIST=$ORGID.$PROJECT.plist
AGENT_CONTENT=`cat $PROJECT/$AGENT_PLIST`
AGENT_TARGET=\$HOME/Library/LaunchAgents/$AGENT_PLIST
# Create a postinstall script which generates and loads a LaunchAgent plist
cat > $SCRIPTDIR/postinstall <<EOF
#!/bin/sh
echo 'Creating launch agent'
su \$USER -c 'cat <<EOPLIST > $AGENT_TARGET
$AGENT_CONTENT
EOPLIST'
echo 'Loading agent'
su \$USER -c 'launchctl load $AGENT_TARGET'
echo 'Restarting Mutify'
su \$USER -c 'launchctl stop $ORGID.$PROJECT'
EOF
chmod +x $SCRIPTDIR/postinstall
pkgbuild --identifier $ORGID.pkg.$PROJECT \
--root $EXECROOT \
--install-location '/' \
--scripts $SCRIPTDIR \
$DISTDIR/$PROJECT.pkg