-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathpatch.sh
More file actions
executable file
·49 lines (42 loc) · 1.17 KB
/
patch.sh
File metadata and controls
executable file
·49 lines (42 loc) · 1.17 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
#!/usr/bin/env bash
set -euo pipefail
err() {
>&2 echo "$@"
}
usage() {
err "usage: $1 ThePathOfYourOpenRestySrcDirectory"
exit 1
}
failed_to_cd() {
err "failed to cd $1"
exit 1
}
if [[ $# != 1 ]]; then
usage "$0"
fi
script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
if [[ "$1" == *openresty-1.19.3.* ]]; then
patch="$script_dir/nginx-1.19.3.patch"
dir="$1/bundle/nginx-1.19.3"
elif [[ "$1" == *openresty-1.19.9.* ]]; then
patch="$script_dir/nginx-1.19.9.patch"
dir="$1/bundle/nginx-1.19.9"
elif [[ "$1" == *openresty-1.21.4.* ]]; then
patch="$script_dir/nginx-1.21.4.patch"
dir="$1/bundle/nginx-1.21.4"
elif [[ "$1" == *openresty-1.25.3.* ]]; then
patch="$script_dir/nginx-1.25.3.patch"
dir="$1/bundle/nginx-1.25.3"
elif [[ "$1" == *openresty-1.27.1.* ]]; then
patch="$script_dir/nginx-1.27.1.patch"
dir="$1/bundle/nginx-1.27.1"
elif [[ "$1" == *openresty-1.29.2.* ]]; then
patch="$script_dir/nginx-1.29.2.patch"
dir="$1/bundle/nginx-1.29.2"
else
err "can't detect OpenResty version"
exit 1
fi
cd "$dir" || failed_to_cd "$dir"
echo "Start to patch $patch to $dir..."
patch -p0 --verbose < "$patch"