Welcome to mirror list, hosted at ThFree Co, Russian Federation.

make-gnu-build-id.sh « _support « workhorse - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 815966dab7e597688c5c59359437c777463cf922 (plain)
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
#!/bin/sh

main()
{
    GO_BINARY=$1

    if [ $# -ne 1 ] || [ ! -f $GO_BINARY ] ; then
        fail "Usage: $0 [path_to_go_binary]"
    fi

    GO_BUILD_ID=$( go tool buildid "$GO_BINARY" || openssl rand -hex 32 )
    if [ -z "$GO_BUILD_ID" ] ; then
        fail "ERROR: Could not extract Go build-id or generate a random hex string."
    fi

    GNU_BUILD_ID=$( echo $GO_BUILD_ID | sha1sum | cut -d' ' -f1 )
    if [ -z "$GNU_BUILD_ID" ] ; then
        fail "ERROR: Could not generate a GNU build-id"
    fi

    echo "$GNU_BUILD_ID"
}

fail()
{
    echo "$@" 1>&2
    exit 1
}

main "$@"