mkclient.pl #1

  • //
  • guest/
  • matthew_rice/
  • p4modules/
  • bin/
  • mkclient.pl
  • View
  • Commits
  • Open Download .zip Download (2 KB)
#!/usr/bin/perl -w

use lib '.';
use Getopt::Long;
use P4::Modules;

($CLIENT, $ROOT, $MODULES, $EXTRAS) = ('', '', '', '');
($OPTIONS, $BRANCH, $file) = ('rmdir', 'main', '');

my $help = 0;
(my $cmd = $0) =~ s/.*\///;

sub usage {
    print <<_EOF_;
Usage: $cmd -f file configfile
       $cmd -b branch -c client -e 'extra' -f file -m 'modules' -o 'options' -r root
       $cmd -h

    -b branch    the default branch to use               (def. $BRANCH)
    -c client    create/update this client               (no default)
    -e extra     one extra client view mapping           (no default)
    -f file      the modules file to use                 (def. system installed)
    -h           show usage
    -m modules   modules to map from the perforce depots (def. all of them)
    -o options   perforce client options                 (def. $OPTIONS)
    -r root      perforce client root directory          (no default)

_EOF_
    exit $_[0] || 0;
}
usage(0) unless @ARGV;
GetOptions('branch=s'	=> \$BRANCH,
	   'client=s'	=> \$CLIENT,
	   'extra=s'	=> \$EXTRAS,
	   'file=s'	=> \$file,
	   'help'	=> \$help,
	   'modules=s'	=> \$MODULES,
	   'options=s'	=> \$OPTIONS,
	   'root=s'	=> \$ROOT) || usage(1);
	
usage(0) if $help;

my $config = shift;
require $config if $config;

my $mod = P4::Modules->new($file);
my %map = $mod->client($BRANCH, $MODULES, $CLIENT);

$client_spec = <<_EOF_;
Client: $CLIENT

Description:
        Automatically generated client
	OPTIONS: $OPTIONS
	BRANCH:  $BRANCH
        MODULES: $MODULES

Root: $ROOT

Options: $OPTIONS

View:
_EOF_

$client_spec .= join("\n", map { "\t$_ $map{$_}" } keys %map) . "\n";
$client_spec .= join("\n", map { "\t$_" } split /\n+/, $EXTRAS) . "\n";
print "$client_spec";
# Change User Description Committed
#1 843 Matthew Rice Matt's cvs2p4 1.2.25 release