[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

gEDA-cvs: gaf.git: branch: master updated (1.5.0-20080706-325-g1625b37)



The branch, master has been updated
       via  1625b379e7066ffe2a8283a4977c794ff55b7db4 (commit)
      from  1d6a2045f618cb2441d386811a49fc3c1686ff13 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


=========
 Summary
=========

 gnetlist/configure.ac            |   10 +++++-
 gnetlist/scripts/Makefile.am     |    8 ++--
 gnetlist/scripts/annotate.sh     |   71 +++++++++++++++++++++++---------------
 gnetlist/scripts/bom_xref.sh     |    4 +-
 gnetlist/scripts/bompp.sh        |    6 ++--
 gnetlist/scripts/sch2eaglepos.sh |   39 ++++++++++++++-------
 6 files changed, 87 insertions(+), 51 deletions(-)


=================
 Commit Messages
=================

commit 1625b379e7066ffe2a8283a4977c794ff55b7db4
Author: Dan McMahill <dan@xxxxxxxxxxxx>
Date:   Sat Nov 29 21:11:07 2008 -0500

    General portability cleanup of scripts.
    
    Expand the autoconf tests for awk to make sure that we have picked up and
    awk that is good enough for the scripts that use them.  Now use this result
    in various scripts instead of hard coding 'gawk' (not available on all systems)
    or 'awk' (picks up the original awk which is not sufficiently advanced on solaris).
    
    Also avoid calling out /bin/bash on scripts for which /bin/sh (even on solaris) should
    be sufficient.  Not all systems have /bin/bash.
    
    Finally, improve temp file usage in shell scripts for improved security.

:100644 100644 d046ece... 4155fef... M	gnetlist/configure.ac
:100644 100644 885185a... f67006a... M	gnetlist/scripts/Makefile.am
:100755 100755 2a2d8d6... 225d963... M	gnetlist/scripts/annotate.sh
:100755 100755 75de459... 8760680... M	gnetlist/scripts/bom_xref.sh
:100755 100755 5d00451... 2c23009... M	gnetlist/scripts/bompp.sh
:100755 100755 f38ef5d... df835eb... M	gnetlist/scripts/sch2eaglepos.sh

=========
 Changes
=========

commit 1625b379e7066ffe2a8283a4977c794ff55b7db4
Author: Dan McMahill <dan@xxxxxxxxxxxx>
Date:   Sat Nov 29 21:11:07 2008 -0500

    General portability cleanup of scripts.
    
    Expand the autoconf tests for awk to make sure that we have picked up and
    awk that is good enough for the scripts that use them.  Now use this result
    in various scripts instead of hard coding 'gawk' (not available on all systems)
    or 'awk' (picks up the original awk which is not sufficiently advanced on solaris).
    
    Also avoid calling out /bin/bash on scripts for which /bin/sh (even on solaris) should
    be sufficient.  Not all systems have /bin/bash.
    
    Finally, improve temp file usage in shell scripts for improved security.

diff --git a/gnetlist/configure.ac b/gnetlist/configure.ac
index d046ece..4155fef 100644
--- a/gnetlist/configure.ac
+++ b/gnetlist/configure.ac
@@ -84,7 +84,9 @@ AC_PROG_CC
 AM_CONDITIONAL(CCISGCC, test "$GCC" = "yes")    
 AC_PROG_CPP
 AC_PROG_MAKE_SET
-AC_PATH_PROGS(AWK, nawk gawk mawk awk, )
+AC_PATH_AWK
+AC_AWK_GSUB([], [AC_MSG_ERROR([We require an awk implementation that provides gsub().  Consider installing gawk.])])
+AC_AWK_TOUPPER([], [AC_MSG_ERROR([We require an awk implementation that provides toupper().  Consider installing gawk.])])
 AC_PATH_PROGS(M4, gm4 m4, m4)
 
 ##############################################################3
@@ -499,8 +501,14 @@ AC_CONFIG_FILES([Makefile
 		 lib/Makefile 
 		 utils/Makefile 
 		 scripts/Makefile
+		 scripts/annotate.sh
+		 scripts/bom_xref.sh
+		 scripts/bompp.sh
 		 scripts/sw2asc 
 		 lib/system-gnetlistrc ])
+AC_CONFIG_COMMANDS([annotate-chmod],[[chmod +x scripts/annotate.sh]],[[]])
+AC_CONFIG_COMMANDS([bom_xref-chmod],[[chmod +x scripts/bom_xref.sh]],[[]])
+AC_CONFIG_COMMANDS([bompp-chmod],[[chmod +x scripts/bompp.sh]],[[]])
 AC_CONFIG_COMMANDS([sw2asc-chmod],[[chmod +x scripts/sw2asc]],[[]])
 
 AC_OUTPUT
diff --git a/gnetlist/scripts/Makefile.am b/gnetlist/scripts/Makefile.am
index 885185a..f67006a 100644
--- a/gnetlist/scripts/Makefile.am
+++ b/gnetlist/scripts/Makefile.am
@@ -1,10 +1,10 @@
 
-EXTRA_DIST = bompp.sh annotate.sh unannotate.sh bom_xref.sh sw2asc.in \
+EXTRA_DIST = bompp.sh.in annotate.sh.in  unannotate.sh bom_xref.sh.in sw2asc.in \
 	     gschem2pcb sch2eaglepos.sh
 
-bin_SCRIPTS = sw2asc sch2eaglepos.sh
+bin_SCRIPTS =  sw2asc sch2eaglepos.sh
 
 MOSTLYCLEANFILES = *.log *~
 CLEANFILES = *.log *~
-DISTCLEANFILES = *.log core FILE *~ prototype.bak sw2asc
-MAINTAINERCLEANFILES = *.log *~ Makefile.in configure sw2asc
+DISTCLEANFILES = *.log core FILE *~ prototype.bak sw2asc bompp.sh annotate.sh bom_xref.sh
+MAINTAINERCLEANFILES = *.log *~ Makefile.in configure sw2asc bompp.sh annotate.sh bom_xref.sh
diff --git a/gnetlist/scripts/annotate.sh b/gnetlist/scripts/annotate.sh
index 2a2d8d6..225d963 100755
--- a/gnetlist/scripts/annotate.sh
+++ b/gnetlist/scripts/annotate.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/bin/sh
 
 # 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
@@ -19,7 +19,7 @@
 #---------------------------------28/02/2000-----------------------
 #------------------------------------------------------------------
 
-if [ -z $1 ]; then
+if [ -z "$1" ]; then
 	echo "No sch file indicated"
 	echo "usage:"
 	echo "annotate file"
@@ -27,13 +27,29 @@ if [ -z $1 ]; then
 	exit 1
 fi 
 
+# create a secure temp directory
+tmpd=${TMP:-/tmp}/annotate.$$
+mkdir -m 0700 ${tmpd}
+rc=$?
+if test $rc -ne 0 ; then
+	cat << EOF
+
+$0:  ERROR -- failed to securily create ${tmpd}
+Check to make sure that the directory does not already
+exist and that you have sufficient permissions to create it.
+
+mkdir returned $rc.
+
+EOF
+	exit 1
+fi
 
 # Determine the different refdes=?
 
-list=`gawk '/^refdes=[A-Z]+\?/ {
+list=`/usr/bin/awk '/^refdes=[A-Z]+\?/ {
 		A=$1; gsub(/refdes=/,"",A)
 		gsub(/\?/,"",A)
-		print A}' $1 | sort | gawk 'BEGIN {if (NR==1) {A=$1} }{if (A !=$1) print ; A=$1}' - `
+		print A}' $1 | sort | /usr/bin/awk 'BEGIN {if (NR==1) {A=$1} }{if (A !=$1) print ; A=$1}' - `
 
 
 if [ -z "$list" ]; then
@@ -46,47 +62,46 @@ fi
 cp $1 $1.sauv
 
 # Replace the ? by a number 
+sc=${tmpd}/sc.awk
 
 for f in  $list; do 
     # creation du script gawk 1 
-    echo "BEGIN {R=0}" >sc.awk
-    echo "/^refdes=$f[0-9]+/ {B=\$1" >>sc.awk
-    echo "gsub(/refdes=[A-Z]+/,\"\",B)" >>sc.awk
-    echo "if (B>R) {R=B}" >>sc.awk
-    echo "}" >>sc.awk
-    echo "END {printf(\"%d\",R)}" >>sc.awk
+    echo "BEGIN {R=0}" >${sc}
+    echo "/^refdes=$f[0-9]+/ {B=\$1" >>${sc}
+    echo "gsub(/refdes=[A-Z]+/,\"\",B)" >>${sc}
+    echo "if (B>R) {R=B}" >>${sc}
+    echo "}" >>${sc}
+    echo "END {printf(\"%d\",R)}" >>${sc}
     # execution des scripts
     
-    IMAX=`gawk -f sc.awk $1`
+    IMAX=`/usr/bin/awk -f ${sc} $1`
     echo "Numbering of $f will start at $IMAX"
     
     # creation du script gawk 2 
     
-    echo "BEGIN {R=MAX} ">sc.awk
-    echo "{if (match(\$1,/^refdes=$f\?/)!=0) {" >>sc.awk
-    echo "R=R+1" >>sc.awk
-    echo "sub(/\?/,R,\$1)" >>sc.awk
-    echo "print \$1 } " >>sc.awk
-    echo "else {print \$0}}">>sc.awk
+    echo "BEGIN {R=MAX} ">${sc}
+    echo "{if (match(\$1,/^refdes=$f\?/)!=0) {" >>${sc}
+    echo "R=R+1" >>${sc}
+    echo "sub(/\?/,R,\$1)" >>${sc}
+    echo "print \$1 } " >>${sc}
+    echo "else {print \$0}}">>${sc}
     
-    #echo "OK=1" >>sc.awk
-    #echo "LL=NR}" >>sc.awk
-    #echo "{" >>sc.awk
-    #echo "if ((OK==1)&&(NR==LL+1)) {print \$1\" \"\$2\" \"\$3\" \"\$4\" \"\$5\" \"1\" \"\$7\" \"\$8 }" >>sc.awk
-    #echo "if (NR==LL+2) {OK=0} " >>sc.awk
-    #echo "if (OK==0) {print \$0} " >>sc.awk
-    #echo "}" >>sc.awk
+    #echo "OK=1" >>${sc}
+    #echo "LL=NR}" >>${sc}
+    #echo "{" >>${sc}
+    #echo "if ((OK==1)&&(NR==LL+1)) {print \$1\" \"\$2\" \"\$3\" \"\$4\" \"\$5\" \"1\" \"\$7\" \"\$8 }" >>${sc}
+    #echo "if (NR==LL+2) {OK=0} " >>${sc}
+    #echo "if (OK==0) {print \$0} " >>${sc}
+    #echo "}" >>${sc}
     
     #execute the second script
     
-    cat $1 | gawk -v MAX=$IMAX -f sc.awk  - > $1.tmp
+    cat $1 | /usr/bin/awk -v MAX=$IMAX -f ${sc}  - > $1.tmp
     mv $1.tmp $1
     
 done
     
 # clean !
 
-if [ -e sc.awk ]; then
-	rm sc.awk
-fi	
+rm  -fr ${tmpd}
 
diff --git a/gnetlist/scripts/bom_xref.sh b/gnetlist/scripts/bom_xref.sh
index 75de459..8760680 100755
--- a/gnetlist/scripts/bom_xref.sh
+++ b/gnetlist/scripts/bom_xref.sh
@@ -1,10 +1,10 @@
 #!/bin/sh
 # ha ha
 
-if [ -z $1 ] ; then
+if [ -z "$1" ] ; then
     echo "usage $0 geda-bom  # output on stdout"
     exit -1
 fi    
 cat $1 | sort -k1,1 |\
-awk '!/device/{printf("%-5s %-20s %-20s %-20s\n", toupper($1), toupper($2), toupper($3), toupper($4));} /device/{}'
+/usr/bin/awk '!/device/{printf("%-5s %-20s %-20s %-20s\n", toupper($1), toupper($2), toupper($3), toupper($4));} /device/{}'
 
diff --git a/gnetlist/scripts/bompp.sh b/gnetlist/scripts/bompp.sh
index 5d00451..2c23009 100755
--- a/gnetlist/scripts/bompp.sh
+++ b/gnetlist/scripts/bompp.sh
@@ -1,12 +1,12 @@
 #!/bin/sh
 # ha ha
 
-if [ -z $1 ] ; then
+if [ -z "$1" ] ; then
     echo "usage $0 geda-bom  # output on stdout"
     exit -1
 fi    
-cat $1 | awk '{print toupper($2)" "toupper($3)" "toupper($4)" "toupper($1)}'\
-| sort +0 | awk '\
+cat $1 | /usr/bin/awk '{print toupper($2)" "toupper($3)" "toupper($4)" "toupper($1)}'\
+| sort +0 | /usr/bin/awk '\
 BEGIN {\
 f1="";f2="";f3="";\
 format1="%3d %-19s %-10s %-10s ";\
diff --git a/gnetlist/scripts/sch2eaglepos.sh b/gnetlist/scripts/sch2eaglepos.sh
index f38ef5d..df835eb 100755
--- a/gnetlist/scripts/sch2eaglepos.sh
+++ b/gnetlist/scripts/sch2eaglepos.sh
@@ -1,17 +1,23 @@
-#!/bin/bash
+#!/bin/sh
 # By Braddock Gaskill (braddock@xxxxxxxxxxxx), August 2004.  This
 # software is hereby declared to be in the public domain by Braddock
 # Gaskill, the author.
 FNAME="$1"
 if [ -z "$FNAME" ]; then
-    echo "$0 <inputfile.sch>"
-    echo "This script will read a gschem schematic and attempt to
-    extract the relative positions of the components in the schematic,
-    and generate corresponding MOVE instructions for Eagle.  You will
-    likely have to adjust XOFFSET, YOFFSET, XSCAL, and YSCALE at the
-    top of the script to obtain usable positions."
-    echo "By Braddock Gaskill (braddock@xxxxxxxxxxxx), August 2004"
-    exit -1;
+    cat << EOF
+
+$0 <inputfile.sch>
+
+This script will read a gschem schematic and attempt to
+extract the relative positions of the components in the schematic,
+and generate corresponding MOVE instructions for Eagle.  You will
+likely have to adjust XOFFSET, YOFFSET, XSCAL, and YSCALE at the
+top of the script to obtain usable positions.
+
+By Braddock Gaskill (braddock@xxxxxxxxxxxx), August 2004
+
+EOF
+    exit -1
 fi
 XOFFSET=40000
 YOFFSET=33000
@@ -24,13 +30,20 @@ tmpdir=/tmp/$$
 mkdir -m 0700 -p $tmpdir
 rc=$?
 if test $rc -ne 0 ; then
-	echo "Failed to create $tmpdir with 0700 permissions.  mkdir returned $rc."
+	cat << EOF
+
+$0: ERROR -- Failed to create $tmpdir with 0700 permissions.  mkdir returned $rc.
+
+Make sure that $tmpdir does not already exist and that you have permissions to 
+create it.
+
+EOF
 	exit 1
 fi
-TMP=${tmpdir}/tmpf
-grep -B1 refdes= "$FNAME" |sed 's/=/ /' | cut -d" " -f2,3 |grep -v '^--' >${TMP}
+tmpf=${tmpdir}/tmpf
+grep -B1 refdes= "$FNAME" |sed 's/=/ /' | cut -d" " -f2,3 |grep -v '^--' >${tmpf}
 
-3<$TMP
+3<$tmpf
 while read -u 3; do
     # the directory on the client to backup
     X=`echo $REPLY | cut -d' ' -f1`




_______________________________________________
geda-cvs mailing list
geda-cvs@xxxxxxxxxxxxxx
http://www.seul.org/cgi-bin/mailman/listinfo/geda-cvs