This repository has been archived by the owner on Nov 21, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build_pkg.sh
executable file
·59 lines (44 loc) · 2.32 KB
/
build_pkg.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
#!/bin/sh
tempFolder="./pkgtemp"
outputFolder="./Build"
name="DEPNotifyOnboarder"
identifier="us.konicaminolta.kmbs.pkg.$name"
version="$(cat ./VERSION)"
appleID="eric_summers@icloud.com"
teamID="L48NM5T974"
keychainProfile="notary-eric_summers"
certName="Developer ID Installer: Eric Summers (L48NM5T974)"
if [ "$(whoami)" != "root" ] ; then
echo "This script must run as the root user."
exit 1
fi
/bin/mkdir -p "$outputFolder"
/bin/rm -rf "$tempFolder"
/bin/mkdir -p "$tempFolder"
/bin/mkdir -p "$tempFolder/root/Library/Application Support/DEPNotify/"
/bin/mkdir -p "$tempFolder/root/Library/LaunchDaemons/"
/bin/mkdir -p "$tempFolder/root/Applications/Utilities/"
/bin/cp ./DEPNotifyOnboarder.sh "$tempFolder/root/Library/Application Support/DEPNotify/"
/bin/cp ./DEPNotifyReset.sh "$tempFolder/root/Library/Application Support/DEPNotify/"
/bin/cp ./LaunchDaemons/us.konicaminolta.kmbs.DEPNotifyOnboarder.plist "$tempFolder/root/Library/LaunchDaemons/"
/usr/bin/ditto ./Utilities/DEPNotify.app/ "$tempFolder/root/Applications/Utilities/DEPNotify.app/"
mkdir "$tempFolder/scripts"
cat << EOF > "$tempFolder/scripts/postinstall"
#!/bin/sh
/bin/launchctl load /Library/LaunchDaemons/us.konicaminolta.kmbs.DEPNotifyOnboarder.plist
EOF
chmod 755 "$tempFolder/scripts/postinstall"
chown -R root:wheel "$tempFolder"
chflags 755 "$tempFolder/scripts/postinstall"
chflags 755 "$tempFolder/root/Library/Application Support/DEPNotify/DEPNotifyOnboarder.sh"
chflags 755 "$tempFolder/root/Library/Application Support/DEPNotify/DEPNotifyReset.sh"
chflags 644 "$tempFolder/root/Library/LaunchDaemons/us.konicaminolta.kmbs.DEPNotifyOnboarder.plist"
/usr/bin/pkgbuild --root "$tempFolder/root/" --scripts "$tempFolder/scripts/" --identifier "$identifier" --version "$version" "$tempFolder/$name-$version.pkg"
/usr/bin/productbuild --package "$tempFolder/$name-$version.pkg" --sign "$certName" "$outputFolder/$name-$version.pkg"
/bin/rm -rf "$tempFolder"
echo "Enter \"$keychainProfile\" when asked for Profile name."
/usr/bin/xcrun notarytool store-credentials --apple-id "$appleID" --team-id "$teamID"
/usr/bin/xcrun notarytool submit "$outputFolder/$name-$version.pkg" --keychain-profile "$keychainProfile" --wait
/usr/bin/xcrun stapler staple "$outputFolder/$name-$version.pkg"
/usr/sbin/spctl --assess --type install -vv "$outputFolder/$name-$version.pkg"
exit 0