-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathunypkg-openresty-build.sh
165 lines (125 loc) · 4.71 KB
/
unypkg-openresty-build.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
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
153
154
155
156
157
158
159
160
161
162
163
164
165
#!/usr/bin/env bash
# shellcheck disable=SC2034,SC1091,SC2154
set -vx
######################################################################################################################
### Setup Build System and GitHub
apt install -y perl dos2unix mercurial
wget -qO- uny.nu/pkg | bash -s buildsys
### Installing build dependencies
unyp install pcre2 openssl dos2unix
#pip3_bin=(/uny/pkg/python/*/bin/pip3)
#"${pip3_bin[0]}" install meson
### Getting Variables from files
UNY_AUTO_PAT="$(cat UNY_AUTO_PAT)"
export UNY_AUTO_PAT
GH_TOKEN="$(cat GH_TOKEN)"
export GH_TOKEN
source /uny/git/unypkg/fn
uny_auto_github_conf
######################################################################################################################
### Timestamp & Download
uny_build_date
mkdir -pv /uny/sources
cd /uny/sources || exit
pkgname="openresty"
pkggit="https://github.com/openresty/openresty.git refs/tags/v*"
gitdepth="--depth=1"
### Get version info from git remote
# shellcheck disable=SC2086
latest_head="$(git ls-remote --refs --tags --sort="v:refname" $pkggit | grep -E "v[0-9.]*$" | tail --lines=1)"
latest_ver="$(echo "$latest_head" | grep -o "v[0-9.]*" | sed "s|v||")"
latest_commit_id="$(echo "$latest_head" | cut --fields=1)"
version_details
# Release package no matter what:
echo "newer" >release-"$pkgname"
git_clone_source_repo
cd openresty || exit
wget -O pcre.patch https://patch-diff.githubusercontent.com/raw/openresty/openresty/pull/956.patch
git apply pcre.patch
make
cd /uny/sources || exit
mv openresty openrestysource
rm openrestysource/openresty-*.tar.*
mv openrestysource/openresty-* openresty
cd openresty/bundle/ngx_stream_lua-* || exit
wget -O config.patch https://patch-diff.githubusercontent.com/raw/openresty/stream-lua-nginx-module/pull/335.patch
git apply config.patch
cd /uny/sources || exit
archiving_source
######################################################################################################################
### Build
# unyc - run commands in uny's chroot environment
# shellcheck disable=SC2154
unyc <<"UNYEOF"
set -vx
source /uny/git/unypkg/fn
pkgname="openresty"
version_verbose_log_clean_unpack_cd
get_env_var_values
get_include_paths_temp
####################################################
### Start of individual build script
#unset LD_RUN_PATH
#pcre2_path=(/uny/pkg/pcre2/*/)
# --with-cc-opt="-I${pcre2_path[0]}include" \
# --with-ld-opt="-L${pcre2_path[0]}lib" \
./configure --prefix=/uny/pkg/"$pkgname"/"$pkgver" \
--with-ld-opt="$LDFLAGS" \
--conf-path=/etc/uny/openresty/nginx.conf \
--with-openssl-opt=enable-ec_nistp_64_gcc_128 \
--with-openssl-opt=no-weak-ssl-ciphers \
--with-pcre-jit \
--with-luajit \
--with-file-aio \
--with-http_dav_module \
--with-http_gzip_static_module \
--with-http_realip_module \
--with-http_ssl_module \
--with-http_stub_status_module \
--with-mail \
--with-mail_ssl_module \
--with-http_v2_module \
--with-stream \
--with-stream_ssl_module \
--with-http_iconv_module \
-j"$(nproc)"
make -j"$(nproc)"
make install
mkdir -pv /uny/pkg/"$pkgname"/"$pkgver"/nginx/conf
cp -a /etc/uny/openresty/* /uny/pkg/"$pkgname"/"$pkgver"/nginx/conf/
mkdir -pv /uny/pkg/"$pkgname"/"$pkgver"/systemd
tee /uny/pkg/"$pkgname"/"$pkgver"/systemd/openresty.service <<EOF
[Unit]
Description=The OpenResty Application Platform
After=syslog.target network-online.target remote-fs.target nss-lookup.target
Wants=network-online.target
[Service]
Type=forking
PIDFile=/uny/pkg/$pkgname/$pkgver/nginx/logs/nginx.pid
ExecStartPre=/uny/pkg/$pkgname/$pkgver/nginx/sbin/nginx -t
ExecStart=/uny/pkg/$pkgname/$pkgver/nginx/sbin/nginx
ExecStartPost=/usr/bin/env bash -c "sleep 1"
ExecReload=/usr/bin/env bash -c "kill -s HUP \$MAINPID"
ExecStop=/usr/bin/env bash -c "kill -s QUIT \$MAINPID"
RuntimeDirectory=openresty
PrivateTmp=true
[Install]
WantedBy=multi-user.target
EOF
####################################################
### End of individual build script
add_to_paths_files
dependencies_file_and_unset_vars
# nginx dependencies
echo "Shared objects required by: nginx"
ldd /uny/pkg/"$pkgname"/"$pkgver"/nginx/sbin/nginx
ldd /uny/pkg/"$pkgname"/"$pkgver"/nginx/sbin/nginx | grep -v "$pkgname/$pkgver" | sed "s|^.*ld-linux.*||" | grep -o "uny/pkg\(.*\)" | sed -e "s+uny/pkg/+unypkg/+" | grep -Eo "(unypkg/[a-z0-9]+/[0-9.]*)" |
sort -u >>/uny/pkg/"$pkgname"/"$pkgver"/rdep
sort -u /uny/pkg/"$pkgname"/"$pkgver"/rdep -o /uny/pkg/"$pkgname"/"$pkgver"/rdep
echo "Packages required by unypkg/$pkgname/$pkgver:"
cat /uny/pkg/"$pkgname"/"$pkgver"/rdep
cleanup_verbose_off_timing_end
UNYEOF
######################################################################################################################
### Packaging
package_unypkg