#!/p4/common/perl/bin/perl #------------------------------------------------------------------------------ # Copyright 2016 (c) Perforce Software, Inc. All rights reserved # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: # # 1 Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # # 2. 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. # # 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 PERFORCE # SOFTWARE, INC. 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. #------------------------------------------------------------------------------ # This script is installed as an archive trigger on the Perforce # server. # An example of its behavior once installed: # echo $(date) | unix2dos > file # file file # file: ASCII text, with CRLF line terminators # p4 add file # p4 submit -d file # p4 retype -l -t +X file # //depot/file#1 - text now text+X # p4 -v lbr.verify.out=0 sync -f file # //depot/file#1 - refreshing /ram/le/c/file # file file # file: ASCII text #------------------------------------------------------------------------------ use 5.014; use strict; use autodie; use IO::File; use File::Spec; use File::Path 'make_path'; use warnings FATAL => 'all'; # todo: %triggerMeta_depotFile% ? my $help = "USAGE:\n\nTriggers:\n\t" . "LE_conv archive //... \"$0" . ' /tmp/conv %op% %rev% %quote%%file%%quote%"'; die "$help\n" unless @ARGV == 4; my ( $root, $op, $rev, $lbr ) = @ARGV; sub ERR { die "$0 line ${\ caller }, '$root', $op, $rev, '$lbr': @_" } my ( $volume, $dir, $file ) = File::Spec->splitpath( $lbr ); my $lbr_dir = File::Spec->catdir( $root, $dir ); make_path $lbr_dir, { error => \ my $err } unless -d $lbr_dir; $err = join "\n", map { join ': ', %$_ } @$err; # Parallel runs can cause the leading parts of the dir to get created # at the same time causing a 'File exists' error. ERR " make_path '$lbr_dir': $!, '$err'" if $err && $err !~ /File exists/; binmode STDOUT; binmode STDIN; my $lbr_file = File::Spec->catfile( $lbr_dir, "$file.$rev" ); my $lbr_fh = IO::File->new( $lbr_file, O_CREAT|O_RDWR, ':raw' ) or ERR "$lbr_file: $!"; goto uc $op; WRITE: chmod 0600, $lbr_file; print $lbr_fh s/\R/\012/gr for <STDIN>; exit; READ: print for <$lbr_fh>; exit; DELETE: ERR 'DELETE action not implemented';
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#4 | 19938 | C. Thomas Tyler | Typo. | ||
#3 | 19937 | C. Thomas Tyler |
Back to not implementing the DELETE action. This is now more like revsion #1, with a tweaked message. |
||
#2 | 19923 | C. Thomas Tyler | Changed DELETE handling to do a silent exit 0. | ||
#1 | 19556 | C. Thomas Tyler | Refactored. | ||
//guest/tom_tyler/d2u/main/dos2unix_normalizer.pl | |||||
#1 | 19555 | C. Thomas Tyler | Moved to Workshop-standard location for personal projects. | ||
//guest/tom_tyler/tmp/dos2unix_normalizer.pl | |||||
#1 | 19459 | C. Thomas Tyler |
Added dos2unix_normalizer sample archive trigger script. Needs work and a wrapper script. |