...

Text file src/github.com/docker/cli/scripts/build/mkversioninfo

Documentation: github.com/docker/cli/scripts/build

     1#!/usr/bin/env sh
     2set -eu
     3
     4: "${PACKAGER_NAME=}"
     5
     6quadVersionNum() {
     7  num=$(echo "${1:-0}" | cut -d. -f"$2")
     8  if [ "$num" != "0" ]; then
     9    echo "${num#0}"
    10  else
    11    echo "$num"
    12  fi
    13}
    14
    15. ./scripts/build/.variables
    16
    17# Create version quad for Windows of the form major.minor.patch.build
    18VERSION_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/')
    19
    20# Generate versioninfo.json to be able to create a syso file which contains
    21# Microsoft Windows Version Information and an icon using goversioninfo.
    22# https://docs.microsoft.com/en-us/windows/win32/menurc/stringfileinfo-block
    23# https://github.com/josephspurrier/goversioninfo/blob/master/testdata/resource/versioninfo.json
    24cat > ./cli/winresources/versioninfo.json <<EOL
    25{
    26  "FixedFileInfo":
    27  {
    28    "FileVersion": {
    29      "Major": $(quadVersionNum "$VERSION_QUAD" 1),
    30      "Minor": $(quadVersionNum "$VERSION_QUAD" 2),
    31      "Patch": $(quadVersionNum "$VERSION_QUAD" 3),
    32      "Build": $(quadVersionNum "$VERSION_QUAD" 4)
    33    },
    34    "FileFlagsMask": "3f",
    35    "FileFlags ": "00",
    36    "FileOS": "040004",
    37    "FileType": "01",
    38    "FileSubType": "00"
    39  },
    40  "StringFileInfo":
    41  {
    42    "Comments": "",
    43    "CompanyName": "${PACKAGER_NAME}",
    44    "FileDescription": "Docker Client",
    45    "FileVersion": "${VERSION}",
    46    "InternalName": "",
    47    "LegalCopyright": "Copyright © 2015-$(date +'%Y') Docker Inc.",
    48    "LegalTrademarks": "",
    49    "OriginalFilename": "$(basename "${TARGET}")",
    50    "PrivateBuild": "",
    51    "ProductName": "Docker Client",
    52    "ProductVersion": "${VERSION}",
    53    "SpecialBuild": "${GITCOMMIT}"
    54  },
    55  "VarFileInfo":
    56  {
    57    "Translation": {
    58      "LangID": "0409",
    59      "CharsetID": "04B0"
    60    }
    61  }
    62}
    63EOL
    64(set -x ; cat ./cli/winresources/versioninfo.json)
    65
    66# Create winresources package stub if removed while using tmpfs in Dockerfile
    67if [ ! -f "./cli/winresources/winresources.go" ]; then
    68  echo "package winresources" > "./cli/winresources/winresources.go"
    69fi

View as plain text