3 # Common paths used in this script
4 # NB: Name will need to be updated for both ODL and RMP version bumps
6 rpm_name="opendaylight-0.2.2-$version.noarch.rpm"
7 rpm_out_path="$HOME/rpmbuild/RPMS/noarch/opendaylight-0.2.2-$version.fc20.noarch.rpm"
8 srpm_name="opendaylight-0.2.2-$version.src.rpm"
9 srpm_out_path="$HOME/rpmbuild/SRPMS/opendaylight-0.2.2-$version.fc20.src.rpm"
10 src_name="distribution-karaf-0.2.2-Helium-SR2.tar.gz"
11 src_cache_path0="$HOME/$src_name"
12 src_cache_path1="/vagrant/$src_name"
15 # Install required software, add user to mock group for rpmbuild
16 sudo yum install -y @development-tools fedora-packager
17 sudo usermod -a -G mock $USER
19 # Configure rpmbuild dir
22 # Put ODL source archive location required by rpmbuild
23 if [ -f $src_cache_path0 ]; then
24 echo "Using cached version of ODL at $src_cache_path0"
25 cp $src_cache_path0 $HOME/rpmbuild/SOURCES/$src_name
26 elif [ -f $src_cache_path1 ]; then
27 echo "Using cached version of ODL at $src_cache_path1"
28 cp $src_cache_path1 $HOME/rpmbuild/SOURCES/$src_name
30 echo "No cached ODL found, downloading from Nexus..."
31 curl -o $HOME/rpmbuild/SOURCES/$src_name https://nexus.opendaylight.org/content/groups/public/org/opendaylight/integration/distribution-karaf/0.2.2-Helium-SR2/$src_name
34 # Put systemd unit file archive in rpmbuild's SOURCES dir
35 # Need `-L` to follow redirects
36 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
38 # Put ODL RPM .spec file in location required by rpmbuild
39 cp opendaylight.spec $HOME/rpmbuild/SPECS
42 cd $HOME/rpmbuild/SPECS
43 rpmbuild -ba opendaylight.spec
45 # Confirm SRPM found in expected location
46 if [ -f $srpm_out_path ]; then
48 echo "Location: $srpm_out_path"
49 if [ -d /vagrant/ ]; then
50 echo "Assuming you want to move RPM off Vagrant box"
51 echo "Also renaming RPM, not actually tagged as for FC20 target OS"
52 echo "cp $srpm_out_path /vagrant/$srpm_name"
53 cp $srpm_out_path /vagrant/$srpm_name
56 echo "SRPM seems to have failed. :(" >&2
59 # Confirm RPM found in expected location
60 if [ -f $rpm_out_path ]; then
62 echo "Location: $rpm_out_path"
63 if [ -d /vagrant/ ]; then
64 echo "Assuming you want to move RPM off Vagrant box"
65 echo "Also renaming RPM, not actually tagged as for FC20 target OS"
66 echo "cp $rpm_out_path /vagrant/$rpm_name"
67 cp $rpm_out_path /vagrant/$rpm_name
70 echo "RPM seems to have failed. :(" >&2