diff options
Diffstat (limited to 'php-PhpCollection-get-source.sh')
-rwxr-xr-x | php-PhpCollection-get-source.sh | 68 |
1 files changed, 40 insertions, 28 deletions
diff --git a/php-PhpCollection-get-source.sh b/php-PhpCollection-get-source.sh index 5c15702..be03311 100755 --- a/php-PhpCollection-get-source.sh +++ b/php-PhpCollection-get-source.sh @@ -1,8 +1,13 @@ #/bin/sh -RPM=$(which rpm) +GIT=`which git` +RPM=`which rpm` -if [ -z "$RPM" ] +if [ -z "$GIT" ] +then + echo "ERROR: 'git' command not found" 1>&2 + exit 1 +elif [ -z "$RPM" ] then echo "ERROR: 'rpm' command not found" 1>&2 exit 1 @@ -19,44 +24,51 @@ 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}') +NAME=`echo $SPEC | sed 's#\.spec##'` +VERSION=`egrep '%global\s*github_version' $SPEC | awk '{print $3}'` +print "SPEC = $SPEC" 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_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}") +GIT_DIR=`echo $GIT_REPO | sed 's#.*/##'` 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" +print "GIT_DIR = $GIT_DIR" -pushd /tmp - print "Getting full source..." - rm -f ${SOURCE_FILENAME} - wget https://github.com/${GIT_OWNER}/${GIT_NAME}/archive/${GIT_COMMIT}/${SOURCE_FILENAME} +TEMP_DIR=$(mktemp --dir) +TAR_FILE=$PWD/${NAME}-${VERSION}-${GIT_COMMIT}.tar.gz +CMP_FILE=$PWD/composer.json - print "Uncompressing full source..." - tar -xvzf ${SOURCE_FILENAME} - rm -f ${SOURCE_FILENAME} +pushd $TEMP_DIR + print "Cloning git repo..." + $GIT clone $GIT_REPO - print "Removing non-allowable licened content..." - rm -rf ${GIT_NAME}-${GIT_COMMIT}/doc + pushd $GIT_DIR + print "Checking out commit..." + $GIT checkout $GIT_COMMIT - 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 "Removing non-allowable licened content..." + rm -rf doc + cp composer.json $CMP_FILE + popd - print "Source = \"${RPM_SOURCE_DIR}/${SOURCE_FILENAME}\"" + TAR_DIR=${GIT_NAME}-${GIT_COMMIT} + print "TAR_DIR = $TAR_DIR" + + mv $GIT_DIR $TAR_DIR + + print "TAR_FILE = $TAR_FILE" + + [ -e $TAR_FILE ] && rm -f $TAR_FILE + tar --exclude-vcs -czf $TAR_FILE $TAR_DIR + chmod 0644 $TAR_FILE popd + +rm -rf $TEMP_DIR |