logo       
Google Custom Search
    AddThis Social Bookmark Button

Patch for second cut scm script: msg#00072

Subject: Patch for second cut scm script
Hi Bryce,

This patch is against your second cut scm script.  The patch allows for
the use of either exports or checkouts.  At first I thought that
checkouts seemed unnecessary but I'm seeing now that one possible
benefit to using checkouts vs. exports is it can take less time to
create the snapshot.  The user does have the overhead of managing the
checkout, but it might be worth it.  Here are some sample time
comparisons for generating a snapshot (note:  all checked out
repositories were up to date at the time of the snapshot being taken):  

generating snapshot of SVN tree using checkout:
# time /tmp/scm_orig.sh -q -p crucible -c /usr/local/crucible

real    1m10.356s
user    0m57.360s
sys     0m2.244s


generating snapshot of SVN tree using export:
# time /tmp/scm_orig.sh -q -p crucible -u 
https://svn.sourceforge.net/svnroot/crucible

real    4m56.173s
user    1m10.968s
sys     0m2.240s

generating snapshot of CVS tree using checkout:
# time /tmp/scm_orig.sh -q -p  utils -t cvs -c /usr/local/utils/

real    0m1.679s
user    0m1.468s
sys     0m0.196s

generating snapshot of CVS tree using export:
# time /tmp/scm_orig.sh -q -p  utils -t cvs -u 
:pserver:anonymous-CF0MX/vz6U6nJ6BriqaqdGjI4wXNbHj0@xxxxxxxxxxxxxxxx:/cvsroot/ltp

real    0m8.176s
user    0m1.524s
sys     0m0.104s


Thanks,
Leann

==============================================================
--- /tmp/scm_orig       2006-09-26 11:51:41.000000000 -0700
+++ /tmp/scm    2006-09-26 13:43:24.000000000 -0700
@@ -12,15 +12,16 @@
 
 usage() {
     cat <<EOF
-Usage:  $0 [-a] [-p <PKGNAME>] [-t <SCM_TYPE>] [-d <DEST_DIR>] [-g <GROUP>] 
-           [-q] [-c <CHECKOUT_DIR>] [-s <SYMLINK_DIR>] [-D <SNAPDATE>]
-           [-G <GOLD_DIR>]
+Usage:  $0 [-a] [-p <PKGNAME>] [-t <SCM_TYPE>] [-d <DEST_DIR>]
+           [-g <GROUP>] [-q] [-c <CHECKOUT_DIR>] [-u <URL> ]
+           [-s <SYMLINK_DIR>] [-D <SNAPDATE>] [-G <GOLD_DIR>]
 
 This tool is used to get a snapshot of a CVS or SVN repository and
 create a tarball.  It creates a snapshot of the repository's current
-head, or the head as of the SNAPDATE if specified.  It requires that
-there is an existing SVN or CVS checkout of the repository located at
-$CHECKOUT_DIR (default is /var/cache/$SCM_TYPE/$PKGNAME).
+head, or the head as of the SNAPDATE if specified.  It can create the
+snapshot from an existing SVN or CVS checkout of the repository located at
+CHECKOUT_DIR (default is /var/cache/SCM_TYPE/PKGNAME) or from a
+specified repository's URL.
 
 SCM_TYPE should be either 'svn' or 'cvs'.  DEST_DIR is the location
 where tarballs will be placed.  If GROUP is specified, then the tarballs
@@ -35,34 +36,38 @@
 from being executed.
 
 Example:
-  $0 -p pgsql \\
-     -t cvs \\
-     -d /testing/packages/pgsql \\
+  $0 -d /testing/packages/crucible \\
+     -D 20060724 \\
      -g crucible \\
-     -c /var/cache/cvs/pgsql \\
-     -s /testing/packages/QUEUE
+     -p crucible \\
+     -q \\
+     -s /testing/packages/QUEUE \\
+     -t svn \\
+     -u https://svn/sourceforge.net/svnroot/crucible
 
 EOF
     exit $1
 }
 
 msg() {
-    if [ ! -z "$QUIET" ]; then
+    if [ -z "$QUIET" ]; then
         echo $1
     fi
 }
 
-while getopts "ac:d:D:g:p:qs:t:h\?" opt; do
+while getopts "ac:d:D:g:p:qs:t:u:h\?" opt; do
     case $opt in
         a) RUN_AUTOGEN="yes" ;;
         c) CHECKOUT_DIR=$OPTARG ;;
         d) DEST_DIR=$OPTARG ;;
-        D) SNAPDATE=$SNAPDATE ;;
+        D) SNAPDATE=$OPTARG ;;
         g) GROUP=$OPTARG ;;
+        G) GOLD_DIR=$OPTARG ;;
         p) PKGNAME=$OPTARG ;;
         q) QUIET="-q" ;;
         s) SYMLINK_DIR=$OPTARG ;;
         t) SCM=$OPTARG ;;
+        u) URL=$OPTARG ;;
         h) usage 1 ;;
         \?) usage 1 ;;
     esac
@@ -70,73 +75,111 @@
 shift `expr $OPTIND - 1`
 
 if [ -z "$PKGNAME" ]; then
-    echo "ERROR:  No package specified (use -p <pkgname>)"
+    echo "ERROR:  No package specified (use -p <PKGNAME>)"
+    usage 1
     exit 1
 fi
 
-if [ ! -z "$SNAPDATE" ]; then
-    CVS_SNAPDATE_FLAG="-D $SNAPDATE"
-    SVN_SNAPDATE_FLAG="--revision {$SNAPDATE}"
-else
-    SNAPDATE=`date +%Y%m%d-%H%M`
-    if [ $? ]; then
-        echo "ERROR:  Could not determine date"
+NOW=`date +%Y%m%d`
+if [ $? != 0 ]; then
+    echo "ERROR:  Could not determine date"
+    exit 1
+fi
+                       
+if [ ! -z "${SNAPDATE}" ]; then
+    if [ ! `expr ${SNAPDATE} : '[[:digit:]]\{6\}'` ]; then
+        echo "ERROR:  Date Format incorrect.  (use -D YYYYMMDD)."
         exit 1
+    elif [ "${SNAPDATE}" -gt "${NOW}" ]; then
+        echo "WARNING:  Date specified is in the future.  Defaulting to 
current date."
+       SNAPDATE=${NOW}
+    else
+        CVS_SNAPDATE_FLAG="-D ${SNAPDATE}"
+        SVN_SNAPDATE_FLAG="--revision {$SNAPDATE}"
     fi
+else
+  SNAPDATE=${NOW}
+fi
+
+if [ -z "${CHECKOUT_DIR}" ] && [ -z "${URL}" ]; then
+    echo "ERROR:  Please specify repository location."
+    echo "Use -c <CHECKOUT_DIR> or -u <URL>"
+    usage 1
+    exit 1
+elif [ ! -z "${CHECKOUT_DIR}" ] && [ ! -z "${URL}" ]; then
+    echo "ERROR:  Please only specify one repository location."
+    echo "Either use -c <CHECKOUT_DIR> or -u <URL>, not both."
+    usage 1
+    exit 1
 fi
 
 SCM=${SCM:-"svn"}
 TEMP_BASE=${TEMP:-"/tmp"}
 PKGSUFFIX=${PKGSUFFIX:-"tar.bz2"}
-CHECKOUT_DIR=${CHECKOUT_DIR:-"/var/cache/$SCM/$PKGNAME"}
 DEST_DIR=${DEST_DIR:-"/testing/packages/$PKGNAME"}
-SCM_CLEAN="${PKGNAME}-${SCM}-clean"
-SCM_DIR="${CHECKOUT_DIR}/${SCM_CLEAN}"
-DIRNAME="${PKGNAME}-${SNAPDATE}"
-PKGFILE="${DIRNAME}.${PKGSUFFIX}"
-
-if [ ! -d ${SCM_DIR} ]; then
-    echo "ERROR:  ${SCM_DIR} does not exist."
-    echo "        Make sure there is a valid checkout there!"
+PKGDIR="${PKGNAME}-${SNAPDATE}"
+PKGFILE="${PKGDIR}.${PKGSUFFIX}"
+
+msg "Create a temp dir for us to do our work in."
+TEMPDIR=`mktemp -d ${TEMP_BASE}/snap-${PKGNAME}-XXXXXX`
+if [ $? -gt 0 ]; then
     exit 1
 fi
 
-cd ${SCM_DIR} || exit 1
+if [ ! -z "$CHECKOUT_DIR" ]; then
+    if [ ! -d "${CHECKOUT_DIR}" ]; then
+        echo "ERROR:  ${CHECKOUT_DIR} does not exist."
+        echo "        Make sure there is a valid checkout there!"
+        exit 1
+    fi
 
-if [ "$SCM" = "svn" ]; then
-    svn update $QUIET $SVN_SNAPDATE_FLAG
-elif [ "$SCM" = "cvs" ]; then
-    cvs status ChangeLog | grep Status | grep "Needs Patch" || exit 0
-    cvs update -Pd $QUIET $CVS_SNAPDATE_FLAG > /dev/null 2>&1
-fi
+    cd ${CHECKOUT_DIR} || exit 1
 
-msg Create a temp dir for us to do our work in
-TEMPDIR=`mktemp -d ${TEMP_BASE}/snap-${PKGNAME}-XXXXXX`
-if [ $? -gt 0 ]; then
-       exit 1
-fi
+    if [ "${SCM}" = "svn" ]; then
+        svn update $QUIET $SVN_SNAPDATE_FLAG
+    elif [ "${SCM}" = "cvs" ]; then
+        cvs update -Pd $QUIET $CVS_SNAPDATE_FLAG > /dev/null 2>&1
+    fi
+
+    cp -dR --preserve=mode ${CHECKOUT_DIR} ${TEMPDIR}/ || exit 1
 
-cp -dR --preserve=mode ${SCM_DIR} ${TEMPDIR}/ || exit 1
+    if [ ! -z "${GOLD_DIR}" ]; then
+        for file in `find "${GOLD_DIR}" -type 'f'`; do
+            if [ ! diff -u ${GOLD_DIR}/$file $file ]; then
+                echo "ERROR:  $file differs from gold version."
+                exit 1
+            fi
+            done
+    fi
 
-if [ ! -z "$GOLD_DIR" ]; then
-    for file in `find "$GOLD_DIR" -type 'f'`; do
-        if [ ! diff -u ${GOLD_DIR}/$file $file ]; then
-            echo "ERROR:  $file differs from gold version."
-            exit 1
-        fi
-    done
+    msg "Creating tarball from checkout ..."
+    cd ${TEMPDIR} || exit rm -rf ${TEMPDIR} || exit 1
+    mv ${PKGNAME} ${PKGDIR} || exit 1
+    tar --exclude .svn --exclude CVS --exclude .cvsignore --group 0 -jchf 
${PKGFILE} ${PKGDIR} || exit 1
+
+elif [ ! -z "${URL}" ]; then
+    cd ${TEMPDIR} || exit 1
+
+    msg "Exporting $SCM repository"
+    if [ "${SCM}" = "svn" ]; then
+        svn export $QUIET ${SVN_SNAPDATE_FLAG} ${URL} ${PKGDIR} || exit 1
+    elif [ "${SCM}" = "cvs" ]; then
+       if [ ! -z ${QUIET} ]; then
+           QUIET="-Q"
+       fi
+       #cvs export requires -D option; ie don't use CVS_SNAPDATE_FLAG here
+        cvs -z3 $QUIET -d${URL} export -D ${SNAPDATE} -d ${PKGDIR} ${PKGNAME} 
|| exit 1
+    fi
+    msg "Creating tarball from export ..."
+    tar -jchf ${PKGFILE} ${PKGDIR} || exit 1
+       
 fi
 
-if [ ! -z "$RUN_AUTOGEN" ]; then
+if [ ! -z "${RUN_AUTOGEN}" ]; then
     ./autogen.sh >/dev/null
 fi
 
-msg Creating tarball ...
-cd ${TEMPDIR} || exit 1
-mv ${SCM_CLEAN} ${DIRNAME} || exit 1
-tar --exclude .svn --exclude CVS --exclude .cvsignore --group 0 -jchf 
${PKGFILE} ${DIRNAME} || exit 1
-
-msg Building snapshot directory ...
+msg "Building snapshot directory ..."
 mkdir -p ${DEST_DIR} || exit 1
 if [ ! -z "${DEST_GROUP}" ]; then
     chgrp ${DEST_GROUP} ${DEST_DIR} || exit 1
@@ -144,15 +187,19 @@
 chmod -fR g+w ${DEST_DIR}
 chmod g+s ${DEST_DIR} || exit 1
 
-msg Moving the tarball ...
+msg "Moving the tarball ..."
 mv ${TEMPDIR}/${PKGFILE} ${DEST_DIR}/ || exit 1
-if [ ! -z ${DEST_GROUP} ]; then
-    msg Setting group ownership to ${DEST_GROUP}
+if [ ! -z "${DEST_GROUP}" ]; then
+    msg "Setting group ownership to ${DEST_GROUP}"
     chgrp ${DEST_GROUP} ${DEST_DIR}/${PKGFILE}
 fi
 
-cd ${DEST_DIR} || exit 1
-ln -sf ${PKGFILE} "${PKGNAME}-current.${PKGSUFFIX}" || exit 1
+if [ ! -z "${SYMLINK_DIR}" ]; then
+    msg "Setting up symlink to tarball ..."
+    ln -sf ${DEST_DIR}/${PKGFILE} 
"${SYMLINK_DIR}/${PKGNAME}-current.${PKGSUFFIX}" || exit 1
+fi
+
+msg "Cleaning up ${TEMPDIR}"
 rm -rf ${TEMPDIR}
 
 exit 0



-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV



Try Searching:
servers, voip, java, networking, microsoft ...
<Prev in Thread] Current Thread [Next in Thread>