Perl/ClearCase Programming - PowerPoint PPT Presentation

About This Presentation
Title:

Perl/ClearCase Programming

Description:

Make use of SMB symlink translation. Must be on UNIX/Samba/TAS/NAS ... Perl 5.6.0 emulates fork but not exec. emulation: exit(system('cmd')!=0) ... – PowerPoint PPT presentation

Number of Views:61
Avg rating:3.0/5.0
Slides: 24
Provided by: david142
Category:

less

Transcript and Presenter's Notes

Title: Perl/ClearCase Programming


1
Perl/ClearCase Programming
  • With an emphasis on UNIX/Windows interoperation
  • David Boyce
  • BMRCCUG 9/25/2001

2
General Notes
  • Me
  • dsb_at_cleartool.com
  • http//www.cleartool.com
  • Focus Scripting vs Programming
  • Portability vs Interoperability
  • Perl vs Java (philosophy)

3
A Co-Operating Win32 Perl
  • ClearCase bundled perl (ccperl)
  • Local-only WIN32 build
  • Local with network modules
  • Networked standard build
  • Networked ActiveState build

4
Sharing modules
  • Make use of SMB symlink translation
  • Must be on UNIX/Samba/TAS/NAS
  • Some SMBs require symlink switch
  • Even WIN32 binary modules work
  • Share /usr/local/bin (\\server\ulb)
  • or /usr/local (\\server\local).
  • All maintenance from UNIX.

5
Sharing and executing scripts
  • Choices executing scripts on Windows
  • Register the .pl/.plx extension
  • Use pl2bat
  • Use a redirector
  • _at_echo off
  • \\server\perl\bin\perl \\server\ulb\whence
  • Local .bat, remote/shared perl script (ulb)
  • Use perls bin directory
  • UNC path entries must be user and at end

6
Trigger Definition
  • ct lstype -l trtypemkelem_post
  • trigger type "mkelem_post"
  • 02-Aug-99.183501 by VOB Admin
    (vobadm.ccusers_at_sparc5)
  • owner vobadm
  • group ccusers
  • all element trigger
  • post-operation mkelem
  • action -execunix /usr/local/bin/perl
    /data/ccase/triggers/mkelem_post.tgr
  • action -execwin perl //ultra10/triggers/mkelem_
    post.tgr
  • excluded users vobadm
  • My triggers are at http//www.cleartool.com

7
Interop Tips and Tricks
  • use constant MSWIN gt O /MSWin32Windows_NT/i
  • Quoting make use of qq() and q()
  • Especially in e scripts
  • No single quote () in cmd.exe
  • Remember 2gt1 works on Windows
  • -e foo_at__at_/main/0
  • Useful for testing dynamic-vs-snapshot
  • Follow with ct desc for snapshot support

8
Interop Tips and Tricks (cont)
  • Make a DNS alias usr for the fileserver
  • Enables e.g. //usr/local/bin anywhere
  • Useful for includes in cspecs etc.
  • Use the notify command for email (4.0)
  • Beware of PERL5LIB et al (CC bug)
  • Use binmode on all binary files
  • Cleartool returns native version paths

9
Interop Tips and Tricks (cont)
  • Use s\\/g if MSWIN
  • FileSpec 0.82 (abstract pathnames)
  • FileSpec-gtrel2abs(path) native
    fmt
  • FileSpecUnix-gtrel2abs(path) force Unix
    fmt
  • my nul MSWIN ? NUL /dev/null
  • system(cmd gtnul 2gt1)

10
Interop system() and exec()
  • The documentation lies!
  • system() always uses a shell
  • exec() always exits
  • Perl 5.6.0 emulates fork but not exec
  • emulation exit(system(cmd)!0))
  • Best use ClearCaseArgv
  • for complex/long-running programs

11
My Perl Modules
  • ClearCaseClearPrompt
  • ClearCaseWrapper
  • ClearCaseSyncTree
  • ClearCaseCRDB
  • EnvPath
  • IPCClearTool
  • ClearCaseArgv

12
ClearCaseClearPrompt
  • Handles temp files automatically
  • Capable of asynchronous operation
  • Handles trigger series automatically
  • Captures/emails error msgs (CC 4.2)
  • use ClearCaseClearPrompt qw(clearprompt
    TRIGGERSERIES CAPTUREvobadm)
  • clearprompt(proceed, -prompt, Hi!))
  • bug clearprompt(qw(text -def 0 prompt), Bug
    ?)

13
ClearCaseWrapper
  • Not an API, a program in module form
  • Potentially wraps all cleartool access
  • Cannot affect Windows GUI
  • Many cmdline features (-rec/-all/-dir)

14
ClearCaseSyncTree
  • Analogous to citree, clearfsimport
  • Preserves CRs
  • Maps filenames
  • Takes or derives file lists
  • Regular expression filtering
  • Comes with synctree program

15
ClearCaseCRDB
  • Unreleased
  • CR analysis (impact analysis)
  • Comes with whouses program
  • Forward or backward analysis

16
EnvPath
  • Simply adds methods to existing EVs
  • Prepend, Append, Remove
  • InsertBefore, InsertAfter
  • Uniqify, DeleteNonexistent
  • Replace, Whence (take REs)
  • Comes with envpath program
  • Comes with whence program for Windows
  • use EnvPath PATH
  • PATH-gtRemove(/usr/ucb)

17
IPCClearTool
  • Interop
  • Speedup order of magnitude, or none.
  • Significant constant overhead
  • CAL on Windows, coprocess on UNIX
  • Preferred interface via ClearCaseArgv

18
ClearCaseArgv Features
  • Command line as object
  • Advanced Option Parsing (option sets)
  • Interoperability
  • Prog, opts, args
  • Attributes
  • Verbosity (debug, quiet)
  • Execution exceptions (autofail)
  • Can exit or call exception handler

19
ClearCaseArgv for Interop
  • Quoting (-gtautoquote)
  • Path normalization (-gtoutpathnorm)
  • Output (-gtstdout, -gtstderr)
  • Globbing (-gtautoglob)
  • Xargs behavior (-gtqxargs, -gtsyxargs)

20
ClearCaseArgv examples
  • my ct ClearCaseArgv-gtnew
  • ct-gtautochomp(1)
  • my _at_co ct-gtlsco(-s, -all, .)-gtqx
  • ct-gtci(-c, comment, _at_co)-gtsystem
  • my _at_co ctqx(lsco s all .)
  • ctsystem(qw(mkelem c comment), _at_co)

21
Special-purpose Objects
  • my ct ClearCaseArgv-gtnew
  • ct-gtautofail(1)
  • ct-gtautochomp(1)
  • my ctq ClearCaseArgv-gtnew
  • ct-gtstdout(0)
  • ct-gtstderr(0)

22
Setting attributes
  • Per-object ct-gtstderr(1)
  • Globally ClearCaseArgv-gtstderr(1)
  • export ARGV_STDERR1
  • ClearCaseArgv-gtattropts
  • -/dbg1
  • -/quiet1
  • -/ipc1

23
Question Time
  • At http//www.cleartool.com
  • This presentation
  • Code samples
  • Detailed documents
Write a Comment
User Comments (0)
About PowerShow.com