File: binary

package info (click to toggle)
docker.io 20.10.24%2Bdfsg1-1%2Bdeb12u1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bookworm-proposed-updates
  • size: 60,824 kB
  • sloc: sh: 5,621; makefile: 593; ansic: 179; python: 162; asm: 7
file content (80 lines) | stat: -rwxr-xr-x 2,338 bytes parent folder | download | duplicates (4)
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
#!/usr/bin/env sh
#
# Build a static binary for the host OS/ARCH
#

set -eu

: "${CGO_ENABLED=}"
: "${GO_LINKMODE=static}"
: "${GO_BUILDMODE=}"
: "${GO_BUILDTAGS=}"
: "${GO_STRIP=}"

. ./scripts/build/.variables

if [ -z "$CGO_ENABLED" ]; then
    case "$(go env GOOS)" in
        linux)
            case "$(go env GOARCH)" in
                amd64|arm64|arm|s390x)
                    CGO_ENABLED=1
                ;;
                *)
                    CGO_ENABLED=0
                ;;
            esac
        ;;
        darwin|windows)
            CGO_ENABLED=1
        ;;
        *)
            CGO_ENABLED=0
        ;;
    esac
fi
export CGO_ENABLED
if [ "$CGO_ENABLED" = "1" ] && [ "$(go env GOOS)" != "windows" ]; then
    case "$(go env GOARCH)" in
        mips*|ppc64)
            # pie build mode is not supported on mips architectures
            ;;
        *)
            GO_BUILDMODE="-buildmode=pie"
            ;;
    esac
    GO_BUILDTAGS="$GO_BUILDTAGS pkcs11"
fi

if [ "$CGO_ENABLED" = "1" ] && [ "$GO_LINKMODE" = "static" ] && [ "$(go env GOOS)" = "linux" ]; then
    GO_LDFLAGS="$GO_LDFLAGS -extldflags -static"
fi

if [ -n "$GO_STRIP" ]; then
    GO_LDFLAGS="$GO_LDFLAGS -s -w"
fi

if [ "$(go env GOOS)" = "windows" ]; then
    # Generate a Windows file version of the form major,minor,patch,build
    VERSION_QUAD=$(printf "%s" "$VERSION" | sed -re 's/^([0-9.]*).*$/\1/' | tr . , | 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/')

    set --
    [ -n "$VERSION" ]      && set -- "$@" -D "DOCKER_VERSION=\"$VERSION\""
    [ -n "$VERSION_QUAD" ] && set -- "$@" -D "DOCKER_VERSION_QUAD=$VERSION_QUAD"
    [ -n "$GITCOMMIT" ]    && set -- "$@" -D "DOCKER_COMMIT=\"$GITCOMMIT\""

    windres=$($(go env CC) --print-prog-name=windres)

    target="$(dirname "$0")/../../cli/winresources/rsrc_$(go env GOARCH).syso"
    mkdir -p "$(dirname "${target}")"
    "$windres" -i "$(dirname "$0")/../winresources/docker.rc" -o "$target" "$@"
    echo "package winresources" > "$(dirname "${target}")/stub_windows.go"
fi

echo "Building $GO_LINKMODE $(basename "${TARGET}")"

export GO111MODULE=auto

go build -o "${TARGET}" -tags "${GO_BUILDTAGS}" --ldflags "${GO_LDFLAGS}" ${GO_BUILDMODE} "${SOURCE}"

ln -sf "$(basename "${TARGET}")" "$(dirname "${TARGET}")/docker"