mirror of
git://projects.qi-hardware.com/eda-tools.git
synced 2024-11-05 06:18:26 +02:00
150f9ab4d4
- schhist/gitsch2ps: new option -k to keep the cloned repository and print the path name of the temporary directory on standard output - schhist/gitsch2ps: invoked "git clone" with -q to suppress progress output on standard output
90 lines
1.6 KiB
Bash
Executable File
90 lines
1.6 KiB
Bash
Executable File
#!/bin/sh
|
|
#
|
|
# gitsch2ps - Generate PS files for KiCad schematics in git
|
|
#
|
|
# Written 2010 by Werner Almesberger
|
|
# Copyright 2010 Werner Almesberger
|
|
#
|
|
# This program is free software; you can redistribute it and/or modify
|
|
# it under the terms of the GNU General Public License as published by
|
|
# the Free Software Foundation; either version 2 of the License, or
|
|
# (at your option) any later version.
|
|
#
|
|
|
|
|
|
usage()
|
|
{
|
|
cat <<EOF 1>&2
|
|
usage: $0 [options] top-dir top-schem [commit] outdir
|
|
|
|
-k keep the temporary directory and print its name
|
|
-S sanitize the KiCad profile
|
|
EOF
|
|
exit 1
|
|
}
|
|
|
|
|
|
sanitize=true
|
|
keep=false
|
|
while true; do
|
|
case "$1" in
|
|
-k) keep=true
|
|
shift;;
|
|
-S) sanitize=`PATH="$PATH":\`dirname "$0"\` which sanitize-profile`
|
|
[ "$sanitize" = "${sanitize#/}" ] && sanitize=`pwd`/"$sanitize"
|
|
shift;;
|
|
-*)
|
|
usage;;
|
|
*)
|
|
break;;
|
|
esac
|
|
done
|
|
|
|
[ ! -z "$3" -a -z "$5" ] || usage
|
|
dir="$1"
|
|
schem="$2"
|
|
sdir=`dirname "$schem"`
|
|
if [ -z "$4" ]; then
|
|
commit=HEAD
|
|
outdir="$3"
|
|
else
|
|
commit="$3"
|
|
outdir="$4"
|
|
fi
|
|
|
|
[ "$dir" != "${dir#/}" ] || dir=`pwd`/$dir
|
|
|
|
[ "$commit" != HEAD -o -f "$dir/$schem" ] || usage
|
|
[ -d "$dir/.git" ] || usage
|
|
|
|
tmp="$dir/../_gitsch2ps"
|
|
sch="$tmp/$sdir"
|
|
|
|
rm -rf "$tmp"
|
|
rm -rf "$outdir"
|
|
|
|
git clone -q -s -n "$dir/.git" "$tmp" || exit
|
|
( cd "$tmp" && git checkout -q "$commit"; ) || exit
|
|
|
|
if [ ! -f "$tmp/$schem" ]; then
|
|
echo "$schem not found (checked out into $tmp)" 1>&2
|
|
exit 1
|
|
fi
|
|
|
|
(
|
|
cd "$sch" || exit
|
|
rm -f *.ps
|
|
$sanitize "$tmp/${schem%.sch}.pro" ||
|
|
exit
|
|
eeschema --plot "$tmp/$schem"
|
|
) || exit
|
|
|
|
mkdir -p "$outdir"
|
|
mv "$sch"/*.ps "$outdir"
|
|
|
|
if $keep; then
|
|
echo "$tmp"
|
|
else
|
|
rm -rf "$tmp"
|
|
fi
|