forked from BandarHL/BHTwitter
-
Notifications
You must be signed in to change notification settings - Fork 218
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
·152 lines (138 loc) · 4.52 KB
/
build.sh
File metadata and controls
executable file
·152 lines (138 loc) · 4.52 KB
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
#!/usr/bin/env bash
set -Eeuo pipefail
# NeoFreeBird builder with required flags.
# Usage: build.sh [--sideloaded | --rootless | --trollstore | --rootfull]
is_tty=0
if [[ -t 1 ]]; then is_tty=1; fi
bold='' green='' reset=''
if [[ "$is_tty" -eq 1 ]]; then
if command -v tput >/dev/null 2>&1; then
bold="$(tput bold || true)"
green="$(tput setaf 2 || true)"
reset="$(tput sgr0 || true)"
else
bold='\033[1m'; green='\033[32m'; reset='\033[0m'
fi
fi
say() { if [[ -n "${bold}${green}${reset}" ]]; then printf "%b%s%b\n" "${bold}${green}" "$1" "${reset}"; else printf "%s\n" "$1"; fi; }
err() { printf "Error: %s\n" "$1" >&2; }
die() { err "$1"; exit 1; }
usage() {
cat <<EOF
Usage: $(basename "$0") [--sideloaded | --rootless | --trollstore | --rootfull]
TL;DR: You need to select one flag to build NeoFreeBird.
Flags (required):
--sideloaded Compile NeoFreeBird as a .ipa so you can sideload it with AltStore, Sideloadly or similar.
--rootless Compile NeoFreeBird as a .deb file that does not require a jailbreak.
--trollstore Compile NeoFreeBird as a .tipa so you can install it using TrollStore.
--rootfull Compile NeoFreeBird as a .deb file that requires a jailbreak.
Options:
-h, --help Show this help
EOF
}
require_cmd() { command -v "$1" >/dev/null 2>&1 || die "'$1' is required but not found in PATH"; }
require_cmd bash
require_cmd make
CYAN_BIN=""; if command -v cyan >/dev/null 2>&1; then CYAN_BIN="cyan"; fi
MODE=""
while [[ $# -gt 0 ]]; do
case "$1" in
--sideloaded|--sideloaded=*)
[[ -n "$MODE" ]] && die "Multiple flags provided. Choose one."
MODE="sideloaded"; shift
;;
--rootless|--rootless=*)
[[ -n "$MODE" ]] && die "Multiple flags provided. Choose one."
MODE="rootless"; shift
;;
--trollstore)
[[ -n "$MODE" ]] && die "Multiple flags provided. Choose one."
MODE="trollstore"; shift
;;
--rootfull)
[[ -n "$MODE" ]] && die "Multiple flags provided. Choose one."
MODE="rootfull"; shift
;;
-h|--help)
usage; exit 0
;;
--)
shift; break
;;
-*)
die "Unknown option: $1"
;;
*)
# no positional args expected
die "Unexpected argument: $1"
;;
esac
done
if [[ -z "$MODE" ]]; then
usage
exit 2
fi
clean_tree() {
if [[ -d .theos ]]; then rm -rf .theos; fi
if [[ -f Makefile ]]; then make clean || true; fi
}
case "$MODE" in
sideloaded)
say "Preparing to compile NeoFreeBird. Argument added: --sideloaded."
clean_tree
make SIDELOADED=1
if [[ $? -ne 0 ]]; then
die "An error occurred when building."
fi
if [[ -e ./packages/com.atebits.Tweetie2.ipa ]]; then
say "Building the IPA."
if command -v cyan >/dev/null 2>&1; then
cyan -i packages/com.atebits.Tweetie2.ipa -o packages/NeoFreeBird-sideloaded --ignore-encrypted \
-uwf .theos/obj/debug/keychainfix.dylib .theos/obj/debug/libbhFLEX.dylib \
.theos/obj/debug/BHTwitter.dylib layout/Library/Application\ Support/BHT/BHTwitter.bundle
else
say "Skipping cyan step because it is not installed."
fi
say "NeoFreeBird has been successfully built. Enjoy!"
else
err "packages/com.atebits.Tweetie2.ipa not found."
fi
;;
rootless)
say "Preparing to compile NeoFreeBird. Argument added: --rootless."
clean_tree
export THEOS_PACKAGE_SCHEME="rootless"
make package
say "NeoFreeBird has been successfully built. Enjoy!"
;;
trollstore)
say "Preparing to compile NeoFreeBird. Argument added: --trollstore."
clean_tree
make
if [[ $? -ne 0 ]]; then
die "An error occurred when building."
fi
if [[ -e ./packages/com.atebits.Tweetie2.ipa ]]; then
say "Merging NeoFreeBird to provided Twitter IPA."
if command -v cyan >/dev/null 2>&1; then
cyan -i packages/com.atebits.Tweetie2.ipa -o packages/NeoFreeBird-trollstore.tipa --ignore-encrypted \
-uwf .theos/obj/debug/BHTwitter.dylib .theos/obj/debug/libbhFLEX.dylib layout/Library/Application\ Support/BHT/BHTwitter.bundle
else
say "Skipping cyan step because it is not installed."
fi
say "NeoFreeBird has been successfully built. Enjoy!"
else
err "packages/com.atebits.Tweetie2.ipa not found."
fi
;;
rootfull)
say "Preparing to compile NeoFreeBird. Argument added: --rootfull."
clean_tree
unset THEOS_PACKAGE_SCHEME || true
make package
say "NeoFreeBird has been successfully built. Enjoy!"
;;
*)
die "Unknown mode: $MODE"
;;
esac