-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbuildenv
181 lines (158 loc) · 4.89 KB
/
buildenv
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
# bump: meta-version /META_VERSION="(.*)"/ https://github.com/ZOSOpenTools/meta.git|semver:^0
META_VERSION="0.8.4"
export ZOPEN_BUILD_LINE="DEV"
export ZOPEN_CATEGORIES="utilities"
export ZOPEN_DEV_URL="https://github.com/ZOSOpenTools/meta.git"
export ZOPEN_DEV_DEPS="git gzip make tar bash zoslib help2man perl curl grep groff coreutils"
export ZOPEN_COMP=SKIP
export ZOPEN_CONFIGURE="skip"
export ZOPEN_MAKE="skip"
export ZOPEN_CHECK="zopen_check"
export ZOPEN_INSTALL="zopen_install"
META_DEV_DIR="${PWD}/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
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 [ -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
mv "${META_DEV_DIR}" "${META_DEV_DIR}-cloned"
else
# There may already be a symbolic link here - if so, delete it in case it is stale
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_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
}
zopen_check()
{
WORK_DIR="${ZOPEN_ROOT}/work"
INCLUDE_DIR="${ZOPEN_ROOT}/tests/include"
mkdir -p "${WORK_DIR}"
#
# Set up environment
#
. ${ZOPEN_ROOT}/meta/.env
# include helper script
. "${INCLUDE_DIR}/common.sh"
# Display banner
zopen_print_banner "Start Tests"
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()
{
dir="$1"
pfx="$2"
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
cp -rv $PWD/* $ZOPEN_INSTALL_DIR/
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
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() {
# Test setup of meta
rm -rf $ZOPEN_ROOT/zopen_test
cd $ZOPEN_INSTALL_DIR
unset ZOPEN_ROOTFS
rm -f .installed
. ./.env
zopen init -y $ZOPEN_ROOT/zopen_test
. $ZOPEN_ROOT/zopen_test/etc/zopen-config
rm -rf .installed
# Test refresh on an existing install
timestamp1=$(stat -c %Y "$ZOPEN_ROOT/zopen_test/etc/zopen-config")
. ./.env # runs setup.sh which should now refresh the zopen-config
timestamp2=$(stat -c %Y "$ZOPEN_ROOT/zopen_test/etc/zopen-config")
# zopen-config timestamp should be updated
if [ "$timestamp1" -ge "$timestamp2" ]; then
printError "zopen-config did not get refreshed"
fi
rm -rf $ZOPEN_ROOT/zopen_test
cd -
}
zopen_get_version()
{
version="$(./bin/zopen --version 2>/dev/null)"
echo "${version}" | head -1 | awk '{ print $4; }'
}