Files
docker-cli/scripts/build/mkversioninfo
Sebastiaan van Stijn 4cd2d9ddd2 Change "COMPANY_NAME" to "PACKAGER_NAME"
The COMPANY_NAME currently sets the "CompanyName" field in the metadata
of Windows binaries. Our intent of this field is this field to contain
information about the company/party that produced the binary.

Also from [FileVersionInfo.CompanyName][FileVersionInfo.CompanyName]:

> Gets the name of the company that produced the file

Based on the above, "PACKAGER_NAME" is a bit more generic, and clearer
on intent, and we may at some point re-use this same information to
propagate equivalent fields on other platforms (rpms, debs)

[FileVersionInfo.CompanyName]: https://docs.microsoft.com/en-us/dotnet/api/system.diagnostics.fileversioninfo.companyname

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-03-27 10:09:50 +02:00

61 lines
1.9 KiB
Bash
Executable File

#!/usr/bin/env sh
set -eu
: "${PACKAGER_NAME=}"
. ./scripts/build/.variables
# Create version quad for Windows of the form major.minor.patch.build
VERSION_QUAD=$(printf "%s" "$VERSION" | sed -re 's/^([0-9.]*).*$/\1/' | sed -re 's/\.$//' | sed -re 's/^[0-9]+$/\0\.0/' | sed -re 's/^[0-9]+\.[0-9]+$/\0\.0/' | sed -re 's/^[0-9]+\.[0-9]+\.[0-9]+$/\0\.0/')
# Generate versioninfo.json to be able to create a syso file which contains
# Microsoft Windows Version Information and an icon using goversioninfo.
# https://docs.microsoft.com/en-us/windows/win32/menurc/stringfileinfo-block
# https://github.com/josephspurrier/goversioninfo/blob/master/testdata/resource/versioninfo.json
cat > ./cli/winresources/versioninfo.json <<EOL
{
"FixedFileInfo":
{
"FileVersion": {
"Major": $(echo "${VERSION_QUAD:-0}" | cut -d. -f1),
"Minor": $(echo "${VERSION_QUAD:-0}" | cut -d. -f2),
"Patch": $(echo "${VERSION_QUAD:-0}" | cut -d. -f3),
"Build": $(echo "${VERSION_QUAD:-0}" | cut -d. -f4)
},
"FileFlagsMask": "3f",
"FileFlags ": "00",
"FileOS": "040004",
"FileType": "01",
"FileSubType": "00"
},
"StringFileInfo":
{
"Comments": "",
"CompanyName": "${PACKAGER_NAME}",
"FileDescription": "Docker Client",
"FileVersion": "${VERSION}",
"InternalName": "",
"LegalCopyright": "Copyright © 2015-$(date +'%Y') Docker Inc.",
"LegalTrademarks": "",
"OriginalFilename": "$(basename "${TARGET}")",
"PrivateBuild": "",
"ProductName": "Docker Client",
"ProductVersion": "${VERSION}",
"SpecialBuild": "${GITCOMMIT}"
},
"VarFileInfo":
{
"Translation": {
"LangID": "0409",
"CharsetID": "04B0"
}
}
}
EOL
(set -x ; cat ./cli/winresources/versioninfo.json)
# Create winresources package stub if removed while using tmpfs in Dockerfile
if [ ! -f "./cli/winresources/winresources.go" ]; then
echo "package winresources" > "./cli/winresources/winresources.go"
fi