-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpack.sh
27 lines (20 loc) · 1.02 KB
/
pack.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
#!/bin/bash
VERSION=0.10.9
TMP_DIR=~/tmp
BUILD_DIR=$TMP_DIR/build
rm -f $BUILD_DIR/Pritunl.unpkg/Build.pkg/{Payload,Bom}
# Create new Payload and new Bom
cd $BUILD_DIR/Pritunl.pkg
find . | cpio -o --format odc | gzip -c \
> $BUILD_DIR/Pritunl.unpkg/Build.pkg/Payload
mkbom $BUILD_DIR/Pritunl.pkg $BUILD_DIR/Pritunl.unpkg/Build.pkg/Bom
# Get installBytes and numberOfFiles
INSTALL_BYTES=$(expr $(du -sk $BUILD_DIR/Pritunl.pkg/ | awk -F ' ' ' { print $1 } ') - 4)
NUMBER_OF_FILES=$(find $BUILD_DIR/Pritunl.pkg/ | wc | awk -F ' ' ' { print $1 } ')
sed -E "s/(numberOfFiles=)\".*\" (installKBytes=)\".*\"/\1\"$NUMBER_OF_FILES\" \2\"$INSTALL_BYTES\"/" \
$BUILD_DIR/Pritunl.unpkg/Build.pkg/PackageInfo > $BUILD_DIR/Pritunl.unpkg/Build.pkg/PackageInfo.tmp
# Overwrite old PackageInfo file
mv $BUILD_DIR/Pritunl.unpkg/Build.pkg/PackageInfo.tmp $BUILD_DIR/Pritunl.unpkg/Build.pkg/PackageInfo
# Recreate package
pkgutil --flatten $BUILD_DIR/Pritunl.unpkg/ $TMP_DIR/Pritunl.new.pkg
echo Your new package is now at $TMP_DIR/Pritunl.new.pkg