Query RPM files directly using rpm for upload info 79/779/1
authorAndrew Grimberg <[email protected]>
Wed, 13 Apr 2016 17:38:00 +0000 (10:38 -0700)
committerAndrew Grimberg <[email protected]>
Wed, 13 Apr 2016 17:38:00 +0000 (10:38 -0700)
Instead of trying to figure out all the maven fields based upon the
filename with possible failures that this can cause, instead, use the
rpm command itself to query the built artifacts for the needed
information.

Also, .src.rpm should be the canonical name for source RPM files. Make
sure that .srpm and .src.rpm are handled properly and they normalize to
.src.rpm in nexus.

Change-Id: I6b35c15e8e6b189a2144fe3cfb991e467933ad46
Signed-off-by: Andrew Grimberg <[email protected]>
jjb/vpp/include-raw-vpp-maven-push.sh

index dc75e90..a8b03f6 100644 (file)
@@ -73,17 +73,15 @@ function push_rpm ()
     repoId="${BASEREPOID}yum"
     url="${BASEURL}yum"
 
-    if grep -q srpm <<<"$rpmfile"
+    if grep -qE '\.s(rc\.)?rpm' <<<"$rpmfile"
     then
-        rpmtype=srpm
-        basefile=$(basename -s .srpm "$rpmfile")
+        rpmrelease=$(rpm -qp --queryformat="%{release}.src" "$rpmfile")
     else
-        rpmtype=rpm
-        basefile=$(basename -s .rpm "$rpmfile")
+        rpmrelease=$(rpm -qp --queryformat="%{release}.%{arch}" "$rpmfile")
     fi
-    artifactId=$(echo "$basefile" | cut -f 1 -d '_')
-    version=$(echo "$basefile" | cut -f 2- -d '_')
-    push_file "$rpmfile" "$repoId" "$url" "$version" "$artifactId" "$rpmtype"
+    artifactId=$(rpm -qp --queryformat="%{name}" "$rpmfile")
+    version=$(rpm -qp --queryformat="%{version}" "$rpmfile")
+    push_file "$rpmfile" "$repoId" "$url" "${version}-${rpmrelease}" "$artifactId" rpm
 }
 
 if [ "${OS}" == "ubuntu1404" ]; then
@@ -103,7 +101,8 @@ elif [ "${OS}" == "centos7" ]; then
     # Find the files
     RPMS=$(find . -type f -iname '*.rpm')
     SRPMS=$(find . -type f -iname '*.srpm')
-    for i in $RPMS $SRPMS
+    SRCRPMS=$(find . -type f -name '*.src.rpm')
+    for i in $RPMS $SRPMS $SRCRPMS
     do
         push_rpm "$i"
     done