Apex: Fixes RPM checking in virtual deployment 83/14683/1
authorTim Rozet <trozet@redhat.com>
Thu, 26 May 2016 01:06:45 +0000 (21:06 -0400)
committerTim Rozet <trozet@redhat.com>
Thu, 26 May 2016 01:06:45 +0000 (21:06 -0400)
Change-Id: I2e02f16173ec495e250bc60bc225ad1bb6a91828
Signed-off-by: Tim Rozet <trozet@redhat.com>
jjb/apex/apex-deploy-virtual.sh

index c7fb17e..4d9b030 100755 (executable)
@@ -92,27 +92,30 @@ if [[ $BUILD_DIRECTORY == *verify-master* ]]; then
         export PYTHONPATH=$PYTHONPATH:${WORKSPACE}/lib/python
     fi
 else
-    VERSION_EXTENSION=$(echo $(basename $RPM_LIST) | sed 's/opnfv-apex-//')
+    VERSION_EXTENSION=$(echo $(basename $RPM_LIST) | grep -Eo '[0-9]+\.[0-9]+-[0-9]{8}')
     for pkg in common undercloud opendaylight-sfc onos; do
-        RPM_LIST+=" ${RPM_INSTALL_PATH}/opnfv-apex-${pkg}-${VERSION_EXTENSION}"
+        RPM_LIST+=" ${RPM_INSTALL_PATH}/opnfv-apex-${pkg}-${VERSION_EXTENSION}.noarch.rpm"
     done
 
     # update / install the new rpm
     if rpm -q opnfv-apex > /dev/null; then
        INSTALLED_RPMS=$(rpm -qa | grep apex)
        for x in $INSTALLED_RPMS; do
-         INSTALLED_RPM_VER=$(echo $x | sed 's/opnfv-apex-//').rpm
+         INSTALLED_RPM_VER=$(echo $x | grep -Eo '[0-9]+\.[0-9]+-[0-9]{8}')
          # Does each RPM's version match the version required for deployment
          if [ "$INSTALLED_RPM_VER" == "$VERSION_EXTENSION" ]; then
            echo "RPM $x is already installed"
          else
-           echo "RPM $x does not match $VERSION_EXTENSION"
+           echo "RPM $x does not match version $VERSION_EXTENSION"
            echo "Will upgrade/downgrade RPMs..."
            # Try to upgrade/downgrade RPMS
            if sudo yum update -y $RPM_LIST | grep "does not update installed package"; then
              if ! sudo yum downgrade -y $RPM_LIST; then
                sudo yum remove -y opnfv-apex-undercloud opnfv-apex-common opnfv-apex-opendaylight-sfc opnfv-apex-onos
-               sudo yum downgrade -y $RPM_INSTALL_PATH
+               if ! sudo yum downgrade -y $RPM_LIST; then
+                 echo "Unable to downgrade RPMs: $RPM_LIST"
+                 exit 1
+               fi
              fi
            fi
            break