#!/bin/ksh # # $Id: mkman.ksh,v 1.10 2003/10/07 00:44:46 vogelke Exp $ # # NAME: # mkman # # SYNOPSIS: # mkman [-hv] [--help] [--version] # # DESCRIPTION: # Create a basic manifest file named MANIFEST. # # OPTIONS: # -h, --help print this message # -v, --version print the version and exit # # AUTHOR: # Based on Free Software Foundation configure scripts. # # Karl Vogel # Sumaria Systems, Inc. PATH=/bin:/usr/bin:/usr/local/bin:/coll/local/bin export PATH umask 022 tag=`basename $0` # ======================== FUNCTIONS ============================= # # die: logs an error message and exits. # A common use for "die" is with a test: # test -f /etc/passwd || die "no passwd file" # This works in subshells and loops, but may not exit with # a code other than 0. die () { echo "$tag: $*" >& 2 exit 1 } # usage: prints an optional string plus part of the comment # header (if any) to stderr, and exits with code 1. usage () { lines=`egrep -n '^# (NAME|AUTHOR)' $0 | sed -e 's/:.*//'` ( case "$#" in 0) ;; *) echo "usage error: $*"; echo ;; esac case "$lines" in "") ;; *) set `echo $lines | sed -e 's/ /,/'` sed -n ${1}p $0 | sed -e 's/^#//g' | egrep -v AUTHOR: ;; esac ) 1>&2 exit 1 } # version: prints the current version to stdout. version () { lsedscr='s/RCSfile: // s/.Date: // s/,v . .Revision: / v/ s/\$//g' lrevno='$RCSfile: mkman.ksh,v $ $Revision: 1.10 $' lrevdate='$Date: 2003/10/07 00:44:46 $' echo "$lrevno $lrevdate" | sed -e "$lsedscr" } # ======================== MAIN PROGRAM ========================== # Defaults: ac_invalid="invalid option; use --help to show usage" for ac_option do case "$ac_option" in -h | --help | --hel | --he) usage ;; -v | --version | --versio | --versi | --vers) version; exit 0 ;; -*) die "$ac_option: $ac_invalid" ;; *) die "$ac_option: $ac_invalid" ;; esac done # # We don't want directories, RCS files, or build files. # manifest="MANIFEST" hdr="# Automatically generated by $tag on `date`" scr='/^\.$/d /\/RCS/d /^\.make$/d /^\.dist$/d /\.[ao]$/d' ( echo $hdr; find . -print | sed -e "$scr" | sort ) > $manifest exit 0