diff -r 000000000000 -r 83f4b4db085c bldsystemtools/commonbldutils/SetP4Client.pm --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bldsystemtools/commonbldutils/SetP4Client.pm Tue Feb 02 01:39:43 2010 +0200 @@ -0,0 +1,150 @@ +# Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies). +# All rights reserved. +# This component and the accompanying materials are made available +# under the terms of the License "Eclipse Public License v1.0" +# which accompanies this distribution, and is available +# at the URL "http://www.eclipse.org/legal/epl-v10.html". +# +# Initial Contributors: +# Nokia Corporation - initial contribution. +# +# Contributors: +# +# Description: +# + +package SetP4Client; + +use strict; +use Carp; +use Sys::Hostname; + +# Start +# +# Inputs +# $iClientName (Name of the client to create) +# $iCodeline (Codeline root) +# $iUser +# $iDrive +# $iHost +# $iType +# +# Outputs +# +# Description +# + +sub Start +{ + my ( $iCodeline, $iDrive, $iType) = @_; + my ($iUser, $iHost, $iClientname); + + $iUser = &get_user(); + ($iHost) = &hostname() =~ /(\S+?)\./; + if ($iHost eq "") + { + # Not a fully qualified Hostname, use use raw name + $iHost = &hostname(); + } + print "Hostname is $iHost\n"; + $iClientname = $iHost."_source_".$iType; + + #processing codeline + $iCodeline =~ s?//CLIENTNAME/?//$iClientname/?g; + my (@iSplit_codeline) = split /\+/, $iCodeline; + for (my ($n)=1; $n <= $#iSplit_codeline; $n=$n+2) + { + $iSplit_codeline[$n] .= "\n"; + } + + #Flushes and deletes old client, then creates new client and sets it as a default + &set_view($iClientname); + #Sets up client specification + &set_client($iHost, $iClientname, $iUser, $iDrive, @iSplit_codeline); + + +} + +# Start +# +# Inputs +# +# Outputs +# $iUser +# +# Description +# This Gets the user name +sub get_user +{ + my ($iLine, $iUser); + + open USER, "p4 user -o |" or die "Can't read user"; + while ($iLine=) + { + if ($iLine =~ /^User:\s+(\S+)/) + { + $iUser = $1; + } + } + close USER; + return ($iUser); +} + +sub set_client +{ + my ($iHost, $iClientname, $iUser, $iDrive, @iSplit_codeline) = @_; + + open CLIENT, "| p4 client -i" or die "Can't create Perforce client"; + + print CLIENT<&1`; + print `p4 set p4client=$iClientname 2>&1`; +} +1;