Fix "make dist" to include version number, docouple it from rpm packaging

Change-Id: If2f9976d668089026c97b897cf449bff09050631
Signed-off-by: Damjan Marion <damarion@cisco.com>
This commit is contained in:
Damjan Marion
2017-04-18 15:26:39 +02:00
committed by Florin Coras
parent b59a705552
commit c06eeb0e3c
7 changed files with 60 additions and 69 deletions

View File

@ -214,18 +214,30 @@ else
$(shell $(BR)/scripts/version > $(BR)/scripts/.version)
endif
dist: $(BR)/scripts/.version
$(MAKE) verstring=$(PLATFORM)-$(shell cat $(BR)/scripts/.version) prefix=$(PLATFORM) distversion
DIST_FILE = $(BR)/vpp-$(shell src/scripts/version).tar
DIST_SUBDIR = vpp-$(shell src/scripts/version|cut -f1 -d-)
distversion: $(BR)/scripts/.version
$(BR)/scripts/verdist ${BR} ${prefix}-$(shell $(BR)/scripts/version rpm-version) ${verstring}
mv $(verstring).tar.gz $(BR)/rpm
dist:
@git archive \
--prefix=$(DIST_SUBDIR)/ \
--format=tar \
-o $(DIST_FILE) \
HEAD
@git describe > $(BR)/.version
@tar --append \
--file $(DIST_FILE) \
--transform='s,.*/.version,$(DIST_SUBDIR)/src/scripts/.version,' \
$(BR)/.version
@$(RM) $(BR)/.version $(DIST_FILE).xz
@xz -v --threads=0 $(DIST_FILE)
@$(RM) $(BR)/vpp-latest.tar.xz
@ln -rs $(DIST_FILE).xz $(BR)/vpp-latest.tar.xz
build: $(BR)/.bootstrap.ok
$(call make,$(PLATFORM)_debug,vpp-install)
wipedist:
$(RM) $(BR)/scripts/.version $(BR)/rpm/*.tar.gz
@$(RM) $(BR)/*.tar.xz
wipe: wipedist $(BR)/.bootstrap.ok
$(call make,$(PLATFORM)_debug,vpp-wipe)
@ -351,7 +363,7 @@ pkg-deb:
$(call make,$(PLATFORM),install-deb)
pkg-rpm: dist
$(call make,$(PLATFORM),install-rpm)
make -C extras/rpm
dpdk-install-dev:
make -C dpdk install-$(PKG)

View File

@ -94,20 +94,3 @@ install-deb: $(patsubst %,%-find-source,$(ROOT_PACKAGES))
dpkg-buildpackage -us -uc -b \
)
.PHONY: install-rpm
install-rpm: $(patsubst %,%-find-source,$(ROOT_PACKAGES))
@$(BUILD_ENV) ; \
set -eu$(BUILD_DEBUG) ; \
$(MAKE) -C $(MU_BUILD_ROOT_DIR) \
$(patsubst %,%-install, \
$(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)" \
--define "_mu_build_root_dir $(MU_BUILD_ROOT_DIR)" \
vpp.spec ; \
mv $$(find RPMS -name \*.rpm -type f) ..

View File

@ -1,31 +0,0 @@
#!/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

30
extras/rpm/Makefile Normal file
View File

@ -0,0 +1,30 @@
# Copyright (c) 2017 Cisco and/or its affiliates.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at:
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
TARBALL=$(shell realpath ../../build-root/vpp-latest.tar.xz)
BASENAME=$(shell basename $(TARBALL) | sed -e s/.tar.\*//)
VERSION=$(shell echo $(BASENAME) | cut -f2 -d-)
RELEASE=$(shell echo $(BASENAME) | cut -f3- -d- | sed -e s/-/_/g)
all:
@echo $(TARBALL)
mkdir -p SOURCES RPMS
cp $(TARBALL) SOURCES/vpp-latest.tar.xz
rpmbuild -bb \
--define "_topdir $(PWD)" \
--define "_version $(VERSION)" \
--define "_release $(RELEASE)" \
vpp.spec
mv $$(find RPMS -name \*.rpm -type f) .

View File

@ -1,11 +1,9 @@
%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}
%define _version %(../scripts/version rpm-version)
%define _release %(../scripts/version rpm-release)
%define _mu_build_dir %{_topdir}/%{name}-%{_version}/build-root
%define _vpp_install_dir install-vpp-native
# Failsafe backport of Python2-macros for RHEL <= 6
%{!?python_sitelib: %global python_sitelib %(%{__python} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())")}
@ -28,7 +26,8 @@ Release: %{_release}
Requires: vpp-lib = %{_version}-%{_release}, net-tools, pciutils, python
BuildRequires: systemd, chrpath
Source: %{name}-%{_version}-%{_release}.tar.gz
# Source: %{name}-%{_version}-%{_release}.tar.xz
Source: vpp-latest.tar.xz
%description
This package provides VPP executables: vpp, vpp_api_test, vpp_json_test
@ -102,6 +101,8 @@ This package contains the python bindings for the vpp api
groupadd -f -r vpp
%build
make bootstrap
make -C build-root PLATFORM=vpp TAG=vpp install-packages
cd %{_mu_build_dir}/../src/vpp-api/python && %py2_build
%install
@ -120,7 +121,7 @@ mkdir -p -m755 %{buildroot}/usr/share/vpp/api
#
mkdir -p -m755 %{buildroot}/etc/vpp
mkdir -p -m755 %{buildroot}/etc/sysctl.d
install -p -m 644 %{_mu_build_dir}/rpm/vpp.service %{buildroot}%{_unitdir}
install -p -m 644 %{_topdir}/vpp.service %{buildroot}%{_unitdir}
install -p -m 644 %{_mu_build_dir}/../src/vpp/conf/startup.conf %{buildroot}/etc/vpp/startup.conf
install -p -m 644 %{_mu_build_dir}/../src/vpp/conf/80-vpp.conf %{buildroot}/etc/sysctl.d
#

View File

@ -4,16 +4,12 @@ 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
if [ -f .version ]; then
vstring=$(cat .version)
else
if [ -f ../rpm/*.gz ]; then
vstring=$(ls ../rpm/*.gz)
else
exit 1
vstring=$(git describe)
if [ $? != 0 ]; then
exit 1
fi
fi