File: pcbdiff

package info (click to toggle)
pcb 20140316-3
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 22,212 kB
  • ctags: 16,012
  • sloc: ansic: 123,955; sh: 7,306; yacc: 5,087; pascal: 4,118; makefile: 1,559; perl: 552; lex: 438; awk: 157; lisp: 86; tcl: 63; xml: 20
file content (80 lines) | stat: -rwxr-xr-x 2,025 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#! /bin/sh

usage ()
{
  echo Usage: 
  echo \\tpcbdiff firstfile secondfile
  echo \\tView a graphical diff of PCB files
  echo
  echo \\tTo use with git, just place this script in your PATH and do
  echo \\tgit difftool -x pcbdiff ...
  echo
  echo \\tTo use with mercurial, add the following lines to your .hgrc:
  echo \\t\\t[extensions]
  echo \\t\\thgext.extdiff =
  echo \\t\\t[extdiff]
  echo \\t\\tcmd.pcbdiff = /PATH/TO/pcbdiff
  echo \\tthen to invoke it, do
  echo \\thg pcbdiff ...
  echo
  echo \\tTo use with subversion, place it in your PATH and do
  echo \\tsvn diff --diff-cmd pcbdiff ...

  echo \\tRequirements: Imagemagick and gschem be installed
}

PCB=`which pcb`
if test -z "${PCB}"; then
  MISSING=pcb
fi

CONVERT=`which convert`
if test -z "${CONVERT}"; then
  MISSING=convert
fi

COMPOSITE=`which composite`
if test -z "${COMPOSITE}"; then
  MISSING=composite
fi

VIEWER=`which display`
if test -z "${VIEWER}"; then
  MISSING=display
fi

if test -z "${MISSING}"; then
  true
else
  echo "Binary for \"${MISSING}\" not found." >&2
  echo "Either it is not installed, or not in your PATH" >&2
  exit 1
fi

#In case the script was invoked with extra option arguments, throw them away
shift `expr $# - 2`

LEFTFILE="${1}"
RIGHTFILE="${2}"
if test -d "${LEFTFILE}" -o -d "${RIGHTFILE}"
  then echo "ERROR: pcbdiff cannot diff entire directories"
  exit 1
fi

LEFTPNG=`mktemp --tmpdir pcbdiff.XXXXXXXXXX`
RIGHTPNG=`mktemp --tmpdir pcbdiff.XXXXXXXXXX`
LEFTBNW=`mktemp --tmpdir pcbdiff.XXXXXXXXXX`
RIGHTBNW=`mktemp --tmpdir pcbdiff.XXXXXXXXXX`
DIFFPNG=`mktemp --tmpdir pcbdiff.XXXXXXXXXX`

"${PCB}" -x png --dpi ${PCBDIFF_DPI:-200} --photo-mode --outfile ${LEFTPNG} "${LEFTFILE}"
"${PCB}" -x png --dpi ${PCBDIFF_DPI:-200} --photo-mode --outfile ${RIGHTPNG} "${RIGHTFILE}"
"${CONVERT}" -colorspace gray $LEFTPNG $LEFTBNW
"${CONVERT}" -colorspace gray $RIGHTPNG $RIGHTBNW
"${COMPOSITE}" -stereo 0 $LEFTBNW $RIGHTBNW $DIFFPNG
"${VIEWER}" $DIFFPNG
rm $LEFTPNG
rm $RIGHTPNG
rm $LEFTBNW
rm $RIGHTBNW
rm $DIFFPNG