[23110] in Source-Commits

home help back first fref pref prev next nref lref last post

/svn/athena r22773 - trunk/debathena/scripts

daemon@ATHENA.MIT.EDU (ghudson@MIT.EDU)
Fri Feb 29 13:33:58 2008

Date: Fri, 29 Feb 2008 13:33:28 -0500 (EST)
From: ghudson@MIT.EDU
Message-Id: <200802291833.NAA02089@drugstore.mit.edu>
To: source-commits@MIT.EDU
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Author: ghudson
Date: 2008-02-29 13:33:27 -0500 (Fri, 29 Feb 2008)
New Revision: 22773

Modified:
   trunk/debathena/scripts/gen-packages
Log:
* debathena/scripts/gen-packages: Add a -c flag to scan a checkout
  instead of the repository, which is much faster but reliant on the
  up-to-dateness of the checkout.


Modified: trunk/debathena/scripts/gen-packages
===================================================================
--- trunk/debathena/scripts/gen-packages	2008-02-28 23:23:13 UTC (rev 22772)
+++ trunk/debathena/scripts/gen-packages	2008-02-29 18:33:27 UTC (rev 22773)
@@ -1,14 +1,19 @@
 #!/bin/sh
 
-# Usage: gen-packages [-r REPOS]
+# Usage: gen-packages [-c|-r] [LOCATION]
 
-# Scans the repository and generates a file named "packages" in the
-# current directory containing a table of source package names and
-# their corresponding directories.
+# Scans the repository or a checkout of it and generates a file named
+# "packages" in the current directory containing a table of source
+# package names and their corresponding directories.  Scanning a
+# checkout is much faster, but relies on the checkout being
+# sufficiently up to date.
 
-# If REPOS is specified, it is used in preference to the canonical
-# Athena repository trunk.
+# If -c is specified, scans a checkout.  If -r is specified, scans the
+# repository.  -r is the default.
 
+# If LOCATION is specified, it is used in preference to the canonical
+# Athena repository trunk or the canonical source checkout.
+
 set -e
 
 die() {
@@ -17,15 +22,18 @@
 }
 
 usage() {
-  die "gen-packages [-r repos]"
+  die "gen-packages [-r|-c] [LOCATION]"
 }
 
-repo=svn+ssh://svn.mit.edu/athena/trunk
+type=repos
 
-while getopts r: opt; do
+while getopts cr opt; do
   case "$opt" in
+  c)
+    type=checkout
+    ;;
   r)
-    type="$OPTARG"
+    type=repos
     ;;
   \?)
     usage
@@ -33,13 +41,31 @@
   esac
 done
 
-echo "Scanning file list of $repo"
+shift $(($OPTIND - 1))
+if [ $# -gt 0 ]; then
+  loc=$1
+elif [ $type = repos ]; then
+  loc=svn+ssh://svn.mit.edu/athena/trunk
+else
+  loc=/afs/dev.mit.edu/source/src-svn
+fi
+
 rm -f packages.unsorted
-for control in $(svn ls -R $repo | grep 'debian/control$'); do
-  echo "Reading $control"
-  name=$(svn cat $repo/$control | sed -ne 's/^Source: \(.*\)$/\1/p')
-  dir=${control%/debian/control}
-  printf "%-35s %s\n" $name $dir >> packages.unsorted
-done
+echo "Scanning file list of $loc"
+if [ $type = repos ]; then
+  for cf in $(svn ls -R $loc | grep 'debian/control$'); do
+    echo "Reading $cf"
+    name=$(svn cat $loc/$cf | sed -ne 's/^Source: \(.*\)$/\1/p')
+    dir=${cf%/debian/control}
+    printf "%-35s %s\n" $name $dir >> packages.unsorted
+  done
+else
+  for cf in $(cd $loc && find | sed -ne '/debian\/control$/s/^\.\///p'); do
+    echo "Reading $cf"
+    name=$(sed -ne 's/^Source: \(.*\)$/\1/p' $loc/$cf)
+    dir=${cf%/debian/control}
+    printf "%-35s %s\n" $name $dir >> packages.unsorted
+  done
+fi
 sort packages.unsorted > packages
 rm -f packages.unsorted


home help back first fref pref prev next nref lref last post