aboutsummaryrefslogtreecommitdiffstats
path: root/git-repository--after-tarball
diff options
context:
space:
mode:
authorPascal Rigaux <pixel@mandriva.com>2009-01-29 14:12:08 +0000
committerPascal Rigaux <pixel@mandriva.com>2009-01-29 14:12:08 +0000
commit6a00e838377de30388dbec6ed48e65ce598b3b7e (patch)
treee35343370bb1310be504666436aa0e1b61df57bc /git-repository--after-tarball
parent0a7ff99241883736064d013c1e8f296f8f93750e (diff)
downloadrpm-setup-6a00e838377de30388dbec6ed48e65ce598b3b7e.tar
rpm-setup-6a00e838377de30388dbec6ed48e65ce598b3b7e.tar.gz
rpm-setup-6a00e838377de30388dbec6ed48e65ce598b3b7e.tar.bz2
rpm-setup-6a00e838377de30388dbec6ed48e65ce598b3b7e.tar.xz
rpm-setup-6a00e838377de30388dbec6ed48e65ce598b3b7e.zip
- when %_with_git_repository is set, define %_after_setup and %_patch to use
the new scripts git-repository--after-tarball and git-repository--apply-patch
Diffstat (limited to 'git-repository--after-tarball')
-rwxr-xr-xgit-repository--after-tarball63
1 files changed, 63 insertions, 0 deletions
diff --git a/git-repository--after-tarball b/git-repository--after-tarball
new file mode 100755
index 0000000..5fda909
--- /dev/null
+++ b/git-repository--after-tarball
@@ -0,0 +1,63 @@
+#!/bin/sh -ex
+
+# usage: git-repository--after-tarball [<tarballs>]
+# with optional environment variables:
+# - GIT_URL="git://xxx/foo.git [branch]"
+# - GIT_REPOSITORY_CACHE=/zzz/foo.git
+#
+# the GIT_REPOSITORY_CACHE can be used with or without GIT_URL
+# - if GIT_URL is given, GIT_REPOSITORY_CACHE will be a "bare" clone of GIT_URL
+# - otherwise, GIT_REPOSITORY_CACHE can be created using:
+# % git clone --bare BUILD/foo-1 $GIT_REPOSITORY_CACHE
+# where foo-1 is the previous version
+
+
+tarballs="$*"
+
+
+git_clone_in_cwd() {
+ URL=$1
+ [ -n "$2" ] && BRANCH="origin/$2"
+
+ git clone $URL .git-tmp
+
+ cd .git-tmp
+ git checkout $BRANCH
+ cd ..
+
+ mv .git-tmp/.git .
+ rm -r .git-tmp
+}
+
+our_git_clone() {
+ URL=$1
+ HEAD=$2
+
+ if [ -n "$GIT_REPOSITORY_CACHE" ]; then
+ if [ -d "$GIT_REPOSITORY_CACHE" ]; then
+ cd "$GIT_REPOSITORY_CACHE"
+ git fetch $GIT_URL
+ cd -
+ else
+ git clone --bare $URL "$GIT_REPOSITORY_CACHE"
+ fi
+ git_clone_in_cwd "$GIT_REPOSITORY_CACHE" $HEAD
+ else
+ git_clone_in_cwd $URL $HEAD
+ fi
+}
+
+if [ ! -e .git ]; then
+ if [ -n "$GIT_URL" ]; then
+ our_git_clone $GIT_URL
+ elif [ -n "$GIT_REPOSITORY_CACHE" -a -d "$GIT_REPOSITORY_CACHE" ]; then
+ git_clone_in_cwd "$GIT_REPOSITORY_CACHE" vanilla
+ else
+ git init
+ fi
+fi
+git add .
+git commit -q -a -m "imported $tarballs"
+git branch -f vanilla
+git branch -f patches-applied
+git checkout patches-applied