-
Notifications
You must be signed in to change notification settings - Fork 0
/
build_package.sh
executable file
·57 lines (51 loc) · 1.21 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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/bin/bash
# Build package "Uninstall-MacKeeper-VERSION.pkg".
export PATH='/usr/bin:/bin:/usr/sbin:/sbin'
NAME='Uninstall-MacKeeper'
IDENTIFIER="com.github.bjoernalbers.${NAME}"
IDENTITY_NAME='Developer ID Installer: Bjoern Albers (2M83WXV6U8)'
VERSION="$(date '+%Y%m%dT%H%M%SZ')"
BASE_DIR="$(dirname "$0")"
BUILD_DIR="${BASE_DIR}/tmp"
SCRIPTS_DIR="${BASE_DIR}/uninstaller"
SUFFIX='pkg'
PKGBUILD_OPTIONS=(
--scripts "${SCRIPTS_DIR}"
--nopayload
--identifier "${IDENTIFIER}"
--version "${VERSION:?}"
--quiet
)
display_usage() {
cat <<EOM
Usage: $0 [OPTIONS]
Options:
-h, --help Display this help and exit
-r, --release Create signed release package
EOM
}
# Process options
while [[ "$#" -gt 0 ]]; do
case "$1" in
-h|--help)
display_usage
exit 0
;;
-r|--release)
VERSION="$(git describe --tags)"
BUILD_DIR="${BASE_DIR}/pkgs"
PKGBUILD_OPTIONS+=(--sign "${IDENTITY_NAME}")
;;
*)
display_usage >&2
exit 1
;;
esac
shift
done
# Build package
mkdir -p "${BUILD_DIR}"
PACKAGE="${BUILD_DIR}/${NAME}-${VERSION}.${SUFFIX}"
if [[ ! -e "${PACKAGE}" ]]; then
pkgbuild "${PKGBUILD_OPTIONS[@]}" "${PACKAGE}" && echo "${PACKAGE}"
fi