Accepting request 55099 from home:wrosenauer:devel

OBS-URL: https://build.opensuse.org/request/show/55099
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Tools/obs-service-tar_scm?expand=0&rev=4
This commit is contained in:
Adrian Schröter 2010-12-08 07:58:14 +00:00 committed by Git OBS Bridge
parent bebd76e674
commit 3f9aafed0e
4 changed files with 48 additions and 6 deletions

View File

@ -1,3 +1,8 @@
-------------------------------------------------------------------
Wed Dec 8 06:29:42 UTC 2010 - wr@rosenauer.org
- support mercurial repositories
-------------------------------------------------------------------
Wed Oct 20 16:27:25 UTC 2010 - reddwarf@opensuse.org

View File

@ -2,19 +2,19 @@
Name: obs-service-tar_scm
License: GPL v2 or later
Group: Development/Tools/Building
Summary: An OBS source service: checkout or update a tar ball from svn/git/cvs
Version: 0.1
Summary: An OBS source service: checkout or update a tar ball from svn/git/hg
Version: 0.2
Release: 1
Source: tar_scm
Source1: tar_scm.service
Requires: subversion git cvs
Requires: subversion git mercurial
BuildRoot: %{_tmppath}/%{name}-%{version}-build
BuildArch: noarch
%description
This is a source service for openSUSE Build Service.
It supports downloading src.rpms and extracting
It supports downloading from svn, git and hg repositories.
%prep

38
tar_scm
View File

@ -65,7 +65,7 @@ FILE="$MYFILENAME"
VERSION="$MYVERSION"
if [ -z "$MYSCM" ]; then
echo "ERROR: no scm is given via --scm parameter (git/svn)!"
echo "ERROR: no scm is given via --scm parameter (git/svn/hg)!"
exit 1
fi
if [ -z "$MYURL" ]; then
@ -88,6 +88,10 @@ if [ -z "$FILE" -a "$MYSCM" == "svn" ]; then
FILE="${MYURL%/}"
FILE="${FILE##*/}"
fi
if [ -z "$FILE" -a "$MYSCM" == "hg" ]; then
FILE="${MYURL%/}"
FILE="${FILE##*/}"
fi
existing_tar=$(echo _service:tar_scm:${FILE}-*.tar*)
if [ -e "$existing_tar" ]; then
@ -168,6 +172,38 @@ elif [ "$MYSCM" == "git" ]; then
VERSION=$MYPREFIX`git show --pretty=%at | head -n 1`
cd -
fi
elif [ "$MYSCM" == "hg" ]; then
if [ -z "$SUBDIR" -a -d "$TAR_DIRECTORY" ]; then
# update existing content for speed/bandwidth reasons
cd "$TAR_DIRECTORY"
OLDVERSION=`hg tip | head -n 1 | sed -e 's/\s*//g' | awk -F':' '{ print $2 }'`
hg pull || exit 1
if [ -n "$MYREVISION" ]; then
hg checkout "$MYREVISION" || exit 1
fi
NEWVERSION=`hg tip | head -n 1 | sed -e 's/\s*//g' | awk -F':' '{ print $2 }'`
cd -
if [ "$OLDVERSION" == "$NEWVERSION" ]; then
# cleanup and skip
rm -rf "$TAR_DIRECTORY"
exit 0
fi
mv "$TAR_DIRECTORY" "${FILE}" || exit 1
else
# new checkout
hg clone "$MYURL" "${FILE}" || exit 1
if [ -n "$MYREVISION" ]; then
cd "$FILE"
hg checkout "$MYREVISION" || exit 1
cd -
fi
fi
if [ -z "$VERSION" ]; then
cd "$FILE"
[ -n "$MYPREFIX" ] && MYPREFIX="$MYPREFIX."
VERSION=$MYPREFIX`hg tip | head -n 1 | sed -e 's/\s*//g' | awk -F':' '{ print $2 }'`
cd -
fi
else
echo "ERROR: unknown scm $MYSCM"
exit 1

View File

@ -1,10 +1,11 @@
<service name="tar_scm">
<summary>Create a tar ball from SCM repository</summary>
<description>This service uses a scm client to checkout or update from a given repository. Supported are svn, cvs and git.</description>
<description>This service uses a scm client to checkout or update from a given repository. Supported are svn, git and hg.</description>
<parameter name="scm">
<description>Used SCM</description>
<allowedvalue>svn</allowedvalue>
<allowedvalue>git</allowedvalue>
<allowedvalue>hg</allowedvalue>
<required/>
</parameter>
<parameter name="url">