head 1.27; access; symbols SHTOOL_2_0_8:1.27 SHTOOL_2_0_7:1.26 SHTOOL_2_0_6:1.25 SHTOOL_2_0_5:1.25 SHTOOL_2_0_4:1.25 SHTOOL_2_0_3:1.23 SHTOOL_2_0_2:1.23 SHTOOL_2_0_1:1.22 SHTOOL_2_0_0:1.22 SHTOOL_2_0b3:1.22 SHTOOL_2_0b2:1.22 SHTOOL_2_0b1:1.22 SHTOOL_1_6:1.16.0.2 SHTOOL_1_6_2:1.16 SHTOOL_1_6_1:1.16 SHTOOL_1_6_0:1.16 SHTOOL_1_5:1.14.0.2 SHTOOL_1_5_4:1.14 SHTOOL_1_5_3:1.14 SHTOOL_1_5_2:1.13 SHTOOL_1_5_1:1.10 SHTOOL_1_5_0:1.10 SHTOOL_1_4_9:1.10 SHTOOL_1_4_8:1.8 SHTOOL_1_4_7:1.6 SHTOOL_1_4_6:1.5 SHTOOL_1_4_5:1.3 SHTOOL_1_4_4:1.3; locks; strict; comment @# @; 1.27 date 2008.04.02.20.13.44; author rse; state Exp; branches; next 1.26; commitid eB5Wirx8MdMyDzXs; 1.26 date 2007.05.19.19.09.39; author rse; state Exp; branches; next 1.25; commitid OPUF1UBbllBTwzis; 1.25 date 2006.02.04.09.54.07; author rse; state Exp; branches; next 1.24; commitid GY6TnBsMlrFlxfkr; 1.24 date 2006.02.04.09.43.25; author rse; state Exp; branches; next 1.23; commitid oWk7BmnyAitJtfkr; 1.23 date 2005.06.15.08.14.36; author rse; state Exp; branches; next 1.22; 1.22 date 2004.02.17.08.54.14; author thl; state Exp; branches; next 1.21; 1.21 date 2004.02.12.16.06.27; author rse; state Exp; branches; next 1.20; 1.20 date 2004.01.01.16.54.20; author rse; state Exp; branches; next 1.19; 1.19 date 2003.08.13.14.20.34; author rse; state Exp; branches; next 1.18; 1.18 date 2003.02.11.13.00.50; author rse; state Exp; branches; next 1.17; 1.17 date 2003.02.11.12.56.40; author rse; state Exp; branches; next 1.16; 1.16 date 2001.12.31.15.06.04; author rse; state Exp; branches; next 1.15; 1.15 date 2001.09.23.10.58.10; author rse; state Exp; branches; next 1.14; 1.14 date 2001.02.27.15.13.32; author rse; state Exp; branches; next 1.13; 1.13 date 2001.01.17.09.55.11; author rse; state Exp; branches; next 1.12; 1.12 date 2000.11.29.19.58.58; author rse; state Exp; branches; next 1.11; 1.11 date 2000.10.05.12.02.06; author rse; state Exp; branches; next 1.10; 1.10 date 2000.03.24.15.22.51; author rse; state Exp; branches; next 1.9; 1.9 date 2000.03.15.07.18.31; author rse; state Exp; branches; next 1.8; 1.8 date 2000.03.12.13.28.24; author rse; state Exp; branches; next 1.7; 1.7 date 2000.03.12.11.12.21; author rse; state Exp; branches; next 1.6; 1.6 date 99.12.24.15.11.23; author rse; state Exp; branches; next 1.5; 1.5 date 99.09.05.13.19.03; author rse; state Exp; branches; next 1.4; 1.4 date 99.09.05.13.14.25; author rse; state Exp; branches; next 1.3; 1.3 date 99.07.17.14.40.52; author rse; state Exp; branches; next 1.2; 1.2 date 99.07.17.14.37.08; author rse; state Exp; branches; next 1.1; 1.1 date 99.07.17.14.28.40; author rse; state Exp; branches; next ; desc @@ 1.27 log @adjust copyright for year 2008 @ text @## ## tarball -- Roll distribution tarballs ## Copyright (c) 1999-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="tarball" str_usage="[-t|--trace] [-v|--verbose] [-o|--output ] [-c|--compress ] [-d|--directory ] [-u|--user ] [-g|--group ] [-e|--exclude ] [ ...]" gen_tmpfile=yes arg_spec="1+" opt_spec="t.v.o:c:d:u:g:e:" opt_alias="t:trace,v:verbose,o:output,c:compress,d:directory,u:user,g:group,e:exclude" opt_t=no opt_v=no opt_o="" opt_c="" opt_d="" opt_u="" opt_g="" opt_e="CVS,\\.cvsignore,\\.svn,\\.[oa]\$" . ./sh.common srcs="$*" # check whether the test command supports the -x option if [ -x /bin/sh ] 2>/dev/null; then minusx="-x" else minusx="-r" fi # find the tools paths="`echo $PATH |\ sed -e 's%/*:%:%g' -e 's%/*$%%' \ -e 's/^:/.:/' -e 's/::/:.:/g' -e 's/:$/:./' \ -e 's/:/ /g'`" for spec in find:gfind,find tar:gtar,tar tardy:tardy,tarcust; do prg=`echo $spec | sed -e 's/:.*$//'` tools=`echo $spec | sed -e 's/^.*://'` eval "prg_${prg}=''" # iterate over tools for tool in `echo $tools | sed -e 's/,/ /g'`; do # iterate over paths for path in $paths; do if [ $minusx "$path/$tool" ] && [ ! -d "$path/$tool" ]; then eval "prg_${prg}=\"$path/$tool\"" break fi done eval "val=\$prg_${prg}" if [ ".$val" != . ]; then break fi done done # expand source paths exclude='' for pat in `echo $opt_e | sed 's/,/ /g'`; do exclude="$exclude | grep -v '$pat'" done if [ ".$opt_t" = .yes ]; then echo "cp /dev/null $tmpfile.lst" 1>&2 fi cp /dev/null $tmpfile.lst for src in $srcs; do if [ -d $src ]; then if [ ".$opt_t" = .yes ]; then echo "(cd $src && $prg_find . -type f -depth -print) | sed -e 's:^\\.\$::' -e 's:^\\./::' | cat $exclude >>$tmpfile.lst" 1>&2 fi (cd $src && $prg_find . -type f -depth -print) |\ sed -e 's:^\.$::' -e 's:^\./::' | eval cat $exclude >>$tmpfile.lst else if [ ".$opt_t" = .yes ]; then echo "echo $src >>$tmpfile.lst" 1>&2 fi echo $src >>$tmpfile.lst fi done sort <$tmpfile.lst >$tmpfile.lst.n mv $tmpfile.lst.n $tmpfile.lst if [ ".$opt_v" = .yes ]; then cat $tmpfile.lst | sed -e 's/^/ /' 1>&2 fi # determine tarball file and directory name if [ ".$opt_o" != . ]; then tarfile="$opt_o" if [ ".$opt_d" != . ]; then tarname="$opt_d" else tarname=`echo $tarfile | sed -e 's/\.tar.*$//' -e 's;.*/\([^/]*\)$;\1;'` fi else if [ ".$opt_d" != . ]; then tarname="$opt_d" elif [ -d "$from" ]; then tarname=`echo $from | sed -e 's;.*/\([^/]*\)$;\1;'` else tarname="out" fi tarfile="$tarname.tar" fi # roll the tarball compress='' if [ ".$opt_c" != . ]; then compress="| $opt_c" fi if [ ".$prg_tardy" != . ]; then # the elegant hackers way tardy_opt="--prefix=$tarname" tardy_opt="$tardy_opt --user_number=0 --group_number=0" # security! if [ ".$opt_u" != . ]; then tardy_opt="$tardy_opt --user_name=$opt_u" fi if [ ".$opt_g" != . ]; then tardy_opt="$tardy_opt --group_name=$opt_g" fi if [ ".$opt_t" = .yes ]; then echo "cat $tmpfile.lst | xargs $prg_tar cf - | $prg_tardy $tardy_opt | cat $compress >$tmpfile.out" 1>&2 fi cat $tmpfile.lst |\ xargs $prg_tar cf - |\ $prg_tardy $tardy_opt |\ eval cat $compress >$tmpfile.out if [ ".$opt_t" = .yes ]; then echo "cp $tmpfile.out $tarfile" 1>&2 fi cp $tmpfile.out $tarfile else # the portable standard way if [ ".$opt_t" = .yes ]; then echo "mkdir $tmpdir/$tarname" 1>&2 fi mkdir $tmpdir/$tarname || shtool_exit 1 if [ ".$opt_t" = .yes ]; then echo "cat $tmpfile.lst | xargs $prg_tar cf - | (cd $tmpdir/$tarname && $prg_tar xf -)" 1>&2 fi cat $tmpfile.lst |\ xargs $prg_tar cf - |\ (cd $tmpdir/$tarname && $prg_tar xf -) if [ ".$opt_u" != . ]; then if [ ".$opt_t" = .yes ]; then echo "chown -R $opt_u $tmpdir/$tarname >/dev/null 2>&1" 2>&1 fi chown -R $opt_u $tmpdir/$tarname >/dev/null 2>&1 ||\ echo "$msgprefix:Warning: cannot set user name \`$opt_u' (would require root privileges)" fi if [ ".$opt_g" != . ]; then if [ ".$opt_t" = .yes ]; then echo "chgrp -R $opt_g $tmpdir/$tarname >/dev/null 2>&1" 2>&1 fi chgrp -R $opt_g $tmpdir/$tarname >/dev/null 2>&1 ||\ echo "$msgprefix:Warning: cannot set group name \`$opt_g' (would require root privileges)" fi if [ ".$opt_t" = .yes ]; then echo "(cd $tmpdir && $prg_find $tarname -type f -depth -print | sort | xargs $prg_tar cf -) | cat $compress >$tmpfile.out" 1>&2 fi (cd $tmpdir && $prg_find $tarname -type f -depth -print | sort | xargs $prg_tar cf -) |\ eval cat $compress >$tmpfile.out if [ ".$opt_t" = .yes ]; then echo "cp $tmpfile.out $tarfile" 1>&2 fi cp $tmpfile.out $tarfile if [ ".$opt_t" = .yes ]; then echo "rm -rf $tmpdir/$tarname" 1>&2 fi rm -rf $tmpdir/$tarname fi # cleanup if [ ".$opt_t" = .yes ]; then echo "rm -f $tmpfile.lst $tmpfile.out" 1>&2 fi rm -f $tmpfile.lst $tmpfile.out shtool_exit 0 ## ## manual page ## =pod =head1 NAME B - B command for rolling standardized tarballs =head1 SYNOPSIS B [B<-t>|B<--trace>] [B<-v>|B<--verbose>] [B<-o>|B<--output> I] [B<-c>|B<--compress> I] [B<-d>|B<--directory> I] [B<-u>|B<--user> I] [B<-g>|B<--group> I] [B<-e>|B<--exclude> I] I [I ...] =head1 DESCRIPTION This command is for rolling input files under I into a distribution tarballs which can be extracted by tar(1). The four important aspects of good open source software tarballs are: (1) unpack into a single top-level directory, (2) top-level directory corresponds to the tarball filename, (3) tarball files should be sorted and (4) arbitrary names for file owner and group. =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<-o>, B<--output> I Output tarball to file I. =item B<-c>, B<--compress> I Pipe resulting tarball through compression program I. =item B<-d>, B<--directory> I Sets the top-level directory into which the tarball unpacks. By default it is I without the trailing C<.tar.*> extension. =item B<-u>, B<--user> I The user (owner) of files and directories in the tarball to I. =item B<-g>, B<--group> I The group of files and directories in the tarball to I. =item B<-e>, B<--exclude> I Exclude files and directories matching comma-separated list of regex I from the tarball. Directories are expanded before the filtering takes place. The default filter pattern is "C". =back =head1 EXAMPLE # Makefile.in dist: ... V=`shtool version -d short ...`; \ shtool tarball -o foobar-$$V.tar.gz -c 'gzip -9' \ -u bar -g gnu -e 'CVS,\.cvsignore' . =head1 HISTORY The B B command was originally written by Ralf S. Engelschall Erse@@engelschall.comE in 1999 for B. =head1 SEE ALSO shtool(1), tar(1), compress(1). =cut @ 1.26 log @Adjust copyright for year 2007. @ text @d3 1 a3 1 ## Copyright (c) 1999-2007 Ralf S. Engelschall @ 1.25 log @Add ".svn" to the default ignore list of "shtool tarball". Add missing documentation for "shtool tarball" option "-d". Submitted by: Sakagami Hiroki @ text @d3 1 a3 1 ## Copyright (c) 1999-2006 Ralf S. Engelschall @ 1.24 log @Adjust copyright for year 2006 @ text @d34 1 a34 1 opt_e="CVS,\\.cvsignore,\\.[oa]\$" d212 1 d225 2 a226 2 corresponds to the tarball filename, (3) tarball should be sorted and (4) arbitrary names for file owner and group. d250 5 d268 1 a268 1 "C". @ 1.23 log @Adjust copyright for year 2005 @ text @d3 1 a3 1 ## Copyright (c) 1999-2005 Ralf S. Engelschall @ 1.22 log @correct spelling: privileges, convenient; @ text @d3 1 a3 1 ## Copyright (c) 1999-2004 Ralf S. Engelschall @ 1.21 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 @d163 1 a163 1 echo "$msgprefix:Warning: cannot set user name \`$opt_u' (would require root priviledges)" d170 1 a170 1 echo "$msgprefix:Warning: cannot set group name \`$opt_g' (would require root priviledges)" @ 1.20 log @Bump copyright year for 2004 @ text @a3 1 ## Originally written for shtool d192 93 @ 1.19 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) 1999-2003 Ralf S. Engelschall @ 1.18 log @Bump year in copyright messages to cover new year 2003. @ text @d61 1 a61 1 if [ $minusx "$path/$tool" -a ! -d "$path/$tool" ]; then @ 1.17 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) 1999-2002 Ralf S. Engelschall @ 1.16 log @bump copyright years @ text @d152 1 a152 1 mkdir $tmpdir/$tarname || exit 1 @ 1.15 log @*** empty log message *** @ text @d3 1 a3 1 ## Copyright (c) 1999-2001 Ralf S. Engelschall @ 1.14 log @*** empty log message *** @ text @d23 1 a23 1 str_usage="[-t] [-v] [-o] [-c] [-d] [-u] [-g] [-e] [ ...]" d27 1 @ 1.13 log @*** empty log message *** @ text @d23 1 a23 1 str_usage="[-t] [-v] [-o ] [-c ] [-d ] [-u ] [-g ] [-e ] [ ...]" @ 1.12 log @*** empty log message *** @ text @d3 1 a3 1 ## Copyright (c) 1999-2000 Ralf S. Engelschall @ 1.11 log @*** empty log message *** @ text @d60 1 a60 1 if [ $minusx "$path/$tool" ] && [ ! -d "$path/$tool" ]; then @ 1.10 log @*** empty log message *** @ text @d86 1 a86 1 (cd $src && find . -type f -depth -print) |\ @ 1.9 log @*** empty log message *** @ text @d41 1 a41 7 cat >$tmpfile </dev/null; then a45 1 rm -f $tmpfile @ 1.8 log @*** empty log message *** @ text @d170 1 a170 1 echo "$msgprefix:Warning: cannot set user name \`$opt_u' (need root priviledges)" d177 1 a177 1 echo "$msgprefix:Warning: cannot set group name \`$opt_g' (need root priviledges)" @ 1.7 log @*** empty log message *** @ text @d26 3 a28 1 opt_spec="tvo:c:d:u:g:e:" @ 1.6 log @*** empty log message *** @ text @d3 1 a3 1 ## Copyright (c) 1999 Ralf S. Engelschall @ 1.5 log @*** empty log message *** @ text @d26 6 a31 1 opt_spec="tvo:c:d:u:g:e:!" @ 1.4 log @*** empty log message *** @ text @d52 1 a52 1 for spec in find:gfind,find tar:gtar,tar tardy:tardy tarcust:tarcust; do d125 1 a125 1 if [ ".$prg_tardy" != . -o ".$prg_tarcust" != . ]; then a126 3 if [ ".$prg_tarcust" != . ]; then prg_tardy="$prg_tarcust" fi @ 1.3 log @*** empty log message *** @ text @d52 1 a52 1 for spec in find:gfind,find tar:gtar,tar tardy:tardy; do d125 1 a125 1 if [ ".$prg_tardy" != . ]; then d127 3 @ 1.2 log @*** empty log message *** @ text @d52 1 a52 1 for spec in find:gfind,find tar:gtar,tar tardy:xtardy; do @ 1.1 log @*** empty log message *** @ text @d52 1 a52 1 for spec in tar:gtar,tar tardy:tardy find:gfind,find; do d84 1 a84 1 echo "(cd $src && find . -type f -depth -print) | sed -e 's:^\\.\$::' -e 's:^\\./::' | cat $exclude >>$tmpfile.lst" 1>&2 d143 1 a143 1 echo "cp $tmpfile.out $tarfile && rm -f $tmpfile.out" 1>&2 d145 1 a145 1 cp $tmpfile.out $tarfile && rm -f $tmpfile.out d173 1 a173 1 echo "(cd $tmpdir && $prg_tar cf - $tarname) | cat $compress >$tmpfile.out" 1>&2 d175 1 a175 1 (cd $tmpdir && $prg_tar cf - $tarname) |\ d178 1 a178 1 echo "cp $tmpfile.out $tarfile && rm -rf $tmpdir/$tarname" 1>&2 d180 5 a184 1 cp $tmpfile.out $tarfile && rm -rf $tmpdir/$tarname d189 1 a189 1 echo "rm -f $tmpfile.lst" 1>&2 d191 1 a191 1 rm -f $tmpfile.lst @