Root/scripts/gitsch2ps

Source at commit b3f201486360ad2ffeb7d1ac24d14972d850f8ca created 10 years 24 days ago.
By Werner Almesberger, Split gitsch2ppm into its constituents.
1#!/bin/sh
2#
3# gitsch2ps - Generate PS files for KiCad schematics in git
4#
5# Written 2010 by Werner Almesberger
6# Copyright 2010 Werner Almesberger
7#
8# This program is free software; you can redistribute it and/or modify
9# it under the terms of the GNU General Public License as published by
10# the Free Software Foundation; either version 2 of the License, or
11# (at your option) any later version.
12#
13
14
15usage()
16{
17    cat <<EOF 1>&2
18usage: $0 [options] top-dir top-schem [commit] outdir
19
20  -S sanitize the KiCad profile
21EOF
22    exit 1
23}
24
25
26sanitize=true
27while true; do
28    case "$1" in
29    -S) sanitize=`PATH="$PATH":\`dirname "$0"\` which sanitize-profile`
30    [ "$sanitize" = "${sanitize#/}" ] && sanitize=`pwd`/"$sanitize"
31    shift;;
32    -*)
33    usage;;
34    *)
35    break;;
36    esac
37done
38
39[ ! -z "$3" -a -z "$5" ] || usage
40dir="$1"
41schem="$2"
42sdir=`dirname "$schem"`
43if [ -z "$4" ]; then
44    commit=HEAD
45    outdir="$3"
46else
47    commit="$3"
48    outdir="$4"
49fi
50
51[ "$dir" != "${dir#/}" ] || dir=`pwd`/$dir
52
53[ "$commit" != HEAD -o -f "$dir/$schem" ] || usage
54[ -d "$dir/.git" ] || usage
55
56tmp="$dir/../_gitsch2ps"
57sch="$tmp/$sdir"
58
59rm -rf "$tmp"
60rm -rf "$outdir"
61
62git clone -s -n "$dir/.git" "$tmp" || exit
63( cd "$tmp" && git checkout -q "$commit"; ) || exit
64
65if [ ! -f "$tmp/$schem" ]; then
66    echo "$schem not found (checked out into $tmp)" 1>&2
67    exit 1
68fi
69
70(
71    cd "$sch" || exit
72    rm -f *.ps
73    $sanitize "$tmp/${schem%.sch}.pro" ||
74      exit
75    eeschema --plot "$tmp/$schem"
76) || exit
77
78mkdir -p "$outdir"
79mv "$sch"/*.ps "$outdir"
80
81rm -rf "$tmp"
82

Archive Download this file



interactive