summaryrefslogtreecommitdiffstats
path: root/dist/create-rpm
blob: bd179f67adad7b4f963da618bad41f7bf2fabaeb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/bin/bash

# Works for x86_64, need to see how to compile for multiple architectures

#
# Commit tag and Version number should be provided as input in the command line
#
# requires:
#   * installation of ronn
#   * installation of rpmbuild
#   * pyinstaller needs to be installed
#
# Output rpm is generated inside build/rpm/RPMS/noarch/
#

if [ $# -ne 2 ];
then
	echo 'create-rpm <commit-hash> <version>'
	exit 1
fi

command -v ronn &>/dev/null || { echo >&2 "ronn needs to be installed."; exit 1; }
command -v rpmbuild &>/dev/null || { echo >&2 "rpmbuild needs to be installed."; exit 1; }

set -e 

base_folder=$(dirname $0)

pushd ${base_folder}

COMMIT_HASH=$1
SHORT_HASH=${COMMIT_HASH:0:7}
VERSION=$2
REAL_PACKAGE_NAME=q
RPM_PACKAGE_NAME=q-text-as-data

FULL_NAME_FOLDER=${RPM_PACKAGE_NAME}-${VERSION}

if [ ! -e ${RPM_PACKAGE_NAME}.spec.template ];
then
	echo "spec template does not exist. can't continue"
	exit 1
fi

rm -vf ~/rpmbuild/SOURCES/q-${COMMIT_HASH}.tar.gz

curl -o ~/rpmbuild/SOURCES/q-${COMMIT_HASH}.tar.gz -L -R "https://github.com/harelba/q/tarball/${COMMIT_HASH}"

cat ${RPM_PACKAGE_NAME}.spec.template | sed "s/VERSION_PLACEHOLDER/$VERSION/g" | sed "s/COMMIT_HASH_PLACEHOLDER/${COMMIT_HASH}/g" | sed "s/SHORT_HASH_PLACEHOLDER/${SHORT_HASH}/g" > ~/rpmbuild/SPECS/${RPM_PACKAGE_NAME}.spec

rpmbuild --noclean -v -bb ~/rpmbuild/SPECS/${RPM_PACKAGE_NAME}.spec

popd