SAVESRC

Section: User Commands (1)
Updated: LOCAL
Index Return to Main Contents
 

NAME

savesrc - organize program sources from Usenet  

SYNOPSIS

savesrc destination [source file ...]  

DESCRIPTION

Savesrc is a shell program designed to simplify the retrieval, testing, documentation, and storage of program sources from the Usenet news network, although it can be used with any source files.

Savesrc will read standard input if no source files are given, so a news article may be piped to it conveniently from newsreaders with this facility, such as rn(1). This makes it much easier to save sources in a standard manner and test them out while actually reading news, rather than accumulating messy directories of miscellaneous sources to be organized Real Soon Now.

Basically, savesrc will take a single program source file or a shell archive, place it in a designated source directory or sub-directory thereof, unshar it if necessary, generate a Makefile entry if necessary, prompt for a half-line description of what the program does, attempt to compile it, give the user a shell to twiddle it when it doesn't work, and add entries to a file of notes indicating what it is, where and who it came from, when it arrived, and whether or not it works. It will also deal sensibly with header files and manual pages.

Savesrc is interactive. It may be terminated by typing ``q'' in response to any question, but cannot be aborted with an interrupt. If panic stikes, quit (normally CTRL-\) will produce a graceful exit.

Directory Structures Etc.

Savesrc assumes that all sources will be placed in a main sources directory, or in sub-directories under it. It will look for an environment variable ``srcdir'' giving the full pathname of this directory; the default value is ``$HOME/src''.

Manual page sources are assumed to live in a directory with subdirectories named ``man1'' through ``man8'', and manual pages which have been formatted using nroff -man are assumed to live in a directory with subdirectories named ``cat1'' through ``cat8''. Savesrc looks for two environment variables, ``mandir'' and ``catdir'', which give the full pathnames of these directories. ``Mandir'' and ``catdir'' may be the same; the default value for each is ``$HOME/man''.

Savesrc further assumes that there will be a Makefile in the main sources directory; one will be created if it does not exist. Incidentally, if a ``makefile'' is found anywhere, it is appended to ``Makefile'' and then removed, in the interests of consistency. (The Makefile is then edited to change all references to ``makefile'' into ``Makefile''.)

A file called ``NOTES'' is also expected in any source directory, and will be created if it does not exist. This file contains short notes on what the programs in the directory do, where and whom they came from (if known), when they were received, and any other relevant information (such as if they work and actually seem to be useful). Savesrc will create a basic NOTES entry for any program it deals with if the user so desires. The NOTES file is intended to be manipulated by a another program, note(1L), but since it is a ordinary ASCII file, it may be attacked with any of the normal Unix utilities.

The destination names that savesrc knows about are ones ending in ``.?'', ``.fix'', ``.bug'', ``.patch'', ``.[1-8]'', and ``READ*'', which are assumed to be source (C, YACC, lex, etc.) or header files, bug fixes, manual pages, or README's. (The ``.bug'', ``.fix'', and ``.patch'' suffixes exist to allow convenient saving of bugs, patches, and fixes in a general sources directory.) Any other destination name is assumed to be a sub-directory under the main sources directory, unless it is a full pathname.

Single Source Programs, Header Files, and README's

Savesrc tries to put single-file sources, header files, and README's in the main sources directory. If the destination name already exists, the user is given the choice of overwriting it, appending to it, or specifying a new destination (which is also checked). The user is given a chance to edit the file or start up a shell for further twiddling. At this point savesrc will terminate for header files and README's; for bugs, fixes, and patches, the user will be offered a shell before savesrc terminates.

Source Programs

For sources, the user is prompted for a half-line description of the program, and a check is made to see if a Makefile entry already exists for the program. If not, and the user indicates he wants one, a default entry of the form:

program:        program.o
        cc $(CFLAGS) program.o -o program

is presented for his approval. If he approves, this is appended to the Makefile. If not, he is prompted for the complete Makefile entry. In either case, the Makefile entry is preceded by a blank line and the half-line program description as a comment. The user is then given a chance to edit the Makefile.

Next, the user is prompted for adding a basic NOTES entry, asked if the program should be compiled, offered a shell to twiddle or test it, and finally prompted for any further NOTES entries (e.g., ``Compiled OK but removed /unix when I ran it. Must remember to sue author.''). If the program came from a netnews article, the basic NOTES entry will include the author and the posting path, if possible, as well as the program name, the current date, and the half-line program description. (In compiling the program, the command used is in effect ``make `basename destination .c`''.)

Manual Pages

Manual pages are placed in the main sources directory, first checking that they will not overwrite a previous copy unless the user wishes to. The user may then edit them. For manual page sources (as opposed to pre-formatted pages), the user is asked if he wishes to move them to the appropriate section of the manual source directory, and if he wants a formatted copy made and filed. If a formatted copy is made, it will also be shown on the terminal. If the correct directory for the source or formatted page does not exist, savesrc attempts to create it. For pre-formatted manual pages, the user is given the option of moving them to the appropriate directory. (As yet there is no utility to generate source from formatted manual pages, but stay tuned...)

Large (Multi-File) C Programs

When savesrc cannot recognize the destination name as a single source program, a manual page, a header file, a bug, fix, or patch, or a README, it looks for a subdirectory of the main sources directory with that name (unless the destination is a full pathname, in which case it looks for that directory). If the directory exists, the user is given the option of working in that directory, or of specifying a different directory (which is also checked).

Once the working directory has been found and made the current directory, the user is prompted for a half-line description of what the program does. If no description is wanted (e.g., a new version is being saved), just hitting RETURN will have no ill effects.

The user is asked if he wants to use unshar(1L) to unpack the sources. If he opts for unshar, he is asked if it worked; if not, a shell is started automatically. If he does not want to use unshar, he may edit the sources or start a shell, is then shown a listing of the directory, and finally prompted for a name to copy the temporary file where savesrc first puts the sources (``/tmp/newsrc$$'') to.

Once the files are unpacked, savesrc looks for a README or READ_ME file, and offers to show it to the user. If it cannot find one, it asks if the user wants to edit one.

Next, savesrc deals with any manual pages just as described above, except that they are copied to the main manual page directories, rather than moved there. The rationale for this is that while one does not usually want lots of manual pages cluttering up a general source directory, for larger software packages which merit directories of their own it is best to keep the original distribution together, as this simplifies packaging for re-distribution. The option of copying the manual pages to a central location is given because it is also convenient to have a canonical collection of manual pages.

The question of a Makefile comes next. Savesrc turns any ``makefile'' into ``Makefile'' as mentioned before. If no Makefile is present, the user is asked if one is hiding somewhere (e.g., ``Makefile.bsd''), and this is copied to Makefile. If no Makefile at all can be found, a basic Makefile is generated automatically, using the one-line program description and simple-mindedly assuming that all the .c files are compiled up together. For example, suppose we have a new game of pacman, being placed in a directory called ``pacman''. The one-line description we have given it is ``a new, improved version of pacman'', and we have unshared four files, pac.c, pac.h, score.c, and tty.c. The default Makefile will contain:

# pacman -- a new, improved version of pacman

CFILES =pac.c score.c tty.c

OFILES =pac.o score.o tty.o

CFLAGS =-O

pacman:  $(OFILES)
    cc $(CFLAGS) $(OFILES) -o pacman

clean:
    rm -f *.o

(Note that CFLAGS may be set in the environment or adjusted by editing savesrc; its default is ``-O''.) No attempts to include libraries are made; the above example would almost certainly need `` -ltermcap'' added to the ``cc'' line.

The user is next offered a chance to edit the Makefile (which it is sensible to accept).

Finally, as for a single C program, the user is prompted for adding a basic NOTES entry, asked if the program should be compiled (using just ``make''), offered a shell to twiddle or test it, and prompted for any further NOTES entries. If the program came from a netnews article, the basic NOTES entry will include the author and the posting path, if possible, as well as the program name, the current date, and the half-line program description.  

EXAMPLES

From rn(1), ``| savesrc pacman'' will unpack a (presumably shar-ed) article into $HOME/src/pacman, and prompt the user for the steps necessary to compile and test it.

``savesrc /usr/joe/mung.c mungstuff'' will save the file ``mungstuff'' as ``/usr/joe/mung.c'', and prompt for compiling etc.  

ENVIRONMENT VARIABLES

Name      Default             Description

VISUAL    /usr/bin/vi         Used to edit files
EDITOR    none                Used if VISUAL is not set
SHELL     /bin/sh             Used to start a shell
PAGER     /usr/local/bin/more Used to page output
srcdir    $HOME/src           Main sources directory
mandir    $HOME/man           Main manual page source directory
catdir    $HOME/man           Main pre-formatted manual page directory
CFLAGS    -O                  Compiler options for Makefile entries
 

FILES

/tmp/newsrc$$  

SEE ALSO

note(1L), shar(1L), unshar(1L), rn(1), readnews(1)  

AUTHOR

Written by Christine Robertson, 1986.  

WARNINGS

Savesrc assumes that `` [ '' exists as a synonym for test(1). If you don't have it, either link test to it, or replace the `` [ ... ] '' constructs with ``test ...''.

The utilities unshar(1L) and note(1L) are also assumed; they may be replaced with ``sh'' and ``cat >> NOTES'', respectively.

If your shell does not support # as the comment character, remove all the # comments.

This program was written to organize sources in the way the author likes them. There is no guarantee you will like this too.  

BUGS

Please send all bug reports to {linus, ihnp4, decvax}!utzoo!toram!chris.


 

Index

NAME
SYNOPSIS
DESCRIPTION
EXAMPLES
ENVIRONMENT VARIABLES
FILES
SEE ALSO
AUTHOR
WARNINGS
BUGS

This document was created by man2html, using the manual pages.
Time: 06:39:32 GMT, December 12, 2024