Skip to content

Commit

Permalink
Merge pull request #637 from thaJeztah/20.10_backport_add_version_checks
Browse files Browse the repository at this point in the history
[20.10 backport] add checks for binary versions set through build-time variables
  • Loading branch information
thaJeztah committed Mar 7, 2022
2 parents 276a6b7 + fd7b7ae commit 96a8316
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 7 deletions.
14 changes: 12 additions & 2 deletions deb/common/rules
Expand Up @@ -36,8 +36,18 @@ override_dh_auto_build:
done

override_dh_auto_test:
./engine/bundles/dynbinary-daemon/dockerd -v
./cli/build/docker -v
ver="$$(engine/bundles/dynbinary-daemon/dockerd --version)"; \
test "$$ver" = "Docker version $(VERSION), build $(ENGINE_GITCOMMIT)" && echo "PASS: daemon version OK" || (echo "FAIL: daemon version ($$ver) did not match" && exit 1)

ver="$$(cli/build/docker --version)"; \
test "$$ver" = "Docker version $(VERSION), build $(CLI_GITCOMMIT)" && echo "PASS: cli version OK" || (echo "FAIL: cli version ($$ver) did not match" && exit 1)

# FIXME: --version currently doesn't work as it makes a connection to the daemon, so using the plugin metadata instead
# TODO change once we support scan-plugin on other architectures
if [ "$(TARGET_ARCH)" = "amd64" ]; then \
ver="$$(/usr/libexec/docker/cli-plugins/docker-scan docker-cli-plugin-metadata | awk '{ gsub(/[",:]/,"")}; $$1 == "Version" { print $$2 }')"; \
test "$$ver" = "$(SCAN_VERSION)" && echo "PASS: docker-scan version OK" || (echo "FAIL: docker-scan version ($$ver) did not match" && exit 1); \
fi

override_dh_strip:
# Go has lots of problems with stripping, so just don't
Expand Down
5 changes: 3 additions & 2 deletions rpm/SPECS/docker-ce-cli.spec
Expand Up @@ -64,8 +64,9 @@ done
popd


# %check
# cli/build/docker -v
%check
ver="$(cli/build/docker --version)"; \
test "$ver" = "Docker version %{_origversion}, build %{_gitcommit_cli}" && echo "PASS: cli version OK" || (echo "FAIL: cli version ($ver) did not match" && exit 1)

%install
# install binary
Expand Down
3 changes: 2 additions & 1 deletion rpm/SPECS/docker-ce.spec
Expand Up @@ -89,7 +89,8 @@ VERSION=%{_origversion} PRODUCT=docker hack/make.sh dynbinary
popd

%check
engine/bundles/dynbinary-daemon/dockerd -v
ver="$(engine/bundles/dynbinary-daemon/dockerd --version)"; \
test "$ver" = "Docker version %{_origversion}, build %{_gitcommit_engine}" && echo "PASS: daemon version OK" || (echo "FAIL: daemon version ($ver) did not match" && exit 1)

%install
# install daemon binary
Expand Down
5 changes: 3 additions & 2 deletions rpm/SPECS/docker-scan-plugin.spec
Expand Up @@ -31,9 +31,10 @@ popd


%check
# FIXME: --version currently doesn't work as it makes a connection to the daemon
# FIXME: --version currently doesn't work as it makes a connection to the daemon, so using the plugin metadata instead
#${RPM_BUILD_ROOT}%{_libexecdir}/docker/cli-plugins/docker-scan scan --accept-license --version
${RPM_BUILD_ROOT}%{_libexecdir}/docker/cli-plugins/docker-scan --help
ver="$(${RPM_BUILD_ROOT}%{_libexecdir}/docker/cli-plugins/docker-scan docker-cli-plugin-metadata | awk '{ gsub(/[",:]/,"")}; $1 == "Version" { print $2 }')"; \
test "$ver" = "%{_scan_version}" && echo "PASS: docker-scan version OK" || (echo "FAIL: docker-scan version ($ver) did not match" && exit 1)

%install
pushd ${RPM_BUILD_DIR}/src/scan-cli-plugin
Expand Down

0 comments on commit 96a8316

Please sign in to comment.