-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathbuildenv
More file actions
272 lines (227 loc) · 7.64 KB
/
Copy pathbuildenv
File metadata and controls
272 lines (227 loc) · 7.64 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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
# bump: meta-version /META_VERSION="(.*)"/ https://github.com/ZOSOpenTools/meta.git|semver:^0
META_VERSION="0.8.5"
# To test a development environment, set the following to the absolute path of the
# 'meta' directory either in the script or in the environment
#export ZOPEN_META_DEV_ROOT=""
export ZOPEN_BUILD_LINE="STABLE"
export ZOPEN_CATEGORIES="utilities"
export ZOPEN_DEV_URL="https://github.com/ZOSOpenTools/meta.git"
export ZOPEN_DEV_TAG="new_installer"
export ZOPEN_DEV_DEPS="git gzip make tar bash zoslib help2man perl curl grep groff coreutils openssl"
export ZOPEN_STABLE_URL="https://github.com/ZOSOpenTools/meta.git"
export ZOPEN_STABLE_DEPS="git gzip make tar bash zoslib help2man perl curl grep groff coreutils openssl"
export ZOPEN_COMP=SKIP
export ZOPEN_CONFIGURE="skip"
export ZOPEN_MAKE="skip"
export ZOPEN_CHECK="zopen_check"
export ZOPEN_INSTALL="zopen_install"
export ZOPEN_SETUP_NO_REPLACE=1
META_DEV_DIR="$(pwd -P)/meta"
if [ -z "${ZOPEN_META_DEV_ROOT}" ] ; then
if [ -d "${META_DEV_DIR}" ]; then
if [ -L "${META_DEV_DIR}" ]; then
echo "ZOPEN_META_DEV_ROOT is NOT set, but ${META_DEV_DIR} is a symbolic link. Either set ZOPEN_META_DEV_ROOT or remove the symbolic link"
exit 8
fi
else
echo "Using meta installation from '${META_DEV_DIR}'"
fi
else
echo "Installation will not be performed - testing dev environment"
if ! [ -d "${ZOPEN_META_DEV_ROOT}" ] ; then
echo "ZOPEN_META_DEV_ROOT points to ${ZOPEN_META_DEV_ROOT}, but the directory does not exist" >&2
exit 8
fi
# Set up our own 'meta' to use from our dev code and skip install
basename=$(basename "${ZOPEN_META_DEV_ROOT}")
if [ "x${basename}" != "xmeta" ]; then
echo "ZOPEN_META_DEV_ROOT should point to a 'meta' cloned directory. It is: ${ZOPEN_META_DEV_ROOT}" >&2
exit 8
fi
if [ -d "${META_DEV_DIR}" ]; then
if ! [ -L "${META_DEV_DIR}" ]; then
# We may already have a git clone'd meta. If so, move the cloned tree to meta-cloned
backup_dir="${META_DEV_DIR}-cloned.$(date +%Y%m%d%H%M%S)"
echo "Backing up old directory '${META_DEV_DIR}' to '${backup_dir}'"
mv "${META_DEV_DIR}" "${backup_dir}"
else
# There may already be a symbolic link here - if so, delete it in case it is stale
echo "Removing existing symlink at '${META_DEV_DIR}'"
rm "${META_DEV_DIR}"
fi
else
# Directory has not yet been cloned - just have symbolic link created (next)
:
fi
if ! ln -s "${ZOPEN_META_DEV_ROOT}" "${META_DEV_DIR}" ; then
echo "Unable to create symbolic from ${META_DEV_DIR} to ${ZOPEN_META_DEV_ROOT}" >&2
exit 8
fi
fi
zopen_post_buildenv()
{
if [ "${ZOPEN_BUILD_LINE}x" = "DEVx" ]; then
ZOPEN_CHECK="skip"
fi
}
zopen_init()
{
export PATH="$PWD/bin:$PATH"
myzopen=$( whence zopen )
if [ $? -gt 0 ]; then
echo "Error - unable to find zopen in the PATH" >&2
return 8
fi
if [ "${myzopen}" != "${PWD}/bin/zopen" ]; then
echo "Error - unable to find local zopen at ${PWD}/bin/zopen" >&2
return 8
fi
# Download curl package
CURL_PACKAGE="curl-8.10.1.20241001_214340.zos.pax.Z"
CURL_URL="https://github.com/zopencommunity/curlport/releases/download/STABLE_curlport_2544/${CURL_PACKAGE}"
mkdir -p "$PWD/packages"
echo "Downloading curl package from ${CURL_URL}..."
curl -L -o "$PWD/packages/${CURL_PACKAGE}" "${CURL_URL}" || {
echo "Error: Failed to download curl package"
return 1
}
# Copy date and sha256sum utilities from coreutils dependency
mkdir -p "$PWD/utilities"
if [ -n "$COREUTILS_HOME" ] && [ -d "$COREUTILS_HOME/bin" ]; then
for util in date sha256sum; do
# Try both regular and GNU-prefixed versions
if [ -f "$COREUTILS_HOME/bin/$util" ]; then
cp -v "$COREUTILS_HOME/bin/$util" "$PWD/utilities/"
elif [ -f "$COREUTILS_HOME/bin/g$util" ]; then
cp -v "$COREUTILS_HOME/bin/g$util" "$PWD/utilities/$util"
else
echo "Warning: $util (or g$util) not found in coreutils at $COREUTILS_HOME/bin"
fi
done
else
echo "Warning: COREUTILS_HOME not set or coreutils bin directory not found"
fi
}
zopen_check()
{
unset ZOPEN_SETUP_NO_REPLACE
WORK_DIR="${ZOPEN_ROOT}/work"
INCLUDE_DIR="${ZOPEN_ROOT}/tests/include"
mkdir -p "${WORK_DIR}"
#
# Set up environment
#
# shellcheck disable=SC1091
. "${ZOPEN_ROOT}/meta/.env"
# include helper script
# shellcheck disable=SC1091
. "${INCLUDE_DIR}/common.sh"
# Display banner
zopen_print_banner "Start Tests"
# shellcheck disable=SC2125 # We want globbing
checks=${ZOPEN_ROOT}/tests/zopen_check_*
echo $checks
for check in $checks ; do
[ ! -x "${check}" ] \
&& echo "FAIL: ${check} (test script is not executable)" \
&& continue
echo "Running: ${check}"
"${check}" "${WORK_DIR}" "${INCLUDE_DIR}"
rc=$?
if [ ${rc} -gt 0 ]; then
echo "FAIL: ${check}"
else
echo "PASS: ${check}"
fi
done
return 0
}
zopen_check_results()
{
chk="$1/$2_check.log"
pass=$( cat "${chk}" | grep -E '^PASS: ' | wc -l)
fail=$( cat "${chk}" | grep -E '^FAIL: ' | wc -l)
echo "actualFailures:$fail"
echo "totalTests:$(( pass+fail ))"
echo "expectedFailures:0"
}
zopen_install()
{
set -e
perlver=$(perl --version | head -2 | tail -1 | awk ' { print $4 }' | tr -d ',')
perlrel=$(perl --version | head -2 | tail -1 | awk ' { print $6 }' | tr -d ',')
if [ $perlver -lt 5 ] || [ $perlrel -lt 38 ]; then
echo "Wrong version of Perl: $perlver.$perlrel (expected 5.38 or higher)"
return 8
fi
mkdir -p "$ZOPEN_INSTALL_DIR"
if [ -z "$ZOPEN_META_DEV_ROOT" ]; then
rm -rvf "$PWD/zotsampleport"
rm -rvf "$PWD/.git"* "$PWD/.editorconfig"
fi
# Copy essential runtime folders
for folder in bin include man data utilities packages patch-utils; do
if [ -d "$PWD/$folder" ]; then
cp -rv "$PWD/$folder" "$ZOPEN_INSTALL_DIR/"
fi
done
# Copy essential runtime files
for file in .env cacert.pem LICENSE; do
if [ -f "$PWD/$file" ]; then
cp -v "$PWD/$file" "$ZOPEN_INSTALL_DIR/"
fi
done
mkdir -p "$ZOPEN_INSTALL_DIR/man/man1"
zopen-help2man "$ZOPEN_INSTALL_DIR/man/man1"
mkdir -p "$ZOPEN_INSTALL_DIR/ref"
echo "HTML reference pages will be written to $ZOPEN_INSTALL_DIR/ref"
for man in "$ZOPEN_INSTALL_DIR"/man/man1/*.1; do
[ ! -f "$man" ] && continue
base=${man##*/}
name=${base%%.1}
html="$ZOPEN_INSTALL_DIR/ref/${name}.html"
groff -m mandoc -Thtml -Wall "${man}" >"${html}"
done
set +e
}
zopen_append_to_setup() {
cat <<ZZ
if [ -n "\$ZOPEN_ROOTFS" ] && [ -d "\$ZOPEN_ROOTFS" ] && [ -x "\$PWD/bin/zopen" ]; then
\$PWD/bin/zopen init --refresh
fi
ZZ
}
zopen_pre_terminate() {
unset ZOPEN_SETUP_NO_REPLACE
# Save the starting directory explicitly
START_DIR="$PWD"
# Clean up any previous test
rm -rf "$ZOPEN_ROOT/zopen_test"
cd "$ZOPEN_INSTALL_DIR"
unset ZOPEN_ROOTFS
rm -f .installed
# Initialize test environment
. ./.env
zopen init -y "$ZOPEN_ROOT/zopen_test"
# Source the newly created config
. "$ZOPEN_ROOT/zopen_test/etc/zopen-config"
rm -rf .installed
# Capture first timestamp
timestamp1=$(stat -c %Y "$ZOPEN_ROOT/zopen_test/etc/zopen-config")
# Trigger a refresh via .env (which calls setup.sh)
. ./.env
# Capture second timestamp
timestamp2=$(stat -c %Y "$ZOPEN_ROOT/zopen_test/etc/zopen-config")
if [ "$timestamp1" -ge "$timestamp2" ]; then
printError "zopen-config did not get refreshed"
fi
# 1. Move out of the directory tree we are about to delete
cd "$START_DIR"
# 2. Now it is safe to delete
rm -rf "$ZOPEN_ROOT/zopen_test"
}
zopen_get_version()
{
version="$(./bin/zopen --version 2>/dev/null)"
echo "${version}" | head -1 | awk '{ print $4; }'
}