-
Notifications
You must be signed in to change notification settings - Fork 208
/
trurl.sh
executable file
·147 lines (113 loc) · 3.88 KB
/
trurl.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
#!/usr/bin/env bash
# Copyright (C) Viktor Szakats. See LICENSE.md
# SPDX-License-Identifier: MIT
# shellcheck disable=SC3040,SC2039
set -o xtrace -o errexit -o nounset; [ -n "${BASH:-}${ZSH_NAME:-}" ] && set -o pipefail
export _NAM _VER _OUT _BAS _DST
_NAM="$(basename "$0" | cut -f 1 -d '.')"
_VER="$1"
(
cd "${_NAM}" || exit 0
rm -r -f "${_PKGDIR:?}"
# Build
export CC="${_CC_GLOBAL}"
export CFLAGS="${_CFLAGS_GLOBAL} ${_CFLAGS_GLOBAL_RAW}"
export CPPFLAGS="${_CPPFLAGS_GLOBAL}"
export LDFLAGS="${_LDFLAGS_GLOBAL}"
export LDLIBS=''
options='TRURL_IGNORE_CURL_CONFIG=1'
if [[ "${_CONFIG}" != *'debug'* ]]; then
options+=' NDEBUG=1'
fi
# musl-debian-gcc issues
# https://github.com/curl/curl-for-win/actions/runs/7095411627/job/19312285992
CFLAGS="${CFLAGS//-fvisibility=hidden/}"
if [[ "${_CONFIG}" != *'main'* ]]; then
LDFLAGS+=' -v'
# [ "${_CC}" = 'gcc' ] && LDFLAGS+=' -Wl,--trace'
fi
if [ "${CW_MAP}" = '1' ]; then
map_name='trurl.map'
if [ "${_OS}" = 'mac' ]; then
LDFLAGS+=" -Wl,-map,${map_name}"
else
LDFLAGS+=" -Wl,-Map,${map_name}"
fi
fi
CPPFLAGS+=" -I../curl/${_PP}/include"
if [[ "${_CONFIG}" = *'zero'* ]]; then
# link statically in 'zero' (no external dependencies) config
LDLIBS+=" ../curl/${_PP}/lib/libcurl.a"
if [ "${_OS}" = 'win' ]; then
CPPFLAGS+=' -DCURL_STATICLIB'
LDLIBS+=' -lws2_32 -lcrypt32 -lbcrypt'
elif [ "${_OS}" = 'mac' ]; then
if [[ "${_CONFIG}" != *'osnotls'* ]]; then
LDLIBS+=' -framework Security'
fi
LDLIBS+=' -framework SystemConfiguration'
elif [ "${_OS}" = 'linux' ]; then
LDFLAGS+=' -static'
fi
else
LDFLAGS+=" -L../curl/${_PP}/lib"
LDLIBS+=' -lcurl'
fi
"${_MAKE}" clean
# shellcheck disable=SC2086
"${_MAKE}" ${options}
if [ "${_OS}" = 'mac' ]; then
install_name_tool -change \
'@rpath/libcurl.4.dylib' \
'@executable_path/../lib/libcurl.4.dylib' "./trurl${BIN_EXT}"
fi
# Install manually
mkdir -p "${_PP}/bin"
cp -f -p "./trurl${BIN_EXT}" "${_PP}/bin/"
if [ "${CW_MAP}" = '1' ]; then
cp -f -p "./${map_name}" "${_PP}/bin/"
fi
# Make steps for determinism
readonly _ref='RELEASE-NOTES'
bin="${_PP}/bin/trurl${BIN_EXT}"
# shellcheck disable=SC2086
"${_STRIP_BIN}" ${_STRIPFLAGS_BIN} "${bin}"
../_clean-bin.sh "${_ref}" "${bin}"
../_sign-code.sh "${_ref}" "${bin}"
touch -c -r "${_ref}" "${bin}"
if [ "${CW_MAP}" = '1' ]; then
touch -c -r "${_ref}" "${_PP}/bin/${map_name}"
fi
../_info-bin.sh --filetype 'exe' "${bin}"
# Execute curl and compiled-in dependency code. This is not secure.
[ "${_OS}" = 'win' ] && cp -p "../curl/${_PP}/bin/"*"${DYN_EXT}" .
if [ "${_OS}" = 'linux' ] && [ "${_HOST}" = 'linux' ]; then
# https://www.man7.org/training/download/shlib_dynlinker_slides.pdf
export LD_DEBUG='libs,versions,statistics'
fi
# On macOS this picks up a system libcurl by default. Ours is picked up
# when running it from the unpacked release tarball.
out="../trurl-version-${_CPUPUB}.txt"
LD_LIBRARY_PATH="$(pwd)/../curl/${_PP}/lib" \
DYLD_LIBRARY_PATH="$(pwd)/../curl/${_PP}/lib" \
${_RUN_BIN} "${bin}" --version | sed 's/\r//g' | tee "${out}" || true
unset LD_DEBUG
[ -s "${out}" ] || rm -f "${out}"
if [ "${CW_TURL_TEST:-}" = '1' ] && \
[ "${_RUN_BIN}" != 'true' ]; then
python3 ./test.py "--runner=${_RUN_BIN}" "--trurl=${bin}"
fi
# Create package
_OUT="${_NAM}-${_VER}${_REVSUFFIX}${_PKGSUFFIX}"
_BAS="${_NAM}-${_VER}${_PKGSUFFIX}"
_DST="$(pwd)/_pkg"; rm -r -f "${_DST}"
mkdir -p "${_DST}/bin"
cp -f -p "${bin}" "${_DST}/bin/"
cp -f -p COPYING "${_DST}/COPYING.txt"
cp -f -p README.md "${_DST}/README.md"
cp -f -p RELEASE-NOTES "${_DST}/RELEASE-NOTES.txt"
if [ "${CW_MAP}" = '1' ]; then
cp -f -p "${_PP}/bin/${map_name}" "${_DST}/bin/"
fi
../_pkg.sh "$(pwd)/${_ref}"
)