/usr/bin/gsymupdate is in geda-utils 1:1.6.2-3.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
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 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 | #!/usr/bin/perl
# gEDA - GPL Electronic Design Automation
# gsymupdate - gEDA Symbol Update
# Copyright (C) 2002 Ales V. Hvezda
#
# 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.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
#
#
# This program takes a symbol filename on the command line and outputs an
# update symbol to stdout.
#
# This program does the following modifications to a symbol
#
# - Removes all pin#=# attributes, converting them into pinseq= and
# pinnumber= attributes
# - Removes all slot#=# attributes, converting them into slotdef= attributes
#
# Right now this program should only be run against symbols which are
# either version 20020527 or earlier.
#
print "gEDA/gsymupdate version 0.2\n";
print "gEDA/gsymupdate comes with ABSOLUTELY NO WARRANTY; see COPYING for more details\n";
print "This is free software, and you are welcome to redistribute it under certain\n";
print "conditions; please see the COPYING file for more details.\n\n";
$numArgs = $#ARGV + 1;
if ($numArgs < 1) {
print "Usage: gsymupdate filename1 filename2 ... filenameN\n";
exit;
}
foreach $filename (@ARGV) {
if (-r "$filename.old") {
print "Found backup file: $filename.old. Not gsymUpdating $filename\n";
next ;
}
if ( -d "$filename") {
print "$filename is a directory not a file. Not gsymUpdating $filename\n";
next ;
}
if (! -f "$filename") {
print "File $filename does not exist. Not gsymUpdating $filename\n";
next ;
}
# FIXME -- we should probably do some sanity checking to see that $filename is
# actually a symbol file.
rename ($filename, "$filename.old");
print "gsymUpdating: $filename (backup: $filename.old)\n";
open (FILE, "$filename.old") || die "Cannot open input file: $filename.old Exiting.\n";
open (NEWFILE, ">$filename") || die "Cannot open output file: $filename Exiting.\n";
while (<FILE>) {
# handle text objects
if (/^T/) {
# Somewhere here you need to deal with multi line text
# items eventually. TODO
$textcmd = $_;
$textline = <FILE>;
# are we dealing with an attribute?
if ($textline =~ /=/) {
# Break the attribute up into name=value
@attrib = split(/=/,$textline,2);
$name=@attrib[0];
$value=@attrib[1];
if ($name =~ /^slot[0-9]+/) {
# It is a slot#=# attribute
@slotnum = split(/slot/,$name);
print NEWFILE $textcmd;
print NEWFILE "slotdef=@slotnum[1]:$value";
} elsif ($name =~ /^pin[0-9]+/) {
# It is a pin#=# attribute
print NEWFILE $textcmd;
print NEWFILE "pinnumber=$value";
@pinseq = split(/pin/,$name);
# need to post process textcmd here to hide text
$newtextcmd = $textcmd;
chop($newtextcmd);
@textsplit = split(" ",$textcmd);
# Hide this new attribute by changing the 5th value to 0
# Also show both the name and value for the pinseq attrib
print NEWFILE "@textsplit[0] @textsplit[1] @textsplit[2] @textsplit[3] @textsplit[4] 0 0 @textsplit[7] @textsplit[8] @textsplit[9]\n";
print NEWFILE "pinseq=@pinseq[1]\n";
} elsif ($name =~ /^uref/) {
# It is a uref= attribute, convert to refdes=
print NEWFILE $textcmd;
print NEWFILE "refdes=$value";
} elsif ($name =~ /^type/) {
# It is a type= attribute, convert to pintype==
print NEWFILE $textcmd;
print NEWFILE "pintype=$value";
} elsif ($name =~ /^label/) {
# It is a label= attribute, convert to pinlabel=
print NEWFILE $textcmd;
print NEWFILE "pinlabel=$value";
} else {
# none of the above, just pass it through
print NEWFILE $textcmd;
print NEWFILE $textline;
}
} else {
# not an attribute
print NEWFILE $textcmd;
print NEWFILE $textline;
}
} else {
# It is not a text, version, or pin object, so pass it through
print NEWFILE;
}
}
close $FILE;
close $NEWFILE;
# Load and Save the file using gschlas
# This updates the file to be absolutely current
system("gschlas $filename");
@args = ("gschlas", "$filename");
system(@args) == 0 || die "system @args failed: $?"
}
|