Sync usage with man page.
[netbsd-mini2440.git] / external / bsd / atf / dist / admin / generate-revision-dist.sh
blobfeaa5f2fd3471220d595b5d1191286f1706d6e9a
1 #! /bin/sh
3 # Automated Testing Framework (atf)
5 # Copyright (c) 2009 The NetBSD Foundation, Inc.
6 # All rights reserved.
8 # Redistribution and use in source and binary forms, with or without
9 # modification, are permitted provided that the following conditions
10 # are met:
11 # 1. Redistributions of source code must retain the above copyright
12 # notice, this list of conditions and the following disclaimer.
13 # 2. Redistributions in binary form must reproduce the above copyright
14 # notice, this list of conditions and the following disclaimer in the
15 # documentation and/or other materials provided with the distribution.
17 # THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND
18 # CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
19 # INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
20 # MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21 # IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS BE LIABLE FOR ANY
22 # DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
24 # GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25 # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
26 # IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
27 # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
28 # IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 # Modifies a revision file to generate a new one that can be redistributed
33 # as part of the source tree.
36 set -e
38 Prog_Name=${0##*/}
41 # err message
43 err() {
44 echo "${Prog_Name}: ${@}" 1>&2
45 exit 1
49 # generate_h infile outfile
51 generate_h() {
52 cp ${1} ${2}
53 echo '#define PACKAGE_REVISION_CACHED 1' >>${2}
57 # main args
59 # Entry point.
61 main() {
62 fmt=
63 infile=
64 outfile=
65 while getopts :f:i:o: arg; do
66 case ${arg} in
68 fmt=${OPTARG}
71 infile=${OPTARG}
74 outfile=${OPTARG}
77 err "Unknown option ${arg}"
79 esac
80 done
81 [ -n "${fmt}" ] || \
82 err "Must specify an output format with -f"
83 [ -n "${infile}" ] || \
84 err "Must specify an input file with -i"
85 [ -n "${outfile}" ] || \
86 err "Must specify an output file with -o"
88 if [ -f ${infile} ]; then
89 case ${fmt} in
91 tmp=$(mktemp -t generate-revision-dist.XXXXXX)
92 generate_${fmt} ${infile} ${tmp}
93 cmp -s ${tmp} ${outfile} || cp -p ${tmp} ${outfile}
94 rm -f ${tmp}
97 err "Unknown format ${fmt}"
99 esac
100 else
101 [ -f ${outfile} ]
105 main "${@}"
107 # vim: syntax=sh:expandtab:shiftwidth=4:softtabstop=4