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