; Copyright (c) 1999, Perforce Software, All rights reserved. ; ; This software was originally developed by Silicon Graphics, Inc (SGI). ; ; Redistribution and use in source and binary forms, with or ; without modification, are permitted provided that the following ; conditions are met: ; ; Redistributions of source code must retain the above copyright notice, ; this list of conditions and the following disclaimer. ; ; Redistributions in binary form must reproduce the above copyright ; notice, this list of conditions and the following disclaimer in the ; documentation and/or other materials provided with the distribution. ; ; Neither name of Perforce Software nor SGI nor the names of its ; contributors may be used to endorse or promote products derived from ; this software without specific prior written permission. ; ; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ; ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT ; LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR ; A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR ; CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, ; EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, ; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR ; PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF ; LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING ; NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS ; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. procedure(CDS_P4BuildClientNames() ;_Sep 24 98 sikand 298 CDS_P4ClientTable = makeTable("CDS_P4ClientTable" nil) ;; build the local client file CDS_P4BuildClientFile() ;; build the table for local + system clients CDS_P4BuildClientTable(strcat(getWorkingDir() "/" "cds.p4client")) CDS_P4BuildClientTable(CDS_P4MasterClientFile) ) procedure(CDS_P4Refresh() ;_Sep 23 98 sikand 171 ;; build the master CDS_P4BuildMasterClientFile(CDS_P4MasterClientFile) ;; build the local file and set up the table CDS_P4BuildClientNames() ) ; ** procedure CDS_P4Refresh ** procedure(CDS_P4BuildMasterClientFile(filename) ;_Mar 22 00 sikand 1611 ; build the master client list for reference and design libs let(( filef cmd status cdata cinfo croot projmatch branch libname endroot bname) println(filename) filef = outfile(filename "w") unless( filef error("Couldn't write to %s\n" filename) ) println(filef) ;; future: embed ref or des in the client description and ;; save the grep ;; or maybe not projmatch = CDS_Project bname=getShellEnvVar(CDS_P4ProjectBranchEnvVar) when(bname branch=t ) if( branch then sprintf(cmd "clients | grep 'cds library' | grep ':%s ' " bname ) else ;; exclude any branched clients for the main code tree sprintf(cmd "clients | grep '%s %s cds library'" CDS_Project CDS_ProjectRev) ) ; ** if branch ** status = CDS_P4IPCDirectBufferProcess(cmd) ;; grep with no success can cause this to fail unless( zerop(status) error("Couldn't execute %s\n" cmd) ) when( CDS_IPCBuffer fprintf(filef "# Master Client File : %s : %s\n" getLogin() getCurrentTime()) cdata = parseString(CDS_IPCBuffer "\n") foreach( client cdata cinfo = parseString(client) ;; an old assumption..that the libname was embedded ;; in the client name ;;libname = car(parseString(nthelem(2 cinfo) ":")) ;; libname is actually the last element of the root croot = nthelem(5 cinfo) ;; Unix rocks forever endroot = parseString(croot "/") libname = car(reverse(endroot)) fprintf(filef "%s %s %s\n" libname croot nthelem(2 cinfo)) printf("%s %s %s\n" libname croot nthelem(2 cinfo)) ) ; ** foreach client ** ) ; ** when CDS_IPCBuffer ** close(filef) ) ; ** let ** ) ; ** procedure CDS_P4BuildMasterClientFile ** procedure(CDS_P4BuildClientTable(filename) ;_Oct 20 98 sikand 666 ; build an assoc table of libs and their clients let(( cfile lin libclient line libname libpath) cfile = infile(filename) unless( cfile error("Could not read %s\n" filename) ) ;; read the client file while( gets(lin cfile) when( ! rexMatchp("^#" lin) line = parseString(lin) libname = car(line) libpath = cadr(line) libclient = caddr(line) unless( libname libpath libclient error("Bad data in file") ) CDS_P4ClientTable[strcat(libname ":" libpath)] = libclient ) ; ** when rexMatchp ** ) ; ** while gets ** ) ; ** let ** ) ; ** procedure CDS_P4BuildClientTable ** procedure(CDS_P4BuildClientFile(@optional dosystem) ;_Nov 5 99 sikand 0 ; build a local client file let(( libf libd lin libname libpath cmd cdata cinfo croot cport status) ;; read the cds.lib file libf = infile(strcat(getWorkingDir() "/" "cds.lib")) cfile=strcat(getWorkingDir() "/" "cds.p4client") if(cfile == CDS_P4MasterClientFile then printf("Mainline mode, skip local client build\n") else cport = outfile(cfile "w") ;;printf("Building cds.p4client file %s\n" cport) fprintf(cport "# cds.p4client file generated from cds.lib file %s\n" getCurrentTime()) unless( libf warn("No local cds.lib file found, trying in $HOME\n") libf = infile(strcat(getShellEnvVar("HOME") "/cds.lib")) unless( libf error("Couldn't find a cds.lib file....") ) ) ; ** unless libf ** while( gets(lin libf) when( rexMatchp("^[A-Z]+" lin) ;;println(lin) libd = parseString(lin) when( length(libd) > 2 libname = cadr(libd) libpath = CDS_NFSSimplify(caddr(libd)) ;; do system is not used, can come back to this ;; later unless( rexMatchp("gfxdesign" libpath) && ! dosystem ;;printf("Searching for %s %s\n" libname libpath) ;; query p4 and find the client for the libary sprintf(cmd "clients | grep %s" libname) status = CDS_P4IPCDirectBufferProcess(cmd) when( status == 0 && CDS_IPCBuffer cdata = parseString(CDS_IPCBuffer "\n") foreach( client cdata cinfo = parseString(client) croot = nthelem(5 cinfo) when( croot == libpath ;;printf("%s %s %s\n" libname croot nthelem(2 cinfo)) fprintf(cport "%s %s %s\n" libname croot nthelem(2 cinfo)) ) ) ; ** foreach client ** ) ; ** when status ** ) ; ** unless rexMatchp ** ) ; ** when length ** ) ; ** when rexMatchp ** ) ; ** while gets ** close(libf) close(cport) ) ) ; ** let ** ) ; ** procedure CDS_P4BuildClientFile ** procedure(CDS_P4Permissions( @key quiet groupname) ;_Mar 28 00 sikand 806 ; read the users of a particular group and give ; them reverse integrate access ; groupname perforce group ;; the parser makes a lot of assumptions !!! let(( dlist user eof ucount glist) CDS_P4Protect = makeTable("reflibprotect" nil) ;; get the list of groups CDS_P4IPCBufferProcess("groups") glist = parseString(CDS_IPCBuffer) foreach( groupname glist ucount = 0 eof = nil unless( quiet printf("Reading group name: %s\n" groupname) ) CDS_P4IPCCommand(strcat("group -o " groupname)) dlist = reverse(parseString(CDS_IPCBuffer)) foreach( el dlist when( el == "unlimited" && !eof error("Bad group %s" groupname) ) when( el == "Users:" eof = t ) unless( eof unless( quiet printf("Added %s\n", el) ) CDS_P4Protect[groupname] = append(list(el) CDS_P4Protect[groupname]) ucount++ ) ; ** unless eof ** ) ; ** foreach el ** unless( quiet printf("Info: %d users added to %s list\n" ucount groupname) ) ) ; ** foreach groupname ** t ) ; ** let ** ) ; ** procedure CDS_P4Permissions ** procedure(CDS_P4CheckProtect(libname user) ;_Mar 28 00 sikand 391 ; check users permissions for a named group prog(( p4group) p4group = ddGetObj(libname)~>p4acl unless( p4group warn("Couldn't get p4acl for lib %s, no access control in effect!\n" libname) return(t) ) when( member(user CDS_P4Protect[p4group]) return(t) ) printf("No write access for %s, group %s\n" libname p4group) return(nil) ) ; ** let ** ) ; ** procedure CDS_P4CheckProtect ** procedure(CDS_P4CheckLocalConfig() ;_Oct 26 00 sikand 494 let(( pb cp ) ;; make sure that PROJECT and PROJECT_BRANCH are in ;; sync cp=getShellEnvVar(CDS_P4ProjectEnvVar) unless(cp error("Session abort: PROJECT is undefined!") ) cp = parseString(cp "/") cp=reverse(cp) when( pb = getShellEnvVar(CDS_P4ProjectBranchEnvVar) pb = parseString(pb "_") unless( nthelem(2 cp) == car(pb) ;;&& rexMatchp(nthelem(1 cp) cadr(pb)) ;; relaxed this check for new branchinh naming scheme ;; ie /projects/phoenix/root warn("Your PROJECT is not consistent with your PROJECT_BRANCH !!!") hiGetAttention() sleep(1) hiGetAttention() sleep(1) hiGetAttention() sleep(1) hiGetAttention() when( hiGraphicMode() CDS_ErrorDialogBox("P4 Interface" "Your PROJECT is not consistent with your PROJECT_BRANCH !!!") ) error("ABORT: Please terminate this session") ) ) ; ** when pb ** t ) ; ** let ** ) ; ** procedure CDS_P4CheckLocalConfig **