From 198610ffe4e0d28d999c9ed2209668cd6c7bd9ff Mon Sep 17 00:00:00 2001 From: Jonas Smedegaard Date: Wed, 26 Dec 2007 15:29:27 +0000 Subject: Use new function debugprint(). --- localdebpool | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) (limited to 'localdebpool') diff --git a/localdebpool b/localdebpool index 3361858..25dfb3b 100755 --- a/localdebpool +++ b/localdebpool @@ -11,6 +11,12 @@ PRVBASE=~/public_debian PUBBASE=~/public_websites/debian.jones.dk #PUBTOSRC=../../public_debian +debugprint() { + [ -n "$DEBUG" ] || return 0 + [ -z "$2" ] || [ "$DEBUG" -lt "$2" ] || return 0 + echo 1>&2 "$1" +} + compactlist() { ( for item in $@; do echo $item; done ) \ | sort -u \ @@ -41,13 +47,13 @@ archsfromdirs() { | sed 's/^.*_\([a-z0-9-]\+\)\.deb$/\1/; s/\ball\b/'"$ARCHS"'/g' \ )" archs="$(compactlist $archs)" - [ -z "$DEBUG" ] || [ "$DEBUG" -lt 2 ] || echo 1>&2 "Archs found: \"$archs\"" + debugprint "Archs found: \"$archs\"" "2" for arch in $archs; do valid= for arch_supported in $ARCHS; do case $arch in $arch_supported) - [ -z "$DEBUG" ] || [ "$DEBUG" -lt 2 ] || echo 1>&2 "Arch ok: \"$arch\"" + debugprint "Arch ok: \"$arch\"" "2" echo "$arch" valid=1 ;; @@ -67,13 +73,13 @@ distsfromprvgrpdirs() { | sed 's,^.*/sections/[^/]*/\([^/]\+\)/.*$,\1,' \ )" dists="$(compactlist $dists)" - [ -z "$DEBUG" ] || [ "$DEBUG" -lt 2 ] || echo 1>&2 "Dists found: \"$dists\"" + debugprint "Dists found: \"$dists\"" "2" for dist in $dists; do valid= for dist_supported in $DISTS; do case $dist in $dist_supported) - [ -z "$DEBUG" ] || [ "$DEBUG" -lt 2 ] || echo 1>&2 "Dist ok: \"$dist\"" + debugprint "Dist ok: \"$dist\"" "2" echo "$dist" valid=1 ;; @@ -105,10 +111,10 @@ genlist() { ;; esac mkdir -p "$destdir" - [ -z "$DEBUG" ] || [ "$DEBUG" -lt 2 ] || echo 1>&2 "genlist: \"$cmd . /dev/null pkg/\"" + debugprint "genlist: \"$cmd . /dev/null pkg/\"" "2" ( cd "$srcdir" && $cmd . /dev/null pkg/ ) > "$destdir/$file" if [ -s "$destdir/$file" ]; then - [ -z "$DEBUG" ] || [ "$DEBUG" -lt 2 ] || echo 1>&2 "Finalizing list at \"$destdir/\"" + debugprint "Finalizing list at \"$destdir/\"" "2" gzip -c "$destdir/$file" > "$destdir/$file.gz" bzip2 -c "$destdir/$file" > "$destdir/$file.bz2" cat < "$destdir/Release" @@ -119,7 +125,7 @@ Label: $LABEL Architecture: $arch EOF else - [ -z "$DEBUG" ] || [ "$DEBUG" -lt 2 ] || echo 1>&2 "purge empty list at \"$destdir/\"" + debugprint "purge empty list at \"$destdir/\"" "2" rm -f "$destdir/$file" "$destdir/$file.gz" "$destdir/$file.bz2" "$destdir/Release" rmdir -p --ignore-fail-on-non-empty "$destdir" fi @@ -148,7 +154,7 @@ EOF packages="$@" packages="$(compactlist $packages)" -[ -z "$DEBUG" ] || echo 1>&2 "Packages: \"$packages\"" +debugprint "Packages: \"$packages\"" case "$packages" in -a|--all) @@ -168,7 +174,7 @@ batchsections="$( \ | sectionsfromhintstream )" batchsections="$(compactlist $batchsections)" -[ -z "$DEBUG" ] || echo 1>&2 "Sections in batch: \"$batchsections\"" +debugprint "Sections in batch: \"$batchsections\"" batchsections_re= if [ -n "$batchsections" ]; then @@ -186,7 +192,7 @@ fi # cd "$PRVBASE" && find * -type f -name HINTS -exec grep -q "^Sections:.*$batchsections_re" '{}' ';' -printf '%h\n' \ | while read prvpkgdir; do - [ -z "$DEBUG" ] || echo 1>&2 "prvpkgdir: \"$prvpkgdir\"" + debugprint "prvpkgdir: \"$prvpkgdir\"" set -- $(pkginfofromprvpkgdir "$prvpkgdir") package="$1" pool="$2" dist="$3" buildhost="$4" shift 4 @@ -208,7 +214,7 @@ done for section in $batchsections; do dists="$(distsfromprvgrpdirs "$PRVBASE/sections/$section")" for dist in $dists; do - [ -z "$DEBUG" ] || echo 1>&2 "genlists \"\$PRVBASE/sections/$section/$dist\" -> \"\$PUBBASE/dists/$dist/$section\"" + debugprint "genlists \"\$PRVBASE/sections/$section/$dist\" -> \"\$PUBBASE/dists/$dist/$section\"" prvgrpdir="$PRVBASE/sections/$section/$dist" pubpkgdir="$PUBBASE/dists/$dist/$section" archs="$(archsfromdirs "$prvgrpdir")" @@ -228,7 +234,7 @@ allsections="$( \ | sectionsfromhintstream )" allsections="$(compactlist $allsections)" -[ -z "$DEBUG" ] || echo 1>&2 "All sections: \"$allsections\"" +debugprint "All sections: \"$allsections\"" dists="$(distsfromprvgrpdirs "$PRVBASE/sections")" dists="$(compactlist $dists)" -- cgit v1.2.3