#!@PERL@ ## ## shtoolize -- Build shtool script out of ingredient scripts ## 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 . ## require 5.000; use strict; ## ## CONFIGURATION ## # General configuration my $version = "@SHTOOL_VERSION_STR@"; my $prefix = "@prefix@"; my $datarootdir = "@datarootdir@"; my $datadir = "@datadir@"; my $scriptdir = "$datadir/shtool"; # Available modules my @available = qw( echo mdate table prop move install mkdir mkln mkshadow fixperm rotate tarball subst platform arx slo scpp version path ); ## ## COMMAND LINE HANDLING ## my $opt_h = 0; my $opt_v = 0; my $opt_q = 0; my $opt_o = 'shtool'; # this subroutine is derived from Perl's getopts.pl with the enhancement of # the "+" metacharater at the format string to allow a list to be build by # subsequent occurance of the same option. We use it here as a local copy # to be maximum independent. sub mygetopt { my ($progname, $argumentative, @ARGV) = @_; my (@args, $first, $rest, $pos); my ($errs) = 0; local ($_); local ($[) = 0; @args = split( / */, $argumentative); while(@ARGV && ($_ = $ARGV[0]) =~ /^-(.)(.*)/) { ($first, $rest) = ($1,$2); if ($_ =~ m|^--$|) { shift(@ARGV); last; } $pos = index($argumentative,$first); if($pos >= $[) { if($args[$pos+1] eq ':') { shift(@ARGV); if($rest eq '') { unless (@ARGV) { print STDERR "$progname:Error: incomplete option: `$first' (needs an argument)\n"; ++$errs; } $rest = shift(@ARGV); } eval "\$opt_$first = \$rest;"; } elsif ($args[$pos+1] eq '+') { shift(@ARGV); if($rest eq '') { unless (@ARGV) { print STDERR "$progname:Error: incomplete option: `$first' (needs an argument)\n"; ++$errs; } $rest = shift(@ARGV); } eval "push(\@opt_$first, \$rest);"; } else { eval "\$opt_$first = 1"; if($rest eq '') { shift(@ARGV); } else { $ARGV[0] = "-$rest"; } } } else { print STDERR "$progname:Error: unknown option: `$first'\n"; ++$errs; if($rest ne '') { $ARGV[0] = "-$rest"; } else { shift(@ARGV); } } } return ($errs == 0, @ARGV); } sub usage { my ($progname, $cmdline, $rc) = @_; print STDERR "Usage: shtoolize [-h] [-v] [-q] [-o