22000: Refresh favorites after deleting processes permanently
[arvados.git] / build / get-package-version.sh
1 #!/bin/bash
2 # Copyright (C) The Arvados Authors. All rights reserved.
3 #
4 # SPDX-License-Identifier: AGPL-3.0
5
6 # When run with WORKSPACE pointing at a git checkout of arvados, this script
7 # calculates the package version of an Arvados component.
8
9 # set to --no-cache-dir to disable pip caching
10 CACHE_FLAG=
11 STDOUT_IF_DEBUG=/dev/null
12 STDERR_IF_DEBUG=/dev/null
13 DASHQ_UNLESS_DEBUG=-q
14 ITERATION="${ARVADOS_BUILDING_ITERATION:-1}"
15
16 . `dirname "$(readlink -f "$0")"`/run-library.sh
17
18 TYPE_LANG=$1
19 SRC_PATH=$2
20
21 if [[ "$TYPE_LANG" == "" ]] || [[ "$SRC_PATH" == "" ]]; then
22   echo "Syntax: $0 <lang> <src_path>"
23   echo
24   echo "Example: $0 go cmd/arvados-client"
25   echo "Example: $0 python3 services/fuse"
26   echo
27   exit 1
28 fi
29
30 if [[ "$WORKSPACE" == "" ]]; then
31   echo "The WORKSPACE environment variable must be set, pointing at the root of the arvados git tree"
32   exit 1
33 fi
34
35
36 debug_echo "get-package-version.sh $TYPE_LANG $SRC_PATH"
37
38 if [[ "$TYPE_LANG" == "go" ]]; then
39   calculate_go_package_version go_package_version $SRC_PATH
40   echo "${go_package_version}-${ITERATION}"
41 elif [[ "$TYPE_LANG" == "python3" ]]; then
42
43   cd $WORKSPACE/$SRC_PATH
44
45   rm -rf dist/*
46
47   if ! python3 setup.py $DASHQ_UNLESS_DEBUG sdist; then
48     echo "Error, unable to run python3 setup.py sdist for $SRC_PATH"
49     exit 1
50   fi
51
52   PYTHON_VERSION=$(awk '($1 == "Version:"){print $2}' *.egg-info/PKG-INFO)
53   UNFILTERED_PYTHON_VERSION=$(echo -n $PYTHON_VERSION | sed s/\.dev/~dev/g |sed 's/\([0-9]\)rc/\1~rc/g')
54
55   echo "${UNFILTERED_PYTHON_VERSION}-${ITERATION}"
56 fi
57