Fix github-maven-merge scm config
[releng/global-jjb.git] / shell / lftools-install.sh
1 #!/bin/bash
2 # SPDX-License-Identifier: EPL-1.0
3 ##############################################################################
4 # Copyright (c) 2017 The Linux Foundation and others.
5 #
6 # All rights reserved. This program and the accompanying materials
7 # are made available under the terms of the Eclipse Public License v1.0
8 # which accompanies this distribution, and is available at
9 # http://www.eclipse.org/legal/epl-v10.html
10 ##############################################################################
11 echo "---> lftools-install.sh"
12 echo "WARNING: The lftools-install.sh script is deprecated. We now recommend \
13 to use `pip install --user lftools` to install."
14
15 # Script to install lftools via a version passed in via lf-infra-parameters
16 #
17 # Required parameters:
18 #
19 #     LFTOOLS_VERSION: Passed in via lf-infra-parameters configuration. Can be
20 #                      set to a strict version number like '1.2.3' or using
21 #                      PEP-440 definitions.
22 #
23 #                      Examples:
24 #                          <1.0.0
25 #                          >=1.0.0,<2.0.0
26 #
27 # By default a released version of lftools should always be used.
28 # The purpose of the 2 variables below is so that lftools devs can test
29 # unreleased versions of lftools. There are 2 methods to install a dev version
30 # of lftools:
31 #
32 #     1) gerrit patch: Used to test a patch that has not yet been merged.
33 #                      To do this set something like this:
34 #                          LFTOOLS_MODE=gerrit
35 #                          LFTOOLS_REFSPEC=refs/changes/96/5296/7
36 #
37 #     2) git branch: Used to install an lftools version from a specific branch.
38 #                    To use this set the variables as follows:
39 #                          LFTOOLS_MODE=git
40 #                          LFTOOLS_REFSPEC=master
41 #
42 #     3) release : The intended use case and default setting.
43 #                  Set LFTOOLS_MODE=release, in this case LFTOOLS_REFSPEC is unused.
44
45 LFTOOLS_MODE=release  # release | git | gerrit
46 LFTOOLS_REFSPEC=master
47
48 # Ensure we fail the job if any steps fail.
49 # DO NOT set -u as virtualenv's activate script has unbound variables
50 set -e -o pipefail
51
52 virtualenv --quiet "/tmp/v/lftools"
53 # shellcheck source=/tmp/v/lftools/bin/activate disable=SC1091
54 source "/tmp/v/lftools/bin/activate"
55 pip install --quiet --upgrade "pip==9.0.3" setuptools
56
57 case $LFTOOLS_MODE in
58     gerrit)
59         git clone https://gerrit.linuxfoundation.org/infra/releng/lftools.git /tmp/lftools
60         pushd /tmp/lftools
61         git fetch origin "$LFTOOLS_REFSPEC"
62         git checkout FETCH_HEAD
63         pip install --quiet --upgrade -r requirements.txt
64         pip install --quiet --upgrade -e .
65         popd
66         ;;
67
68     git)
69         pip install --quiet --upgrade git+https://gerrit.linuxfoundation.org/infra/releng/lftools.git@"$BRANCH"
70         ;;
71
72     release)
73         if [[ $LFTOOLS_VERSION =~ ^[0-9] ]]; then
74             LFTOOLS_VERSION="==$LFTOOLS_VERSION"
75         fi
76
77         pip install --quiet --upgrade "lftools${LFTOOLS_VERSION}"
78         ;;
79 esac
80
81 lftools --version
82
83 # pipdeptree prints out a lot of information because lftools pulls in many
84 # dependencies. Let's only print it if we want to debug.
85 # echo "----> Pip Dependency Tree"
86 # pip install --quiet --upgrade pipdeptree
87 # pipdeptree