From f68e5a58b62200c0014487372645b1ceda9f63d5 Mon Sep 17 00:00:00 2001 From: Werner Almesberger Date: Wed, 6 Oct 2010 03:35:46 -0300 Subject: [PATCH] Option -D to keep temporary work trees for analysis/debugging. - schhist/gitsch2ps: option -D to give _gitsch2ps a unique name, to copy the Postscript files instead of moving them, and to refrain from deleting _gitsch2ps - schhist/schhist2web: option -D to refrain from deleting _gitsch2ps and to pass -D to gitsch2ps --- schhist/gitsch2ps | 19 ++++++++++++++++--- schhist/schhist2web | 14 +++++++++++--- 2 files changed, 27 insertions(+), 6 deletions(-) diff --git a/schhist/gitsch2ps b/schhist/gitsch2ps index afd2f68..5f9f803 100755 --- a/schhist/gitsch2ps +++ b/schhist/gitsch2ps @@ -19,6 +19,7 @@ usage: $0 [options] top-dir top-schem [commit] outdir -c keep .lib.cache (default: delete it) -k keep the temporary directory and print its name + -D debug mode: make temporary work tree unique and keep it -S sanitize the KiCad profile and the top-level sheet EOF exit 1 @@ -29,12 +30,16 @@ sanitize_profile=true sanitize_schem=true keep=false cache=false +debug=false + while true; do case "$1" in -c) cache=true shift;; -k) keep=true shift;; + -D) debug=true; + shift;; -S) sanitize_profile=`PATH="$PATH":\`dirname "$0"\` which sanitize-profile` [ "$sanitize_profile" = "${sanitize_profile#/}" ] && sanitize_profile=`pwd`/"$sanitize_profile" @@ -66,7 +71,11 @@ fi [ "$commit" != HEAD -o -f "$dir/$schem" ] || usage [ -d "$dir/.git" ] || usage -tmp="$dir/../_gitsch2ps" +if $debug; then + tmp="$dir/../_gitsch2ps_$$" +else + tmp="$dir/../_gitsch2ps" +fi sch="$tmp/$sdir" rm -rf "$tmp" @@ -111,10 +120,14 @@ fi ) || exit mkdir -p "$outdir" -mv "$sch"/*.ps "$outdir" +if $debug; then + cp "$sch"/*.ps "$outdir" +else + mv "$sch"/*.ps "$outdir" +fi if $keep; then echo "$tmp" else - rm -rf "$tmp" + $debug || rm -rf "$tmp" fi diff --git a/schhist/schhist2web b/schhist/schhist2web index cc0f1cc..d1d940a 100755 --- a/schhist/schhist2web +++ b/schhist/schhist2web @@ -110,7 +110,7 @@ ordered_names() usage() { cat <&1 -usage: $0 [-c cache-dir] [-f] [-n] [-S] [top-dir] [top-schem] [out-dir] +usage: $0 [options] [top-dir] [top-schem] [out-dir] top-dir top-level directory of the git archive (default: locate it) top-schem root sheet of the schematics (default: locate it in top-dir) @@ -118,6 +118,7 @@ usage: $0 [-c cache-dir] [-f] [-n] [-S] [top-dir] [top-schem] [out-dir] -c cache-dir cache directory (default: same as out-dir) -f identify sheets by their file name, not the sheet name -n don't use previous cache content (rebuild the cache) + -D debug mode: make temporary work trees unique and keep them -S sanitize KiCad profile and top-level sheet EOF exit 1 @@ -130,6 +131,8 @@ EOF no_cache=false sanitize= use_sch_name=false +debug=false +debug_opt= while true; do case "$1" in @@ -140,6 +143,9 @@ while true; do shift 2;; -f) use_sch_name=true shift;; + -D) debug=true + debug_opt=-D + shift;; -S) sanitize=-S shift;; -*) usage;; @@ -237,7 +243,8 @@ for n in $first `cd "$dir" && git rev-list --reverse $first..HEAD`; do # the ghostscript run and just put a symlink, replacing the less # efficient optimization below. # - tmp2=`gitsch2ps -k $sanitize "$dir" "$schname" $n "$tmp"` || exit + tmp2=`gitsch2ps -k $sanitize $debug_opt "$dir" "$schname" $n "$tmp"` || + exit for m in "$tmp"/*.ps; do [ "$m" = "$tmp/*.ps" ] && break # call sub-sheets by their own name, without prepending the @@ -281,7 +288,8 @@ for n in $first `cd "$dir" && git rev-list --reverse $first..HEAD`; do ppm="$cache/$n/ppm2/$name.ppm" normalizeschps -w 500 "$m" | schps2ppm - "$ppm" || exit done - rm -rf "$tmp" "$tmp2" + rm -rf "$tmp" + $debug || rm -rf "$tmp2" fi for m in "$cache/$n/ppm0/"*; do [ "$m" = "$cache/$n/ppm0/*" ] && break