r13847 - /scripts/qa/packagecheck

dmn at users.alioth.debian.org dmn at users.alioth.debian.org
Tue Jan 29 21:03:00 UTC 2008


Author: dmn
Date: Tue Jan 29 21:03:00 2008
New Revision: 13847

URL: http://svn.debian.org/wsvn/?sc=1&rev=13847
Log:
* make the checking subroutines accept a directory, instead of a package
  name that is then appended to $TRUNK
* add new option "-c" -- checks the package that is checked out in the current
  working directory
* fix bashism (${var_name/search/repl})

Modified:
    scripts/qa/packagecheck

Modified: scripts/qa/packagecheck
URL: http://svn.debian.org/wsvn/scripts/qa/packagecheck?rev=13847&op=diff
==============================================================================
--- scripts/qa/packagecheck (original)
+++ scripts/qa/packagecheck Tue Jan 29 21:03:00 2008
@@ -35,62 +35,68 @@
 	echo "  -A       - all checks"
 	echo "  -h       - this help"
 	echo "  -p PKG   - test only this one package"
+	echo "  -c       - test only the package that is checked out in the"
+	echo "             current working directory"
 	exit 1
 }
 
 testvcs() {
+	dir=$1
+	pkg=`basename \`realpath $dir\``
 	# check for and add missing Vcs-Svn field
-	if ! grep ^Vcs-Svn $TRUNK/$1/debian/control > /dev/null; then
-		echo "$1: adding missing Vcs-Svn field"
-		perl -pi -e "s;(Standards-Version:.+);\$1\nVcs-Svn: svn://svn.debian.org/pkg-perl/trunk/$1/;" $TRUNK/$1/debian/control
+	if ! grep ^Vcs-Svn $dir/debian/control > /dev/null; then
+		echo "$pkg: adding missing Vcs-Svn field"
+		perl -pi -e "s;(Standards-Version:.+);\$1\nVcs-Svn: svn://svn.debian.org/pkg-perl/trunk/$pkg/;" $dir/debian/control
 		MSG_CONTROL_ADD="${MSG_CONTROL_ADD:+$MSG_CONTROL_ADD; }Vcs-Svn field (source stanza)"
 		CHANGED=1
 	fi
 
 	# check for and add missing Vcs-Browser field
-	if ! grep ^Vcs-Browser $TRUNK/$1/debian/control > /dev/null; then
-		echo "$1: adding missing Vcs-Browser field"
-		perl -pi -e "s;(^Vcs-Svn:.+);\$1\nVcs-Browser: http://svn.debian.org/wsvn/pkg-perl/trunk/$1/;" $TRUNK/$1/debian/control
+	if ! grep ^Vcs-Browser $dir/debian/control > /dev/null; then
+		echo "$pkg: adding missing Vcs-Browser field"
+		perl -pi -e "s;(^Vcs-Svn:.+);\$1\nVcs-Browser: http://svn.debian.org/wsvn/pkg-perl/trunk/$pkg/;" $dir/debian/control
 		MSG_CONTROL_ADD="${MSG_CONTROL_ADD:+$MSG_CONTROL_ADD; }Vcs-Browser field (source stanza)"
 		CHANGED=1
 	fi
 
 	# remove old XS-Vcs-(Svn|Browser) fields
-	if grep ^XS-Vcs- $TRUNK/$1/debian/control > /dev/null; then
-		echo "$1: removing old XS-Vcs-* fields"
-		sed -i -e '/^XS-Vcs-/ d' $TRUNK/$1/debian/control
+	if grep ^XS-Vcs- $dir/debian/control > /dev/null; then
+		echo "$pkg: removing old XS-Vcs-* fields"
+		sed -i -e '/^XS-Vcs-/ d' $dir/debian/control
 		MSG_CONTROL_RM="${MSG_CONTROL_RM:+$MSG_CONTROL_RM; }XS-Vcs-Svn fields (source stanza)"
 		CHANGED=1
 	fi
 }
 
 testhomepage() {
+	dir=$1
+	pkg=`basename \`realpath $dir\``
 	# check for and remove old Homepage from long description
-	OLDHP=$(egrep "^  Homepage: " $TRUNK/$1/debian/control | egrep -o "http.+")
+	OLDHP=$(egrep "^  Homepage: " $dir/debian/control | egrep -o "http.+")
 	if [ -n "$OLDHP" ] ; then
-		echo "$1: removing Homepage: pseudo-field from Description"
-		perl -e "undef \$/; my \$buf=<STDIN>; \$buf =~ s/\n \.\n  Homepage: .*//; print \$buf" < $TRUNK/$1/debian/control > $TRUNK/$1/debian/control.new
-		mv $TRUNK/$1/debian/control.new $TRUNK/$1/debian/control
+		echo "$pkg: removing Homepage: pseudo-field from Description"
+		perl -e "undef \$/; my \$buf=<STDIN>; \$buf =~ s/\n \.\n  Homepage: .*//; print \$buf" < $dir/debian/control > $dir/debian/control.new
+		mv $dir/debian/control.new $dir/debian/control
 		MSG_CONTROL_RM="${MSG_CONTROL_RM:+$MSG_CONTROL_RM; }Homepage pseudo-field (Description)"
 		CHANGED=1
 		NEWHP=$OLDHP
 	fi
 
 	# check for and add missing new Homepage to source stanza
-	if ! egrep "^Homepage: " $TRUNK/$1/debian/control > /dev/null; then
-		echo "$1: trying to add missing Homepage field to source stanza"
+	if ! egrep "^Homepage: " $dir/debian/control > /dev/null; then
+		echo "$pkg: trying to add missing Homepage field to source stanza"
 		
 		# only construct new URL if we don't have a "real one"
 		if [ -z "$NEWHP" ] || echo "$NEWHP" | grep cpan\.org > /dev/null; then
 			# try to construct canonical URL
-			if [ -s $TRUNK/$1/Build.PL ]; then 
-				PERLNAME=$(perl -n -e "print if s;^.*module_name.*=>.*['\"[]([a-zA-Z0-9:_-]+)[]'\"].*\$;\$1;" $TRUNK/$1/Build.PL | sed -e 's/::/-/g' | head -n 1)
-			fi
-			if [ -s $TRUNK/$1/Makefile.PL ]; then 
-				PERLNAME=$(perl -n -e "print if s;^.*(?:DIST)?NAME.*=>.*['\"[]([a-zA-Z0-9:_-]+)[]'\"].*\$;\$1;" $TRUNK/$1/Makefile.PL | sed -e 's/::/-/g' | head -n 1)
-			fi
-			if [ -s $TRUNK/$1/META.yml ]; then 
-				PERLNAME=$(perl -n -e "print if s;^name:.* ([a-zA-Z0-9:_-]+).*\$;\$1;" $TRUNK/$1/META.yml | head -n 1)
+			if [ -s $dir/Build.PL ]; then 
+				PERLNAME=$(perl -n -e "print if s;^.*module_name.*=>.*['\"[]([a-zA-Z0-9:_-]+)[]'\"].*\$;\$1;" $dir/Build.PL | sed -e 's/::/-/g' | head -n 1)
+			fi
+			if [ -s $dir/Makefile.PL ]; then 
+				PERLNAME=$(perl -n -e "print if s;^.*(?:DIST)?NAME.*=>.*['\"[]([a-zA-Z0-9:_-]+)[]'\"].*\$;\$1;" $dir/Makefile.PL | sed -e 's/::/-/g' | head -n 1)
+			fi
+			if [ -s $dir/META.yml ]; then 
+				PERLNAME=$(perl -n -e "print if s;^name:.* ([a-zA-Z0-9:_-]+).*\$;\$1;" $dir/META.yml | head -n 1)
 			fi
 			if [ -n "$PERLNAME" ]; then
 				if curl --silent http://search.cpan.org/dist/$PERLNAME/ | grep '<title>.*</title>' | grep --silent $PERLNAME; then
@@ -103,7 +109,7 @@
 		fi
 		
 		if [ -n "$NEWHP" ]; then
-			perl -pi -e "s;(Standards-Version:.+);\$1\nHomepage: $NEWHP;" $TRUNK/$1/debian/control
+			perl -pi -e "s;(Standards-Version:.+);\$1\nHomepage: $NEWHP;" $dir/debian/control
 			MSG_CONTROL_ADD="${MSG_CONTROL_ADD:+$MSG_CONTROL_ADD; }Homepage field (source stanza)"
 			CHANGED=1
 		fi
@@ -112,19 +118,21 @@
 }
 
 testmaintainer() {
+	dir=$1
+	pkg=`basename \`realpath $dir\``
 	# get Maintainer, check and change
-	OLDMAINT=$(grep ^Maintainer: $TRUNK/$1/debian/control | cut -f2- -d" ")
+	OLDMAINT=$(grep ^Maintainer: $dir/debian/control | cut -f2- -d" ")
 	if [ "$OLDMAINT" != "Debian Perl Group <pkg-perl-maintainers at lists.alioth.debian.org>" ] ; then
-		echo "$1: setting Maintainer to Debian Perl Group <pkg-perl-maintainers at lists.alioth.debian.org>"
-		perl -pi -e "s;^Maintainer:.+;Maintainer: Debian Perl Group <pkg-perl-maintainers\@lists.alioth.debian.org>;" $TRUNK/$1/debian/control
+		echo "$pkg: setting Maintainer to Debian Perl Group <pkg-perl-maintainers at lists.alioth.debian.org>"
+		perl -pi -e "s;^Maintainer:.+;Maintainer: Debian Perl Group <pkg-perl-maintainers\@lists.alioth.debian.org>;" $dir/debian/control
 		MSG_CONTROL_CH="${MSG_CONTROL_CH:+$MSG_CONTROL_CH; }Maintainer set to Debian Perl Group <pkg-perl-maintainers at lists.alioth.debian.org> (was: $OLDMAINT)"
 		# keep old Maintainer in Uploaders unless it's the group in some other form
 		# TODO: remove DPG from Uploaders if we've added it to Maintainer
 		if ! echo $OLDMAINT | grep pkg-perl-maintainers ; then
-			if grep Uploaders $TRUNK/$1/debian/control > /dev/null; then
-				perl -pi -e "s;(Uploaders:.+);\$1, ${OLDMAINT/@/\@};" $TRUNK/$1/debian/control
+			if grep Uploaders $dir/debian/control > /dev/null; then
+				perl -pi -e "BEGIN { our \$m=shift @ARVG }; s;(Uploaders:.+);\$1, \$m;" "$OLDMAINT" $dir/debian/control
 			else
-				perl -pi -e "s;(Maintainer:.+);\$1\nUploaders: ${OLDMAINT/@/\@};" $TRUNK/$1/debian/control
+				perl -pi -e "BEGIN { our \$m=shift @ARGV }; s;(Maintainer:.+);\$1\nUploaders: \$m;" "${OLDMAINT}" $dir/debian/control
 			fi
 			MSG_CONTROL_CH="${MSG_CONTROL_CH:+$MSG_CONTROL_CH; }$OLDMAINT moved to Uploaders"
 		fi
@@ -133,11 +141,13 @@
 }
 
 testwatchdist() {
+	dir=$1
+	pkg=`basename \`realpath $dir\``
 	# watchfile
-	if [ -e $TRUNK/$1/debian/watch ] && ! grep search\.cpan\.org/dist/ $TRUNK/$1/debian/watch >/dev/null; then
-		echo "$1: trying to change URL in debian/watch"
-		if perl -i -e "my \$changed=1; while(<>){ \$changed=0 if s{(?:^|\s+)(?:ht|f)tp://.*cpan.+/\s*(\S+)-(?:\S+)(\s.+)?$}{http://search.cpan.org/dist/\$1/   .*/\$1-v?(\\\\d[\\\\d_.]+)\\\\.(?:tar(?:\\\\.gz|\\\\.bz2)?|tgz|zip)\$2}i; print;} exit \$changed" $TRUNK/$1/debian/watch ; then
-			perl -pi -e "s;^version=2;version=3;" $TRUNK/$1/debian/watch
+	if [ -e $dir/debian/watch ] && ! grep search\.cpan\.org/dist/ $dir/debian/watch >/dev/null; then
+		echo "$pkg: trying to change URL in debian/watch"
+		if perl -i -e "my \$changed=1; while(<>){ \$changed=0 if s{(?:^|\s+)(?:ht|f)tp://.*cpan.+/\s*(\S+)-(?:\S+)(\s.+)?$}{http://search.cpan.org/dist/\$1/   .*/\$1-v?(\\\\d[\\\\d_.]+)\\\\.(?:tar(?:\\\\.gz|\\\\.bz2)?|tgz|zip)\$2}i; print;} exit \$changed" $dir/debian/watch ; then
+			perl -pi -e "s;^version=2;version=3;" $dir/debian/watch
 			MSG_WATCH="debian/watch: use dist-based URL."
 			CHANGED=1
 		fi
@@ -145,9 +155,11 @@
 }
 
 testrmdir() {
+	dir=$1
+	pkg=`basename \`realpath $dir\``
 	# handle rmdir /usr/{share,lib}/perl5
-	if egrep -m 1 "(rmdir.*ignore-fail-on-non-empty|rm -r.*usr/(lib|share)(/perl5)?$)" $TRUNK/$1/debian/rules | grep -v "\[ \! -d" > /dev/null ; then
-		ARCH=$(grep -m 1 -h "Architecture:" $TRUNK/$1/debian/control | awk '{print $2;}')
+	if egrep -m 1 "(rmdir.*ignore-fail-on-non-empty|rm -r.*usr/(lib|share)(/perl5)?$)" $dir/debian/rules | grep -v "\[ \! -d" > /dev/null ; then
+		ARCH=$(grep -m 1 -h "Architecture:" $dir/debian/control | awk '{print $2;}')
 		case $ARCH in
 			any)
 				DELDIR="/share/perl5"
@@ -158,12 +170,12 @@
 			*)
 				;;
 		esac
-		echo "$1: trying to make rmdir /usr${DELDIR} conditional"
-		if perl -i -e "my \$changed=1; while(<>){ \$changed=0 if s{rmdir.*ignore-fail-on-non-empty.*\s(\S+)$DELDIR}{[ ! -d \$1${DELDIR} ] || rmdir --ignore-fail-on-non-empty --parents --verbose \$1${DELDIR}}; print;} exit \$changed" $TRUNK/$1/debian/rules ; then
+		echo "$pkg: trying to make rmdir /usr${DELDIR} conditional"
+		if perl -i -e "my \$changed=1; while(<>){ \$changed=0 if s{rmdir.*ignore-fail-on-non-empty.*\s(\S+)$DELDIR}{[ ! -d \$1${DELDIR} ] || rmdir --ignore-fail-on-non-empty --parents --verbose \$1${DELDIR}}; print;} exit \$changed" $dir/debian/rules ; then
 			MSG_RULES="debian/rules: delete /usr${DELDIR} only if it exists." && \
 			CHANGED=1
 		fi
-		if perl -i -e "my \$changed=1; while(<>){ \$changed=0 if s{-?rm -r.* (.*usr)/(?:lib|share)(?:/perl5)?\$}{[ ! -d \$1${DELDIR} ] || rmdir --ignore-fail-on-non-empty --parents --verbose \$1${DELDIR}}; print;} exit \$changed" $TRUNK/$1/debian/rules ; then
+		if perl -i -e "my \$changed=1; while(<>){ \$changed=0 if s{-?rm -r.* (.*usr)/(?:lib|share)(?:/perl5)?\$}{[ ! -d \$1${DELDIR} ] || rmdir --ignore-fail-on-non-empty --parents --verbose \$1${DELDIR}}; print;} exit \$changed" $dir/debian/rules ; then
 			MSG_RULES="debian/rules: delete /usr${DELDIR} only if it exists." && \
 			CHANGED=1
 		fi
@@ -183,10 +195,15 @@
 
 [ $# -ge 1 ] || usage "No parameter."
 
-while getopts p:VHMWRAh O; do
+ONLY_CURDIR=""
+
+while getopts p:cVHMWRAh O; do
 	case "$O" in
 		p)
 			PKG=$OPTARG
+			;;
+		c)
+			ONLY_CURDIR=1
 			;;
 		V)
 			TESTVCS=1
@@ -257,13 +274,13 @@
 		[ -n "$MSG_CONTROL_ADD" ] && MSG_CONTROL="$MSG_CONTROL Added: $MSG_CONTROL_ADD."
 		[ -n "$MSG_CONTROL_RM" ] && MSG_CONTROL="$MSG_CONTROL Removed: $MSG_CONTROL_RM."
 		[ -n "$MSG_CONTROL_CH" ] && MSG_CONTROL="$MSG_CONTROL Changed: $MSG_CONTROL_CH."
-		dch --mainttrailer --release-heuristic=changelog --changelog $TRUNK/$p/debian/changelog "$MSG_CONTROL"
+		dch --mainttrailer --release-heuristic=changelog --changelog $p/debian/changelog "$MSG_CONTROL"
 	fi
 	if [ -n "$MSG_WATCH" ] ; then
-		dch --mainttrailer --release-heuristic=changelog --changelog $TRUNK/$p/debian/changelog "$MSG_WATCH"
+		dch --mainttrailer --release-heuristic=changelog --changelog $p/debian/changelog "$MSG_WATCH"
 	fi
 	if [ -n "$MSG_RULES" ] ; then
-		dch --mainttrailer --release-heuristic=changelog --changelog $TRUNK/$p/debian/changelog "$MSG_RULES"
+		dch --mainttrailer --release-heuristic=changelog --changelog $p/debian/changelog "$MSG_RULES"
 	fi
 }
 
@@ -272,13 +289,14 @@
 CHANGED=0
 TRUNK=${1:-trunk}
 
-if [ -n "$PKG" ]; then
+if [ -n "$ONLY_CURDIR" ]; then
+	WORK_DIR="."
+elif [ -n "$PKG" ]; then
 	WORK_DIR=$TRUNK/$PKG
 else
 	WORK_DIR=$TRUNK
 fi
 
-# package given. work only with it, not all trunk
 echo "Running svn up $WORK_DIR ..."
 svn up $WORK_DIR
 
@@ -289,8 +307,10 @@
 	echo WARNING: $WORK_DIR is not clean
 fi
 
-if [ -n "$PKG" ]; then
-	check_package $PKG
+if [ -n "$ONLY_CURDIR" ]; then
+	check_package .
+elif [ -n "$PKG" ]; then
+	check_package $TRUNK/$PKG
 else
 	# loop over packages
 
@@ -298,7 +318,7 @@
 	for PKG in $(svn ls $TRUNK); do 
 
 		PKG=${PKG%/}
-		check_package $PKG
+		check_package $TRUNK/$PKG
 
 	done
 fi




More information about the Pkg-perl-cvs-commits mailing list