[Lunar-commits] r19639 - in moonbase/trunk: devel/git devel/git/plugin.d zbeta zbeta/git-git zbeta/git-git/plugin.d

Auke Kok sofar at lunar-linux.org
Tue Apr 11 01:18:07 UTC 2006


Author: sofar
Date: 2006-04-11 01:18:06 +0000 (Tue, 11 Apr 2006)
New Revision: 19639

Added:
   moonbase/trunk/devel/git/plugin.d/
   moonbase/trunk/devel/git/plugin.d/download-git.plugin
   moonbase/trunk/zbeta/git-git/
   moonbase/trunk/zbeta/git-git/BUILD
   moonbase/trunk/zbeta/git-git/DETAILS
   moonbase/trunk/zbeta/git-git/POST_INSTALL
   moonbase/trunk/zbeta/git-git/plugin.d/
   moonbase/trunk/zbeta/git-git/plugin.d/download-git.plugin
Log:
Proof of concept/ working implementation of git plugin for lunar. This will require git to be installed , but you can upgrade from git to git-git seamlessly. Just install git and after that install git-git.


Added: moonbase/trunk/devel/git/plugin.d/download-git.plugin
===================================================================
--- moonbase/trunk/devel/git/plugin.d/download-git.plugin	                        (rev 0)
+++ moonbase/trunk/devel/git/plugin.d/download-git.plugin	2006-04-11 01:18:06 UTC (rev 19639)
@@ -0,0 +1,125 @@
+#!/bin/bash
+############################################################
+#                                                          #
+# download-git.plugin - download GIT urls                  #
+#                                                          #
+############################################################
+#                                                          #
+# Copyright 2005 by Auke Kok under GPLv2                   #
+#                                                          #
+############################################################
+
+# valid SVN urls are:
+# git://
+# git+http:// (will be transformed to http://)
+# git+https:// (will be transformed to https://)
+# git+rsync:// (will be transformed to rsync://)
+# git+ssh:// (will be transformed to ssh://)
+
+plugin_source_download_git() {
+  # check if we can handle this URL format
+  if [ "${1:0:6}" != "git://" -a "${1:0:11}" != "git+http://" -a "${1:0:12}" != "git+https://" -a "${1:0:10}" != "git+rsync://" -a "${1:0:10}" != "git+ssh://" ] ; then
+    return 2
+  fi
+  debug_msg "plugin_source_needrefresh_git($@)"
+
+  if [ ! -x `which git` ] ; then
+    # full stop: we need to make sure the user sees this error:
+    message "${PROBLEM_COLOR}! Cannot fetch git sources without \"git\" installed${DEFAULT_COLOR}"
+    exit 1
+  fi
+
+  GIT_URL=$(echo $1 | cut -d: -f1-2)
+  GIT_BRANCH=$(echo $1 | cut -d: -f3)
+  # translate git+http(s) urls:
+  if [ "${GIT_URL:0:8}" == "git+http" ]; then
+    GIT_URL="${GIT_URL:4}"
+  elif [ "${GIT_URL:0:9}" == "git+rsync" ]; then
+    GIT_URL="${GIT_URL:4}"
+  fi
+
+  message  "${MESSAGE_COLOR}Downloading GIT module for" \
+ 	   "module ${MODULE_COLOR}${MODULE}${DEFAULT_COLOR}"
+
+  mk_source_dir $TMPDIR/$MODULE-$VERSION
+  cd $TMPDIR/$MODULE-$VERSION
+  if [ -f "$3/$2" ] ; then
+    verbose_msg "Extracting local GIT copy"
+    # unpacking in last component dir of $GIT_BRANCH
+    CD=$(pwd -P)
+    cd $CD
+    if ! tar xjf $3/$2 ; then
+      message "${PROBLEM_COLOR}Warning: bad local GIT copy, checking out fresh GIT copy${DEFAULT_COLOR}"
+
+      rm_source_dir $TMPDIR/$MODULE-$VERSION
+      mk_source_dir $TMPDIR/$MODULE-$VERSION
+    fi
+  fi
+
+  NUM_RETRY=${NUM_RETRY:-5}
+  if [ "$NUM_RETRY" -eq 0 ]; then
+      NUM_RETRY=1000
+  fi
+
+  for (( TRY=1 ; $TRY<$NUM_RETRY+1 ; TRY++ )) ; do
+    if [ "$MODULE-$VERSION/.git" ] ; then
+      cd $MODULE-$VERSION
+      verbose_msg "[${TRY}] git pull"
+      git pull && GOT_GIT="yes" 
+      cd ${CD}
+    else
+      verbose_msg "[${TRY}] git clone $GIT_URL $GIT_BRANCH"
+      git clone $GIT_URL $MODULE-$VERSION && GOT_GIT="yes"
+    fi
+
+    if [ "$?" == "0" ] ; then
+      break
+    fi
+
+    sleep 2
+  done
+
+  if [ "$GOT_GIT" == "yes" ] ; then
+    message "${MESSAGE_COLOR}Creating ${FILE_COLOR}$2${DEFAULT_COLOR}"
+    # pack in last component dir of $GIT_BRANCH
+    tar cjf $3/$2 $MODULE-$VERSION
+  else
+    activity_log "lget" "$MODULE" "$VERSION" "failed" "Could not fetch \"$1\""
+  fi
+
+  cd $TMPDIR
+  rm_source_dir $TMPDIR/$MODULE-$VERSION
+
+}
+
+
+plugin_source_needrefresh_git() {
+  # check if we can handle this URL format
+  if [ "${1:0:6}" != "git://" -a "${1:0:11}" != "git+http://" -a "${1:0:12}" != "git+https://" -a "${1:0:12}" != "git+rsync://" -a "${1:0:10}" != "git+ssh://" ] ; then
+    return 2
+  fi
+  debug_msg "plugin_source_needrefresh_git($@)"
+
+  if [ ! -f $3/$2 ]; then
+    return 0
+  fi
+
+  GIT_THRESHOLD=${GIT_THRESHOLD:-10}
+  if (( "GIT_THRESHOLD" > 0 )) ; then
+	if [ "$(find $3/$2 -amin +$GIT_THRESHOLD)" == "$3/$2" ] ; then
+      # it is older:
+	  return 0
+	else
+      message "${MESSAGE_COLOR}GIT update not required for \"${FILE_COLOR}$(basename $2)${DEFAULT_COLOR}${CYAN}\" (less than $GIT_THRESHOLD minutes old)${DEFAULT_COLOR}"
+      # now we can send a FAIL so the next plugins are skipped:
+	  return 1
+    fi
+  else
+    # always return true if threshhold is zero
+    return 0
+  fi
+}
+
+
+plugin_register SOURCE_DOWNLOAD plugin_source_download_git
+plugin_register SOURCE_NEEDREFRESH plugin_source_needrefresh_git

Added: moonbase/trunk/zbeta/git-git/BUILD
===================================================================
--- moonbase/trunk/zbeta/git-git/BUILD	                        (rev 0)
+++ moonbase/trunk/zbeta/git-git/BUILD	2006-04-11 01:18:06 UTC (rev 19639)
@@ -0,0 +1,8 @@
+(
+
+  sedit "s/-g -O2/${CFLAGS}/" Makefile &&
+  make prefix=/usr &&
+  prepare_install  &&
+  make prefix=/usr install 
+
+) > $C_FIFO 2>&1

Added: moonbase/trunk/zbeta/git-git/DETAILS
===================================================================
--- moonbase/trunk/zbeta/git-git/DETAILS	                        (rev 0)
+++ moonbase/trunk/zbeta/git-git/DETAILS	2006-04-11 01:18:06 UTC (rev 19639)
@@ -0,0 +1,20 @@
+          MODULE=git-git
+         VERSION=beta
+          SOURCE=$MODULE-$VERSION.tar.bz2
+      SOURCE_URL=git://git.kernel.org/pub/scm/git/git.git:master
+        WEB_SITE=http://kernel.org/pub/software/scm/git/
+         ENTERED=20060410
+         UPDATED=`date -u +%Y%m%d`
+           SHORT="The stupid content tracker"
+PSAFE=no
+
+cat << EOF
+Linus Torvalds new toolset for a "userland filesystem upon which other SCM
+implementations are being built or adapted."
+
+This is a stupid (but extremely fast) directory content manager. It doesn't
+do a whole lot, but what it _does_ do is track directory contents efficiently.
+
+There are two object abstractions: the "object database", and the "current
+directory cache" aka "index".
+EOF

Added: moonbase/trunk/zbeta/git-git/POST_INSTALL
===================================================================
--- moonbase/trunk/zbeta/git-git/POST_INSTALL	                        (rev 0)
+++ moonbase/trunk/zbeta/git-git/POST_INSTALL	2006-04-11 01:18:06 UTC (rev 19639)
@@ -0,0 +1,2 @@
+# very, very, very bad:
+remove_module git

Added: moonbase/trunk/zbeta/git-git/plugin.d/download-git.plugin
===================================================================
--- moonbase/trunk/zbeta/git-git/plugin.d/download-git.plugin	                        (rev 0)
+++ moonbase/trunk/zbeta/git-git/plugin.d/download-git.plugin	2006-04-11 01:18:06 UTC (rev 19639)
@@ -0,0 +1,125 @@
+#!/bin/bash
+############################################################
+#                                                          #
+# download-git.plugin - download GIT urls                  #
+#                                                          #
+############################################################
+#                                                          #
+# Copyright 2005 by Auke Kok under GPLv2                   #
+#                                                          #
+############################################################
+
+# valid SVN urls are:
+# git://
+# git+http:// (will be transformed to http://)
+# git+https:// (will be transformed to https://)
+# git+rsync:// (will be transformed to rsync://)
+# git+ssh:// (will be transformed to ssh://)
+
+plugin_source_download_git() {
+  # check if we can handle this URL format
+  if [ "${1:0:6}" != "git://" -a "${1:0:11}" != "git+http://" -a "${1:0:12}" != "git+https://" -a "${1:0:10}" != "git+rsync://" -a "${1:0:10}" != "git+ssh://" ] ; then
+    return 2
+  fi
+  debug_msg "plugin_source_needrefresh_git($@)"
+
+  if [ ! -x `which git` ] ; then
+    # full stop: we need to make sure the user sees this error:
+    message "${PROBLEM_COLOR}! Cannot fetch git sources without \"git\" installed${DEFAULT_COLOR}"
+    exit 1
+  fi
+
+  GIT_URL=$(echo $1 | cut -d: -f1-2)
+  GIT_BRANCH=$(echo $1 | cut -d: -f3)
+  # translate git+http(s) urls:
+  if [ "${GIT_URL:0:8}" == "git+http" ]; then
+    GIT_URL="${GIT_URL:4}"
+  elif [ "${GIT_URL:0:9}" == "git+rsync" ]; then
+    GIT_URL="${GIT_URL:4}"
+  fi
+
+  message  "${MESSAGE_COLOR}Downloading GIT module for" \
+ 	   "module ${MODULE_COLOR}${MODULE}${DEFAULT_COLOR}"
+
+  mk_source_dir $TMPDIR/$MODULE-$VERSION
+  cd $TMPDIR/$MODULE-$VERSION
+  if [ -f "$3/$2" ] ; then
+    verbose_msg "Extracting local GIT copy"
+    # unpacking in last component dir of $GIT_BRANCH
+    CD=$(pwd -P)
+    cd $CD
+    if ! tar xjf $3/$2 ; then
+      message "${PROBLEM_COLOR}Warning: bad local GIT copy, checking out fresh GIT copy${DEFAULT_COLOR}"
+
+      rm_source_dir $TMPDIR/$MODULE-$VERSION
+      mk_source_dir $TMPDIR/$MODULE-$VERSION
+    fi
+  fi
+
+  NUM_RETRY=${NUM_RETRY:-5}
+  if [ "$NUM_RETRY" -eq 0 ]; then
+      NUM_RETRY=1000
+  fi
+
+  for (( TRY=1 ; $TRY<$NUM_RETRY+1 ; TRY++ )) ; do
+    if [ "$MODULE-$VERSION/.git" ] ; then
+      cd $MODULE-$VERSION
+      verbose_msg "[${TRY}] git pull"
+      git pull && GOT_GIT="yes" 
+      cd ${CD}
+    else
+      verbose_msg "[${TRY}] git clone $GIT_URL $GIT_BRANCH"
+      git clone $GIT_URL $MODULE-$VERSION && GOT_GIT="yes"
+    fi
+
+    if [ "$?" == "0" ] ; then
+      break
+    fi
+
+    sleep 2
+  done
+
+  if [ "$GOT_GIT" == "yes" ] ; then
+    message "${MESSAGE_COLOR}Creating ${FILE_COLOR}$2${DEFAULT_COLOR}"
+    # pack in last component dir of $GIT_BRANCH
+    tar cjf $3/$2 $MODULE-$VERSION
+  else
+    activity_log "lget" "$MODULE" "$VERSION" "failed" "Could not fetch \"$1\""
+  fi
+
+  cd $TMPDIR
+  rm_source_dir $TMPDIR/$MODULE-$VERSION
+
+}
+
+
+plugin_source_needrefresh_git() {
+  # check if we can handle this URL format
+  if [ "${1:0:6}" != "git://" -a "${1:0:11}" != "git+http://" -a "${1:0:12}" != "git+https://" -a "${1:0:12}" != "git+rsync://" -a "${1:0:10}" != "git+ssh://" ] ; then
+    return 2
+  fi
+  debug_msg "plugin_source_needrefresh_git($@)"
+
+  if [ ! -f $3/$2 ]; then
+    return 0
+  fi
+
+  GIT_THRESHOLD=${GIT_THRESHOLD:-10}
+  if (( "GIT_THRESHOLD" > 0 )) ; then
+	if [ "$(find $3/$2 -amin +$GIT_THRESHOLD)" == "$3/$2" ] ; then
+      # it is older:
+	  return 0
+	else
+      message "${MESSAGE_COLOR}GIT update not required for \"${FILE_COLOR}$(basename $2)${DEFAULT_COLOR}${CYAN}\" (less than $GIT_THRESHOLD minutes old)${DEFAULT_COLOR}"
+      # now we can send a FAIL so the next plugins are skipped:
+	  return 1
+    fi
+  else
+    # always return true if threshhold is zero
+    return 0
+  fi
+}
+
+
+plugin_register SOURCE_DOWNLOAD plugin_source_download_git
+plugin_register SOURCE_NEEDREFRESH plugin_source_needrefresh_git



More information about the Lunar-commits mailing list