diff options
author | Remi Collet <fedora@famillecollet.com> | 2015-07-14 08:52:32 +0200 |
---|---|---|
committer | Remi Collet <fedora@famillecollet.com> | 2015-07-14 08:52:32 +0200 |
commit | 281d00402c1d83cc0c403515b7d7a02921236aa1 (patch) | |
tree | 444b3439846d9b7d4d03dcef3ef9f03afdee6814 /php-JMSParser-get-source.sh | |
parent | ffec025b1b448e93b69ab2ca1ff74a95301e6c1b (diff) |
php-JMSParser: backport fedora changes
Diffstat (limited to 'php-JMSParser-get-source.sh')
-rwxr-xr-x | php-JMSParser-get-source.sh | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/php-JMSParser-get-source.sh b/php-JMSParser-get-source.sh new file mode 100755 index 0000000..5c15702 --- /dev/null +++ b/php-JMSParser-get-source.sh @@ -0,0 +1,62 @@ +#/bin/sh + +RPM=$(which rpm) + +if [ -z "$RPM" ] +then + echo "ERROR: 'rpm' command not found" 1>&2 + exit 1 +fi + +function print { + echo -e "\e[0;33m>>>>> ${1}\e[0m" +} + +if [ -x "$1" ] +then + SPEC=$1 +else + SPEC=`ls *.spec | head -1` +fi + +print "SPEC = $SPEC" + +NAME=$(echo $SPEC | sed 's#\.spec##') +VERSION=$(egrep '%global\s*github_version' $SPEC | awk '{print $3}') + +print "NAME = $NAME" +print "VERSION = $VERSION" + +GIT_OWNER=$(egrep '%global\s*github_owner' $SPEC | awk '{print $3}') +GIT_NAME=$(egrep '%global\s*github_name' $SPEC | awk '{print $3}') +GIT_COMMIT=$(egrep '%global\s*github_commit' $SPEC | awk '{print $3}') +GIT_REPO=https://github.com/${GIT_OWNER}/${GIT_NAME} +SOURCE_FILENAME=${NAME}-${VERSION}-${GIT_COMMIT}.tar.gz +RPM_SOURCE_DIR=$(rpm --eval "%{_sourcedir}") + +print "GIT_OWNER = $GIT_OWNER" +print "GIT_NAME = $GIT_NAME" +print "GIT_COMMIT = $GIT_COMMIT" +print "GIT_REPO = $GIT_REPO" +print "SOURCE_FILENAME = $SOURCE_FILENAME" +print "RPM_SOURCE_DIR = $RPM_SOURCE_DIR" + +pushd /tmp + print "Getting full source..." + rm -f ${SOURCE_FILENAME} + wget https://github.com/${GIT_OWNER}/${GIT_NAME}/archive/${GIT_COMMIT}/${SOURCE_FILENAME} + + print "Uncompressing full source..." + tar -xvzf ${SOURCE_FILENAME} + rm -f ${SOURCE_FILENAME} + + print "Removing non-allowable licened content..." + rm -rf ${GIT_NAME}-${GIT_COMMIT}/doc + + print "Re-compressing allowable source..." + rm -f ${RPM_SOURCE_DIR}/${SOURCE_FILENAME} + tar -cvzf ${RPM_SOURCE_DIR}/${SOURCE_FILENAME} ${GIT_NAME}-${GIT_COMMIT} + rm -rf ${GIT_NAME}-${GIT_COMMIT} + + print "Source = \"${RPM_SOURCE_DIR}/${SOURCE_FILENAME}\"" +popd |