forked from openshift/origin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconstants.sh
executable file
·395 lines (353 loc) · 16.1 KB
/
constants.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
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
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
#!/bin/bash
# This script provides constants for the Golang binary build process
readonly OS_GO_PACKAGE=github.com/openshift/origin
readonly OS_BUILD_ENV_GOLANG="${OS_BUILD_ENV_GOLANG:-1.9}"
readonly OS_BUILD_ENV_IMAGE="${OS_BUILD_ENV_IMAGE:-openshift/origin-release:golang-${OS_BUILD_ENV_GOLANG}}"
readonly OS_REQUIRED_GO_VERSION="go${OS_BUILD_ENV_GOLANG}"
readonly OS_GLIDE_MINOR_VERSION="13"
readonly OS_REQUIRED_GLIDE_VERSION="0.$OS_GLIDE_MINOR_VERSION"
readonly OS_GOFLAGS_TAGS="include_gcs include_oss containers_image_openpgp"
readonly OS_GOFLAGS_TAGS_LINUX_AMD64="gssapi"
readonly OS_GOFLAGS_TAGS_LINUX_S390X="gssapi"
readonly OS_GOFLAGS_TAGS_LINUX_ARM64="gssapi"
readonly OS_GOFLAGS_TAGS_LINUX_PPC64LE="gssapi"
readonly OS_OUTPUT_BASEPATH="${OS_OUTPUT_BASEPATH:-_output}"
readonly OS_BASE_OUTPUT="${OS_ROOT}/${OS_OUTPUT_BASEPATH}"
readonly OS_OUTPUT_SCRIPTPATH="${OS_OUTPUT_SCRIPTPATH:-"${OS_BASE_OUTPUT}/scripts"}"
readonly OS_OUTPUT_SUBPATH="${OS_OUTPUT_SUBPATH:-${OS_OUTPUT_BASEPATH}/local}"
readonly OS_OUTPUT="${OS_ROOT}/${OS_OUTPUT_SUBPATH}"
readonly OS_OUTPUT_RELEASEPATH="${OS_OUTPUT}/releases"
readonly OS_OUTPUT_RPMPATH="${OS_OUTPUT_RELEASEPATH}/rpms"
readonly OS_OUTPUT_BINPATH="${OS_OUTPUT}/bin"
readonly OS_OUTPUT_PKGDIR="${OS_OUTPUT}/pkgdir"
readonly OS_SDN_COMPILE_TARGETS_LINUX=(
pkg/network/sdn-cni-plugin
vendor/github.com/containernetworking/plugins/plugins/ipam/host-local
vendor/github.com/containernetworking/plugins/plugins/main/loopback
)
readonly OS_IMAGE_COMPILE_TARGETS_LINUX=(
"${OS_SDN_COMPILE_TARGETS_LINUX[@]}"
)
readonly OS_SCRATCH_IMAGE_COMPILE_TARGETS_LINUX=(
images/pod
examples/hello-openshift
)
readonly OS_IMAGE_COMPILE_BINARIES=("${OS_SCRATCH_IMAGE_COMPILE_TARGETS_LINUX[@]##*/}" "${OS_IMAGE_COMPILE_TARGETS_LINUX[@]##*/}")
readonly OS_CROSS_COMPILE_TARGETS=(
cmd/openshift
cmd/oc
cmd/oadm
cmd/template-service-broker
vendor/k8s.io/kubernetes/cmd/hyperkube
)
readonly OS_CROSS_COMPILE_BINARIES=("${OS_CROSS_COMPILE_TARGETS[@]##*/}")
readonly OS_TEST_TARGETS=(
test/extended/extended.test
)
readonly OS_GOVET_BLACKLIST=(
"pkg/.*/generated/internalclientset/fake/clientset_generated.go:[0-9]+: literal copies lock value from fakePtr: github.com/openshift/origin/vendor/k8s.io/client-go/testing.Fake"
"pkg/.*/generated/clientset/fake/clientset_generated.go:[0-9]+: literal copies lock value from fakePtr: github.com/openshift/origin/vendor/k8s.io/client-go/testing.Fake"
"pkg/build/vendor/github.com/docker/engine-api/client/hijack.go:[0-9]+: assignment copies lock value to c: crypto/tls.Config contains sync.Once contains sync.Mutex"
"cmd/cluster-capacity/.*"
"pkg/build/builder/vendor/.*"
"pkg/cmd/server/start/.*"
)
#If you update this list, be sure to get the images/origin/Dockerfile
readonly OPENSHIFT_BINARY_SYMLINKS=(
openshift-router
openshift-deploy
openshift-recycle
openshift-sti-build
openshift-docker-build
openshift-git-clone
openshift-manage-dockerfile
openshift-extract-image-content
origin
)
readonly OC_BINARY_COPY=(
kubectl
)
readonly OS_BINARY_RELEASE_CLIENT_WINDOWS=(
oc.exe
README.md
./LICENSE
)
readonly OS_BINARY_RELEASE_CLIENT_MAC=(
oc
README.md
./LICENSE
)
readonly OS_BINARY_RELEASE_CLIENT_LINUX=(
./oc
./README.md
./LICENSE
)
readonly OS_BINARY_RELEASE_SERVER_LINUX=(
'./*'
)
readonly OS_BINARY_RELEASE_CLIENT_EXTRA=(
${OS_ROOT}/README.md
${OS_ROOT}/LICENSE
)
# os::build::get_product_vars exports variables that we expect to change
# depending on the distribution of Origin
function os::build::get_product_vars() {
export OS_BUILD_LDFLAGS_IMAGE_PREFIX="${OS_IMAGE_PREFIX:-"openshift/origin"}"
export OS_BUILD_LDFLAGS_DEFAULT_IMAGE_STREAMS="${OS_BUILD_LDFLAGS_DEFAULT_IMAGE_STREAMS:-"centos7"}"
export OS_BUILD_LDFLAGS_FEDERATION_SERVER_IMAGE_NAME="${OS_BUILD_LDFLAGS_FEDERATION_SERVER_IMAGE_NAME:-"${OS_BUILD_LDFLAGS_IMAGE_PREFIX}-federation"}"
export OS_BUILD_LDFLAGS_FEDERATION_ETCD_IMAGE="${OS_BUILD_LDFLAGS_FEDERATION_ETCD_IMAGE:-"quay.io/coreos/etcd:v3.1.7"}"
}
# os::build::ldflags calculates the -ldflags argument for building OpenShift
function os::build::ldflags() {
# Run this in a subshell to prevent settings/variables from leaking.
set -o errexit
set -o nounset
set -o pipefail
cd "${OS_ROOT}"
os::build::version::get_vars
os::build::get_product_vars
local buildDate="$(date -u +'%Y-%m-%dT%H:%M:%SZ')"
declare -a ldflags=()
ldflags+=($(os::build::ldflag "${OS_GO_PACKAGE}/pkg/oc/bootstrap/docker.defaultImageStreams" "${OS_BUILD_LDFLAGS_DEFAULT_IMAGE_STREAMS}"))
ldflags+=($(os::build::ldflag "${OS_GO_PACKAGE}/pkg/cmd/util/variable.DefaultImagePrefix" "${OS_BUILD_LDFLAGS_IMAGE_PREFIX}"))
ldflags+=($(os::build::ldflag "${OS_GO_PACKAGE}/pkg/version.majorFromGit" "${OS_GIT_MAJOR}"))
ldflags+=($(os::build::ldflag "${OS_GO_PACKAGE}/pkg/version.minorFromGit" "${OS_GIT_MINOR}"))
ldflags+=($(os::build::ldflag "${OS_GO_PACKAGE}/pkg/version.versionFromGit" "${OS_GIT_VERSION}"))
ldflags+=($(os::build::ldflag "${OS_GO_PACKAGE}/pkg/version.commitFromGit" "${OS_GIT_COMMIT}"))
ldflags+=($(os::build::ldflag "${OS_GO_PACKAGE}/pkg/version.buildDate" "${buildDate}"))
ldflags+=($(os::build::ldflag "${OS_GO_PACKAGE}/vendor/k8s.io/kubernetes/pkg/version.gitCommit" "${KUBE_GIT_COMMIT}"))
ldflags+=($(os::build::ldflag "${OS_GO_PACKAGE}/vendor/k8s.io/kubernetes/pkg/version.gitVersion" "${KUBE_GIT_VERSION}"))
ldflags+=($(os::build::ldflag "${OS_GO_PACKAGE}/vendor/k8s.io/kubernetes/pkg/version.buildDate" "${buildDate}"))
ldflags+=($(os::build::ldflag "${OS_GO_PACKAGE}/vendor/k8s.io/kubernetes/pkg/version.gitTreeState" "clean"))
ldflags+=($(os::build::ldflag "${OS_GO_PACKAGE}/vendor/k8s.io/client-go/pkg/version.gitCommit" "${KUBE_GIT_COMMIT}"))
ldflags+=($(os::build::ldflag "${OS_GO_PACKAGE}/vendor/k8s.io/client-go/pkg/version.gitVersion" "${KUBE_GIT_VERSION}"))
ldflags+=($(os::build::ldflag "${OS_GO_PACKAGE}/vendor/k8s.io/client-go/pkg/version.buildDate" "${buildDate}"))
ldflags+=($(os::build::ldflag "${OS_GO_PACKAGE}/vendor/k8s.io/client-go/pkg/version.gitTreeState" "clean")
)
# The -ldflags parameter takes a single string, so join the output.
echo "${ldflags[*]-}"
}
readonly -f os::build::ldflags
# os::util::list_go_src_files lists files we consider part of our project
# source code, useful for tools that iterate over source to provide vet-
# ting or linting, etc.
#
# Globals:
# None
# Arguments:
# None
# Returns:
# None
function os::util::list_go_src_files() {
find . -not \( \
\( \
-wholename './_output' \
-o -wholename './.*' \
-o -wholename './pkg/assets/bindata.go' \
-o -wholename './pkg/assets/*/bindata.go' \
-o -wholename './pkg/oc/bootstrap/bindata.go' \
-o -wholename './openshift.local.*' \
-o -wholename './test/extended/testdata/bindata.go' \
-o -wholename '*/vendor/*' \
-o -wholename './cmd/service-catalog/*' \
-o -wholename './cmd/cluster-capacity/*' \
-o -wholename './assets/bower_components/*' \
\) -prune \
\) -name '*.go' | sort -u
}
readonly -f os::util::list_go_src_files
# os::util::list_go_src_dirs lists dirs in origin/ and cmd/ dirs excluding
# cmd/cluster-capacity and cmd/service-catalog and doc.go useful for tools that
# iterate over source to provide vetting or linting, or for godep-save etc.
#
# Globals:
# None
# Arguments:
# None
# Returns:
# None
function os::util::list_go_src_dirs() {
os::util::list_go_src_files | cut -d '/' -f 1-2 | grep -v ".go$" | grep -v "^./cmd" | LC_ALL=C sort -u
os::util::list_go_src_files | grep "^./cmd/"| cut -d '/' -f 1-3 | grep -v ".go$" | LC_ALL=C sort -u
}
readonly -f os::util::list_go_src_dirs
# os::util::list_go_deps outputs the list of dependencies for the project.
function os::util::list_go_deps() {
go list -f '{{.ImportPath}}{{.Imports}}' ./pkg/... ./cmd/... | tr '[]' ' ' |
grep -vE '^github.com/openshift/origin/cmd/(service-catalog|cluster-capacity)' |
sed -e 's|github.com/openshift/origin/vendor/||g' |
sed -e 's|github.com/openshift/origin/pkg/build/vendor/||g'
}
# os::util::list_test_packages_under lists all packages containing Golang test files that we
# want to run as unit tests under the given base dir in the source tree
function os::util::list_test_packages_under() {
local basedir=$*
# we do not quote ${basedir} to allow for multiple arguments to be passed in as well as to allow for
# arguments that use expansion, e.g. paths containing brace expansion or wildcards
# we do not quote ${basedir} to allow for multiple arguments to be passed in as well as to allow for
# arguments that use expansion, e.g. paths containing brace expansion or wildcards
find ${basedir} -not \( \
\( \
-path 'vendor' \
-o -path '*_output' \
-o -path '*.git' \
-o -path '*openshift.local.*' \
-o -path '*vendor/*' \
-o -path '*assets/node_modules' \
-o -path '*test/*' \
-o -path '*cmd/cluster-capacity' \
-o -path '*cmd/service-catalog' \
-o -path '*pkg/proxy' \
\) -prune \
\) -name '*_test.go' | xargs -n1 dirname | sort -u | xargs -n1 printf "${OS_GO_PACKAGE}/%s\n"
local kubernetes_path="vendor/k8s.io/kubernetes"
if [[ -n "${TEST_KUBE-}" ]]; then
# we need to find all of the kubernetes test suites, excluding those we directly whitelisted before, the end-to-end suite, and
# the go2idl tests which we currently do not support
# etcd3 isn't supported yet and that test flakes upstream
# cmd wasn't done before using glide and constantly flakes
find -L vendor/k8s.io/{apimachinery,apiserver,client-go,kube-aggregator,kubernetes} -not \( \
\( \
-path "${kubernetes_path}/staging" \
-o -path "${kubernetes_path}/cmd" \
-o -path "${kubernetes_path}/test" \
-o -path "${kubernetes_path}/cmd/libs/go2idl/client-gen/testoutput/testgroup/unversioned" \
-o -path "${kubernetes_path}/pkg/storage/etcd3" \
-o -path "${kubernetes_path}/third_party/golang/go/build" \
\) -prune \
\) -name '*_test.go' | cut -f 2- -d / | xargs -n1 dirname | sort -u | xargs -n1 printf "${OS_GO_PACKAGE}/vendor/%s\n"
else
echo "${OS_GO_PACKAGE}/vendor/k8s.io/kubernetes/pkg/api/..."
echo "${OS_GO_PACKAGE}/vendor/k8s.io/kubernetes/pkg/apis/..."
fi
}
readonly -f os::util::list_test_packages_under
# Generates the .syso file used to add compile-time VERSIONINFO metadata to the
# Windows binary.
function os::build::generate_windows_versioninfo() {
os::build::version::get_vars
local major="${OS_GIT_MAJOR}"
local minor="${OS_GIT_MINOR%+}"
local patch="${OS_GIT_PATCH}"
local windows_versioninfo_file=`mktemp --suffix=".versioninfo.json"`
cat <<EOF >"${windows_versioninfo_file}"
{
"FixedFileInfo":
{
"FileVersion": {
"Major": ${major},
"Minor": ${minor},
"Patch": ${patch}
},
"ProductVersion": {
"Major": ${major},
"Minor": ${minor},
"Patch": ${patch}
},
"FileFlagsMask": "3f",
"FileFlags ": "00",
"FileOS": "040004",
"FileType": "01",
"FileSubType": "00"
},
"StringFileInfo":
{
"Comments": "",
"CompanyName": "Red Hat, Inc.",
"InternalName": "openshift client",
"FileVersion": "${OS_GIT_VERSION}",
"InternalName": "oc",
"LegalCopyright": "© Red Hat, Inc. Licensed under the Apache License, Version 2.0",
"LegalTrademarks": "",
"OriginalFilename": "oc.exe",
"PrivateBuild": "",
"ProductName": "OpenShift Client",
"ProductVersion": "${OS_GIT_VERSION}",
"SpecialBuild": ""
},
"VarFileInfo":
{
"Translation": {
"LangID": "0409",
"CharsetID": "04B0"
}
}
}
EOF
goversioninfo -o ${OS_ROOT}/cmd/oc/oc.syso ${windows_versioninfo_file}
}
readonly -f os::build::generate_windows_versioninfo
# Removes the .syso file used to add compile-time VERSIONINFO metadata to the
# Windows binary.
function os::build::clean_windows_versioninfo() {
rm ${OS_ROOT}/cmd/oc/oc.syso
}
readonly -f os::build::clean_windows_versioninfo
# OS_ALL_IMAGES is the list of images built by os::build::images.
readonly OS_ALL_IMAGES=(
openshift/origin
openshift/origin-base
openshift/origin-pod
openshift/origin-deployer
openshift/origin-docker-builder
openshift/origin-keepalived-ipfailover
openshift/origin-sti-builder
openshift/origin-haproxy-router
openshift/origin-f5-router
openshift/origin-egress-router
openshift/origin-egress-http-proxy
openshift/origin-egress-dns-proxy
openshift/origin-recycler
openshift/origin-cluster-capacity
openshift/origin-service-catalog
openshift/origin-template-service-broker
openshift/hello-openshift
openshift/openvswitch
openshift/node
)
# os::build::images builds all images in this repo.
function os::build::images() {
# Create link to file if the FS supports hardlinks, otherwise copy the file
function ln_or_cp {
local src_file=$1
local dst_dir=$2
if os::build::archive::internal::is_hardlink_supported "${dst_dir}" ; then
ln -f "${src_file}" "${dst_dir}"
else
cp -pf "${src_file}" "${dst_dir}"
fi
}
# Link or copy image binaries to the appropriate locations.
ln_or_cp "${OS_OUTPUT_BINPATH}/linux/amd64/hello-openshift" examples/hello-openshift/bin
# determine the correct tag prefix
tag_prefix="${OS_IMAGE_PREFIX:-"openshift/origin"}"
# images that depend on "${tag_prefix}-source"
( os::build::image "${tag_prefix}-pod" images/pod ) &
( os::build::image "${tag_prefix}-cluster-capacity" images/cluster-capacity ) &
( os::build::image "${tag_prefix}-service-catalog" images/service-catalog ) &
( os::build::image "${tag_prefix}-template-service-broker" images/template-service-broker ) &
for i in `jobs -p`; do wait $i; done
# images that depend on "${tag_prefix}-base"
( os::build::image "${tag_prefix}" images/origin ) &
( os::build::image "${tag_prefix}-egress-router" images/egress/router ) &
( os::build::image "${tag_prefix}-egress-http-proxy" images/egress/http-proxy ) &
( os::build::image "${tag_prefix}-egress-dns-proxy" images/egress/dns-proxy ) &
( os::build::image "${tag_prefix}-federation" images/federation ) &
for i in `jobs -p`; do wait $i; done
# images that depend on "${tag_prefix}
( os::build::image "${tag_prefix}-haproxy-router" images/router/haproxy ) &
( os::build::image "${tag_prefix}-keepalived-ipfailover" images/ipfailover/keepalived ) &
( os::build::image "${tag_prefix}-deployer" images/deployer ) &
( os::build::image "${tag_prefix}-recycler" images/recycler ) &
( os::build::image "${tag_prefix}-docker-builder" images/builder/docker/docker-builder ) &
( os::build::image "${tag_prefix}-sti-builder" images/builder/docker/sti-builder ) &
( os::build::image "${tag_prefix}-f5-router" images/router/f5 ) &
( os::build::image "openshift/node" images/node ) &
for i in `jobs -p`; do wait $i; done
# images that depend on "openshift/node"
( os::build::image "openshift/openvswitch" images/openvswitch ) &
# extra images (not part of infrastructure)
( os::build::image "openshift/hello-openshift" examples/hello-openshift ) &
for i in `jobs -p`; do wait $i; done
}
readonly -f os::build::images