-echo "Building User Space..."
-rpmbuild -bb --define "_topdir `echo $RPMDIR`" $setnocheck rhel/openvswitch.spec
+ if [ ! -z $OVS_PATCH ]; then
+ echo "-------------------------------------------"
+ echo "Apply OVS patches."
+ echo
+ apply_nsh_patches
+ fi
+ echo "----------------------------------"
+ echo "Create dist name and rpm name. Put $snapver into spec file"
+ echo
+ cd $BUILD_BASE
+ sed -i "s/%define snapver.*/%define snapver ${snapver}/" openvswitch-kmod.spec
+ echo "----------------------------------"
+ echo "Copy spec file."
+ echo
+ cp $BUILD_BASE/openvswitch-kmod.spec $RPMDIR/SPECS
+ cp $BUILD_BASE/openvswitch-kmod.spec $RPMDIR/SOURCES
+ echo "-------------------------------------------"
+ echo "Apply nsh patches."
+ echo
+ apply_nsh_patches
+ echo "--------------------------------------------"
+ echo "Creating snapshot, $archive with name same as in spec file."
+ echo
+ cd $TEMPDIR/ovs
+ git archive --prefix=${prefix}-${snapser}.NSH${snapgit}/ HEAD | gzip -9 > $RPMDIR/SOURCES/${archive}
+ echo "--------------------------------------------"
+ echo "Building openvswitch kernel module RPM"
+ echo
+ cd $BUILD_BASE
+ rpmbuild -bb -vv -D "kversion $kernel_version" -D "kflavors default" --define "_topdir `echo $RPMDIR`" $setnocheck openvswitch-kmod.spec
+fi