head 1.36; access; symbols SHTOOL_2_0_8:1.36 SHTOOL_2_0_7:1.35 SHTOOL_2_0_6:1.33 SHTOOL_2_0_5:1.33 SHTOOL_2_0_4:1.33 SHTOOL_2_0_3:1.32 SHTOOL_2_0_2:1.32 SHTOOL_2_0_1:1.31 SHTOOL_2_0_0:1.31 SHTOOL_2_0b3:1.31 SHTOOL_2_0b2:1.31 SHTOOL_2_0b1:1.31 SHTOOL_1_6:1.25.0.2 SHTOOL_1_6_2:1.25 SHTOOL_1_6_1:1.24 SHTOOL_1_6_0:1.24 SHTOOL_1_5:1.21.0.2 SHTOOL_1_5_4:1.21 SHTOOL_1_5_3:1.20 SHTOOL_1_5_2:1.20 SHTOOL_1_5_1:1.16 SHTOOL_1_5_0:1.16 SHTOOL_1_4_9:1.15 SHTOOL_1_4_8:1.15 SHTOOL_1_4_7:1.12 SHTOOL_1_4_6:1.11 SHTOOL_1_4_5:1.11 SHTOOL_1_4_4:1.11 SHTOOL_1_4_3:1.11 SHTOOL_1_4_2:1.11 SHTOOL_1_4_1:1.11 SHTOOL_1_4_0:1.11 SHTOOL_1_3_3:1.7 SHTOOL_1_3_2:1.6 SHTOOL_1_3_1:1.5 SHTOOL_1_3_0:1.5 SHTOOL_1_2_9:1.2 SHTOOL_1_2_8:1.2 SHTOOL_1_2_7:1.2 SHTOOL_1_2_6:1.2 SHTOOL_1_2_5:1.2 SHTOOL_1_2_4:1.2 SHTOOL_1_2_3:1.2 SHTOOL_1_2_2:1.2 SHTOOL_1_2_1:1.1.1.1 SHTOOL_1_2_0:1.1.1.1 SHTOOL_1_1_0:1.1.1.1 RSE:1.1.1; locks; strict; comment @# @; 1.36 date 2008.04.02.20.13.43; author rse; state Exp; branches; next 1.35; commitid eB5Wirx8MdMyDzXs; 1.35 date 2007.05.19.19.09.39; author rse; state Exp; branches; next 1.34; commitid OPUF1UBbllBTwzis; 1.34 date 2007.05.15.19.35.48; author rse; state Exp; branches; next 1.33; commitid GJKJUVDzn7sdO3is; 1.33 date 2006.02.04.09.43.25; author rse; state Exp; branches; next 1.32; commitid oWk7BmnyAitJtfkr; 1.32 date 2005.06.15.08.14.35; author rse; state Exp; branches; next 1.31; 1.31 date 2004.02.12.16.06.26; author rse; state Exp; branches; next 1.30; 1.30 date 2004.01.01.16.54.20; author rse; state Exp; branches; next 1.29; 1.29 date 2003.08.13.14.20.34; author rse; state Exp; branches; next 1.28; 1.28 date 2003.06.03.08.28.19; author rse; state Exp; branches; next 1.27; 1.27 date 2003.02.11.13.00.50; author rse; state Exp; branches; next 1.26; 1.26 date 2003.02.11.12.56.39; author rse; state Exp; branches; next 1.25; 1.25 date 2002.11.02.12.46.19; author rse; state Exp; branches; next 1.24; 1.24 date 2001.12.31.15.06.04; author rse; state Exp; branches; next 1.23; 1.23 date 2001.09.23.10.58.10; author rse; state Exp; branches; next 1.22; 1.22 date 2001.06.14.19.02.54; author rse; state Exp; branches; next 1.21; 1.21 date 2001.06.14.14.24.16; author rse; state Exp; branches; next 1.20; 1.20 date 2001.01.17.11.05.40; author rse; state Exp; branches; next 1.19; 1.19 date 2001.01.17.10.15.02; author rse; state Exp; branches; next 1.18; 1.18 date 2001.01.17.09.55.11; author rse; state Exp; branches; next 1.17; 1.17 date 2000.11.18.16.46.09; author rse; state Exp; branches; next 1.16; 1.16 date 2000.06.14.18.43.24; author rse; state Exp; branches; next 1.15; 1.15 date 2000.03.12.13.28.24; author rse; state Exp; branches; next 1.14; 1.14 date 2000.03.12.12.46.42; author rse; state Exp; branches; next 1.13; 1.13 date 2000.03.12.11.12.21; author rse; state Exp; branches; next 1.12; 1.12 date 99.12.24.15.11.23; author rse; state Exp; branches; next 1.11; 1.11 date 99.07.02.07.22.29; author rse; state Exp; branches; next 1.10; 1.10 date 99.07.01.15.04.36; author rse; state Exp; branches; next 1.9; 1.9 date 99.07.01.15.02.48; author rse; state Exp; branches; next 1.8; 1.8 date 99.07.01.14.42.07; author rse; state Exp; branches; next 1.7; 1.7 date 99.06.29.17.37.34; author rse; state Exp; branches; next 1.6; 1.6 date 99.06.28.15.18.44; author rse; state Exp; branches; next 1.5; 1.5 date 99.06.17.07.35.08; author rse; state Exp; branches; next 1.4; 1.4 date 99.06.12.14.46.37; author rse; state Exp; branches; next 1.3; 1.3 date 99.06.12.14.08.49; author rse; state Exp; branches; next 1.2; 1.2 date 99.05.02.10.23.41; author rse; state Exp; branches; next 1.1; 1.1 date 99.04.29.11.19.49; author rse; state Exp; branches 1.1.1.1; next ; 1.1.1.1 date 99.04.29.11.19.49; author rse; state Exp; branches; next ; desc @@ 1.36 log @adjust copyright for year 2008 @ text @## ## install -- Install a program, script or datafile ## Copyright (c) 1997-2008 Ralf S. Engelschall ## ## This file is part of shtool and free software; you can redistribute ## it and/or modify it under the terms of the GNU General Public ## License as published by the Free Software Foundation; either version ## 2 of the License, or (at your option) any later version. ## ## This file is distributed in the hope that it will be useful, ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ## General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this program; if not, write to the Free Software ## Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, ## USA, or contact Ralf S. Engelschall . ## str_tool="install" str_usage="[-v|--verbose] [-t|--trace] [-d|--mkdir] [-c|--copy] [-C|--compare-copy] [-s|--strip] [-m|--mode ] [-o|--owner ] [-g|--group ] [-e|--exec ] [ ...] " arg_spec="1+" opt_spec="v.t.d.c.C.s.m:o:g:e+" opt_alias="v:verbose,t:trace,d:mkdir,c:copy,C:compare-copy,s:strip,m:mode,o:owner,g:group,e:exec" opt_v=no opt_t=no opt_d=no opt_c=no opt_C=no opt_s=no opt_m="0755" opt_o="" opt_g="" opt_e="" . ./sh.common # special case: "shtool install -d [...]" internally # maps to "shtool mkdir -f -p -m 755 [...]" if [ "$opt_d" = yes ]; then cmd="$0 mkdir -f -p -m 755" if [ ".$opt_o" != . ]; then cmd="$cmd -o '$opt_o'" fi if [ ".$opt_g" != . ]; then cmd="$cmd -g '$opt_g'" fi if [ ".$opt_v" = .yes ]; then cmd="$cmd -v" fi if [ ".$opt_t" = .yes ]; then cmd="$cmd -t" fi for dir in "$@@"; do eval "$cmd $dir" || shtool_exit $? done shtool_exit 0 fi # determine source(s) and destination argc=$# srcs="" while [ $# -gt 1 ]; do srcs="$srcs $1" shift done dstpath="$1" # type check for destination dstisdir=0 if [ -d $dstpath ]; then dstpath=`echo "$dstpath" | sed -e 's:/$::'` dstisdir=1 fi # consistency check for destination if [ $argc -gt 2 ] && [ $dstisdir = 0 ]; then echo "$msgprefix:Error: multiple sources require destination to be directory" 1>&2 shtool_exit 1 fi # iterate over all source(s) for src in $srcs; do dst=$dstpath # if destination is a directory, append the input filename if [ $dstisdir = 1 ]; then dstfile=`echo "$src" | sed -e 's;.*/\([^/]*\)$;\1;'` dst="$dst/$dstfile" fi # check for correct arguments if [ ".$src" = ".$dst" ]; then echo "$msgprefix:Warning: source and destination are the same - skipped" 1>&2 continue fi if [ -d "$src" ]; then echo "$msgprefix:Warning: source \`$src' is a directory - skipped" 1>&2 continue fi # make a temp file name in the destination directory dsttmp=`echo $dst |\ sed -e 's;[^/]*$;;' -e 's;\(.\)/$;\1;' -e 's;^$;.;' \ -e "s;\$;/#INST@@$$#;"` # verbosity if [ ".$opt_v" = .yes ]; then echo "$src -> $dst" 1>&2 fi # copy or move the file name to the temp name # (because we might be not allowed to change the source) if [ ".$opt_C" = .yes ]; then opt_c=yes fi if [ ".$opt_c" = .yes ]; then if [ ".$opt_t" = .yes ]; then echo "cp $src $dsttmp" 1>&2 fi cp "$src" "$dsttmp" || shtool_exit $? else if [ ".$opt_t" = .yes ]; then echo "mv $src $dsttmp" 1>&2 fi mv "$src" "$dsttmp" || shtool_exit $? fi # adjust the target file if [ ".$opt_e" != . ]; then sed='sed' OIFS="$IFS"; IFS="$ASC_NL"; set -- $opt_e; IFS="$OIFS" for e do sed="$sed -e '$e'" done cp "$dsttmp" "$dsttmp.old" chmod u+w $dsttmp eval "$sed <$dsttmp.old >$dsttmp" || shtool_exit $? rm -f $dsttmp.old fi if [ ".$opt_s" = .yes ]; then if [ ".$opt_t" = .yes ]; then echo "strip $dsttmp" 1>&2 fi strip $dsttmp || shtool_exit $? fi if [ ".$opt_o" != . ]; then if [ ".$opt_t" = .yes ]; then echo "chown $opt_o $dsttmp" 1>&2 fi chown $opt_o $dsttmp || shtool_exit $? fi if [ ".$opt_g" != . ]; then if [ ".$opt_t" = .yes ]; then echo "chgrp $opt_g $dsttmp" 1>&2 fi chgrp $opt_g $dsttmp || shtool_exit $? fi if [ ".$opt_m" != ".-" ]; then if [ ".$opt_t" = .yes ]; then echo "chmod $opt_m $dsttmp" 1>&2 fi chmod $opt_m $dsttmp || shtool_exit $? fi # determine whether to do a quick install # (has to be done _after_ the strip was already done) quick=no if [ ".$opt_C" = .yes ]; then if [ -r $dst ]; then if cmp -s "$src" "$dst"; then quick=yes fi fi fi # finally, install the file to the real destination if [ $quick = yes ]; then if [ ".$opt_t" = .yes ]; then echo "rm -f $dsttmp" 1>&2 fi rm -f $dsttmp else if [ ".$opt_t" = .yes ]; then echo "rm -f $dst && mv $dsttmp $dst" 1>&2 fi rm -f $dst && mv $dsttmp $dst fi done shtool_exit 0 ## ## manual page ## =pod =head1 NAME B - B install(1) command =head1 SYNOPSIS B [B<-v>|B<--verbose>] [B<-t>|B<--trace>] [B<-d>|B<--mkdir>] [B<-c>|B<--copy>] [B<-C>|B<--compare-copy>] [B<-s>|B<--strip>] [B<-m>|B<--mode> I] [B<-o>|B<--owner> I] [B<-g>|B<--group> I] [B<-e>|B<--exec> I] I [I ...] I =head1 DESCRIPTION This command installs a one or more Is to a given target I providing all important options of the BSD install(1) command. The trick is that the functionality is provided in a portable way. =head1 OPTIONS The following command line options are available. =over 4 =item B<-v>, B<--verbose> Display some processing information. =item B<-t>, B<--trace> Enable the output of the essential shell commands which are executed. =item B<-d>, B<--mkdir> To maximize BSD compatiblity, the BSD "B C" usage is internally mapped to the "B C" command. =item B<-c>, B<--copy> Copy the I to the target I. Default is to move. =item B<-C>, B<--compare-copy> Same as B<-c> except if the destination file already exists and is identical to the source file, no installation is done and the target remains untouched. =item B<-s>, B<--strip> This option strips program executables during the installation, see strip(1). Default is to install verbatim. =item B<-m>, B<--mode> I The file mode applied to the target, see chmod(1). Setting mode to "C<->" skips this step and leaves the operating system default which is usually based on umask(1). Some file modes require superuser privileges to be set. Default is 0755. =item B<-o>, B<--owner> I The file owner name or id applied to the target, see chown(1). This option requires superuser privileges to execute. Default is to skip this step and leave the operating system default which is usually based on the executing uid or the parent setuid directory. =item B<-g>, B<--group> I The file group name or id applied to the target, see chgrp(1). This option requires superuser privileges to execute to the fullest extend, otherwise the choice of I is limited on most operating systems. Default is to skip this step and leave the operating system default which is usually based on the executing gid or the parent setgid directory. =item B<-e>, B<--exec> I This option can be used one or multiple times to apply one or more sed(1) commands to the file contents during installation. =back =head1 EXAMPLE # Makefile install: : shtool install -c -s -m 4755 foo $(bindir)/ shtool install -c -m 644 foo.man $(mandir)/man1/foo.1 shtool install -c -m 644 -e "s/@@p@@/$prefix/g" foo.conf $(etcdir)/ =head1 HISTORY The B B command was originally written by Ralf S. Engelschall Erse@@engelschall.comE in 1997 for B. It was prompted by portability issues in the installation procedures of B libraries. =head1 SEE ALSO shtool(1), umask(1), chmod(1), chown(1), chgrp(1), strip(1), sed(1). =cut @ 1.35 log @Adjust copyright for year 2007. @ text @d3 1 a3 1 ## Copyright (c) 1997-2007 Ralf S. Engelschall @ 1.34 log @1. Fix "shtool mkln" by fixing the determination whether relative source paths can be used or not. 2. Make "shtool install" more robust by quoting arguments. @ text @d3 1 a3 1 ## Copyright (c) 1997-2006 Ralf S. Engelschall @ 1.33 log @Adjust copyright for year 2006 @ text @d122 1 a122 1 cp $src $dsttmp || shtool_exit $? d127 1 a127 1 mv $src $dsttmp || shtool_exit $? d138 1 a138 1 cp $dsttmp $dsttmp.old d173 1 a173 1 if cmp -s $src $dst; then @ 1.32 log @Adjust copyright for year 2005 @ text @d3 1 a3 1 ## Copyright (c) 1997-2005 Ralf S. Engelschall @ 1.31 log @Embedded the command documentation from shtool.pod into the individual sh.xxxx scripts and this way split the large shtool(1) manual page into individual manual pages shtool-xxxx(1). Submitted partly by: Thomas Lotterer @ text @d3 1 a3 1 ## Copyright (c) 1997-2004 Ralf S. Engelschall @ 1.30 log @Bump copyright year for 2004 @ text @a3 1 ## Originally written for shtool d192 120 @ 1.29 log @Replace "[ x -o/-a x ]" constructs with "[ x ] ||/&& [ x ]" and "egrep"/"fgrep" constructs with compatible "grep" or "case" constructs. This way GNU shtool is now more POSIX 1003.1-2001 compliant. Submitted by: Paul Eggert @ text @d3 1 a3 1 ## Copyright (c) 1997-2003 Ralf S. Engelschall @ 1.28 log @Make sure "shtool install -e ..." does not fail with "permission denied" on the internally created temporary files if the source file is not writeable to the current user. This occurs because cp(1) does not in all cases honor umask(2) (even without option -p) -- mainly if the source file is already owned by the current user (then the permissions are always copied). Hence an explicit "chmod u+w" is required if the "shtool install" substitution feature (option -e) is used. Discovered by: Thomas Lotterer @ text @d79 1 a79 1 if [ $argc -gt 2 -a $dstisdir = 0 ]; then @ 1.27 log @Bump year in copyright messages to cover new year 2003. @ text @d140 1 @ 1.26 log @Fixed error exit in all commands by introducing an "shtool_exit" function (which correctly cleans up temporary files) and replacing all "exit" calls with "shtool_exit". THIS THE FIRST TIME INTRODUCED THE USAGE OF A SHELL FUNCTION TO THE SHTOOL CODE. This is known to break on _very_ anchient and broken Bourne-Shell implementations and is considered to be no longer a real problem in the year 2003. Especially there is no alternative way anyway. @ text @d3 1 a3 1 ## Copyright (c) 1997-2002 Ralf S. Engelschall @ 1.25 log @Map "shtool install -d [...]" internally to "shtool mkdir -f -p -m 755 [...]" in order to support the BSD-style "install -d" variant. Idea (and initial patch) submitted by: Alan Eldridge @ text @d57 1 a57 1 eval "$cmd $dir" || exit $? d59 1 a59 1 exit 0 d81 1 a81 1 exit 1 d123 1 a123 1 cp $src $dsttmp || exit $? d128 1 a128 1 mv $src $dsttmp || exit $? d140 1 a140 1 eval "$sed <$dsttmp.old >$dsttmp" || exit $? d147 1 a147 1 strip $dsttmp || exit $? d153 1 a153 1 chown $opt_o $dsttmp || exit $? d159 1 a159 1 chgrp $opt_g $dsttmp || exit $? d165 1 a165 1 chmod $opt_m $dsttmp || exit $? @ 1.24 log @bump copyright years @ text @d23 4 a26 4 str_usage="[-v|--verbose] [-t|--trace] [-c|--copy] [-C|--compare-copy] [-s|--strip] [-m|--mode ] [-o|--owner ] [-g|--group ] [-e|--exec ] [ ...] " arg_spec="2+" opt_spec="v.t.c.C.s.m:o:g:e+" opt_alias="v:verbose,t:trace,c:copy,C:compare-copy,s:strip,m:mode,o:owner,g:group,e:exec" d29 1 d39 22 @ 1.23 log @*** empty log message *** @ text @d3 1 a3 1 ## Copyright (c) 1997-2001 Ralf S. Engelschall @ 1.22 log @*** empty log message *** @ text @d23 1 a23 1 str_usage="[-v] [-t] [-c] [-C] [-s] [-m] [-o] [-g] [-e] [ ...] " d26 1 @ 1.21 log @*** empty log message *** @ text @d110 3 a112 1 for e in $opt_e; do @ 1.20 log @*** empty log message *** @ text @d38 1 a38 1 # determine source(s) and destination @ 1.19 log @*** empty log message *** @ text @d115 1 @ 1.18 log @*** empty log message *** @ text @d23 1 a23 1 str_usage="[-v] [-t] [-c] [-C] [-s] [-m] [-o] [-g] [-e] [ ...] " d25 1 a25 1 opt_spec="v.t.c.C.s.m:o:g:e:" d64 1 a64 1 # If destination is a directory, append the input filename d70 1 a70 7 # Add a possible extension to src and dst if [ ".$opt_e" != . ]; then src="$src$opt_e" dst="$dst$opt_e" fi # Check for correct arguments d80 1 a80 1 # Make a temp file name in the destination directory d85 1 a85 1 # Verbosity d90 2 a91 2 # Copy or move the file name to the temp name # (because we might be not allowed to change the source) d107 9 a115 1 # Adjust the target file d134 5 a138 2 if [ ".$opt_t" = .yes ]; then echo "chmod $opt_m $dsttmp" 1>&2 a139 1 chmod $opt_m $dsttmp || exit $? d141 1 a141 1 # Determine whether to do a quick install d152 1 a152 1 # Finally install the file to the real destination @ 1.17 log @*** empty log message *** @ text @d3 1 a3 1 ## Copyright (c) 1997-2000 Ralf S. Engelschall @ 1.16 log @*** empty log message *** @ text @d31 1 a31 1 opt_m="" a113 1 # (we do chmod last to preserve setuid bits) d132 2 a133 5 if [ ".$opt_m" != . ]; then if [ ".$opt_t" = .yes ]; then echo "chmod $opt_m $dsttmp" 1>&2 fi chmod $opt_m $dsttmp || exit $? d135 1 @ 1.15 log @*** empty log message *** @ text @d23 2 a24 2 str_usage="[-v] [-t] [-c] [-C] [-s] [-m] [-o] [-g] [-e] " arg_spec="2=" d38 31 a68 2 src="$1" dst="$2" d70 5 a74 6 # If destination is a directory, append the input filename if [ -d $dst ]; then dst=`echo "$dst" | sed -e 's:/$::'` dstfile=`echo "$src" | sed -e 's;.*/\([^/]*\)$;\1;'` dst="$dst/$dstfile" fi d76 9 a84 5 # Add a possible extension to src and dst if [ ".$opt_e" != . ]; then src="$src$opt_e" dst="$dst$opt_e" fi d86 4 a89 5 # Check for correct arguments if [ ".$src" = ".$dst" ]; then echo "$msgprefix:Error: source and destination are the same" 1>&2 exit 1 fi d91 4 a94 8 # Make a temp file name in the destination directory dstdir=`echo $dst | sed -e 's;[^/]*$;;' -e 's;\(.\)/$;\1;' -e 's;^$;.;'` dsttmp="$dstdir/#INST@@$$#" # Verbosity if [ ".$opt_v" = .yes ]; then echo "$src -> $dst" 1>&2 fi d96 15 a110 13 # Copy or move the file name to the temp name # (because we might be not allowed to change the source) if [ ".$opt_C" = .yes ]; then opt_c=yes fi if [ ".$opt_c" = .yes ]; then if [ ".$opt_t" = .yes ]; then echo "cp $src $dsttmp" 1>&2 fi cp $src $dsttmp || exit $? else if [ ".$opt_t" = .yes ]; then echo "mv $src $dsttmp" 1>&2 a111 2 mv $src $dsttmp || exit $? fi d113 7 a119 5 # Adjust the target file # (we do chmod last to preserve setuid bits) if [ ".$opt_s" = .yes ]; then if [ ".$opt_t" = .yes ]; then echo "strip $dsttmp" 1>&2 d121 5 a125 5 strip $dsttmp || exit $? fi if [ ".$opt_o" != . ]; then if [ ".$opt_t" = .yes ]; then echo "chown $opt_o $dsttmp" 1>&2 d127 5 a131 5 chown $opt_o $dsttmp || exit $? fi if [ ".$opt_g" != . ]; then if [ ".$opt_t" = .yes ]; then echo "chgrp $opt_g $dsttmp" 1>&2 d133 5 a137 5 chgrp $opt_g $dsttmp || exit $? fi if [ ".$opt_m" != . ]; then if [ ".$opt_t" = .yes ]; then echo "chmod $opt_m $dsttmp" 1>&2 a138 2 chmod $opt_m $dsttmp || exit $? fi d140 8 a147 7 # Determine whether to do a quick install # (has to be done _after_ the strip was already done) quick=no if [ ".$opt_C" = .yes ]; then if [ -r $dst ]; then if cmp -s $src $dst; then quick=yes a149 1 fi d151 11 a161 9 # Finally install the file to the real destination if [ $quick = yes ]; then if [ ".$opt_t" = .yes ]; then echo "rm -f $dsttmp" 1>&2 fi rm -f $dsttmp else if [ ".$opt_t" = .yes ]; then echo "rm -f $dst && mv $dsttmp $dst" 1>&2 d163 1 a163 2 rm -f $dst && mv $dsttmp $dst fi @ 1.14 log @*** empty log message *** @ text @d25 6 a30 1 opt_spec="vtcCsm:o:g:e:" @ 1.13 log @*** empty log message *** @ text @d24 1 a24 1 arg_spec="2" @ 1.12 log @*** empty log message *** @ text @d3 1 a3 1 ## Copyright (c) 1997-1999 Ralf S. Engelschall @ 1.11 log @*** empty log message *** @ text @d26 4 @ 1.10 log @*** empty log message *** @ text @d62 3 @ 1.9 log @*** empty log message *** @ text @d66 1 a66 1 cp $src $dsttmp || exit $? d82 1 a82 1 if [ ".$opt_o" != . ]; then @ 1.8 log @*** empty log message *** @ text @d88 1 a88 1 if [ ".$opt_g" != . ]; then @ 1.7 log @*** empty log message *** @ text @d23 1 a23 1 str_usage="[-c] [-C] [-s] [-m] [-o] [-g] [-e] " d25 1 a25 1 opt_spec="cCsm:o:g:e:" d34 3 a36 1 dst="$dst/`echo "$src" | sed -e 's;.*/\([^/]*\)$;\1;'`" d45 6 d52 7 a58 2 dstdir=`echo $dst | sed -e 's;[^/]*$;;' -e 's;\(.\)/$;\1;'` dsttmp="$dstdir/#inst.$$#" d61 1 d63 4 a66 1 cp $src $dsttmp d68 4 a71 1 mv $src $dsttmp d74 2 a75 1 # Set options; do chmod last to preserve setuid bits d77 4 a80 1 strip $dsttmp d83 4 a86 1 chown $opt_o $dsttmp d89 4 a92 1 chgrp $opt_g $dsttmp d95 4 a98 1 chmod $opt_m $dsttmp d102 1 d114 3 d119 4 a122 2 rm -f $dst mv $dsttmp $dst @ 1.6 log @*** empty log message *** @ text @d64 1 a64 1 if [ ".$opt_m" != . ]; then @ 1.5 log @*** empty log message *** @ text @d27 1 a27 1 . sh.common @ 1.4 log @*** empty log message *** @ text @d23 1 a23 1 str_usage="[-c] [-C] [-s] [-m] [-o] [-g] [-e] " @ 1.3 log @*** empty log message *** @ text @d6 15 @ 1.2 log @*** empty log message *** @ text @a0 1 #!/bin/sh d4 1 a4 3 ## Originally written and placed into public domain 1989 by X Consortium ## Cleaned up for the Apache configuration mechanism by Ralf S. Engelschall ## Usage: install [-c] [-m ] [-o ] [-g ] [-s] [-S ] [-e ] d7 11 a17 69 # # put in absolute paths if you don't have them in your path; # or use env. vars. # mvprog="${MVPROG-mv}" cpprog="${CPPROG-cp}" chmodprog="${CHMODPROG-chmod}" chownprog="${CHOWNPROG-chown}" chgrpprog="${CHGRPPROG-chgrp}" stripprog="${STRIPPROG-strip}" rmprog="${RMPROG-rm}" # # parse argument line # instcmd="$mvprog" chmodcmd="" chowncmd="" chgrpcmd="" stripcmd="" rmcmd="$rmprog -f" mvcmd="$mvprog" ext="" src="" dst="" while [ ".$1" != . ]; do case $1 in -c) instcmd="$cpprog" shift; continue ;; -m) chmodcmd="$chmodprog $2" shift; shift; continue ;; -o) chowncmd="$chownprog $2" shift; shift; continue ;; -g) chgrpcmd="$chgrpprog $2" shift; shift; continue ;; -s) stripcmd="$stripprog" shift; continue;; -S) stripcmd="$stripprog $2" shift; shift; continue ;; -e) ext="$2" shift; shift; continue ;; *) if [ ".$src" = . ]; then src=$1 else dst=$1 fi shift; continue ;; esac done if [ ".$src" = . ]; then echo "install.sh: no input file specified" exit 1 fi if [ ".$dst" = . ]; then echo "install.sh: no destination specified" exit 1 fi # # If destination is a directory, append the input filename; if # your system does not like double slashes in filenames, you may # need to add some logic # d19 1 a19 1 dst="$dst/`basename $src`" d22 5 a26 3 # Add a possible extension (such as ".exe") to src and dst src="$src$ext" dst="$dst$ext" d28 10 a37 3 # Make a temp file name in the proper directory. dstdir=`dirname $dst` dsttmp=$dstdir/#inst.$$# d39 13 a51 2 # Move or copy the file name to the temp name $instcmd $src $dsttmp d53 9 a61 5 # And set any options; do chmod last to preserve setuid bits if [ ".$chowncmd" != . ]; then $chowncmd $dsttmp; fi if [ ".$chgrpcmd" != . ]; then $chgrpcmd $dsttmp; fi if [ ".$stripcmd" != . ]; then $stripcmd $dsttmp; fi if [ ".$chmodcmd" != . ]; then $chmodcmd $dsttmp; fi d63 7 a69 5 # Now rename the file to the real destination. $rmcmd $dst $mvcmd $dsttmp $dst exit 0 @ 1.1 log @Initial revision @ text @d7 1 a7 1 ## Usage: install [-c] [-m ] [-o ] [-g ] [-s] [-S ] d32 1 d53 3 d82 4 @ 1.1.1.1 log @Import of shtool 1.1.0 @ text @@