[Blends-commit] r3273 - in /blends/trunk/machine_readable: ./ fetch-machine-readable

tille at users.alioth.debian.org tille at users.alioth.debian.org
Thu Apr 5 19:20:14 UTC 2012


Author: tille
Date: Thu Apr  5 19:20:12 2012
New Revision: 3273

URL: http://svn.debian.org/wsvn/blends/?sc=1&rev=3273
Log:
Script which fetches all machine readable files in certain VCSes

Added:
    blends/trunk/machine_readable/
    blends/trunk/machine_readable/fetch-machine-readable   (with props)

Added: blends/trunk/machine_readable/fetch-machine-readable
URL: http://svn.debian.org/wsvn/blends/blends/trunk/machine_readable/fetch-machine-readable?rev=3273&op=file
==============================================================================
--- blends/trunk/machine_readable/fetch-machine-readable (added)
+++ blends/trunk/machine_readable/fetch-machine-readable Thu Apr  5 19:20:12 2012
@@ -1,0 +1,110 @@
+#!/bin/sh
+# This script should be called on Alioth to gather all machine readable files
+# of VCSes mentioned in SVNDIRS and GITDIRS
+#
+# TODO: store file <pkg>.vcs with the Vcs URL where the files were found
+
+MACHINEREADABLEARCHIVE=/srv/home/groups/blends/htdocs/upstream/machine-readable_no-clone.tar.bz2
+TDNAME=machine-readable-files
+TARGETDIR=${HOME}/$TDNAME
+mkdir -p $TARGETDIR
+
+SVNDIRS="debian-med/trunk/packages
+         debian-science/packages
+         debichem/unstable"
+
+GITDIRS="debian-med
+         debian-science/packages
+         pkg-exppsy"
+
+svn_checkout_machine_readable () {
+  curdir=`pwd`
+  cd $TARGETDIR
+  TMPLIST=`mktemp`
+  svn list --verbose svn://localhost/$1 --recursive | \
+    grep -v -e '/tags/' -e '/branches/' -e '/patches/' | \
+    grep -e "control$" -e "changelog$" -e "copyright$" -e "upstream$" | \
+    sed 's/^.*[[:space:]]\([^[:space:]]\+\)/\1/' \
+    > $TMPLIST
+  # debug
+  # cp -a $TMPLIST ~/_svnfiles
+  PKGLIST=`mktemp`
+  # Regard different directory layout options
+  if grep -q "/trunk/debian/" $TMPLIST ; then
+    # for Debian Med and Debian Science layout
+    sed 's?/trunk/debian/.*??' $TMPLIST | sed 's?^.*/\([^/]\+\)?\1?' | sort | uniq > $PKGLIST
+  else
+    # for DebiChemn layout
+    sed 's?/debian/.*??' $TMPLIST | sort | uniq > $PKGLIST
+  fi
+#  set -x
+  for pkg in `cat $PKGLIST` ; do
+    chlog=`grep -e "/$pkg/trunk/debian/changelog$" -e "^$pkg/trunk/debian/changelog$" -e "^$pkg/debian/changelog$" $TMPLIST 2>/dev/null`
+    if [ "" != "$chlog" ] ; then
+      svn export svn://localhost/$1/$chlog >/dev/null
+      srcname=`dpkg-parsechangelog -lchangelog 2>/dev/null | sed -n 's/^Source: //p'`
+      if [ "" != "$srcname" ] ; then
+        firstletter=`echo $srcname | sed "s/^\(.\).*/\1/"`
+        mkdir -p $TARGETDIR/$firstletter
+        mv changelog $TARGETDIR/$firstletter/${srcname}.changelog
+        for file in control copyright upstream ; do
+          getfile=`grep -e "/$pkg/trunk/debian/$file$" -e "^$pkg/trunk/debian/$file$" -e "^$pkg/debian/$file$" $TMPLIST 2>/dev/null`
+          if [ "" != "$getfile" ] ; then
+            svn export svn://localhost/$1/$getfile >/dev/null
+            mv $file $TARGETDIR/$firstletter/${srcname}.$file
+          fi
+        done
+      else
+        echo "Can not parse changelog for source name of $pkg"
+        mv changelog ${pkg}.broken.changelog
+      fi
+    else
+      echo "No changelog found for $pkg"
+      cp -a $TMPLIST ~/_changelog_for_${pkg}_missing
+      cp -a $PKGLIST ~/_pkglist_for_${pkg}_missing
+    fi
+  done
+  rm $TMPLIST $PKGLIST
+  cd $curdir
+}
+
+git_checkout_machine_readable () {
+  curdir=`pwd`
+  cd $1
+  TMPCHLOG=`mktemp`
+  if git show HEAD:debian/changelog 2>/dev/null > $TMPCHLOG ; then
+    srcname=`dpkg-parsechangelog -l$TMPCHLOG 2>/dev/null | sed -n 's/^Source: //p'`
+    firstletter=`echo $srcname | sed "s/^\(.\).*/\1/"`
+    mkdir -p $TARGETDIR/$firstletter
+    mv $TMPCHLOG $TARGETDIR/$firstletter/${srcname}.changelog
+    for file in `git ls-tree master debian/ 2>/dev/null | grep -e control -e changelog -e copyright -e upstream | sed 's/^[0-9]\+[[:space:]]\+blob[[:space:]]\+[0-9a-f]\+[[:space:]]\+//'` ; do
+      target=$TARGETDIR/$firstletter/${srcname}.`echo $file | sed 's?debian/??'`
+      git show HEAD:$file > $target
+    done
+  else
+    echo "Can not find debian/changelog in $1"
+  fi
+  cd $curdir
+}
+
+mkdir -p $TARGETDIR
+rm -rf $TARGETDIR/*
+
+for svndir in $SVNDIRS ; do
+  svn_checkout_machine_readable $svndir
+done
+
+for gitdir in $GITDIRS ; do
+  echo $gitdir
+  for gitrepo in `find /git/$gitdir -mindepth 1 -maxdepth 1 -type d -name "*.git"` ; do
+    echo $gitrepo
+    if [ "$gitrepo" != ".git" ] ; then
+      git_checkout_machine_readable $gitrepo
+    fi
+  done
+done
+
+rm -f $MACHINEREADABLEARCHIVE
+cd $TARGETDIR
+cd ..
+tar -cjf $MACHINEREADABLEARCHIVE $TDNAME

Propchange: blends/trunk/machine_readable/fetch-machine-readable
------------------------------------------------------------------------------
    svn:executable = *




More information about the Blends-commit mailing list