File: mkversioninfo

package info (click to toggle)
docker.io 26.1.5%2Bdfsg1-9
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 68,576 kB
  • sloc: sh: 5,748; makefile: 912; ansic: 664; asm: 228; python: 162
file content (69 lines) | stat: -rwxr-xr-x 2,081 bytes parent folder | download
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
#!/usr/bin/env sh
set -eu

: "${PACKAGER_NAME=}"

quadVersionNum() {
  num=$(echo "${1:-0}" | cut -d. -f"$2")
  if [ "$num" != "0" ]; then
    echo "${num#0}"
  else
    echo "$num"
  fi
}

. ./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": $(quadVersionNum "$VERSION_QUAD" 1),
      "Minor": $(quadVersionNum "$VERSION_QUAD" 2),
      "Patch": $(quadVersionNum "$VERSION_QUAD" 3),
      "Build": $(quadVersionNum "$VERSION_QUAD" 4)
    },
    "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