#!/usr/bin/perl #============================================================================== # Copyright and license info is available in the LICENSE file included with # the Server Deployment Package (SDP), and also available online: # https://swarm.workshop.perforce.com/projects/perforce-software-sdp/view/main/LICENSE #------------------------------------------------------------------------------ # # Verifies a depot path one directory at a time. # # The required arguments are: # 1. Depot path to start searching in. Must end with a trailing '/...'. # 2. Perforce command string # # subs sub verify_dirs($); # parse command line: # - depot path to search if($#ARGV ne 0) { die "\n\nUsage: p4verify.pl \n\nThe depot path to search must end in '/...'\n\n"; } my $depotDir = $ARGV[0]; if($depotDir !~ /\/\.\.\.$/) { die "\n\n\nUsage Error: Depot path for search must end with '/...'.\n\n"; } die "\nError: SDP shell environment not set. Source /p4/common/bin/p4_vars first.\n\n" unless ($ENV{'P4BIN'}); # run 'p4 verify' on each directory in the tree verify_dirs(substr($depotDir, 0, -4)); exit(0); # # verify_dirs: Runs p4 verify on a dir and all sub-dirs # sub verify_dirs($) { my ($dir) = @_; $dir = $dir . '/*'; print ("CALL verify_dirs ($dir)\n") if ($ENV{'P4VERIFY_DEBUG'}); my $verifyCmd = $ENV{'P4BIN'} . ' -s verify -qz '; # On a replica, add the '-t' flag to the 'p4 verify' command. if ($ENV{'P4REPLICA'} eq 'TRUE') { $verifyCmd = $verifyCmd . ' -t'; } $verifyCmd = $verifyCmd . '"' . $dir . '"'; print (" VCMD: $verifyCmd\n") if ($ENV{'P4VERIFY_DEBUG'}); my $verifyList = `$verifyCmd 2>&1`; if($verifyList !~ /^exit: 0$/ and $verifyList !~ /no such file/) { print $verifyList; } my $dirListCmd = $ENV{'P4BIN'} . ' dirs "' . $dir . '"'; my $dirList = `$dirListCmd 2>&1`; if($dirList !~ /no such file/) { foreach my $adir (split(/\n/, $dirList)) { next unless $adir =~ /\/\//; verify_dirs($adir); } } } # end verify_dirs