Merge "Updating the license with Creative Commons Attribution 4.0 with SPDX shorthand"
[releng.git] / jjb / apex / apex-download-artifact.sh
1 #!/bin/bash
2 set -o errexit
3 set -o nounset
4 set -o pipefail
5
6 APEX_PKGS="common undercloud" # removed onos for danube
7
8 # log info to console
9 echo "Downloading the Apex artifact. This could take some time..."
10 echo "--------------------------------------------------------"
11 echo
12
13 [[ -d $BUILD_DIRECTORY ]] || mkdir -p $BUILD_DIRECTORY
14
15 if [[ "$ARTIFACT_VERSION" =~ dev ]]; then
16   # dev build
17   GERRIT_PATCHSET_NUMBER=$(echo $GERRIT_REFSPEC | grep -Eo '[0-9]+$')
18   export OPNFV_ARTIFACT_VERSION="dev${GERRIT_CHANGE_NUMBER}_${GERRIT_PATCHSET_NUMBER}"
19   # get build artifact
20   pushd ${BUILD_DIRECTORY} > /dev/null
21   echo "Downloading packaged dev build: apex-${OPNFV_ARTIFACT_VERSION}.tar.gz"
22   curl --fail -s -o $BUILD_DIRECTORY/apex-${OPNFV_ARTIFACT_VERSION}.tar.gz http://$GS_URL/apex-${OPNFV_ARTIFACT_VERSION}.tar.gz
23   tar -xvf apex-${OPNFV_ARTIFACT_VERSION}.tar.gz
24   popd > /dev/null
25 else
26   echo "Will download RPMs..."
27
28   # Must be RPMs/ISO
29   echo "Downloading latest properties file"
30
31   # get the properties file in order to get info regarding artifacts
32   curl --fail -s -o $BUILD_DIRECTORY/opnfv.properties http://$GS_URL/latest.properties
33
34   # source the file so we get OPNFV vars
35   source $BUILD_DIRECTORY/opnfv.properties
36
37   RPM_INSTALL_PATH=$(echo "http://"$OPNFV_RPM_URL | sed 's/\/'"$(basename $OPNFV_RPM_URL)"'//')
38   RPM_LIST=${RPM_INSTALL_PATH}/$(basename $OPNFV_RPM_URL)
39
40   # find version of RPM
41   VERSION_EXTENSION=$(echo $(basename $RPM_LIST) | grep -Eo '[0-9]+\.[0-9]+-([0-9]{8}|[a-z]+-[0-9]\.[0-9]+)')
42   # build RPM List which already includes base Apex RPM
43   for pkg in ${APEX_PKGS}; do
44     RPM_LIST+=" ${RPM_INSTALL_PATH}/opnfv-apex-${pkg}-${VERSION_EXTENSION}.noarch.rpm"
45   done
46
47   # remove old / install new RPMs
48   if rpm -q opnfv-apex > /dev/null; then
49     INSTALLED_RPMS=$(rpm -qa | grep apex)
50     if [ -n "$INSTALLED_RPMS" ]; then
51       sudo yum remove -y ${INSTALLED_RPMS}
52     fi
53   fi
54   if ! sudo yum install -y $RPM_LIST; then
55     echo "Unable to install new RPMs: $RPM_LIST"
56     exit 1
57   fi
58 fi
59
60 # TODO: Uncomment these lines to verify SHA512SUMs once the sums are
61 # fixed.
62 # echo "$OPNFV_ARTIFACT_SHA512SUM $BUILD_DIRECTORY/apex.iso" | sha512sum -c
63 # echo "$OPNFV_RPM_SHA512SUM $BUILD_DIRECTORY/$(basename $OPNFV_RPM_URL)" | sha512sum -c
64
65 # list the files
66 ls -al $BUILD_DIRECTORY
67
68 echo
69 echo "--------------------------------------------------------"
70 echo "Done!"