~ubuntu-branches/ubuntu/feisty/gst-plugins-good0.10/feisty-security

« back to all changes in this revision

Viewing changes to install-sh

  • Committer: Bazaar Package Importer
  • Author(s): Sebastian Dröge
  • Date: 2006-08-15 02:58:26 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20060815025826-h1sa4q0uxwqgzwki
Tags: 0.10.4-0ubuntu1
* Sync with Debian (pkg-gstreamer SVN, rev 470):
  + debian/rules,
    debian/control.in:
    - Add a -dbg package again

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#!/bin/sh
2
2
# install - install a program, script, or datafile
3
3
 
4
 
scriptversion=2004-04-01.17
 
4
scriptversion=2005-02-02.21
5
5
 
6
6
# This originates from X11R5 (mit/util/scripts/install.sh), which was
7
7
# later released in X11R6 (xc/config/util/install.sh) with the
58
58
rmprog="${RMPROG-rm}"
59
59
mkdirprog="${MKDIRPROG-mkdir}"
60
60
 
61
 
transformbasename=
62
 
transform_arg=
63
 
instcmd="$mvprog"
64
61
chmodcmd="$chmodprog 0755"
65
62
chowncmd=
66
63
chgrpcmd=
70
67
src=
71
68
dst=
72
69
dir_arg=
 
70
dstarg=
 
71
no_target_directory=
73
72
 
74
 
usage="Usage: $0 [OPTION]... SRCFILE DSTFILE
 
73
usage="Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE
75
74
   or: $0 [OPTION]... SRCFILES... DIRECTORY
76
 
   or: $0 -d DIRECTORIES...
 
75
   or: $0 [OPTION]... -t DIRECTORY SRCFILES...
 
76
   or: $0 [OPTION]... -d DIRECTORIES...
77
77
 
78
 
In the first form, install SRCFILE to DSTFILE, removing SRCFILE by default.
79
 
In the second, create the directory path DIR.
 
78
In the 1st form, copy SRCFILE to DSTFILE.
 
79
In the 2nd and 3rd, copy all SRCFILES to DIRECTORY.
 
80
In the 4th, create DIRECTORIES.
80
81
 
81
82
Options:
82
 
-b=TRANSFORMBASENAME
83
 
-c         copy source (using $cpprog) instead of moving (using $mvprog).
 
83
-c         (ignored)
84
84
-d         create directories instead of installing files.
85
 
-g GROUP   $chgrp installed files to GROUP.
86
 
-m MODE    $chmod installed files to MODE.
87
 
-o USER    $chown installed files to USER.
88
 
-s         strip installed files (using $stripprog).
89
 
-t=TRANSFORM
 
85
-g GROUP   $chgrpprog installed files to GROUP.
 
86
-m MODE    $chmodprog installed files to MODE.
 
87
-o USER    $chownprog installed files to USER.
 
88
-s         $stripprog installed files.
 
89
-t DIRECTORY  install into DIRECTORY.
 
90
-T         report an error if DSTFILE is a directory.
90
91
--help     display this help and exit.
91
92
--version  display version info and exit.
92
93
 
96
97
 
97
98
while test -n "$1"; do
98
99
  case $1 in
99
 
    -b=*) transformbasename=`echo $1 | sed 's/-b=//'`
100
 
        shift
101
 
        continue;;
102
 
 
103
 
    -c) instcmd=$cpprog
104
 
        shift
 
100
    -c) shift
105
101
        continue;;
106
102
 
107
103
    -d) dir_arg=true
113
109
        shift
114
110
        continue;;
115
111
 
116
 
    --help) echo "$usage"; exit 0;;
 
112
    --help) echo "$usage"; exit $?;;
117
113
 
118
114
    -m) chmodcmd="$chmodprog $2"
119
115
        shift
129
125
        shift
130
126
        continue;;
131
127
 
132
 
    -t=*) transformarg=`echo $1 | sed 's/-t=//'`
133
 
        shift
134
 
        continue;;
135
 
 
136
 
    --version) echo "$0 $scriptversion"; exit 0;;
 
128
    -t) dstarg=$2
 
129
        shift
 
130
        shift
 
131
        continue;;
 
132
 
 
133
    -T) no_target_directory=true
 
134
        shift
 
135
        continue;;
 
136
 
 
137
    --version) echo "$0 $scriptversion"; exit $?;;
137
138
 
138
139
    *)  # When -d is used, all remaining arguments are directories to create.
139
 
        test -n "$dir_arg" && break
 
140
        # When -t is used, the destination is already specified.
 
141
        test -n "$dir_arg$dstarg" && break
140
142
        # Otherwise, the last argument is the destination.  Remove it from $@.
141
143
        for arg
142
144
        do
174
176
    src=
175
177
 
176
178
    if test -d "$dst"; then
177
 
      instcmd=:
 
179
      mkdircmd=:
178
180
      chmodcmd=
179
181
    else
180
 
      instcmd=$mkdirprog
 
182
      mkdircmd=$mkdirprog
181
183
    fi
182
184
  else
183
 
    # Waiting for this to be detected by the "$instcmd $src $dsttmp" command
 
185
    # Waiting for this to be detected by the "$cpprog $src $dsttmp" command
184
186
    # might cause directories to be created, which would be especially bad
185
187
    # if $src (and thus $dsttmp) contains '*'.
186
188
    if test ! -f "$src" && test ! -d "$src"; then
202
204
    # If destination is a directory, append the input filename; won't work
203
205
    # if double slashes aren't ignored.
204
206
    if test -d "$dst"; then
 
207
      if test -n "$no_target_directory"; then
 
208
        echo "$0: $dstarg: Is a directory" >&2
 
209
        exit 1
 
210
      fi
205
211
      dst=$dst/`basename "$src"`
206
212
    fi
207
213
  fi
208
214
 
209
215
  # This sed command emulates the dirname command.
210
 
  dstdir=`echo "$dst" | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'`
 
216
  dstdir=`echo "$dst" | sed -e 's,/*$,,;s,[^/]*$,,;s,/*$,,;s,^$,.,'`
211
217
 
212
218
  # Make sure that the destination directory exists.
213
219
 
220
226
    oIFS=$IFS
221
227
    # Some sh's can't handle IFS=/ for some reason.
222
228
    IFS='%'
223
 
    set - `echo "$dstdir" | sed -e 's@/@%@g' -e 's@^%@/@'`
 
229
    set x `echo "$dstdir" | sed -e 's@/@%@g' -e 's@^%@/@'`
 
230
    shift
224
231
    IFS=$oIFS
225
232
 
226
233
    pathcomp=
229
236
      pathcomp=$pathcomp$1
230
237
      shift
231
238
      if test ! -d "$pathcomp"; then
232
 
        $mkdirprog "$pathcomp" || lasterr=$?
 
239
        $mkdirprog "$pathcomp"
233
240
        # mkdir can fail with a `File exist' error in case several
234
241
        # install-sh are creating the directory concurrently.  This
235
242
        # is OK.
236
 
        test ! -d "$pathcomp" && { (exit ${lasterr-1}); exit; }
 
243
        test -d "$pathcomp" || exit
237
244
      fi
238
245
      pathcomp=$pathcomp/
239
246
    done
240
247
  fi
241
248
 
242
249
  if test -n "$dir_arg"; then
243
 
    $doit $instcmd "$dst" \
 
250
    $doit $mkdircmd "$dst" \
244
251
      && { test -z "$chowncmd" || $doit $chowncmd "$dst"; } \
245
252
      && { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } \
246
253
      && { test -z "$stripcmd" || $doit $stripcmd "$dst"; } \
247
254
      && { test -z "$chmodcmd" || $doit $chmodcmd "$dst"; }
248
255
 
249
256
  else
250
 
    # If we're going to rename the final executable, determine the name now.
251
 
    if test -z "$transformarg"; then
252
 
      dstfile=`basename "$dst"`
253
 
    else
254
 
      dstfile=`basename "$dst" $transformbasename \
255
 
               | sed $transformarg`$transformbasename
256
 
    fi
257
 
 
258
 
    # don't allow the sed command to completely eliminate the filename.
259
 
    test -z "$dstfile" && dstfile=`basename "$dst"`
 
257
    dstfile=`basename "$dst"`
260
258
 
261
259
    # Make a couple of temp file names in the proper directory.
262
260
    dsttmp=$dstdir/_inst.$$_
263
261
    rmtmp=$dstdir/_rm.$$_
264
262
 
265
263
    # Trap to clean up those temp files at exit.
266
 
    trap 'status=$?; rm -f "$dsttmp" "$rmtmp" && exit $status' 0
 
264
    trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0
267
265
    trap '(exit $?); exit' 1 2 13 15
268
266
 
269
 
    # Move or copy the file name to the temp name
270
 
    $doit $instcmd "$src" "$dsttmp" &&
 
267
    # Copy the file name to the temp name.
 
268
    $doit $cpprog "$src" "$dsttmp" &&
271
269
 
272
270
    # and set any options; do chmod last to preserve setuid bits.
273
271
    #
274
272
    # If any of these fail, we abort the whole thing.  If we want to
275
273
    # ignore errors from any of these, just make sure not to ignore
276
 
    # errors from the above "$doit $instcmd $src $dsttmp" command.
 
274
    # errors from the above "$doit $cpprog $src $dsttmp" command.
277
275
    #
278
276
    { test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } \
279
277
      && { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } \
298
296
               || $doit $mvcmd -f "$dstdir/$dstfile" "$rmtmp" 2>/dev/null \
299
297
               || {
300
298
                 echo "$0: cannot unlink or rename $dstdir/$dstfile" >&2
301
 
                 (exit 1); exit
 
299
                 (exit 1); exit 1
302
300
               }
303
301
             else
304
302
               :
309
307
           $doit $mvcmd "$dsttmp" "$dstdir/$dstfile"
310
308
         }
311
309
    }
312
 
  fi || { (exit 1); exit; }
 
310
  fi || { (exit 1); exit 1; }
313
311
done
314
312
 
315
313
# The final little trick to "correctly" pass the exit status to the exit trap.
316
314
{
317
 
  (exit 0); exit
 
315
  (exit 0); exit 0
318
316
}
319
317
 
320
318
# Local variables: