Move to new Karaf-based RPM
[integration.git] / packaging / rpm / build.sh
1 #!/usr/bin/env sh
2
3 # Common paths used in this script
4 # NB: Name will need to be updated for both ODL and RMP version bumps
5 rpm_name="opendaylight-0.2.1-5.fc20.noarch.rpm"
6 rpm_out_path="$HOME/rpmbuild/RPMS/noarch/$rpm_name"
7 src_name="distribution-karaf-0.2.1-Helium-SR1.1.tar.gz"
8 src_cache_path="$HOME/$src_name"
9 sysd_commit=520321a
10
11 # Install required software, add user to mock group for rpmbuild
12 sudo yum install -y @development-tools fedora-packager
13 sudo usermod -a -G mock $USER
14
15 # Configure rpmbuild dir
16 rpmdev-setuptree
17
18 # Put ODL source archive location required by rpmbuild
19 if [ -f  $src_cache_path ]; then
20     echo "Using cached version of ODL at $src_cache_path"
21     cp $src_cache_path $HOME/rpmbuild/SOURCES/$src_name
22 else
23     echo "No cached ODL found, downloading from Nexus..."
24     curl -o $HOME/rpmbuild/SOURCES/$src_name https://nexus.opendaylight.org/content/groups/public/org/opendaylight/integration/distribution-karaf/0.2.1-Helium-SR1.1/$src_name
25 fi
26
27 # Put systemd unit file archive in rpmbuild's SOURCES dir
28 # Need `-L` to follow redirects
29 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
30
31 # Put ODL RPM .spec file in location required by rpmbuild
32 cp opendaylight.spec $HOME/rpmbuild/SPECS
33
34 # Build ODL RPM
35 cd $HOME/rpmbuild/SPECS
36 rpmbuild -ba opendaylight.spec
37
38 # Confirm RPM found in expected location
39 if [ -f  $rpm_out_path ]; then
40     echo "RPM built!"
41     echo "Should be at: $rpm_out_path"
42 else
43     echo "RPM seems to have failed. :(" &>2
44 fi