1f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project#!/bin/sh 2f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project# 3f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project# install - install a program, script, or datafile 4f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project# This comes from X11R5 (mit/util/scripts/install.sh). 5f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project# 6f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project# Copyright 1991 by the Massachusetts Institute of Technology 7f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project# 8f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project# Permission to use, copy, modify, distribute, and sell this software and its 9f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project# documentation for any purpose is hereby granted without fee, provided that 10f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project# the above copyright notice appear in all copies and that both that 11f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project# copyright notice and this permission notice appear in supporting 12f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project# documentation, and that the name of M.I.T. not be used in advertising or 13f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project# publicity pertaining to distribution of the software without specific, 14f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project# written prior permission. M.I.T. makes no representations about the 15f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project# suitability of this software for any purpose. It is provided "as is" 16f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project# without express or implied warranty. 17f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project# 18f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project# Calling this script install-sh is preferred over install.sh, to prevent 19f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project# `make' implicit rules from creating a file called install from it 20f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project# when there is no Makefile. 21f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project# 22f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project# This script is compatible with the BSD install script, but was written 23f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project# from scratch. It can only install one file at a time, a restriction 24f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project# shared with many OS's install programs. 25f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project 26f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project 27f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project# set DOITPROG to echo to test this script 28f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project 29f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project# Don't use :- since 4.3BSD and earlier shells don't like it. 30f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Projectdoit="${DOITPROG-}" 31f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project 32f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project 33f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project# put in absolute paths if you don't have them in your path; or use env. vars. 34f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project 35f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Projectmvprog="${MVPROG-mv}" 36f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Projectcpprog="${CPPROG-cp}" 37f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Projectchmodprog="${CHMODPROG-chmod}" 38f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Projectchownprog="${CHOWNPROG-chown}" 39f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Projectchgrpprog="${CHGRPPROG-chgrp}" 40f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Projectstripprog="${STRIPPROG-strip}" 41f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Projectrmprog="${RMPROG-rm}" 42f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Projectmkdirprog="${MKDIRPROG-mkdir}" 43f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project 44f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Projecttransformbasename="" 45f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Projecttransform_arg="" 46f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Projectinstcmd="$mvprog" 47f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Projectchmodcmd="$chmodprog 0755" 48f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Projectchowncmd="" 49f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Projectchgrpcmd="" 50f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Projectstripcmd="" 51f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Projectrmcmd="$rmprog -f" 52f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Projectmvcmd="$mvprog" 53f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Projectsrc="" 54f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Projectdst="" 55f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Projectdir_arg="" 56f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project 57f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Projectwhile [ x"$1" != x ]; do 58f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project case $1 in 59f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project -c) instcmd="$cpprog" 60f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project shift 61f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project continue;; 62f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project 63f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project -d) dir_arg=true 64f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project shift 65f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project continue;; 66f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project 67f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project -m) chmodcmd="$chmodprog $2" 68f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project shift 69f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project shift 70f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project continue;; 71f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project 72f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project -o) chowncmd="$chownprog $2" 73f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project shift 74f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project shift 75f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project continue;; 76f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project 77f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project -g) chgrpcmd="$chgrpprog $2" 78f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project shift 79f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project shift 80f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project continue;; 81f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project 82f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project -s) stripcmd="$stripprog" 83f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project shift 84f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project continue;; 85f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project 86f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project -t=*) transformarg=`echo $1 | sed 's/-t=//'` 87f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project shift 88f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project continue;; 89f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project 90f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project -b=*) transformbasename=`echo $1 | sed 's/-b=//'` 91f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project shift 92f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project continue;; 93f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project 94f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project *) if [ x"$src" = x ] 95f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project then 96f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project src=$1 97f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project else 98f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project # this colon is to work around a 386BSD /bin/sh bug 99f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project : 100f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project dst=$1 101f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project fi 102f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project shift 103f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project continue;; 104f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project esac 105f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Projectdone 106f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project 107f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Projectif [ x"$src" = x ] 108f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Projectthen 109f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project echo "install: no input file specified" 110f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project exit 1 111f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Projectelse 112f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project true 113f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Projectfi 114f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project 115f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Projectif [ x"$dir_arg" != x ]; then 116f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project dst=$src 117f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project src="" 118f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project 119f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project if [ -d $dst ]; then 120f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project instcmd=: 121f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project chmodcmd="" 122f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project else 123f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project instcmd=mkdir 124f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project fi 125f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Projectelse 126f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project 127f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project# Waiting for this to be detected by the "$instcmd $src $dsttmp" command 128f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project# might cause directories to be created, which would be especially bad 129f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project# if $src (and thus $dsttmp) contains '*'. 130f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project 131f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project if [ -f $src -o -d $src ] 132f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project then 133f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project true 134f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project else 135f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project echo "install: $src does not exist" 136f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project exit 1 137f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project fi 138f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project 139f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project if [ x"$dst" = x ] 140f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project then 141f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project echo "install: no destination specified" 142f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project exit 1 143f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project else 144f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project true 145f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project fi 146f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project 147f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project# If destination is a directory, append the input filename; if your system 148f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project# does not like double slashes in filenames, you may need to add some logic 149f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project 150f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project if [ -d $dst ] 151f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project then 152f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project dst="$dst"/`basename $src` 153f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project else 154f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project true 155f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project fi 156f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Projectfi 157f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project 158f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project## this sed command emulates the dirname command 159f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Projectdstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'` 160f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project 161f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project# Make sure that the destination directory exists. 162f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project# this part is taken from Noah Friedman's mkinstalldirs script 163f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project 164f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project# Skip lots of stat calls in the usual case. 165f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Projectif [ ! -d "$dstdir" ]; then 166f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source ProjectdefaultIFS=' 167f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project' 168f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source ProjectIFS="${IFS-${defaultIFS}}" 169f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project 170f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source ProjectoIFS="${IFS}" 171f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project# Some sh's can't handle IFS=/ for some reason. 172f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source ProjectIFS='%' 173f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Projectset - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'` 174f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source ProjectIFS="${oIFS}" 175f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project 176f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Projectpathcomp='' 177f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project 178f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Projectwhile [ $# -ne 0 ] ; do 179f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project pathcomp="${pathcomp}${1}" 180f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project shift 181f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project 182f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project if [ ! -d "${pathcomp}" ] ; 183f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project then 184f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project $mkdirprog "${pathcomp}" 185f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project else 186f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project true 187f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project fi 188f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project 189f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project pathcomp="${pathcomp}/" 190f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Projectdone 191f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Projectfi 192f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project 193f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Projectif [ x"$dir_arg" != x ] 194f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Projectthen 195f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project $doit $instcmd $dst && 196f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project 197f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi && 198f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi && 199f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi && 200f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi 201f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Projectelse 202f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project 203f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project# If we're going to rename the final executable, determine the name now. 204f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project 205f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project if [ x"$transformarg" = x ] 206f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project then 207f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project dstfile=`basename $dst` 208f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project else 209f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project dstfile=`basename $dst $transformbasename | 210f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project sed $transformarg`$transformbasename 211f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project fi 212f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project 213f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project# don't allow the sed command to completely eliminate the filename 214f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project 215f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project if [ x"$dstfile" = x ] 216f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project then 217f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project dstfile=`basename $dst` 218f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project else 219f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project true 220f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project fi 221f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project 222f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project# Make a temp file name in the proper directory. 223f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project 224f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project dsttmp=$dstdir/#inst.$$# 225f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project 226f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project# Move or copy the file name to the temp name 227f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project 228f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project $doit $instcmd $src $dsttmp && 229f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project 230f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project trap "rm -f ${dsttmp}" 0 && 231f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project 232f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project# and set any options; do chmod last to preserve setuid bits 233f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project 234f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project# If any of these fail, we abort the whole thing. If we want to 235f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project# ignore errors from any of these, just make sure not to ignore 236f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project# errors from the above "$doit $instcmd $src $dsttmp" command. 237f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project 238f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi && 239f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi && 240f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi && 241f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi && 242f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project 243f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project# Now rename the file to the real destination. 244f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project 245f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project $doit $rmcmd -f $dstdir/$dstfile && 246f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project $doit $mvcmd $dsttmp $dstdir/$dstfile 247f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project 248f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Projectfi && 249f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project 250f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Project 251f7fc46c63fdc8f39234fea409b8dbe116d73ebf8The Android Open Source Projectexit 0 252