diff options
author | Thomas F Herbert <therbert@redhat.com> | 2016-10-13 18:36:50 -0400 |
---|---|---|
committer | Damjan Marion <dmarion.lists@gmail.com> | 2016-11-04 22:22:53 +0000 |
commit | 20a29c7b4d1b5b68112498bee21ee7f3fe123b13 (patch) | |
tree | 364bb9682084282b94102f6a433111dea3851c24 | |
parent | dea606321942132521effe5a3a1bfdaa77d41ebf (diff) |
VPP-498: Prepare vpp RPM packaging for use by downstream distros.
Change spec to add new macros to get rid of relative dir reference and
use vpp version. Store version string in .version to store metadata in
dist archive. New script to create dist archive.
Add dist and wipedist targets to Makefile for builds of source RPMs.
Change-Id: I7cf0164f0cb094ec70f3dc323ed7fa2ee82bd902
Signed-off-by: Thomas F Herbert <therbert@redhat.com>
-rw-r--r-- | Makefile | 21 | ||||
-rw-r--r-- | build-data/platforms.mk | 6 | ||||
-rw-r--r-- | build-root/rpm/vpp.spec | 48 | ||||
-rwxr-xr-x | build-root/scripts/verdist | 31 | ||||
-rwxr-xr-x | build-root/scripts/version | 45 |
5 files changed, 120 insertions, 31 deletions
@@ -167,10 +167,27 @@ define make @make -C $(BR) PLATFORM=$(PLATFORM) TAG=$(1) $(2) endef +$(BR)/scripts/.version: +ifneq ("$(wildcard /etc/redhat-release)","") + $(shell $(BR)/scripts/version rpm-string > $(BR)/scripts/.version) +else + $(shell $(BR)/scripts/version > $(BR)/scripts/.version) +endif + +dist: $(BR)/scripts/.version + $(MAKE) verstring=$(PLATFORM)-$(shell cat $(BR)/scripts/.version) prefix=$(PLATFORM) distversion + +distversion: $(BR)/scripts/.version + $(BR)/scripts/verdist ${BR} ${prefix}-$(shell $(BR)/scripts/version rpm-version) ${verstring} + mv $(verstring).tar.gz $(BR)/rpm + build: $(BR)/.bootstrap.ok $(call make,$(PLATFORM)_debug,vpp-install) -wipe: $(BR)/.bootstrap.ok +wipedist: + $(RM) $(BR)/scripts/.version $(BR)/rpm/*.tar.gz + +wipe: wipedist $(BR)/.bootstrap.ok $(call make,$(PLATFORM)_debug,vpp-wipe) rebuild: wipe build @@ -271,7 +288,7 @@ run-vat: pkg-deb: $(call make,$(PLATFORM),install-deb) -pkg-rpm: +pkg-rpm: dist $(call make,$(PLATFORM),install-rpm) ctags: ctags.files diff --git a/build-data/platforms.mk b/build-data/platforms.mk index 9d87815177f..16e61e3f641 100644 --- a/build-data/platforms.mk +++ b/build-data/platforms.mk @@ -89,7 +89,11 @@ install-rpm: $(patsubst %,%-find-source,$(ROOT_PACKAGES)) $(ROOT_PACKAGES)) || exit 1; \ \ cd rpm ; \ + mkdir -p SOURCES ; \ + if test -f *.tar.gz ; then mv *.tar.gz SOURCES ; fi ; \ rpmbuild -bb --define "_topdir $$PWD" --define \ - "_install_dir $(INSTALL_PREFIX)$(ARCH)" vpp.spec ; \ + "_install_dir $(INSTALL_PREFIX)$(ARCH)" \ + --define "_mu_build_root_dir $(MU_BUILD_ROOT_DIR)" \ + vpp.spec ; \ mv $$(find RPMS -name \*.rpm -type f) .. diff --git a/build-root/rpm/vpp.spec b/build-root/rpm/vpp.spec index 8c4f4f05e15..7f0e2a342c4 100644 --- a/build-root/rpm/vpp.spec +++ b/build-root/rpm/vpp.spec @@ -1,5 +1,6 @@ -%define _vpp_install_dir ../%{_install_dir} -%define _vpp_build_dir ../build-tool-native +%define _mu_build_dir %{_mu_build_root_dir} +%define _vpp_install_dir %{_install_dir} +%define _vpp_build_dir build-tool-native %define _unitdir /lib/systemd/system %define _topdir %(pwd) %define _builddir %{_topdir} @@ -27,6 +28,8 @@ Release: %{_release} Requires: vpp-lib = %{_version}-%{_release}, net-tools, pciutils, python BuildRequires: systemd +Source: %{name}-%{_version}-%{_release}.tar.gz + %description This package provides VPP executables: vpp, vpp_api_test, vpp_json_test vpp - the vector packet engine @@ -76,6 +79,13 @@ Requires: vpp = %{_version}-%{_release}, vpp-lib = %{_version}-%{_release} %description python-api This package contains the python bindings for the vpp api +%prep +%setup -q -n %{name}-%{_version} + +%build +make bootstrap +make build-release + %pre # Add the vpp group groupadd -f -r vpp @@ -86,22 +96,22 @@ groupadd -f -r vpp # mkdir -p -m755 %{buildroot}%{_bindir} mkdir -p -m755 %{buildroot}%{_unitdir} -install -p -m 755 %{_vpp_install_dir}/*/bin/* %{buildroot}%{_bindir} -install -p -m 755 %{_vpp_build_dir}/vppapigen/vppapigen %{buildroot}%{_bindir} -install -p -m 755 ../../vppapigen/pyvppapigen.py %{buildroot}%{_bindir} +install -p -m 755 %{_mu_build_dir}/%{_vpp_install_dir}/*/bin/* %{buildroot}%{_bindir} +install -p -m 755 %{_mu_build_dir}/%{_vpp_build_dir}/vppapigen/vppapigen %{buildroot}%{_bindir} +install -p -m 755 %{_mu_build_dir}/../vppapigen/pyvppapigen.py %{buildroot}%{_bindir} # # configs # mkdir -p -m755 %{buildroot}/etc/vpp mkdir -p -m755 %{buildroot}/etc/sysctl.d -install -p -m 644 vpp.service %{buildroot}%{_unitdir} -install -p -m 644 ../../vpp/conf/startup.uiopcigeneric.conf %{buildroot}/etc/vpp/startup.conf -install -p -m 644 ../../vpp/conf/80-vpp.conf %{buildroot}/etc/sysctl.d +install -p -m 644 %{_mu_build_dir}/rpm/vpp.service %{buildroot}%{_unitdir} +install -p -m 644 %{_mu_build_dir}/../vpp/conf/startup.uiopcigeneric.conf %{buildroot}/etc/vpp/startup.conf +install -p -m 644 %{_mu_build_dir}/../vpp/conf/80-vpp.conf %{buildroot}/etc/sysctl.d # # libraries # mkdir -p -m755 %{buildroot}%{_libdir} -for file in $(find %{_vpp_install_dir}/*/lib* -type f -name '*.so.*.*.*' -print ) +for file in $(find %{_mu_build_dir}/%{_vpp_install_dir}/*/lib* -type f -name '*.so.*.*.*' -print ) do install -p -m 755 $file %{buildroot}%{_libdir} done @@ -116,7 +126,7 @@ done # Python bindings mkdir -p -m755 %{buildroot}%{python2_sitelib}/vpp_papi -for file in $(find %{_vpp_install_dir}/*/lib/python2.7/site-packages/ -type f -print | grep -v pyc | grep -v pyo) +for file in $(find %{_mu_build_dir}/%{_vpp_install_dir}/*/lib/python2.7/site-packages/ -type f -print | grep -v pyc | grep -v pyo) do install -p -m 666 $file %{buildroot}%{python2_sitelib}/vpp_papi/ done @@ -124,7 +134,7 @@ done # # devel # -for dir in $(find %{_vpp_install_dir}/*/include/ -maxdepth 0 -type d -print | grep -v dpdk) +for dir in $(find %{_mu_build_dir}/%{_vpp_install_dir}/*/include/ -maxdepth 0 -type d -print | grep -v dpdk) do for subdir in $(cd ${dir} && find . -type d -print) do @@ -137,16 +147,16 @@ do done mkdir -p -m755 %{buildroot}%{python2_sitelib}/jvppgen -install -p -m755 ../../vpp-api/java/jvpp/gen/jvpp_gen.py %{buildroot}/usr/bin -for i in $(ls ../../vpp-api/java/jvpp/gen/jvppgen/*.py); do +install -p -m755 %{_mu_build_dir}/../vpp-api/java/jvpp/gen/jvpp_gen.py %{buildroot}/usr/bin +for i in $(ls %{_mu_build_dir}/../vpp-api/java/jvpp/gen/jvppgen/*.py); do install -p -m666 ${i} %{buildroot}%{python2_sitelib}/jvppgen done; # sample plugin mkdir -p -m755 %{buildroot}/usr/share/doc/vpp/examples/sample-plugin/sample -for file in $(cd %{_vpp_install_dir}/../../sample-plugin && find -type f -print) +for file in $(cd %{_mu_build_dir}/%{_vpp_install_dir}/../../sample-plugin && find -type f -print) do - install -p -m 644 %{_vpp_install_dir}/../../sample-plugin/$file \ + install -p -m 644 %{_mu_build_dir}/%{_vpp_install_dir}/../../sample-plugin/$file \ %{buildroot}/usr/share/doc/vpp/examples/sample-plugin/$file done @@ -156,15 +166,15 @@ done # mkdir -p -m755 %{buildroot}/usr/lib/vpp_plugins mkdir -p -m755 %{buildroot}/usr/lib/vpp_api_test_plugins -for file in $(cd %{_vpp_install_dir}/plugins/lib64/vpp_plugins && find -type f -print) +for file in $(cd %{_mu_build_dir}/%{_vpp_install_dir}/plugins/lib64/vpp_plugins && find -type f -print) do - install -p -m 644 %{_vpp_install_dir}/plugins/lib64/vpp_plugins/$file \ + install -p -m 644 %{_mu_build_dir}/%{_vpp_install_dir}/plugins/lib64/vpp_plugins/$file \ %{buildroot}/usr/lib/vpp_plugins/$file done -for file in $(cd %{_vpp_install_dir}/plugins/lib64/vpp_api_test_plugins && find -type f -print) +for file in $(cd %{_mu_build_dir}/%{_vpp_install_dir}/plugins/lib64/vpp_api_test_plugins && find -type f -print) do - install -p -m 644 %{_vpp_install_dir}/plugins/lib64/vpp_api_test_plugins/$file \ + install -p -m 644 %{_mu_build_dir}/%{_vpp_install_dir}/plugins/lib64/vpp_api_test_plugins/$file \ %{buildroot}/usr/lib/vpp_api_test_plugins/$file done diff --git a/build-root/scripts/verdist b/build-root/scripts/verdist new file mode 100755 index 00000000000..9d1f1b5adcd --- /dev/null +++ b/build-root/scripts/verdist @@ -0,0 +1,31 @@ +#!/bin/bash + +# +# Add version to dist tarball. +# +BR=$1 +prefix=$2 +verstring=$3 +BASE=`pwd` + +git rev-parse 2> /dev/null +if [ $? == 0 ]; then + git archive --prefix=${prefix}/ HEAD | gzip -9 > ${verstring}.tar.gz +else + cd .. + tar -c ${prefix} | gzip -9 > ${verstring}.tar.gz + cp ${verstring}.tar.gz $BASE + cd $BASE +fi + +mkdir ${BASE}/tmp +cd ${BASE}/tmp +tar -xzf ${BASE}/${verstring}.tar.gz +rm ${BASE}/${verstring}.tar.gz + +cp ${BR}/scripts/.version ${BASE}/tmp/${prefix}/build-root/scripts +tar -c ${prefix} | gzip -9 > ${verstring}.tar.gz +mv ${verstring}.tar.gz ${BASE} + +cd ${BASE} +rm -rf tmp diff --git a/build-root/scripts/version b/build-root/scripts/version index 84ee5dbe4de..af447286912 100755 --- a/build-root/scripts/version +++ b/build-root/scripts/version @@ -1,8 +1,32 @@ #!/bin/bash -TAG=$(git describe | cut -d- -f1 | sed -e 's/^v//') -ADD=$(git describe | cut -s -d- -f2) -CMT=$(git describe --dirty --match 'v*'| cut -s -d- -f3,4) +path=$( cd "$(dirname "${BASH_SOURCE}")" ; pwd -P ) + +cd "$path" + +git rev-parse 2> /dev/null +if [ $? == 0 ]; then + vstring=$(git describe) +elif [ -f .version ]; then + vstring=$(cat .version) +else + if [ -f ../rpm/*.gz ]; then + vstring=$(ls ../rpm/*.gz) + else + exit 1 + fi +fi + +TAG=$(echo ${vstring} | cut -d- -f1 | sed -e 's/^v//') +ADD=$(echo ${vstring} | cut -s -d- -f2) + +git rev-parse 2> /dev/null +if [ $? == 0 ]; then + CMT=$(git describe --dirty --match 'v*'| cut -s -d- -f3,4) +else + CMT=$(echo ${vstring} | cut -s -d- -f3,4) +fi +CMTR=$(echo $CMT | sed 's/-/_/') if [ -n "${BUILD_NUMBER}" ]; then BLD="~b${BUILD_NUMBER}" @@ -15,13 +39,16 @@ fi if [ "$1" = "rpm-release" ]; then [ -z "${ADD}" ] && echo release && exit - CMT=$(git describe --dirty --match 'v*'| cut -s -d- -f3,4 | sed 's/-/_/') - echo ${ADD}${CMT:+~${CMT}}${BLD} + echo ${ADD}${CMTR:+~${CMTR}}${BLD} exit fi -if [ -n "${ADD}" ]; then - echo ${TAG}-${ADD}${CMT:+~${CMT}}${BLD} -else - echo ${TAG} + if [ -n "${ADD}" ]; then + if [ "$1" = "rpm-string" ]; then + echo ${TAG}-${ADD}${CMTR:+~${CMTR}}${BLD} + else + echo ${TAG}-${ADD}${CMT:+~${CMT}}${BLD} + fi + else + echo ${TAG} fi |