Fix "make dist" to include version number, docouple it from rpm packaging 44/6244/3
authorDamjan Marion <damarion@cisco.com>
Tue, 18 Apr 2017 13:26:39 +0000 (15:26 +0200)
committerFlorin Coras <florin.coras@gmail.com>
Wed, 19 Apr 2017 20:16:14 +0000 (20:16 +0000)
Change-Id: If2f9976d668089026c97b897cf449bff09050631
Signed-off-by: Damjan Marion <damarion@cisco.com>
Makefile
build-data/platforms.mk
build-root/scripts/verdist [deleted file]
extras/rpm/Makefile [new file with mode: 0644]
extras/rpm/vpp.service [moved from build-root/rpm/vpp.service with 100% similarity]
extras/rpm/vpp.spec [moved from build-root/rpm/vpp.spec with 96% similarity]
src/scripts/version

index 133c3d4..791127a 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -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
-
-distversion:   $(BR)/scripts/.version
-       $(BR)/scripts/verdist ${BR} ${prefix}-$(shell $(BR)/scripts/version rpm-version) ${verstring}
-       mv $(verstring).tar.gz $(BR)/rpm
+DIST_FILE = $(BR)/vpp-$(shell src/scripts/version).tar
+DIST_SUBDIR = vpp-$(shell src/scripts/version|cut -f1 -d-)
+
+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)
index f491ee5..7904cc4 100644 (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) ..
-
diff --git a/build-root/scripts/verdist b/build-root/scripts/verdist
deleted file mode 100755 (executable)
index 9d1f1b5..0000000
+++ /dev/null
@@ -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
diff --git a/extras/rpm/Makefile b/extras/rpm/Makefile
new file mode 100644 (file)
index 0000000..1dcbb20
--- /dev/null
@@ -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) .
similarity index 96%
rename from build-root/rpm/vpp.spec
rename to extras/rpm/vpp.spec
index 2cfe67c..55b2010 100644 (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
 #
index d92eb8b..d8728a9 100755 (executable)
@@ -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