Merge "Fix pep8 violations in csit/libraries/RequestsLibrary.py"
[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 version=4
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"
13 sysd_commit=4a87227
14
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
18
19 # Configure rpmbuild dir
20 rpmdev-setuptree
21
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
29 else
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
32 fi
33
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
37
38 # Put ODL RPM .spec file in location required by rpmbuild
39 cp opendaylight.spec $HOME/rpmbuild/SPECS
40
41 # Build ODL RPM
42 cd $HOME/rpmbuild/SPECS
43 rpmbuild -ba opendaylight.spec
44
45 # Confirm SRPM found in expected location
46 if [ -f  $srpm_out_path ]; then
47     echo "SRPM built!"
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
54     fi
55 else
56     echo "SRPM seems to have failed. :(" >&2
57 fi
58
59 # Confirm RPM found in expected location
60 if [ -f  $rpm_out_path ]; then
61     echo "RPM built!"
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
68     fi
69 else
70     echo "RPM seems to have failed. :(" >&2
71 fi