Add Build Requirements from Makefile to spec file.

JIRA: VPP-498

Changes to build to help with downstream distro builds
for Fedora, Centos and RHEL distros.
Add nasm, automake, libtool, byacc, bison and flex.
Remove libconfuse and dependencies.
Remove epel-release rpm and dependencies.
Add conditionals to work around Python 2 packaging
inconsistency in Fed 25.
Add numactl to rpm requirements.

Change-Id: Ia39f8b931dc87e42df56414d38662eb33c7a4ca7
Signed-off-by: Thomas F Herbert <therbert@redhat.com>
diff --git a/Makefile b/Makefile
index ea9d6be..e5eb1b3 100644
--- a/Makefile
+++ b/Makefile
@@ -72,12 +72,18 @@
 endif
 
 RPM_DEPENDS  = redhat-lsb glibc-static java-1.8.0-openjdk-devel yum-utils
-RPM_DEPENDS += openssl-devel https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm apr-devel
-RPM_DEPENDS += python-devel numactl-devel
+RPM_DEPENDS += openssl-devel
+RPM_DEPENDS += numactl-devel
 ifeq ($(OS_ID)-$(OS_VERSION_ID),fedora-25)
+	RPM_DEPENDS += python-devel
+	RPM_DEPENDS += python2-virtualenv
+	RPM_DEPENDS_GROUPS = 'C Development Tools and Libraries'
+else ifeq ($(shell if [ "$(OS_VERSION_ID)" -gt "25" ] ; then echo "y" ; fi),"y")
+	RPM_DEPENDS += python2-devel
 	RPM_DEPENDS += python2-virtualenv
 	RPM_DEPENDS_GROUPS = 'C Development Tools and Libraries'
 else
+	RPM_DEPENDS += python-devel
 	RPM_DEPENDS += python-virtualenv
 	RPM_DEPENDS_GROUPS = 'Development Tools'
 endif
@@ -90,12 +96,6 @@
 else
 	RPM_DEPENDS += https://kojipkgs.fedoraproject.org//packages/nasm/2.12.02/2.fc26/x86_64/nasm-2.12.02-2.fc26.x86_64.rpm
 endif
-EPEL_DEPENDS = libconfuse-devel epel-rpm-macros
-ifeq ($(filter rhel centos,$(OS_ID)),$(OS_ID))
-	EPEL_DEPENDS += lcov
-else
-	RPM_DEPENDS += lcov
-endif
 
 RPM_SUSE_DEPENDS = autoconf automake bison ccache chrpath distribution-release gcc6 glibc-devel-static
 RPM_SUSE_DEPENDS += java-1_8_0-openjdk-devel libopenssl-devel libtool lsb-release make openssl-devel
@@ -206,13 +206,9 @@
 	fi ; \
 	exit 0
 else ifneq ("$(wildcard /etc/redhat-release)","")
-	@for i in $(RPM_DEPENDS) $(EPEL_DEPENDS) ; do \
+	@for i in $(RPM_DEPENDS) ; do \
 	    RPM=$$(basename -s .rpm "$${i##*/}" | cut -d- -f1,2,3)  ;	\
-	    if [[ "$$RPM" =~ "epel-release-latest" ]] ; then		\
-	        MISSING+=$$(rpm -q epel-release | grep "^package") ;	\
-	    else							\
-		MISSING+=$$(rpm -q $$RPM | grep "^package")	   ;    \
-	    fi							   ;    \
+	    MISSING+=$$(rpm -q $$RPM | grep "^package")	   ;    \
 	done							   ;	\
 	if [ -n "$$MISSING" ] ; then \
 	  echo "Please install missing RPMs: \n$$MISSING\n" ; \
@@ -255,7 +251,6 @@
 else ifneq ("$(wildcard /etc/redhat-release)","")
 	@sudo -E yum groupinstall $(CONFIRM) $(RPM_DEPENDS_GROUPS)
 	@sudo -E yum install $(CONFIRM) $(RPM_DEPENDS)
-	@sudo -E yum install $(CONFIRM) --enablerepo=epel $(EPEL_DEPENDS)
 	@sudo -E debuginfo-install $(CONFIRM) glibc openssl-libs zlib
 else ifeq ($(filter opensuse,$(OS_ID)),$(OS_ID))
 	@sudo -E zypper -n install -y $(RPM_SUSE_DEPENDS)
diff --git a/extras/rpm/vpp.spec b/extras/rpm/vpp.spec
index ffb6382..439e6bd 100644
--- a/extras/rpm/vpp.spec
+++ b/extras/rpm/vpp.spec
@@ -29,6 +29,21 @@
 Release: %{_release}
 Requires: vpp-lib = %{_version}-%{_release}, net-tools, pciutils, python
 BuildRequires: systemd, chrpath
+BuildRequires: libffi-devel, openssl-devel
+%if 0%{?fedora} >= 26
+BuildRequires: python2-devel, python2-virtualenv
+%else
+%if 0%{?fedora} == 25
+BuildRequires: python-devel, python2-virtualenv
+%else
+BuildRequires: python-devel, python-virtualenv
+%endif
+%endif
+BuildRequires: glibc-static, java-1.8.0-openjdk, java-1.8.0-openjdk-devel yum-utils, redhat-lsb
+BuildRequires: apr-devel
+BuildRequires: nasm
+BuildRequires: numactl-devel
+BuildRequires: autoconf automake libtool byacc bison flex
 
 Source: %{name}-%{_version}-%{_release}.tar.xz
 # Source: vpp-latest.tar.xz
@@ -156,10 +171,11 @@
 # Lua bindings
 mkdir -p -m755 %{buildroot}/usr/share/doc/vpp/examples/lua/examples/cli
 mkdir -p -m755 %{buildroot}/usr/share/doc/vpp/examples/lua/examples/lute
-for file in $(cd %{_mu_build_dir}/%{_vpp_install_dir}/../../src/vpp-api/lua && git ls-files .)
+# for file in $(cd %{_mu_build_dir}/%{_vpp_install_dir}/../../src/vpp-api/lua && git ls-files .)
+for file in $(cd %{_mu_build_dir}/%{_vpp_install_dir}/../../src/vpp-api/lua && find . -type f -regex '.*/*.[luteamd]' -print | sed -e 's/^\.\///')
 do
-	install -p -m 644 %{_mu_build_dir}/%{_vpp_install_dir}/../../src/vpp-api/lua/$file \
-	   %{buildroot}/usr/share/doc/vpp/examples/lua/$file
+	( cd %{_mu_build_dir}/%{_vpp_install_dir}/../../src/vpp-api/lua && install -p -m 644 $file \
+	   %{buildroot}/usr/share/doc/vpp/examples/lua/$file )
 done
 
 # Java bindings
@@ -195,10 +211,11 @@
 
 # sample plugin
 mkdir -p -m755 %{buildroot}/usr/share/doc/vpp/examples/sample-plugin/sample
-for file in $(cd %{_mu_build_dir}/%{_vpp_install_dir}/../../src/examples/sample-plugin && git ls-files .)
+#for file in $(cd %{_mu_build_dir}/%{_vpp_install_dir}/../../src/examples/sample-plugin && git ls-files .)
+for file in $(cd %{_mu_build_dir}/%{_vpp_install_dir}/../../src/examples/sample-plugin && find . -type f -regex '.*/*.[acdhimp]' -print | sed -e 's/^\.\///')
 do
-	install -p -m 644 %{_mu_build_dir}/%{_vpp_install_dir}/../../src/examples/sample-plugin/$file \
-	   %{buildroot}/usr/share/doc/vpp/examples/sample-plugin/$file
+	( cd %{_mu_build_dir}/%{_vpp_install_dir}/../../src/examples/sample-plugin && install -p -m 644 $file \
+	   %{buildroot}/usr/share/doc/vpp/examples/sample-plugin/$file )
 done