~ubuntu-branches/ubuntu/lucid/libatomic-ops/lucid

« back to all changes in this revision

Viewing changes to install-sh

  • Committer: Bazaar Package Importer
  • Author(s): Ian Wienand
  • Date: 2006-10-16 09:45:29 UTC
  • mfrom: (2.1.4 dapper)
  • Revision ID: james.westby@ubuntu.com-20061016094529-r3bevpq5w6g3rv20
Tags: 1.1-4
* Closes: #322027, #338469 -- add 04_m68k.patch for M68K support, from
  Roman Zippel <zippel@linux-m68k.org>.  Add note in README.Debian about
  port.
* Change mainatiner address to my @debian.org

Show diffs side-by-side

added added

removed removed

Lines of Context:
74
74
 
75
75
while [ x"$1" != x ]; do
76
76
    case $1 in
77
 
        -c) instcmd=$cpprog
 
77
        -c) instcmd="$cpprog"
78
78
            shift
79
79
            continue;;
80
80
 
97
97
            shift
98
98
            continue;;
99
99
 
100
 
        -s) stripcmd=$stripprog
 
100
        -s) stripcmd="$stripprog"
101
101
            shift
102
102
            continue;;
103
103
 
124
124
 
125
125
if [ x"$src" = x ]
126
126
then
127
 
        echo "$0: no input file specified" >&2
 
127
        echo "install:  no input file specified"
128
128
        exit 1
129
129
else
130
 
        :
 
130
        true
131
131
fi
132
132
 
133
133
if [ x"$dir_arg" != x ]; then
134
134
        dst=$src
135
135
        src=""
136
 
 
137
 
        if [ -d "$dst" ]; then
 
136
        
 
137
        if [ -d $dst ]; then
138
138
                instcmd=:
139
139
                chmodcmd=""
140
140
        else
141
 
                instcmd=$mkdirprog
 
141
                instcmd=mkdir
142
142
        fi
143
143
else
144
144
 
145
145
# Waiting for this to be detected by the "$instcmd $src $dsttmp" command
146
 
# might cause directories to be created, which would be especially bad
 
146
# might cause directories to be created, which would be especially bad 
147
147
# if $src (and thus $dsttmp) contains '*'.
148
148
 
149
 
        if [ -f "$src" ] || [ -d "$src" ]
 
149
        if [ -f $src -o -d $src ]
150
150
        then
151
 
                :
 
151
                true
152
152
        else
153
 
                echo "$0: $src does not exist" >&2
 
153
                echo "install:  $src does not exist"
154
154
                exit 1
155
155
        fi
156
 
 
 
156
        
157
157
        if [ x"$dst" = x ]
158
158
        then
159
 
                echo "$0: no destination specified" >&2
 
159
                echo "install:  no destination specified"
160
160
                exit 1
161
161
        else
162
 
                :
 
162
                true
163
163
        fi
164
164
 
165
165
# If destination is a directory, append the input filename; if your system
166
166
# does not like double slashes in filenames, you may need to add some logic
167
167
 
168
 
        if [ -d "$dst" ]
 
168
        if [ -d $dst ]
169
169
        then
170
 
                dst=$dst/`basename "$src"`
 
170
                dst="$dst"/`basename $src`
171
171
        else
172
 
                :
 
172
                true
173
173
        fi
174
174
fi
175
175
 
176
176
## this sed command emulates the dirname command
177
 
dstdir=`echo "$dst" | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'`
 
177
dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'`
178
178
 
179
179
# Make sure that the destination directory exists.
180
180
#  this part is taken from Noah Friedman's mkinstalldirs script
181
181
 
182
182
# Skip lots of stat calls in the usual case.
183
183
if [ ! -d "$dstdir" ]; then
184
 
defaultIFS='
185
 
        '
186
 
IFS="${IFS-$defaultIFS}"
 
184
defaultIFS='    
 
185
'
 
186
IFS="${IFS-${defaultIFS}}"
187
187
 
188
 
oIFS=$IFS
 
188
oIFS="${IFS}"
189
189
# Some sh's can't handle IFS=/ for some reason.
190
190
IFS='%'
191
 
set - `echo "$dstdir" | sed -e 's@/@%@g' -e 's@^%@/@'`
192
 
IFS=$oIFS
 
191
set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'`
 
192
IFS="${oIFS}"
193
193
 
194
194
pathcomp=''
195
195
 
196
196
while [ $# -ne 0 ] ; do
197
 
        pathcomp=$pathcomp$1
 
197
        pathcomp="${pathcomp}${1}"
198
198
        shift
199
199
 
200
 
        if [ ! -d "$pathcomp" ] ;
 
200
        if [ ! -d "${pathcomp}" ] ;
201
201
        then
202
 
                $mkdirprog "$pathcomp"
 
202
                $mkdirprog "${pathcomp}"
203
203
        else
204
 
                :
 
204
                true
205
205
        fi
206
206
 
207
 
        pathcomp=$pathcomp/
 
207
        pathcomp="${pathcomp}/"
208
208
done
209
209
fi
210
210
 
211
211
if [ x"$dir_arg" != x ]
212
212
then
213
 
        $doit $instcmd "$dst" &&
 
213
        $doit $instcmd $dst &&
214
214
 
215
 
        if [ x"$chowncmd" != x ]; then $doit $chowncmd "$dst"; else : ; fi &&
216
 
        if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd "$dst"; else : ; fi &&
217
 
        if [ x"$stripcmd" != x ]; then $doit $stripcmd "$dst"; else : ; fi &&
218
 
        if [ x"$chmodcmd" != x ]; then $doit $chmodcmd "$dst"; else : ; fi
 
215
        if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi &&
 
216
        if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi &&
 
217
        if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi &&
 
218
        if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi
219
219
else
220
220
 
221
221
# If we're going to rename the final executable, determine the name now.
222
222
 
223
 
        if [ x"$transformarg" = x ]
 
223
        if [ x"$transformarg" = x ] 
224
224
        then
225
 
                dstfile=`basename "$dst"`
 
225
                dstfile=`basename $dst`
226
226
        else
227
 
                dstfile=`basename "$dst" $transformbasename |
 
227
                dstfile=`basename $dst $transformbasename | 
228
228
                        sed $transformarg`$transformbasename
229
229
        fi
230
230
 
231
231
# don't allow the sed command to completely eliminate the filename
232
232
 
233
 
        if [ x"$dstfile" = x ]
 
233
        if [ x"$dstfile" = x ] 
234
234
        then
235
 
                dstfile=`basename "$dst"`
 
235
                dstfile=`basename $dst`
236
236
        else
237
 
                :
 
237
                true
238
238
        fi
239
239
 
240
 
# Make a couple of temp file names in the proper directory.
241
 
 
242
 
        dsttmp=$dstdir/_inst.$$_
243
 
        rmtmp=$dstdir/_rm.$$_
244
 
 
245
 
# Trap to clean up temp files at exit.
246
 
 
247
 
        trap 'status=$?; rm -f "$dsttmp" "$rmtmp" && exit $status' 0
248
 
        trap '(exit $?); exit' 1 2 13 15
 
240
# Make a temp file name in the proper directory.
 
241
 
 
242
        dsttmp=$dstdir/#inst.$$#
249
243
 
250
244
# Move or copy the file name to the temp name
251
245
 
252
 
        $doit $instcmd "$src" "$dsttmp" &&
 
246
        $doit $instcmd $src $dsttmp &&
 
247
 
 
248
        trap "rm -f ${dsttmp}" 0 &&
253
249
 
254
250
# and set any options; do chmod last to preserve setuid bits
255
251
 
257
253
# ignore errors from any of these, just make sure not to ignore
258
254
# errors from the above "$doit $instcmd $src $dsttmp" command.
259
255
 
260
 
        if [ x"$chowncmd" != x ]; then $doit $chowncmd "$dsttmp"; else :;fi &&
261
 
        if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd "$dsttmp"; else :;fi &&
262
 
        if [ x"$stripcmd" != x ]; then $doit $stripcmd "$dsttmp"; else :;fi &&
263
 
        if [ x"$chmodcmd" != x ]; then $doit $chmodcmd "$dsttmp"; else :;fi &&
264
 
 
265
 
# Now remove or move aside any old file at destination location.  We try this
266
 
# two ways since rm can't unlink itself on some systems and the destination
267
 
# file might be busy for other reasons.  In this case, the final cleanup
268
 
# might fail but the new file should still install successfully.
269
 
 
270
 
{
271
 
        if [ -f "$dstdir/$dstfile" ]
272
 
        then
273
 
                $doit $rmcmd -f "$dstdir/$dstfile" 2>/dev/null ||
274
 
                $doit $mvcmd -f "$dstdir/$dstfile" "$rmtmp" 2>/dev/null ||
275
 
                {
276
 
                  echo "$0: cannot unlink or rename $dstdir/$dstfile" >&2
277
 
                  (exit 1); exit
278
 
                }
279
 
        else
280
 
                :
281
 
        fi
282
 
} &&
 
256
        if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi &&
 
257
        if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi &&
 
258
        if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi &&
 
259
        if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi &&
283
260
 
284
261
# Now rename the file to the real destination.
285
262
 
286
 
        $doit $mvcmd "$dsttmp" "$dstdir/$dstfile"
 
263
        $doit $rmcmd -f $dstdir/$dstfile &&
 
264
        $doit $mvcmd $dsttmp $dstdir/$dstfile 
287
265
 
288
266
fi &&
289
267
 
290
 
# The final little trick to "correctly" pass the exit status to the exit trap.
291
268
 
292
 
{
293
 
        (exit 0); exit
294
 
}
 
269
exit 0