[27262] in Source-Commits

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

scripts commit: Convert dasource and gen-packages from svn to git

daemon@ATHENA.MIT.EDU (Jonathan D Reed)
Thu Sep 5 15:27:25 2013

Date: Thu, 5 Sep 2013 15:27:17 -0400
From: Jonathan D Reed <jdreed@MIT.EDU>
Message-Id: <201309051927.r85JRHXr030348@drugstore.mit.edu>
To: source-commits@MIT.EDU

https://github.com/mit-athena/scripts/commit/227bdf9212354a2fd5bb18f28aa59d2bdd5931d6
commit 227bdf9212354a2fd5bb18f28aa59d2bdd5931d6
Author: Jonathan Reed <jdreed@mit.edu>
Date:   Thu Sep 5 10:53:40 2013 -0400

    Convert dasource and gen-packages from svn to git
    
    * Convert gen-packages to use the git repository, which for now involves
      hard-coding paths and using Github.  It can really only be used by
      someone on debathena-root at this point.
    * gen-packages now writes a packages file that includes the paths (on
      git.mit.edu) to the repositories
    * Convert dasource to use git, and correctly checkout and clean package
      build directories.  We can no longer determine by a pathname whether
      daconfiscate is needed, so we use our best guess, because we're
      phasing that out anyway.
    * dasource will look for old svn checkouts in package build directories
      and kill them if needed

 dasource     |   34 ++++++++++++++---------
 gen-packages |   84 +++++++++++++++++----------------------------------------
 2 files changed, 46 insertions(+), 72 deletions(-)

diff --git a/dasource b/dasource
index 257ae58..d76e96a 100755
--- a/dasource
+++ b/dasource
@@ -27,7 +27,7 @@ usage() {
 }
 : ${DA_SCRIPTS_DIR="$(dirname "$(readlink -f "$0")")"}
 basedir="$DA_SCRIPTS_DIR"
-repo=svn+ssh://svn.mit.edu/athena/trunk
+repo=git+ssh://git.mit.edu
 
 while getopts r: opt; do
   case "$opt" in
@@ -64,13 +64,20 @@ do_package() {
     die "More than one checkout under $pkgname!"
   elif [ -d $pattern ]; then
     dir=$(echo $pattern)
-    echo "Updating and cleaning $dir"
-    (cd $dir && svn update && svn revert -R . &&
-     svn st | awk '/^?/ {print $2}' | xargs rm -vrf)
+    if [ -d "${dir}/.svn" ]; then
+	echo "Old SVN checkout found.  Killing with fire..."
+	rm -rf "$dir"
+	dir=$pkgname/$pkgname
+	echo "Checking out $repo$pkgpath into $dir"
+	git clone $repo$pkgpath $dir
+    else
+	echo "Updating and cleaning $dir"
+	(cd $dir && git checkout -f && git pull)
+    fi
   else
     dir=$pkgname/$pkgname
-    echo "Checking out $repo/$pkgpath into $dir"
-    svn co $repo/$pkgpath $dir
+    echo "Checking out $repo$pkgpath into $dir"
+    git clone $repo$pkgpath $dir
   fi
 
   # Ensure that we're not trying to do something stupid
@@ -93,14 +100,15 @@ do_package() {
     dir=$correctdir
   fi
 
+  # TODO: Sanity-check that the version in configure.ac matches the
+  #       upstream version
+
   # Add autoconf goo if it's an Athena source directory.
-  case $pkgpath in
-  athena/*)
-    if [ -e "$dir/configure.in" ]; then
-	(cd $dir && $basedir/daconfiscate)
-    fi
-    ;;
-  esac
+  # We can no longer determine this from the repo path
+  if [ -e "$dir/configure.in" ] && ! [ -e "$dir/configure.ac" ] \
+      && ! [ -e "$dir/configure" ]; then
+      (cd $dir && $basedir/daconfiscate)
+  fi
 
   # Generate debian/control from debian/control.in if control.in exists
  [ -f "$dir/debian/control.in" ] && echo "NOTE: Obsolete CDBS package -- convert to DH7!"
diff --git a/gen-packages b/gen-packages
index 1c4311b..e201e90 100755
--- a/gen-packages
+++ b/gen-packages
@@ -1,18 +1,10 @@
 #!/bin/sh
 
-# Usage: gen-packages [-c|-r] [LOCATION]
+# Usage: gen-packages
 
 # 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 -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.
+# package names and their corresponding directories.
 
 set -e
 
@@ -22,56 +14,30 @@ die() {
 }
 
 usage() {
-  die "gen-packages [-r|-c] [LOCATION]"
+  die "gen-packages"
 }
 
-type=repos
-
-while getopts cr opt; do
-  case "$opt" in
-  c)
-    type=checkout
-    ;;
-  r)
-    type=repos
-    ;;
-  \?)
-    usage
-    ;;
-  esac
+rm -f packages.git.unsorted
+GITHUB_PREFIX="https://raw.github.com/mit-athena"
+# Change this once submodules are working
+REPOS=$(ssh athenasnap@git.mit.edu "ls -d /git/athena/*.git")
+for repo in $REPOS; do
+  echo "Looking at $repo"
+  repo_base=${repo%.git}
+  repo_base=${repo_base#/git/athena/}
+  URI="${GITHUB_PREFIX}/${repo_base}/master/debian/control"
+  name=$(curl -sf "$URI" | sed -ne 's/^Source: \(.*\)$/\1/p')
+  if [ -n "$name" ]; then
+    printf "%-35s %s\n" $name $repo >> packages.git.unsorted
+    continue
+  fi
+  name=$(curl -sf "${URI}.in" | sed -ne 's/^Source: \(.*\)$/\1/p')
+  if [ -n "$name" ]; then
+    printf "%-35s %s\n" $name $repo >> packages.git.unsorted
+    continue
+  fi
+  echo "** Couldn't find a control or control.in file!  Skipping..."
 done
 
-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
-echo "Scanning file list of $loc"
-if [ $type = repos ]; then
-  for cf in $(svn ls -R $loc | egrep 'debian/control(\.in)*$'); do
-    echo "Reading $cf"
-    name=$(svn cat $loc/$cf | sed -ne 's/^Source: \(.*\)$/\1/p')
-    dir=${cf%.in}
-    dir=${dir%/debian/control}
-    printf "%-35s %s\n" $name $dir >> packages.unsorted
-  done
-else
-  for cf in $(cd $loc && find | egrep 'debian/control(\.in)*$' \
-      | sed -ne 's/^\.\///p'); do
-    echo "Reading $cf"
-    name=$(sed -ne 's/^Source: \(.*\)$/\1/p' $loc/$cf)
-    dir=${cf%.in}
-    dir=${dir%/debian/control}
-    printf "%-35s %s\n" $name $dir >> packages.unsorted
-  done
-fi
-
-# cyrus-sasl2-mit has a debian dir but is really a debathenify package.
-# config-package dev has some example packages we want to filter out.
-sort -u packages.unsorted | egrep -v "cyrus-sasl2-mit|/examples/" > packages
-rm -f packages.unsorted
+sort -u packages.git.unsorted > packages.git
+rm -f packages.git.unsorted

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