diff mbox

[PATCHv3,8/9] scripts: make rpm packages

Message ID 1447191136-21213-9-git-send-email-anders.roxell@linaro.org
State New
Headers show

Commit Message

Anders Roxell Nov. 10, 2015, 9:32 p.m. UTC
Signed-off-by: Anders Roxell <anders.roxell@linaro.org>
Reviewed-by: Fathi Boudra <fathi.boudra@linaro.org>
---
 scripts/builddeb            | 14 ++++----------
 scripts/buildrpm            | 30 ++++++++++++++++++++++++++++++
 scripts/common_pkg_build.sh | 17 +++++++++++++++++
 3 files changed, 51 insertions(+), 10 deletions(-)
 create mode 100755 scripts/buildrpm
 create mode 100644 scripts/common_pkg_build.sh
diff mbox

Patch

diff --git a/scripts/builddeb b/scripts/builddeb
index 48c3183..829fd1d 100755
--- a/scripts/builddeb
+++ b/scripts/builddeb
@@ -2,19 +2,13 @@ 
 
 set -e
 
-ROOT_DIR=$(readlink -e $(dirname $0) | sed 's|/scripts||')
+export ROOT_DIR=$(readlink -e $(dirname $0) | sed 's|/scripts||')
 
-pushd ${ROOT_DIR}
-./bootstrap
-./configure
-make dist
+source ${ROOT_DIR}/scripts/common_pkg_build.sh
 
-version=$(cat ${ROOT_DIR}/.scmversion)
+prepare_tarball
 
-cp opendataplane-${version}.tar.gz opendataplane_${version}.orig.tar.gz
-tar xzf opendataplane_${version}.orig.tar.gz
-
-pushd ${ROOT_DIR}/opendataplane-${version}
+pushd ${ROOT_DIR}/${package}-${version}
 cp -r ${ROOT_DIR}/pkg/debian .
 
 current=$(echo ${version} | awk -F . '{printf("%d\n", (($1 * 100) + $2))}')
diff --git a/scripts/buildrpm b/scripts/buildrpm
new file mode 100755
index 0000000..8568592
--- /dev/null
+++ b/scripts/buildrpm
@@ -0,0 +1,30 @@ 
+#!/bin/bash
+
+set -e
+
+export ROOT_DIR=$(readlink -e $(dirname $0) | sed 's|/scripts||')
+
+source ${ROOT_DIR}/scripts/common_pkg_build.sh
+
+prepare_tarball
+
+mkdir -p ${ROOT_DIR}/rpm/RPMS
+mkdir -p ${ROOT_DIR}/rpm/SRPMS
+mkdir -p ${ROOT_DIR}/rpm/BUILD
+mkdir -p ${ROOT_DIR}/rpm/SOURCES
+mkdir -p ${ROOT_DIR}/rpm/tmp
+rm -rf ${ROOT_DIR}/rpm/BUILD/${package}-root
+rm -rf ${ROOT_DIR}/rpm/RPMS/${package}*
+rm -rf ${ROOT_DIR}/rpm/SRPMS/${package}*
+rm -rf ${ROOT_DIR}/rpm/SOURCES/${package}*
+cp ${ROOT_DIR}/${package}-${version}.tar.gz ${ROOT_DIR}/rpm/SOURCES/
+cp ${ROOT_DIR}/pkg/rpm/odp.spec ${ROOT_DIR}/rpm/odp.spec
+if [ $(egrep "\.([a-z0-9]{8}\>|dirty)" .scmversion |wc -l) -gt 0 ]; then
+	creation_date=$(date '+%a %b %e %G')
+	RPMEMAIL="donald.duck (at) linaro.org"
+	sed -i -e "s/changelog/changelog\n* ${creation_date} - ${RPMEMAIL}\n- not a official release\!/g" ${ROOT_DIR}/rpm/odp.spec
+fi
+sed -i "s|^Version: .*$|Version: ${version}|g" ${ROOT_DIR}/rpm/odp.spec
+rpmbuild --quiet --nodeps --define="_topdir ${ROOT_DIR}/rpm" -ba ${ROOT_DIR}/rpm/odp.spec
+cp ${ROOT_DIR}/rpm/RPMS/*/* ${ROOT_DIR}/
+popd
diff --git a/scripts/common_pkg_build.sh b/scripts/common_pkg_build.sh
new file mode 100644
index 0000000..cf4f6e3
--- /dev/null
+++ b/scripts/common_pkg_build.sh
@@ -0,0 +1,17 @@ 
+#!/bin/bash
+
+set -e
+
+prepare_tarball() {
+	export package=opendataplane
+
+	pushd ${ROOT_DIR}
+	./bootstrap
+	./configure
+	make dist
+
+	version=$(cat ${ROOT_DIR}/.scmversion)
+
+	cp ${package}-${version}.tar.gz ${package}_${version}.orig.tar.gz
+	tar xzf ${package}_${version}.orig.tar.gz
+}