#!/usr/local/bin/perl -w =head1 NAME fo_customise_client.pl - Sets client form defaults for our site. =head1 SYNOPSIS customise_client.pl %serverport% %formname% %formfile% =head1 DESCRIPTION Form-out trigger script to modify new client forms when presented to the user. Some default values such as the SubmitOptions, LineEnd and the mapping of the specdepot are changed. =head1 NOTES This script requires P4 Perl API 2007.3 or above, which is not bundled with Perl. =head1 AUTHOR Guillaume Barthelemy >, June 2008. =cut use strict; use File::Basename; use P4; our $p4 = new P4; my $port = shift; my $client = shift; my $form = shift; # Identify trigger in server logs $p4->SetProg(basename($0)); $p4->SetPort($port); $p4->SetClient($client); # Tagged mode by default $p4->Connect() or die ("Couldn't initialise p4 connection.\n\n", $p4->Errors(), "\n"); # use p4 info to efficiently check if client exists my $inforef = $p4->RunInfo(); $p4->Disconnect(); # exit if client exists if (@$inforef[0]->{'clientName'} eq '*unknown*') { # Slurp temporary file open FORM, '<', $form or die ("Trigger couldn't read from temporary file $form.\n"); my @lines =
; close FORM; # Perform modifications open FORM, '>', $form or die ("Couldn't write to temporary file $form.\n"); foreach my $line (@lines) { $line =~ s/^SubmitOptions:\s+submitunchanged/SubmitOptions:\trevertunchanged/; $line =~ s/^LineEnd:\s+local/LineEnd:\tshare/; next if ($line =~ m|^\s+//specdepot/\.\.\.|); print FORM $line; } close FORM; } exit 0;