From 1a80391713f8ac2c6408ce09e2a6ce9e88e1c108 Mon Sep 17 00:00:00 2001 From: Donald Buczek Date: Mon, 20 Jun 2016 09:31:56 +0200 Subject: [PATCH] pdist: style: set opening brackets on same line (except subs) --- pdist/pdist | 430 ++++++++++++++++------------------------------------ 1 file changed, 131 insertions(+), 299 deletions(-) diff --git a/pdist/pdist b/pdist/pdist index 9b9fade..9372193 100755 --- a/pdist/pdist +++ b/pdist/pdist @@ -23,6 +23,7 @@ sub fn_escape $fn=~s/([[:^graph:]\\])/'\x'.sprintf('%02x',ord($1))/ge; return $fn; } + sub fn_unescape { my ($fn)=@_; @@ -73,8 +74,7 @@ sub export_index { my ($self)=@_; my $type=$self->type; - return - ( + return ( $type, fn_escape($self->name), $self->perm, @@ -94,8 +94,7 @@ sub import_index { my ($class,@F)=@_; my $type=$F[0]; - return bless - [ + return bless [ fn_unescape($F[1]), # name 0,0, # dev,ino $type, # type @@ -117,13 +116,11 @@ sub lstat my $target; my @f; - unless (@f=lstat $filename) - { + unless (@f=lstat $filename) { $!==2 and return undef; # ENOENT die "$filename: $!\n"; } - if (-l _) - { + if (-l _) { defined ($target=readlink($filename)) or die "$filename: $!\n"; } my $type = @@ -135,8 +132,7 @@ sub lstat S_ISFIFO($f[2]) ? 'P' : S_ISSOCK($f[2]) ? 'S' : die ("$filename: unsupported file type\n"); - return bless - [ + return bless [ $filename, # name @f[0,1], # dev,ino $type, # type @@ -157,8 +153,7 @@ use warnings; # Emergency search path for perl modules at end of @INC # only to be used if local copy is missing # -BEGIN -{ +BEGIN { use Config; push @INC,"/project/admin/pdist/lib/$Config{archname}"; } @@ -175,15 +170,13 @@ import My::Escaper; use Net::Ping; use Socket; -BEGIN -{ +BEGIN { $ENV{PATH} = '/usr/local/bin:/sbin:/bin:'.($ENV{PATH}||''); # for AXP to use gtar/mount } # constants -use constant -{ +use constant { DISTFILE => '/root/Distfile', # read FILES,HOSTS,EXCEPTS here }; @@ -208,9 +201,7 @@ our ($distfilename) = (DISTFILE); # globals -our -( - +our ( $server_pid, # if we forked a pack server %HARDLINK, # ( 'dev.inode' => first-filename-save , ... ) cache for indexer @@ -227,10 +218,8 @@ END { $server_pid and kill TERM=>$server_pid } sub is_excepted { my ($fn)=@_; - for my $pat (@EXCEPTS) - { - if (fnmatch($pat,$fn,FNM_PATHNAME|FNM_PERIOD)) - { + for my $pat (@EXCEPTS) { + if (fnmatch($pat,$fn,FNM_PATHNAME|FNM_PERIOD)) { return 1; } } @@ -243,8 +232,7 @@ sub cache_local_fs #/dev/sdb on /amd/afk/1 type xfs (rw,noatime) #OneFS on /ifs (efs, NFS exported, local, noatime, noexec) - for (`mount`) - { + for (`mount`) { m"(.+) on (/.*) type (\S+)" || m"(.+) on (/.*) \(([^,)]+),"; my ($fs,$path,$type)=($1,$2,$3); next unless $type && $type =~ /^advfs|ufs|ext\d+|reiserfs|xfs|fuseblk|vfat|efs$/; @@ -262,8 +250,7 @@ sub read_distfile my $distfile=(join '',); $distfile=~s/#.*//g; - while ($distfile =~ /(\S+) ?= ?\(([^)]*)\)/g) - { + while ($distfile =~ /(\S+) ?= ?\(([^)]*)\)/g) { $DIST{$1} = [split (' ',$2)]; } @@ -285,8 +272,7 @@ sub init_from_distfile @FILES=@{$files}; @EXCEPTS=map { $_ eq 'core' ? () : $_ } @{$excepts}; # remove 'core' for /arch/i686/usr/local/include/boost-1_32/boost/spirit/core - push @EXCEPTS, - ( + push @EXCEPTS,( '/root/.viminfo', '/root/.nedit', '/usr/share/man/cat*', @@ -314,7 +300,6 @@ sub init_from_distfile /\S/ and push @HOSTS,$_; } } - } sub index_file_sort { return sort @_; } @@ -323,28 +308,19 @@ sub index_file_sort { return sort @_; } our ($machine,$SYS_lchown,$SYS_mknod); chomp($machine=`uname -m`); -if ($machine eq 'i686') -{ +if ($machine eq 'i686') { $SYS_lchown=198; # __NR_lchown32 in /usr/include/asm/unistd.h $SYS_mknod=14; # __NR_mknod -} -elsif ($machine eq 'x86_64') -{ +} elsif ($machine eq 'x86_64') { $SYS_lchown=94; # __NR_lchown in /usr/include/asm-x86_64/unistd.h $SYS_mknod=133; # __NR_mknod -} -elsif ($machine eq 'alpha') -{ - +} elsif ($machine eq 'alpha') { $SYS_lchown=208; # SYS_lchown in /usr/include/syscall.h $SYS_mknod=14; # SYS_mknod -} -elsif ($machine eq 'amd64') { +} elsif ($machine eq 'amd64') { $SYS_lchown=254; # SYS_lchown in /usr/include/syscall.h $SYS_mknod=14; # SYS_mknod -} -else -{ +} else { warn "unknown machine type $machine: symlink ownership can't be set.\n"; warn "unknown machine type $machine: named pipes,character and block devices can't be created\n"; } @@ -420,14 +396,12 @@ sub fileop_cp my @f=stat($from) or die "$from: $!\n"; my $in=new IO::File $from,O_RDONLY or die "$from: $!\n"; my $out=new IO::File $to,O_CREAT|O_EXCL|O_WRONLY or die "$to: $!\n"; - if ($IO::File::VERSION >= 1.13) - { + if ($IO::File::VERSION >= 1.13) { $in->binmode; $out->binmode; } my $buf; - while ($in->sysread($buf,10240)) - { + while ($in->sysread($buf,10240)) { $out->syswrite($buf) or die "$out: $!\n"; } close $in; @@ -474,8 +448,7 @@ sub fileop_ln_or_cp my ($from,$to)=@_; $fileop_debug and warn "fileop: ln_or_cp $from $to\n"; $fileop_noop and return; - unless (link $from,$to) - { + unless (link $from,$to) { fileop_cp($from,$to); } } @@ -489,16 +462,14 @@ sub index_wanted # # - if (is_excepted($_)) - { + if (is_excepted($_)) { $File::Find::prune=1; return; } my $st=My::FileInfo->lstat($_) or die "$_ : $!\n"; - if ( !exists $LOCAL_DEV{$st->dev} && !($st->dev == -1 && $st->type eq 'P')) # osf bug: pipes show -1 as dev - { + if ( !exists $LOCAL_DEV{$st->dev} && !($st->dev == -1 && $st->type eq 'P')) { # osf bug: pipes show -1 as dev warn "$_ : remote filesystem\n"; $File::Find::prune=1; return; @@ -507,15 +478,11 @@ sub index_wanted my $save_fn=fn_escape($_); my $hardlink='-'; - if ($st->type ne 'D' && $st->nlink>1) - { + if ($st->type ne 'D' && $st->nlink>1) { my $tag=$st->dev.'.'.$st->ino; - if (exists $HARDLINK{$tag}) - { + if (exists $HARDLINK{$tag}) { $hardlink=$HARDLINK{$tag} - } - else - { + } else { $HARDLINK{$tag}=$st->name_escaped } } @@ -530,15 +497,13 @@ sub prog_index local($, , $\)=(' ',"\n"); - for (@EXCEPTS) - { + for (@EXCEPTS) { print '!',fn_escape($_); } @files and @FILES=@files; # override via --files - find - ( + find ( { wanted => \&index_wanted, no_chdir => 1, @@ -555,33 +520,28 @@ sub prog_pack my $errors=0; my $pid=open TAR,'|-'; defined $pid or die "$0 : $!\n"; - unless ($pid) - { + unless ($pid) { exec 'tar','cf','-','-C','/','-T','-'; die "tar: exec failed: $!\n"; } - while () - { + while () { my ($tag,$save_fn,$size,$mtime)=split; $tag eq '+' or die "$0 invalid input record $_\n"; my $fn=fn_unescape($save_fn); my @S; - unless (@S=lstat $fn) - { + unless (@S=lstat $fn) { warn "$fn: $!\n"; next; } - unless (S_ISREG($S[2]) && $S[7]==$size && $S[9]==$mtime) - { + unless (S_ISREG($S[2]) && $S[7]==$size && $S[9]==$mtime) { warn "$fn: requested files has changed\n"; } $fn=~s"^/+""; print TAR $fn,"\n"; } - unless (close TAR) - { + unless (close TAR) { $! and die "$0: $!\n"; exit 1; # child exit status. diagnostics should already be out. }; @@ -606,13 +566,11 @@ sub check_perm my ($st_is,$st_want)=@_; my $path=$st_is->name; $st_is->type eq '-' || $st_is->type eq 'L' and die "internal error"; - if ($st_is->uid != $st_want->uid || $st_is->gid != $st_want->gid) - { + if ($st_is->uid != $st_want->uid || $st_is->gid != $st_want->gid) { $quiet or warn "chown ".$st_want->uid.':'.$st_want->gid." $path\n"; fileop_chown($st_want->uid,$st_want->gid,$path); } - if ($st_want->perm != $st_is->perm) - { + if ($st_want->perm != $st_is->perm) { $quiet or warn sprintf("chmod %03o %s\n",$st_want->perm,$path); fileop_chmod($st_want->perm,$path); } @@ -642,23 +600,19 @@ sub out_of_the_way $st->type eq '-' and return; - if ($st->type eq 'D') - { + if ($st->type eq 'D') { my $path=$st->name; my $deleteme="$path.deleteme"; fileop_mv($path,$deleteme); push @CLEAN_DIRS,$deleteme; - } - else - { + } else { fileop_rm($st->name); } } #-------------------------------------------- -use constant -{ +use constant { F_REQUEST=>1, F_UPDATE=>2, }; @@ -680,15 +634,11 @@ sub prog_update local($, , $\)=(' ',"\n"); - if ($tarfile && $tarfile ne '-') - { + if ($tarfile && $tarfile ne '-') { -d $TMPDIR or mkdir $TMPDIR or die $TMPDIR.": $!\n"; - if (-d $TMPUPDDIR) - { + if (-d $TMPUPDDIR) { $verbose and warn 'reusing existing directory '.$TMPUPDDIR."\n"; - } - else - { + } else { mkdir $TMPUPDDIR or die $TMPUPDDIR.": $!\n"; } $verbose and warn 'unpacking to '.$TMPUPDDIR."\n"; @@ -696,13 +646,11 @@ sub prog_update } open INDEX,"<$index1" or die "$index1: $!\n"; - while () - { + while () { my @F=split ' '; $F[0] eq '%' and last; - if ($F[0] eq '!') - { + if ($F[0] eq '!') { push @EXCEPTS,fn_unescape($F[1]); next; } @@ -711,13 +659,11 @@ sub prog_update my $filename=$st_want->name;; next if is_excepted($filename); - if ($function==F_REQUEST) - { + if ($function==F_REQUEST) { next if $st_want->type ne 'F'; next if $F[7] ne '-'; my $st_is=My::FileInfo->lstat($filename); - if (!$st_is || $st_is->type ne 'F' || $st_is->size != $st_want->size || $st_is->mtime != $st_want->mtime) - { + if (!$st_is || $st_is->type ne 'F' || $st_is->size != $st_want->size || $st_is->mtime != $st_want->mtime) { print '+',$st_want->name_escaped,$st_want->size,$st_want->mtime; $requested_files++; $requested_bytes+=$st_want->size; @@ -730,46 +676,32 @@ sub prog_update my $st_is=My::FileInfo->lstat($filename); - if ($st_want->type eq 'D') - { - if ($st_is && $st_is->type eq 'D') - { + if ($st_want->type eq 'D') { + if ($st_is && $st_is->type eq 'D') { check_perm($st_is,$st_want); $delete and add_clean_dir($filename); - } - else - { + } else { $st_is and fileop_rm($filename); make_dir($filename,$st_want->perm,$st_want->uid,$st_want->gid) } push @DIR_MTIME_QUEUE,$filename,$st_want->mtime; - } - else - { + } else { my $hardlink=fn_unescape($F[7]); my $tmp_filename=$TMPUPDDIR.$filename; - if ($hardlink ne '-') - { + if ($hardlink ne '-') { my $st_src=My::FileInfo->lstat($hardlink); - if (!$st_src && !$fileop_noop) - { + if (!$st_src && !$fileop_noop) { warn "$hardlink: $!\n"; - } - elsif ( !$st_is || !$st_src || $st_is->dev!=$st_src->dev || $st_is->ino != $st_src->ino) - { + } elsif ( !$st_is || !$st_src || $st_is->dev!=$st_src->dev || $st_is->ino != $st_src->ino) { $st_is and out_of_the_way($st_is); $quiet or warn "ln $hardlink $filename\n"; fileop_ln_or_cp($hardlink,$filename) } - } - elsif ($st_want->type eq 'F') - { - if (!$st_is || $st_is->type ne 'F' || $st_is->size != $st_want->size || $st_is->mtime != $st_want->mtime) - { - if ($tarfile) - { + } elsif ($st_want->type eq 'F') { + if (!$st_is || $st_is->type ne 'F' || $st_is->size != $st_want->size || $st_is->mtime != $st_want->mtime) { + if ($tarfile) { my $st_tmp=My::FileInfo->lstat($tmp_filename); unless ($st_tmp) { warn "$filename: missing from archive\n"; @@ -779,93 +711,62 @@ sub prog_update $st_tmp->size == $st_want->size && $st_tmp->mtime == $st_want->mtime or warn "$tmp_filename: does not match index\n"; $st_is and out_of_the_way($st_is); install_file($tmp_filename,$filename,$st_want->perm,$st_want->uid,$st_want->gid); - } - else - { + } else { die "required file $filename not available\n"; } - } - else - { + } else { check_perm($st_is,$st_want); } - } - elsif ($st_want->type eq 'L') - { - if (!$st_is || $st_is->type ne 'L' || $st_is->target ne $st_want->target) - { + } elsif ($st_want->type eq 'L') { + if (!$st_is || $st_is->type ne 'L' || $st_is->target ne $st_want->target) { $st_is and out_of_the_way($st_is); $quiet or warn "ln -s ".$st_want->target." $filename\n"; fileop_symlink($st_want->target,$filename); fileop_lchown($st_want->uid,$st_want->gid,$filename); - } - else - { - if ($st_is->uid != $st_want->uid || $st_is->gid != $st_want->gid) - { + } else { + if ($st_is->uid != $st_want->uid || $st_is->gid != $st_want->gid) { $quiet or warn "lchown ".$st_want->uid.':'.$st_want->gid." $filename\n"; fileop_lchown($st_want->uid,$st_want->gid,$filename); } } - } - elsif ($st_want->type eq 'P') - { - if (!$st_is || $st_is->type ne 'P') - { + } elsif ($st_want->type eq 'P') { + if (!$st_is || $st_is->type ne 'P') { $st_is and out_of_the_way($st_is); $quiet or warn "mknod $filename P\n"; fileop_mknod($filename,'P'); fileop_chown($st_want->uid,$st_want->gid,$filename); fileop_chmod($st_want->perm,$filename); - } - else - { + } else { check_perm($st_is,$st_want); } - } - elsif ($st_want->type eq 'S') - { + } elsif ($st_want->type eq 'S') { warn "$filename: is a socket (ignored)\n"; - } - elsif ($st_want->type eq 'C' || $st_want->type eq 'B') - { - if (!$st_is || $st_is->type ne $st_want->type || $st_is->rdev != $st_want->rdev) - { + } elsif ($st_want->type eq 'C' || $st_want->type eq 'B') { + if (!$st_is || $st_is->type ne $st_want->type || $st_is->rdev != $st_want->rdev) { $st_is and out_of_the_way($st_is); $quiet or warn "mknod $filename ",$st_want->type,"\n"; fileop_mknod($filename,$st_want->type,$st_want->rdev); fileop_chown($st_want->uid,$st_want->gid,$filename); fileop_chmod($st_want->perm,$filename); - } - else - { + } else { check_perm($st_is,$st_want); } - } - else - { + } else { die "type ".$st_want->type." not yet implemented\n"; } } } defined $_ or die "$index1 : truncated\n"; # emergency exit - if ($function==F_UPDATE) - { - if ($delete) - { - for my $path (keys %CLEAN) - { + if ($function==F_UPDATE) { + if ($delete) { + for my $path (keys %CLEAN) { lstat $path or die "$path: $!\n"; - if (-e _) - { - if (-d _) - { + if (-e _) { + if (-d _) { $quiet or warn "rm -r $path\n"; fileop_rmdir_recurse($path); - } - else - { + } else { $quiet or warn "rm $path\n"; fileop_rm($path); } @@ -873,41 +774,31 @@ sub prog_update } } - for my $path (@CLEAN_DIRS) - { - if (-e $path) - { + for my $path (@CLEAN_DIRS) { + if (-e $path) { fileop_rmdir_recurse($path); } } - for (my $i=0;$i<@DIR_MTIME_QUEUE;$i+=2) - { + for (my $i=0;$i<@DIR_MTIME_QUEUE;$i+=2) { my ($fn,$mtime)=($DIR_MTIME_QUEUE[$i],$DIR_MTIME_QUEUE[$i+1]); - if (my @f=lstat $fn) - { + if (my @f=lstat $fn) { S_ISDIR($f[2]) or next; # no longer a directory $f[9]==$mtime and next; # mtime is okay $quiet or warn "fix directory mtime of $fn ",$f[9],' -> ',$mtime,"\n"; - unless ($fileop_noop) - { + unless ($fileop_noop) { utime($mtime,$mtime,$fn) or warn "$fn: $!\n"; } - } - else - { + } else { warn "$fn: $!\n"; } } } - if ($function==F_REQUEST) - { + if ($function==F_REQUEST) { $verbose and warn sprintf "requesting %d files %5.2f MB\n",$requested_files,$requested_bytes/1024/1024; return ($requested_files,$requested_bytes); - } - else - { + } else { return; } } @@ -923,8 +814,7 @@ sub prog_client -d $TMPDIR or mkdir $TMPDIR or die $TMPDIR.": $!\n"; - my ($tmp_free); - { + my ($tmp_free); { open P,'df -Pk '.$TMPDIR.'|' or die "$0 : $\n"; $_=

; $_=

; @@ -955,39 +845,30 @@ sub prog_client close OUT; rename ($tmpfile,$requestfile) or die "$requestfile: $!\n"; - if ($req_bytes/1024*1.2 > $tmp_free) - { + if ($req_bytes/1024*1.2 > $tmp_free) { die sprintf ("%s: insufficient disk space (%dk needed, %dk free)\n",$TMPDIR,$req_bytes/1024*1.2,$tmp_free); } - if ($req_files) - { + if ($req_files) { my $s; - if ($ssh_tunnel) - { + if ($ssh_tunnel) { $verbose and warn "$hostname calling back $master via 127.0.0.1:$port\n"; $s=new IO::Socket::INET (PeerHost=>'127.0.0.1',PeerPort=>$port,Proto=>'tcp') or die "$master: $!\n"; - } - else - { + } else { $verbose and warn "$hostname calling back $master via $master:$port\n"; $s=new IO::Socket::INET (PeerHost=>$master,PeerPort=>$port,Proto=>'tcp') or die "$master: $!\n"; } $verbose and warn "$hostname: connected to $master\n"; defined (my $copy_pid=fork) or die "$0: $!\n"; - unless ($copy_pid) - { + unless ($copy_pid) { $0="pdist [receiving tar from $master]"; -d $TMPDIR or mkdir $TMPDIR or die $TMPDIR.": $!\n"; - if (-d $TMPUPDDIR) - { + if (-d $TMPUPDDIR) { $verbose and warn 'reusing existing directory '.$TMPUPDDIR."\n"; - } - else - { + } else { mkdir $TMPUPDDIR or die $TMPUPDDIR.": $!\n"; } $verbose and warn 'unpacking to '.$TMPUPDDIR."\n"; @@ -999,8 +880,7 @@ sub prog_client } $verbose and warn "$hostname sending request to $master\n"; open IN,"<$requestfile" or die "$requestfile: $!\n"; - while () - { + while () { $s->print($_); } $verbose and warn "$hostname: finished sending request\n"; @@ -1011,9 +891,7 @@ sub prog_client $verbose and warn "$hostname finished reading file data\n"; $verbose and warn "$hostname installing\n"; prog_update(F_UPDATE,$master_index,'-'); - } - else - { + } else { $verbose and warn "$hostname: installing from index $master_index (no files needed)\n"; prog_update(F_UPDATE,$master_index,undef); } @@ -1023,17 +901,16 @@ sub prog_client unlink ($master_index); unlink ($requestfile); - if ($post_command) - { + if ($post_command) { $verbose and warn "$hostname: executing $post_command\n"; $fileop_noop or system $post_command; } - } #-------------------------------------------- -sub set_prefix { +sub set_prefix +{ my ($client)=@_; $SIG{__WARN__} = sub { warn sprintf "%-30s: %s",$client,$_[0] }; $SIG{__DIE__} = sub { die sprintf "%-30s: %s",$client,$_[0] }; @@ -1049,25 +926,19 @@ sub fork_pack_daemon my $server_port; my $s_listen; - if ($ssh_tunnel) - { + if ($ssh_tunnel) { $s_listen=new IO::Socket::INET (Listen=>1,LocalAddr=>'127.0.0.1') or die "$0: $!\n"; - } - else - { + } else { $s_listen=new IO::Socket::INET (Listen=>1) or die "$0: $!\n"; } $server_port=$s_listen->sockport; defined ($server_pid=fork) or die "$0: $!\n"; - unless ($server_pid) - { + unless ($server_pid) { $0="pdist [listening for $client]"; - while (defined (my $s=$s_listen->accept)) - { + while (defined (my $s=$s_listen->accept)) { my $peer=$s->peerhost; - unless ($ssh_tunnel or $peer eq $addr) - { + unless ($ssh_tunnel or $peer eq $addr) { warn "master: connect from wrong client $peer\n"; $s->print("go away\n"); $s->close; @@ -1098,8 +969,7 @@ sub push_single my ($server_port)=fork_pack_daemon($client); defined (my $pid = open OUT,"|-") or die "$0: $!\n"; - unless ($pid) - { + unless ($pid) { my @remote_opts; $verbose and push @remote_opts,'--verbose'; @@ -1112,8 +982,7 @@ sub push_single $parallel && $parallel>1 and push @remote_opts,'--msg-prefix',$client; - my @l= - ( + my @l= ( 'ssh','-l','root', ($prompt ? () : '-oBatchMode=yes'), '-oFallBackToRsh=no', @@ -1140,8 +1009,7 @@ sub push_single while () {print OUT;alarm(600);} alarm(0); defined $timeout and alarm($timeout); - unless (close OUT) - { + unless (close OUT) { $! and die "$0: $!\n"; exit 1; # child exit status. diagnostics should already be out. }; @@ -1159,29 +1027,19 @@ sub client_expand my @ret; my %did; - while (my $spec=shift @spec) - { + while (my $spec=shift @spec) { next if $did{$spec}; - if ($spec eq 'ALL') - { + if ($spec eq 'ALL') { unshift @spec,@HOSTS; - } - elsif ($spec =~ /^@(\S+)/) - { - unless ($ng_init) - { - for (`ypcat -k netgroup`) - { + } elsif ($spec =~ /^@(\S+)/) { + unless ($ng_init) { + for (`ypcat -k netgroup`) { my ($n,@v)=split ' '; my $a = $NG{$n} = []; - for (@v) - { - if (/\(/) - { + for (@v) { + if (/\(/) { /\((\S+),,\)/ and push @$a,$1 - } - else - { + } else { push @$a,'@'.$_; } } @@ -1190,11 +1048,8 @@ sub client_expand } defined $NG{$1} or die "netgroup $1 unknown\n"; unshift @spec,@{$NG{$1}}; - } - else - { - unless ($spec =~ /\./) - { + } else { + unless ($spec =~ /\./) { $spec.='.molgen.mpg.de'; next if $did{$spec}; } @@ -1220,11 +1075,9 @@ sub prog_push select($old); close SNAPSHOT; - if (@_==1 && @client_list==1) - { + if (@_==1 && @client_list==1) { push_single($client_list[0],$tmpfile); - } - elsif ($parallel) { + } elsif ($parallel) { my $running=0; while (1) { last unless @client_list; @@ -1250,21 +1103,16 @@ sub prog_push my $pid=wait; $pid==-1 and last; } - } - else - { + } else { my $pinger=new Net::Ping; - for my $client (@client_list) - { + for my $client (@client_list) { warn localtime()." processing client $client\n"; - unless ($pinger->ping($client)) - { + unless ($pinger->ping($client)) { warn "$client: DOWN\n"; next; } defined (my $pid=fork) or die "$0: $!\n"; - unless ($pid) - { + unless ($pid) { $0 = "pdist [push $client]"; push_single($client,$tmpfile); exit; @@ -1333,8 +1181,7 @@ eg: __EOF__ -use constant OPTIONS => -( +use constant OPTIONS => ( 'noop' => \$fileop_noop, 'quiet' => \$quiet, 'timeout=i' => \$timeout, @@ -1363,45 +1210,30 @@ GetOptions(OPTIONS) or die USAGE; my $cmd=shift; defined $cmd or die USAGE; -if ($cmd eq 'index') -{ +if ($cmd eq 'index') { init_from_distfile($distfilename); @ARGV==0 or die USAGE; prog_index(); -} -elsif ($cmd eq 'request') -{ +} elsif ($cmd eq 'request') { @ARGV==1 or die USAGE; prog_update(F_REQUEST,@ARGV); -} -elsif ($cmd eq 'pack') -{ +} elsif ($cmd eq 'pack') { @ARGV==0 or die USAGE; prog_pack(); -} -elsif ($cmd eq 'update') -{ +} elsif ($cmd eq 'update') { @ARGV==1 || @ARGV==2 or die USAGE; prog_update(F_UPDATE,@ARGV); -} -elsif ($cmd eq 'client') -{ +} elsif ($cmd eq 'client') { @ARGV==2 or die USAGE; prog_client(@ARGV); -} -elsif ($cmd eq 'push') -{ +} elsif ($cmd eq 'push') { init_from_distfile($distfilename); defined $delete or $delete=(@files ? 0 : 1); @ARGV>=1 or die USAGE; prog_push(@ARGV); -} -elsif ($cmd eq 'devel') -{ +} elsif ($cmd eq 'devel') { @ARGV==2 or die USAGE; fileop_cp(@ARGV); -} -else -{ +} else { die USAGE; }