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