Skip to content

Commit aa13700

Browse files
author
OpenShift Bot
authored
Merge pull request #15180 from fabianofranz/bugs_1429314
Merged by openshift-bot
2 parents ebde951 + c8c201d commit aa13700

File tree

3 files changed

+74
-5
lines changed

3 files changed

+74
-5
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
/dind-*.rc
1414
/os-version-defs
1515
/.make/
16+
/cmd/oc/oc.syso
1617
*.swp
1718
.vimrc
1819
.vagrant-openshift.json*

hack/lib/build/binaries.sh

+68-2
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,11 @@ os::build::internal::build_binaries() {
219219
local_ldflags+=" -s"
220220
fi
221221

222+
#Add Windows File Properties/Version Info and Icon Resource for oc.exe
223+
if [[ "$platform" == "windows/amd64" ]]; then
224+
os::build::generate_windows_versioninfo
225+
fi
226+
222227
if [[ ${#nonstatics[@]} -gt 0 ]]; then
223228
GOOS=${platform%/*} GOARCH=${platform##*/} go install \
224229
-pkgdir "${OS_OUTPUT_PKGDIR}/${platform}" \
@@ -234,6 +239,10 @@ os::build::internal::build_binaries() {
234239
fi
235240
fi
236241

242+
if [[ "$platform" == "windows/amd64" ]]; then
243+
rm ${OS_ROOT}/cmd/oc/oc.syso
244+
fi
245+
237246
for test in "${tests[@]:+${tests[@]}}"; do
238247
local outfile="${OS_OUTPUT_BINPATH}/${platform}/$(basename ${test})"
239248
# disabling cgo allows use of delve
@@ -249,7 +258,64 @@ os::build::internal::build_binaries() {
249258
}
250259
readonly -f os::build::build_binaries
251260

252-
# Generates the set of target packages, binaries, and platforms to build for.
261+
# Generates the .syso file used to add compile-time VERSIONINFO metadata to the
262+
# Windows binary.
263+
function os::build::generate_windows_versioninfo() {
264+
os::util::ensure::gopath_binary_exists 'goversioninfo' 'github.com/josephspurrier/goversioninfo/cmd/goversioninfo'
265+
os::build::version::get_vars
266+
local major="${OS_GIT_MAJOR}"
267+
local minor="${OS_GIT_MINOR%+}"
268+
local patch="${OS_GIT_PATCH}"
269+
local windows_versioninfo_file=`mktemp --suffix=".versioninfo.json"`
270+
cat <<EOF >"${windows_versioninfo_file}"
271+
{
272+
"FixedFileInfo":
273+
{
274+
"FileVersion": {
275+
"Major": ${major},
276+
"Minor": ${minor},
277+
"Patch": ${patch}
278+
},
279+
"ProductVersion": {
280+
"Major": ${major},
281+
"Minor": ${minor},
282+
"Patch": ${patch}
283+
},
284+
"FileFlagsMask": "3f",
285+
"FileFlags ": "00",
286+
"FileOS": "040004",
287+
"FileType": "01",
288+
"FileSubType": "00"
289+
},
290+
"StringFileInfo":
291+
{
292+
"Comments": "",
293+
"CompanyName": "Red Hat, Inc.",
294+
"InternalName": "openshift client",
295+
"FileVersion": "${OS_GIT_VERSION}",
296+
"InternalName": "oc",
297+
"LegalCopyright": "© Red Hat, Inc. Licensed under the Apache License, Version 2.0",
298+
"LegalTrademarks": "",
299+
"OriginalFilename": "oc.exe",
300+
"PrivateBuild": "",
301+
"ProductName": "OpenShift Client",
302+
"ProductVersion": "${OS_GIT_VERSION}",
303+
"SpecialBuild": ""
304+
},
305+
"VarFileInfo":
306+
{
307+
"Translation": {
308+
"LangID": "0409",
309+
"CharsetID": "04B0"
310+
}
311+
}
312+
}
313+
EOF
314+
goversioninfo -o ${OS_ROOT}/cmd/oc/oc.syso ${windows_versioninfo_file}
315+
}
316+
readonly -f os::build::generate_windows_versioninfo
317+
318+
# Generates the set of target packages, binaries, and platforms to build for.
253319
# Accepts binaries via $@, and platforms via OS_BUILD_PLATFORMS, or defaults to
254320
# the current platform.
255321
function os::build::export_targets() {
@@ -533,4 +599,4 @@ function os::build::commit_range() {
533599

534600
echo "$1"
535601
}
536-
readonly -f os::build::commit_range
602+
readonly -f os::build::commit_range

hack/lib/build/version.sh

+5-3
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,11 @@ function os::build::version::openshift_vars() {
4040
# Try to match the "git describe" output to a regex to try to extract
4141
# the "major" and "minor" versions and whether this is the exact tagged
4242
# version or whether the tree is between two tagged versions.
43-
if [[ "${OS_GIT_VERSION}" =~ ^v([0-9]+)\.([0-9]+)(\.[0-9]+)*([-].*)?$ ]]; then
43+
if [[ "${OS_GIT_VERSION}" =~ ^v([0-9]+)\.([0-9]+)\.([0-9]+)(\.[0-9]+)*([-].*)?$ ]]; then
4444
OS_GIT_MAJOR=${BASH_REMATCH[1]}
4545
OS_GIT_MINOR=${BASH_REMATCH[2]}
46-
if [[ -n "${BASH_REMATCH[4]}" ]]; then
46+
OS_GIT_PATCH=${BASH_REMATCH[3]}
47+
if [[ -n "${BASH_REMATCH[5]}" ]]; then
4748
OS_GIT_MINOR+="+"
4849
fi
4950
fi
@@ -111,10 +112,11 @@ OS_GIT_TREE_STATE='${OS_GIT_TREE_STATE-}'
111112
OS_GIT_VERSION='${OS_GIT_VERSION-}'
112113
OS_GIT_MAJOR='${OS_GIT_MAJOR-}'
113114
OS_GIT_MINOR='${OS_GIT_MINOR-}'
115+
OS_GIT_PATCH='${OS_GIT_PATCH-}'
114116
KUBE_GIT_COMMIT='${KUBE_GIT_COMMIT-}'
115117
KUBE_GIT_VERSION='${KUBE_GIT_VERSION-}'
116118
ETCD_GIT_VERSION='${ETCD_GIT_VERSION-}'
117119
ETCD_GIT_COMMIT='${ETCD_GIT_COMMIT-}'
118120
EOF
119121
}
120-
readonly -f os::build::version::save_vars
122+
readonly -f os::build::version::save_vars

0 commit comments

Comments
 (0)