Log In
Log In
Places
All Projects
Status Monitor
Collapse sidebar
obs:server:fedora-2.5
gitpkg
_service:gitpkg:0001-Add-url-parameter-to-allow...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File _service:gitpkg:0001-Add-url-parameter-to-allow-gitpkg-service-to-use-rep.patch of Package gitpkg
From afe5d23b20dd9ee8d0d21ff067a9fb544cccd48e Mon Sep 17 00:00:00 2001 From: Oleg Girko <ol@infoserver.lv> Date: Fri, 8 Nov 2013 23:00:03 +0000 Subject: [PATCH] Add url parameter to allow gitpkg service to use repos at arbitrary URLs. Without this change gitpkg OBS service can use only specially whitlisted services (github, gitorious, mer) to clone git repos from. This change allows to specify arbitrary URL using url parameter. This parameter conflicts with service and repo parameters. Signed-off-by: Oleg Girko <ol@infoserver.lv> --- gitpkg.service | 5 +++-- gitpkg.sh | 59 +++++++++++++++++++++++++++++++++++++++++++++------------- 2 files changed, 49 insertions(+), 15 deletions(-) diff --git a/gitpkg.service b/gitpkg.service index d241b72..ece57f8 100644 --- a/gitpkg.service +++ b/gitpkg.service @@ -6,11 +6,12 @@ <allowedvalue>github</allowedvalue> <allowedvalue>gitorious</allowedvalue> <allowedvalue>Mer</allowedvalue> - <required/> </parameter> <parameter name="repo"> <description>Name of the repository to clone or remote update (including path)</description> - <required/> + </parameter> + <parameter name="url"> + <description>URL of the repository to clone or remote update</description> </parameter> <parameter name="tag"> <description>Tag containing the _src file to build</description> diff --git a/gitpkg.sh b/gitpkg.sh index 5e14409..6247ef3 100755 --- a/gitpkg.sh +++ b/gitpkg.sh @@ -12,6 +12,8 @@ STORE=/data/service/gitpkg SVC="" REPO="" OUTDIR="" +WORKDIR="" +URL="" SERVICES="github|gitorious|mer" @@ -21,10 +23,12 @@ Usage: $0 --service <service> --repo <path/pkg> [--outdir <outdir>] Options: --service <service> Git hosting service to use ($SERVICES) --repo <path/pkg> Repository path to check out + --url <url> URL of git repo to clone from --outdir <outdir> Move files to outdir after checkout (optional) Examples: $0 --service github --repo lbt/powertop + $0 --url https://github.com/lbt/powertop EOF } @@ -45,6 +49,10 @@ while test $# -gt 0; do REPO="$2" shift ;; + *-url) + URL="$2" + shift + ;; *-tag) TAG="$2" shift @@ -66,16 +74,39 @@ while test $# -gt 0; do shift done -if [ -z "$SVC" ]; then - fatal "ERROR: no --service parameter ($SERVICES)" -fi -if [ -z "$REPO" ]; then - fatal "ERROR: no --repo parameter" -fi +if [ -n "$URL" ]; then + + if [ -n "$SVC" ]; then + fatal "ERROR: --service parameter conflicts with --url parameter" + fi + if [ -n "$REPO" ]; then + fatal "ERROR: --repo parameter conflicts with --url parameter" + fi + + regex1='^[a-z]+://([[:alnum:]_.-]+@)?[[:alnum:]_./~%-]+$' # url + regex2='^([[:alnum:]_.-]+@)?[[:alnum:]_.-]+:[[:alnum:]_./-]+$' # ssh + if [[ -z "$URL" || ! "$URL" =~ $regex1|$regex2 && ! -d "$URL" ]]; then + fatal "ERROR: URL '$URL' is has wrong format" + fi + + WORKDIR="`basename \"$URL\"`" + +else + + if [ -z "$SVC" ]; then + fatal "ERROR: no --service parameter ($SERVICES)" + fi + if [ -z "$REPO" ]; then + fatal "ERROR: no --repo parameter" + fi + + repo_regexp="^[A-Za-z0-9_-]*/[A-Za-z0-9_-]*$" + if ! [[ $REPO =~ $repo_regexp ]]; then + fatal "ERROR: repo '$REPO'is not in area/repo format (omit .git and any http://.../ part)" + fi + + WORKDIR="$SVC/$REPO" -repo_regexp="^[A-Za-z0-9_-]*/[A-Za-z0-9_-]*$" -if ! [[ $REPO =~ $repo_regexp ]]; then - fatal "ERROR: repo '$REPO'is not in area/repo format (omit .git and any http://.../ part)" fi tag_regexp="^[A-Za-z0-9_.-]*$" @@ -83,7 +114,8 @@ if ! [[ $TAG =~ $tag_regexp ]]; then fatal "ERROR: repo '$TAG'is not valid (must match '$tag_regexp')" fi -case "$SVC" in +if [ -z "$URL" ]; then + case "$SVC" in github) URL="git://github.com/${REPO}.git" ;; gitorious) @@ -93,7 +125,8 @@ case "$SVC" in *) echo "Sorry, git service $SVC is not whitelisted. please contact lbt in #mer" exit 1 ;; -esac + esac +fi PRJDIR=$(pwd) cd $STORE 2>/dev/null @@ -107,8 +140,8 @@ if [ $? -ne 0 ]; then cd $TMPSTORE fi -mkdir -p $SVC/$REPO -cd $SVC/$REPO +mkdir -p "$WORKDIR" +cd "$WORKDIR" # clone or update if [ -d .git ]; then -- 1.9.3
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Contact
Support
@OBShq
The Open Build Service is an
openSUSE project
.
Log In
Places
Places
All Projects
Status Monitor