From 1e8731c242c2e2926819e24856743d0ec7e70a56 Mon Sep 17 00:00:00 2001 From: Ward Vandewege Date: Tue, 26 Oct 2021 14:52:32 -0400 Subject: [PATCH] 18264: add a script that uses the existing version logic in the build scripts to generate a package version string from a local Arvados git checkout. Arvados-DCO-1.1-Signed-off-by: Ward Vandewege --- build/get-package-version.sh | 64 ++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100755 build/get-package-version.sh diff --git a/build/get-package-version.sh b/build/get-package-version.sh new file mode 100755 index 0000000000..e4579cbb3f --- /dev/null +++ b/build/get-package-version.sh @@ -0,0 +1,64 @@ +#!/bin/bash +# Copyright (C) The Arvados Authors. All rights reserved. +# +# SPDX-License-Identifier: AGPL-3.0 + +# When run with WORKSPACE pointing at a git checkout of arvados, this script +# calculates the package version of an Arvados component. + +# set to --no-cache-dir to disable pip caching +CACHE_FLAG= +STDOUT_IF_DEBUG=/dev/null +STDERR_IF_DEBUG=/dev/null +DASHQ_UNLESS_DEBUG=-q +ITERATION="${ARVADOS_BUILDING_ITERATION:-1}" + +. `dirname "$(readlink -f "$0")"`/run-library.sh + +TYPE_LANG=$1 +SRC_PATH=$2 + +if [[ "$TYPE_LANG" == "" ]] || [[ "$SRC_PATH" == "" ]]; then + echo "Syntax: $0 " + echo + echo "Example: $0 go cmd/arvados-client" + echo "Example: $0 python3 services/fuse" + echo + exit 1 +fi + +if [[ "$WORKSPACE" == "" ]]; then + echo "The WORKSPACE environment variable must be set, pointing at the root of the arvados git tree" + exit 1 +fi + + +debug_echo "package_go_binary $SRC_PATH" + +if [[ "$TYPE_LANG" == "go" ]]; then + calculate_go_package_version go_package_version $SRC_PATH + echo "${go_package_version}-${ITERATION}" +elif [[ "$TYPE_LANG" == "python3" ]]; then + + cd $WORKSPACE/$SRC_PATH + + rm -rf dist/* + + # Get the latest setuptools + if ! pip3 install $DASHQ_UNLESS_DEBUG $CACHE_FLAG -U 'setuptools<45'; then + echo "Error, unable to upgrade setuptools with" + echo " pip3 install $DASHQ_UNLESS_DEBUG $CACHE_FLAG -U 'setuptools<45'" + exit 1 + fi + # filter a useless warning (when building the cwltest package) from the stderr output + if ! python3 setup.py $DASHQ_UNLESS_DEBUG sdist 2> >(grep -v 'warning: no previously-included files matching' |grep -v 'for version number calculation'); then + echo "Error, unable to run python3 setup.py sdist for $SRC_PATH" + exit 1 + fi + + PYTHON_VERSION=$(awk '($1 == "Version:"){print $2}' *.egg-info/PKG-INFO) + UNFILTERED_PYTHON_VERSION=$(echo -n $PYTHON_VERSION | sed s/\.dev/~dev/g |sed 's/\([0-9]\)rc/\1~rc/g') + + echo "${UNFILTERED_PYTHON_VERSION}-${ITERATION}" +fi + -- 2.30.2