glsl2: Add and use new variable mode ir_var_temporary
[mesa/nouveau-pmpeg.git] / bin / minstall
blob130025829ba727210ab8eef55b15b8412eeb9879
1 #!/bin/sh
4 # A minimal replacement for 'install' that supports installing symbolic links.
5 # Only a limited number of options are supported:
6 # -d dir Create a directory
7 # -m mode Sets a file's mode when installing
10 # If these commands aren't portable, we'll need some "if (arch)" type stuff
11 SYMLINK="ln -s"
12 MKDIR="mkdir -p"
13 RM="rm -f"
15 MODE=""
17 if [ "$1" = "-d" ] ; then
18 # make a directory path
19 $MKDIR "$2"
20 exit 0
23 if [ "$1" = "-m" ] ; then
24 # set file mode
25 MODE=$2
26 shift 2
29 # install file(s) into destination
30 if [ $# -ge 2 ] ; then
32 # Last cmd line arg is the dest dir
33 for FILE in $@ ; do
34 DEST="$FILE"
35 done
37 # Loop over args, moving them to DEST directory
38 I=1
39 for FILE in $@ ; do
40 if [ $I = $# ] ; then
41 # stop, don't want to install $DEST into $DEST
42 exit 0
45 PWDSAVE=`pwd`
47 # determine file's type
48 if [ -h "$FILE" ] ; then
49 #echo $FILE is a symlink
50 # Unfortunately, cp -d isn't universal so we have to
51 # use a work-around.
53 # Use ls -l to find the target that the link points to
54 LL=`ls -l "$FILE"`
55 for L in $LL ; do
56 TARGET=$L
57 done
58 #echo $FILE is a symlink pointing to $TARGET
60 FILE=`basename "$FILE"`
61 # Go to $DEST and make the link
62 cd "$DEST" # pushd
63 $RM "$FILE"
64 $SYMLINK "$TARGET" "$FILE"
65 cd "$PWDSAVE" # popd
67 elif [ -f "$FILE" ] ; then
68 #echo "$FILE" is a regular file
69 # Only copy if the files differ
70 if ! cmp -s $FILE $DEST/`basename $FILE`; then
71 $RM "$DEST/`basename $FILE`"
72 cp "$FILE" "$DEST"
74 if [ $MODE ] ; then
75 FILE=`basename "$FILE"`
76 chmod $MODE "$DEST/$FILE"
78 else
79 echo "Unknown type of argument: " "$FILE"
80 exit 1
83 I=`expr $I + 1`
84 done
86 exit 0
89 # If we get here, we didn't find anything to do
90 echo "Usage:"
91 echo " install -d dir Create named directory"
92 echo " install [-m mode] file [...] dest Install files in destination"