Skip to content

Commit

Permalink
Merge pull request #3886 from afbjorklund/crio-version-master
Browse files Browse the repository at this point in the history
Restore version output from crio --version
  • Loading branch information
openshift-merge-robot committed Jun 25, 2020
2 parents 518e147 + 6b6a604 commit d0dc0d3
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
12 changes: 6 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ BASE_LDFLAGS = ${SHRINKFLAGS} \
-X ${PROJECT}/internal/version.gitCommit=${COMMIT_NO} \
-X ${PROJECT}/internal/version.gitTreeState=${GIT_TREE_STATE}

LDFLAGS = -ldflags '${BASE_LDFLAGS} ${EXTRA_LDFLAGS}'
GO_LDFLAGS = -ldflags '${BASE_LDFLAGS} ${EXTRA_LDFLAGS}'

TESTIMAGE_VERSION := master-1.3.6
TESTIMAGE_REGISTRY := quay.io/crio
Expand Down Expand Up @@ -163,16 +163,16 @@ bin/pinns:
$(MAKE) -C pinns

test/copyimg/copyimg: $(GO_FILES) .gopathok
$(GO_BUILD) $(GCFLAGS) $(LDFLAGS) -tags "$(BUILDTAGS)" -o $@ $(PROJECT)/test/copyimg
$(GO_BUILD) $(GCFLAGS) $(GO_LDFLAGS) -tags "$(BUILDTAGS)" -o $@ $(PROJECT)/test/copyimg

test/checkseccomp/checkseccomp: $(GO_FILES) .gopathok
$(GO_BUILD) $(GCFLAGS) $(LDFLAGS) -tags "$(BUILDTAGS)" -o $@ $(PROJECT)/test/checkseccomp
$(GO_BUILD) $(GCFLAGS) $(GO_LDFLAGS) -tags "$(BUILDTAGS)" -o $@ $(PROJECT)/test/checkseccomp

bin/crio: $(GO_FILES) .gopathok
$(GO_BUILD) $(GCFLAGS) $(LDFLAGS) -tags "$(BUILDTAGS)" -o $@ $(PROJECT)/cmd/crio
$(GO_BUILD) $(GCFLAGS) $(GO_LDFLAGS) -tags "$(BUILDTAGS)" -o $@ $(PROJECT)/cmd/crio

bin/crio-status: $(GO_FILES) .gopathok
$(GO_BUILD) $(GCFLAGS) $(LDFLAGS) -tags "$(BUILDTAGS)" -o $@ $(PROJECT)/cmd/crio-status
$(GO_BUILD) $(GCFLAGS) $(GO_LDFLAGS) -tags "$(BUILDTAGS)" -o $@ $(PROJECT)/cmd/crio-status

build-static:
$(CONTAINER_RUNTIME) run --rm -it -v $(shell pwd):/cri-o $(TESTIMAGE_NIX) sh -c \
Expand Down Expand Up @@ -219,7 +219,7 @@ bin/crio.cross.%: .gopathok .explicit_phony
TARGET="$*"; \
GOOS="$${TARGET%%.*}" \
GOARCH="$${TARGET##*.}" \
$(GO_BUILD) $(LDFLAGS) -tags "containers_image_openpgp btrfs_noversion" -o "$@" $(PROJECT)/cmd/crio
$(GO_BUILD) $(GO_LDFLAGS) -tags "containers_image_openpgp btrfs_noversion" -o "$@" $(PROJECT)/cmd/crio

local-image:
$(TESTIMAGE_SCRIPT)
Expand Down
2 changes: 1 addition & 1 deletion cmd/crio/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ func main() {
app.Authors = []*cli.Author{{Name: "The CRI-O Maintainers"}}
app.UsageText = usage
app.Description = app.Usage
app.Version = "\n" + version.Get().String()
app.Version = version.Version + "\n" + version.Get().String()

var err error
app.Flags, app.Metadata, err = criocli.GetFlagsAndMetadata()
Expand Down
4 changes: 4 additions & 0 deletions internal/version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"fmt"
"io/ioutil"
"os"
"os/exec"
"path/filepath"
"reflect"
"runtime"
Expand Down Expand Up @@ -171,6 +172,9 @@ func getLinkmode() string {
return ""
}

if _, err = exec.LookPath("ldd"); err != nil {
return ""
}
if _, err = utils.ExecCmd("ldd", abspath); err != nil {
if strings.Contains(err.Error(), "not a dynamic executable") {
return "static"
Expand Down

0 comments on commit d0dc0d3

Please sign in to comment.