Fix minor bug in RPM build script cache handling
authorDaniel Farrell <dfarrell@redhat.com>
Tue, 26 May 2015 17:34:25 +0000 (13:34 -0400)
committerLuis Gomez <ecelgp@gmail.com>
Wed, 27 May 2015 17:04:57 +0000 (17:04 +0000)
The release tarball wasn't being curl'd down to the
same location deemed to be the cache path, so it
wasn't used unless the user manually copied it to
the cache path.

Change-Id: Ic4154034d5b43429f3f330e0679c94d8c9ce8d0a
Signed-off-by: Daniel Farrell <dfarrell@redhat.com>
packaging/rpm/build.sh

index b0efd7a54b64960fc1f20edb5f7be14d559d90a6..bd61069c9ebca0b484c037eea04e426217ca9a15 100755 (executable)
@@ -8,8 +8,7 @@ rpm_out_path="$HOME/rpmbuild/RPMS/noarch/opendaylight-0.2.3-$version.fc20.noarch
 srpm_name="opendaylight-0.2.3-$version.src.rpm"
 srpm_out_path="$HOME/rpmbuild/SRPMS/opendaylight-0.2.3-$version.fc20.src.rpm"
 src_name="distribution-karaf-0.2.3-Helium-SR3.tar.gz"
-src_cache_path0="$HOME/$src_name"
-src_cache_path1="/vagrant/$src_name"
+src_cache_path="/vagrant/$src_name"
 sysd_commit=4a87227
 
 # Install required software, add user to mock group for rpmbuild
@@ -19,18 +18,17 @@ sudo usermod -a -G mock $USER
 # Configure rpmbuild dir
 rpmdev-setuptree
 
-# Put ODL source archive location required by rpmbuild
-if [ -f  $src_cache_path0 ]; then
-    echo "Using cached version of ODL at $src_cache_path0"
-    cp $src_cache_path0 $HOME/rpmbuild/SOURCES/$src_name
-elif [ -f  $src_cache_path1 ]; then
-    echo "Using cached version of ODL at $src_cache_path1"
-    cp $src_cache_path1 $HOME/rpmbuild/SOURCES/$src_name
-else
+# Download ODL release tarball if it's not cached locally already
+if [ ! -f  $src_cache_path ]; then
     echo "No cached ODL found, downloading from Nexus..."
-    curl -o $HOME/rpmbuild/SOURCES/$src_name https://nexus.opendaylight.org/content/groups/public/org/opendaylight/integration/distribution-karaf/0.2.3-Helium-SR3/$src_name
+    curl -o $src_cache_path https://nexus.opendaylight.org/content/groups/public/org/opendaylight/integration/distribution-karaf/0.2.3-Helium-SR3/$src_name
+else
+    echo "Using cached version of ODL at $src_cache_path"
 fi
 
+# Put ODL release tarball in the location required by rpmbuild
+cp $src_cache_path $HOME/rpmbuild/SOURCES/$src_name
+
 # Put systemd unit file archive in rpmbuild's SOURCES dir
 # Need `-L` to follow redirects
 curl -L -o $HOME/rpmbuild/SOURCES/opendaylight-systemd-$sysd_commit.tar.gz https://github.com/dfarrell07/opendaylight-systemd/archive/$sysd_commit/opendaylight-systemd-$sysd_commit.tar.gz