1 Star 0 Fork 1

fulinux/WorkScripts

forked from Ethan Tang/WorkScripts 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
leapFrog.pl 2.63 KB
一键复制 编辑 原始数据 按行查看 历史
#!/usr/local/bin/perl
use strict;
use warnings;
use File::Copy;
use File::Path;
#This script is used to do leap frog on multiple files
#arguments: filelist.file comment
#Prepare dir for top files ( to leap back )
our $topFileDir = 'top_files';
mkdir $topFileDir unless ( -e $topFileDir );
system( 'chmod 777 -R '.$topFileDir );
our $mso_top = $ENV{'MSO_TOP'};
my $listFile = $ARGV[0];
our $prodDir = $ARGV[1];
my $comment = $ARGV[2];
$prodDir =~ /(mso|msc|msr).*/;
my $prod = $1;
open FILELIST, $listFile or die "Unable to open filelist $listFile :$!\n";
open VERSION, '>versions' or die "Unable to open versions for writing:$!\n";
print "File versions will be saved as versions\n";
while(<FILELIST>)
{
chomp;
if( /rev-up (.*)/ )
{
#justCheckin($1,'leapback');
leapFrog( $1, 'revup'.$comment );
}else{
#justCheckin($_,'leapback');
leapFrog($_,$comment );
}
}
close FILELIST;
close VERSION;
print "All jobs done!\n";
sub justCheckin
{
my $file = $_[0];
my $comment = $_[1];
print "Rev up $file\n";
my $status = system("arcs unlock $file");
$status = system("arcs lock $file");
$status = system("arcs in $file ".'\\'.$comment.'\\');
}
sub leapFrog
{
my $file = $_[0];
my $comment = $_[1];
my $status = 1;
print "Leap frog : $file comment=$comment ...";
copy( $prodDir.'/'.$file, './') or die "Unable to copy $file";
chdir $topFileDir;
$status = system( "arcs unlock $file" );
die" arcs unlock $file failure status:$status" if( $status<0 );
$status = system("arcs out $file ");
die "arcs out $file failure status:$status " if ( $status <0);
chdir '..';
$status = system("arcs in $file ".'\\'.$comment.'\\');
die "arcs in $file failure :$status" if ($status<0);
my $fileVersion = getFileVersion($mso_top.'/'.$file);
$file =~ /(.*)\/([^\/]+)$/;
my $srcDir = $1;
my $fileName = $2;
print VERSION "$prod $srcDir $fileName $fileVersion\n";
#Leap back
chdir $topFileDir;
$status = system("arcs lock $file");
die "arcs lock failure $status" if ($status <0);
Y
$status = system("arcs in $file ".'\\leapback\\' );
die "arcs in failure while rev up $status" if ($status < 0);
chdir '..';
print " [Done]\n";
}
sub getFileVersion
{
my $fileName = $_[0];
my $fileVersion;
unless ( open IDENT_PIPE, "-|" )
{
exec "ident $fileName";
exit;
}
while ( <IDENT_PIPE> )
{
chomp;
if( /\s([0-9.]+)\s/ )
{
$fileVersion = $1;
}
}
close IDENT_PIPE;
$fileVersion;
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/fulinux/WorkScripts.git
git@gitee.com:fulinux/WorkScripts.git
fulinux
WorkScripts
WorkScripts
master

搜索帮助