156 lines
3.9 KiB
Bash
Executable File
156 lines
3.9 KiB
Bash
Executable File
#!/bin/bash
|
|
#
|
|
# clone the repo into the local relevant directory and run mockbuild on it
|
|
# monitor results and log
|
|
#
|
|
inifilename=$(echo ~)"/.smegit/config"
|
|
if [ ! -e $inifilename ] ; then
|
|
# Not here, look at system default
|
|
if [ ! -e /etc/smegit.ini ] ; then
|
|
echo "No ini file found $inifiename or /etc/smegit.ini"
|
|
echo "get-repo-and-build.sh <organisation> <reponame> [<local>]"
|
|
exit 1
|
|
else
|
|
initfilename="/etc/smegit.ini"
|
|
fi
|
|
fi
|
|
while read -r line || [[ -n "$line" ]]; do
|
|
if [[ $line =~ ^\[.*\]$ ]]
|
|
then
|
|
section=${line#*[}
|
|
section=${section%]*}
|
|
else
|
|
if [[ $line =~ ^[^#]*= ]]
|
|
then
|
|
key=${line%=*}
|
|
value=${line#*=}
|
|
declare "${section}_${key}=$value"
|
|
fi
|
|
fi
|
|
done < "$inifilename"
|
|
|
|
if [[ -z $1 && -z $2 ]] ; then
|
|
echo "get-repo-and-build.sh <organisation> <reponame> [<local>]"
|
|
exit 0
|
|
fi
|
|
|
|
DEBUG=
|
|
if [ ${smegit_DEBUG} == "true" ] ; then DEBUG=true ; fi
|
|
if [ $DEBUG ] ; then echo "found ini file: $inifilename" ; fi
|
|
|
|
curlsilent="-s"
|
|
if [ $DEBUG ] ; then curlsilent= ; fi
|
|
|
|
GITEAHOST=${remote_GITEAHOST}
|
|
ACCESSTOKEN=${remote_GITEAACCESSTOKEN}
|
|
if [ $3 ] ; then
|
|
if [ $3 == "local" ] ; then
|
|
GITEAHOST=${local_GITEAHOST}
|
|
ACCESSTOKEN=${local_GITEAACCESSTOKEN}
|
|
fi
|
|
fi
|
|
ORG_NAME="$1"
|
|
REPO_NAME="$2"
|
|
if [[ $smegit_WORKDIR == ~* ]] ; then
|
|
# relative to users home dir
|
|
WORKDIR=$(echo ~)${smegit_WORKDIR:1}
|
|
else
|
|
# absolute path
|
|
WORKDIR=${smegit_WORKDIR}
|
|
fi
|
|
if [ $DEBUG ] ; then echo "WORKDIR=$WORKDIR" ; fi
|
|
GITFiles=$WORKDIR/GITFiles/$ORG_NAME
|
|
REPOURL="$GITEAHOST/$ORG_NAME/$REPO_NAME.git"
|
|
|
|
if [ $DEBUG ] ; then echo "getting $REPO_NAME from $ORG_NAME on $GITEAHOST" ; fi
|
|
|
|
mkdir -p $GITFiles
|
|
|
|
touch "$GITFiles/mockbuilds.log"
|
|
|
|
if [ $DEBUG ] ; then echo $GITFiles ; fi
|
|
|
|
# one Common directory for each Organisation
|
|
#
|
|
# See if it already exists
|
|
if [ ! -e $GITFiles/common ]; then
|
|
#Get it
|
|
cd $GITFiles
|
|
git clone "${smegit_COMMONREPO}"
|
|
if [ ! -e $GITFiles/common ]; then
|
|
echo "ERROR*******No Common Repo found - package $1"
|
|
exit 1
|
|
fi
|
|
else
|
|
# Just refresh it
|
|
cd $GITFiles/common
|
|
git pull
|
|
fi
|
|
|
|
# Now make sure that the make-archive is executible
|
|
chmod +x $GITFiles/common/make-archive.sh
|
|
|
|
# See if repo exits in git
|
|
RESPONSE=$(curl $curlsilent -o /dev/null -w "%{http_code}" "$GITEAHOST/api/v1/repos/$ORG_NAME/$REPO_NAME")
|
|
if [ "$RESPONSE" == "200" ]; then
|
|
if [ $DEBUG ] ; then echo "Repository for $1/$2 exists!" ; fi
|
|
else
|
|
if [ $DEBUG ] ; then echo "Repository for $1/$2 does not exist" ; fi
|
|
logname="git-cvs2git-create-$2-$1-$(date +'%FT%H%M').log"
|
|
while true; do
|
|
read -p "Do you wish to run git-cvs2git?(y/n) " yn
|
|
case $yn in
|
|
[Yy]* ) git-cvs2git.sh "$REPO_NAME" "$ORG_NAME" > $logname; break;;
|
|
[Nn]* ) exit;;
|
|
* ) echo "Please answer yes or no.";;
|
|
esac
|
|
done
|
|
# And check it is now there
|
|
RESPONSE=$(curl $curlsilent -o /dev/null -w "%{http_code}" "$GITEAHOST/api/v1/repos/$ORG_NAME/$REPO_NAME")
|
|
if [ "$RESPONSE" == "200" ]; then
|
|
if [ $DEBUG ] ; then echo "Repository for $1/$2 created sucessfully!" ; fi
|
|
else
|
|
echo "git-cvs2git.sh was unable to create $1/$2 sucessfully"
|
|
exit 1
|
|
fi
|
|
fi
|
|
# Ok, we have a repo!!
|
|
cd $GITFiles
|
|
echo $GITFiles
|
|
# Delete it if these already
|
|
if [[ -d $REPO_NAME ]] ; then
|
|
# Should delete everything....
|
|
cd $GITFiles/$REPO_NAME
|
|
if [ $DEBUG ] ; then echo "Deleting all files in $GITFiles/$REPO_NAME" ; fi
|
|
rm -rf "$REPO_NAME"
|
|
fi
|
|
cd $GITFiles
|
|
git clone "$REPOURL"
|
|
|
|
|
|
cd $GITFiles
|
|
if [[ ! -d $REPO_NAME ]] ; then
|
|
echo "git clone has not created the directory"
|
|
exit 1
|
|
fi
|
|
cd $GITFiles/$REPO_NAME
|
|
# and run mockbuild
|
|
logname="mockbuild-$2-$1-$(date +'%FT%H%M').log"
|
|
if make mockbuild 2>&1 > $logname ; then
|
|
echo "Looks like mockbuild worked for $1/$2"
|
|
echo "$(date +'%FT%H%M') Mockbuild worked for $1/$2 " >> $GITFiles/mockbuilds.log
|
|
else
|
|
echo "Mockbuild failed"
|
|
echo "$(date +'%FT%H%M') Mockbuild failed for $1/$2 " >> $GITFiles/mockbuilds.log
|
|
exit 1
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|