home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!mcsun!corton!ircam!fingerhu
- From: fingerhu@ircam.fr (Michel Fingerhut)
- Newsgroups: comp.lang.perl
- Subject: versions 2.1 (extract version number of programs)
- Message-ID: <1992Jul21.143117.24207@ircam.fr>
- Date: 21 Jul 92 14:31:17 GMT
- Organization: Inst. de Recherche et Coordination Acoustique/Musique, Paris
- Lines: 368
-
- Here is the second (and last, I let it rest for a day or two) version of
- my 'versions' program, used to list the version number of selected programs.
- The main differences with the previous version are:
-
- 1. as an option, it lists the installation date of the program.
- 2. the description file's format has been extended to allow for macros,
- which simplify the writing.
-
- Comments by email are welcome.
-
- ------------------------------ cut here -------------------------------------
- #! /bin/sh
- # This is a shell archive. Remove anything before this line, then unpack
- # it by saving it into a file and typing "sh file". To overwrite existing
- # files, type "sh file -c". You can also feed this as standard input via
- # unshar, or by typing "sh <file", e.g.. If this archive is complete, you
- # will see the following message at the end:
- # "End of shell archive."
- # Contents: versions.1 versions versions.dat Makefile
- # Wrapped by fingerhu@nadia on Tue Jul 21 16:30:00 1992
- PATH=/bin:/usr/bin:/usr/ucb ; export PATH
- if test -f 'versions.1' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'versions.1'\"
- else
- echo shar: Extracting \"'versions.1'\" \(1776 characters\)
- sed "s/^X//" >'versions.1' <<'END_OF_FILE'
- X.TH VERSIONS 1 "IRCAM 2.1 7/21/92"
- X.SH NAME
- Xversions - print versions of locally-installed programs
- X.SH SYNOPSIS
- X.B versions
- X[
- X.B -v
- X]
- X[
- X.B -l
- X]
- X[
- X.I program ...
- X]
- X.SH DESCRIPTION
- X.PP
- X.I Versions
- Xprints the current version number (and installation date, if
- X.BR \-l )
- Xof some locally installed programs.
- XIf no option is given, it lists all the programs found in the
- X.B /usr/local/bin/versions.dat
- Xdescription file, otherwise it lists only those whose names are
- Xspecified on the command line.
- X.SH OPTIONS
- X.TP
- X.B -v
- Xprints its own version (equivalent to
- X.B versions\ version )
- Xand exit.
- X.TP
- X.B \-l
- X(long format) prints also installation date
- X.TP
- X.I program ...
- Xprint only the version numbers (and installation dates)
- Xof the programs (if their names
- Xappear in the description file).
- X.SH FILES
- X.TP
- X.I /usr/local/bin/versions.dat
- Xcontains a list of programs with the method used to retrieve the version
- Xnumber in each. Each line consists of 3 tab-separated fields: the first one
- Xis the absolute path to the program, the second one a shell command to extract
- Xa string containing the version information, and the last a perl pattern
- Xused to extract the version from the string obtained via the shell command.
- X
- XA limited form of macros is permitted so as to simplify the description.
- XThe special
- X.B %%
- Xmacro stands for the full path (i.e., the first field
- Xin each line, usually used in the 2nd field). Other macros can
- Xbe defined in that file: the definition is on a line of the form
- X.IR macro=string ,
- Xand any subsequent occurrence of
- X.BI % macro
- Xis replaced by
- X.I string.
- X.SH BUGS
- XNot all programs are included, since some don't have an idea of their
- Xown version number (other than in the sources, sometimes, wherever they
- Xmay be).
- X.SH AUTHOR
- XMichel Fingerhut (fingerhu@ircam.fr)
- END_OF_FILE
- if test 1776 -ne `wc -c <'versions.1'`; then
- echo shar: \"'versions.1'\" unpacked with wrong size!
- fi
- # end of 'versions.1'
- fi
- if test -f 'versions' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'versions'\"
- else
- echo shar: Extracting \"'versions'\" \(3496 characters\)
- sed "s/^X//" >'versions' <<'END_OF_FILE'
- X#!/usr/local/bin/perl -s
- X# Copyright (c) 1992 by IRCAM
- X# All rights reserved.
- X#
- X# For any information regarding this and other IRCAM software, please
- X# send email to:
- X# manager@ircam.fr
- X
- X#
- X# versions 2.1 IRCAM 7/21/92
- X#
- X# Modification history
- X#
- X# Extract program version number
- X#
- X# 20-Jul-92 - Michel Fingerhut (fingerhu@ircam.fr)
- X#
- X
- X$[ = 1; # set array base to 1
- X$, = ' '; # set output field separator
- X$\ = "\n"; # set output record separator
- X
- X#-------------------------------------------------------------------------------
- X# formats for short form of output
- X#-------------------------------------------------------------------------------
- X
- X$format_top_s= "
- Xprogram version
- X------- -------
- X.
- X";
- X
- X$format_s= '
- X@<<<<<<<<<<<< @<<<<<<<<<<<<<<<<<<
- X$program, $version
- X.
- X';
- X
- X#-------------------------------------------------------------------------------
- X# formats for long form of output
- X#-------------------------------------------------------------------------------
- X
- X$format_top_l= "
- Xprogram version date installed
- X------- ------- --------------
- X.
- X";
- X
- X$format_l= '
- X@<<<<<<<<<<<< @<<<<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<<<<
- X$program, $version, &asctime($path)
- X.
- X';
- X
- X#------------------------------------------------------------------------------
- X# main program
- X#------------------------------------------------------------------------------
- X
- X# if -v, print version and exit
- Xif ($v) {
- X print "2.1 IRCAM 7/21/92";
- X exit;
- X}
- X
- X# set format according to -l (long) otherwise short
- Xif ($l) {
- X eval "format top= $format_top_l; format= $format_l" ;
- X} else {
- X eval "format top= $format_top_s; format= $format_s" ;
- X}
- X
- X# determine which selected programs to list
- Xif ($#ARGV) {
- X foreach $a (@ARGV) {
- X $doit{$a} = 1;
- X }
- X}
- X
- X# read dat file and execute program
- X
- Xopen (DAT, "/usr/local/lib/versions.dat") || die "Couldn't find dat file: $!\n";
- X
- Xwhile (<DAT>) {
- X
- X chop;
- X next if /^$/;
- X
- X if ( ! /\t/ ) { # macro descr section contains no tabs
- X
- X # this is a macro definition - find name and store the definition
- X @l = split(/=/);
- X $macro{$l[1]}= $l[2];
- X
- X } else { # if tab, description section
- X
- X # perform macro substitution on all the line
- X foreach $key (%macro) {
- X s/\%$key/$macro{$key}/g;
- X }
- X
- X # split the line into the path, shell command and perl pattern
- X ($path, $command, $pattern)= split(/\t+/);
- X next if (! -f $path);
- X
- X # perform special macro subst: %% -> $path
- X $command=~ s/\%\%/$path/g;
- X
- X # identify the program name (after last / in path name)
- X ($program= $path) =~ s/.*\///; # isolate prog name (after last / )
- X
- X # ignore this entry if there are arguments and it is not one of them
- X next if $#ARGV && ! defined $doit{$program};
- X
- X # find version number from pattern
- X undef $version;
- X $version= $1 if `$command` =~ /.*$pattern.*/;
- X $version .= "($2)" if $2;
- X
- X # print
- X write;
- X }
- X}
- Xclose(DAT);
- X
- X#------------------------------------------------------------------------------
- X# asctime - convert time from 1/1/1970 to ascii
- X#------------------------------------------------------------------------------
- Xsub asctime {{
- X @mon= ('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
- X 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec');
- X @time= localtime((stat($_[1]))[10]);
- X return sprintf("%2d %s 19%02d %02d:%02d",
- X $time[4], $mon[$time[5]+1], $time[6], $time[3], $time[2]);
- X}}
- END_OF_FILE
- if test 3496 -ne `wc -c <'versions'`; then
- echo shar: \"'versions'\" unpacked with wrong size!
- fi
- chmod +x 'versions'
- # end of 'versions'
- fi
- if test -f 'versions.dat' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'versions.dat'\"
- else
- echo shar: Extracting \"'versions.dat'\" \(1034 characters\)
- sed "s/^X//" >'versions.dat' <<'END_OF_FILE'
- XBIN=/usr/local/bin
- Xl=level
- Xv=version
- XV=Version
- Xp=patch.c,v
- X
- X%BIN/f2c echo | %% %v of (.*) ..:
- X%BIN/find %% /dev/null -%v 2>&1 %v ([^ ]*)
- X%BIN/flex %% -v < /dev/null 2>&1 %v ([^ ]*)
- X%BIN/formes %% -h NEW:\t([^ ]*)
- X%BIN/ftoch %% -v %V . ([^ ]*)
- X%BIN/g++ gcc -v 2>&1 %v ([\d\.]+)
- X%BIN/gcc %% -v 2>&1 %v ([\d\.]+)
- X%BIN/gdb echo quit | %% GDB ([\d\.]+)
- X%BIN/X11/ghostview strings %% Ghostview, %v ([\d\.]+)
- X%BIN/grep %% -V 2>&1 grep, %v ([^ ]*)
- X%BIN/kcl echo \(bye\) | %% %V\((.*)\)
- X%BIN/kermit echo quit | %% C-Kermit, ([^ ]*)
- X%BIN/lelisp echo \(end\) | %% %v ([^ ]*)
- X%BIN/make %% -v 2>/dev/null %v ([\d\.]+)
- X%BIN/matlab %% -v 2>/dev/null %V ([^ ]*)
- X%BIN/patch %% -v 2>&1 | tr '\012' ' ' %p ([^ ]*).*%l: ([^ ]*)
- X%BIN/perl %% -v | tr '\012' ' ' %v ([^ ]*).*%l: ([^ ]*)
- X%BIN/rcs strings %% rcs.c,v ([^ ]*)
- X%BIN/svp %% 2>&1 %v. ([^ ]*)
- X%BIN/tar %% -%v 2>&1 %v ([\d\.]+)
- X%BIN/tex cd /tmp; echo \\end | %% %V ([^ ]*)
- X%BIN/top strings %% Top, %v ([^,]*)
- X%BIN/versions %% -v ^([^ ]*)
- END_OF_FILE
- if test 1034 -ne `wc -c <'versions.dat'`; then
- echo shar: \"'versions.dat'\" unpacked with wrong size!
- fi
- # end of 'versions.dat'
- fi
- if test -f 'Makefile' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'Makefile'\"
- else
- echo shar: Extracting \"'Makefile'\" \(1765 characters\)
- sed "s/^X//" >'Makefile' <<'END_OF_FILE'
- X# %G% IRCAM %W%
- X# Copyright (c) 1991 by IRCAM
- X# All rights reserved.
- X#
- X# For any information regarding this and other IRCAM software, please
- X# send email to:
- X# manager@ircam.fr
- X
- X#
- X# Gnumake file automatically generated by makemake for versions
- X#
- X# Modification history
- X#
- X
- XMAKEFILE := Makefile
- XTARGET := versions
- XROOTDIR := /usr/local
- XOWNER := root
- XGROUP := wheel
- X# Where executables and man pages go
- XBINDIR := $(ROOTDIR)/bin
- XLIBDIR := $(ROOTDIR)/lib
- XMANDIR := $(ROOTDIR)/man
- XDESTDIR := $(BINDIR)
- XSHFILES := versions.sh
- XTAPE := /dev/rmt0h
- XLIBFILES := versions.dat
- XMANFILES1 := versions.1
- XMANFILES := $(MANFILES1)
- XINSTMANFILES := $(addprefix $(MANDIR)/man1/, $(MANFILES1))
- XINSTLIBFILES := $(addprefix $(LIBDIR)/, $(LIBFILES))
- XDOCFILES :=
- XOTHERS :=
- XOBJECTS :=
- XSOURCE := $(MAKEFILE) $(MANFILES) $(DOCFILES) $(SHFILES) \
- X $(OTHERS) $(INCLUDES) $(YACCFILES) $(LEXFILES) \
- X $(CFILES) $(FFILES) $(ASFILES)
- XLISTFILES := $(MAKEFILE) $(SHFILES) $(INCLUDES) $(YACCFILES) \
- X $(LEXFILES) $(CFILES) $(FFILES) $(ASFILES)
- X
- X.PHONY: all install uninstall clean depend
- Xall: $(TARGET)
- X
- Xinstall: $(DESTDIR)/$(TARGET) $(INSTMANFILES) $(INSTLIBFILES)
- X
- Xuninstall:
- X rm -f $(DESTDIR)/$(TARGET) $(INSTMANFILES) $(INSTLIBFILES)
- X
- Xdepend:
- X
- X$(TARGET): $(TARGET).sh
- X
- X$(DESTDIR)/$(TARGET): $(TARGET)
- X install -c -o $(OWNER) -g $(GROUP) -m 0755 $< $@
- X
- X$(MANDIR)/man1/% : %
- X install -c -o $(OWNER) -g $(GROUP) -m 0644 $< $@
- X$(LIBDIR)/% : %
- X install -c -o $(OWNER) -g $(GROUP) -m 0644 $< $@
- Xtar:
- X tar rfcb $(TAPE) 20 $(SOURCE)
- Xcpio:
- X ls $(SOURCE) | cpio -oB
- Xlint:
- X $(LINT) $(CPPFLAGS) $(CFILES)
- Xclean:
- X -rm -f $(OBJECTS)
- X sccs clean
- Xclobber: clean
- X -rm -f $(TARGET)
- Xtouch:
- X touch $(TARGET)
- X
- END_OF_FILE
- if test 1765 -ne `wc -c <'Makefile'`; then
- echo shar: \"'Makefile'\" unpacked with wrong size!
- fi
- # end of 'Makefile'
- fi
- echo shar: End of shell archive.
- exit 0
-