debian: Switch to using CDBS for Debian builds.
[cfd] / mklinks.in
1 #! /bin/sh
2
3 # -*-sh-*-
4 #
5 # Create links to the repository
6 #
7 # (c) 1997 Mark Wooding
8 #
9
10 #----- Licensing notice -----------------------------------------------------
11 #
12 # This file is part of the Common Files Distribution (`common').
13 #
14 # `Common' is free software; you can redistribute it and/or modify
15 # it under the terms of the GNU General Public License as published by
16 # the Free Software Foundation; either version 2 of the License, or
17 # (at your option) any later version.
18 #
19 # `Common' is distributed in the hope that it will be useful,
20 # but WITHOUT ANY WARRANTY; without even the implied warranty of
21 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 # GNU General Public License for more details.
23 #
24 # You should have received a copy of the GNU General Public License
25 # along with `common'; if not, write to the Free Software Foundation,
26 # Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
27
28 # --- Configuration variables ---
29
30 prefix=@prefix@
31 datarootdir=@datarootdir@
32 datadir=@datadir@/@PACKAGE@
33
34 # --- Parse command line arguments ---
35
36 while [ $# -gt 0 ]; do
37 case $1 in
38 -h | --h | --he | --hel | --help)
39 cat <<EOF
40 Usage: mklinks [FILE...]
41
42 The FILEs listed are themselves lists of filenames. Makes each named file a
43 link to the corresponding file in the shared files repository. With no
44 arguments, \`mklinks' reads \`.links' from the current directory.
45 EOF
46 exit 0
47 ;;
48 -v | --v | --ve | --ver | --vers | --versi | --versio | --version)
49 version=`echo '$Revision: 1.4 $' |
50 sed -n -e 's;^.*: \([0-9.]*\) *\\$;\1;p'`
51 echo "mklinks $version; Common Files Distribution version @VERSION@"
52 exit 0
53 ;;
54 --)
55 shift
56 break
57 ;;
58 -)
59 break
60 ;;
61 -*)
62 echo "mklinks: unknown option \`$1'" >&2
63 exit 1
64 ;;
65 *)
66 break
67 ;;
68 esac
69 shift
70 done
71
72 # --- Main code ---
73 #
74 # This is really trivial.
75
76 [ $# = 0 ] && set .links
77 cat "$@" | while read name; do
78 base="`echo $name | sed -e 's;^.*/;;'`"
79 [ -r "$datadir/$base" ] && ln -sf "$datadir/$base" "$name"
80 done