Changeset 290 for trunk/dasscm


Ignore:
Timestamp:
Mar 11, 2009, 7:51:54 AM (15 years ago)
Author:
joergs
Message:

perltidy

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/dasscm/dasscm

    r289 r290  
    2929
    3030# Nagios return codes
    31 my $RETURN_WARN = 1;
    32 my $RETURN_CRIT = 2;
     31my $RETURN_WARN    = 1;
     32my $RETURN_CRIT    = 2;
    3333my $RETURN_UNKNOWN = 3;
    34 
    3534
    3635# documentation file (for usage)
     
    278277}
    279278
    280 
    281279#
    282280# normalize path namens:
     
    288286    my $path = shift || "";
    289287
    290     if( $path =~ m|^/| ) {
     288    if ( $path =~ m|^/| ) {
     289
    291290        # full path
    292         if( -d $path ) {
     291        if ( -d $path ) {
     292
    293293            # ensure, a directory ends with '/'
    294294            $path .= '/';
    295295        }
    296     } elsif( -d cwd() . '/' . $path ) {
    297             # ensure, a directory ends with '/'
    298             $path .= '/';
     296    } elsif ( -d cwd() . '/' . $path ) {
     297
     298        # ensure, a directory ends with '/'
     299        $path .= '/';
    299300    }
    300301
     
    304305    return $path;
    305306}
    306 
    307 
    308307
    309308#
     
    330329    # herefore make sure, that if filename is a directory,
    331330    # it will end by "/"
    332     $filename_prod = normalize_path( $filename_prod );
     331    $filename_prod = normalize_path($filename_prod);
    333332
    334333    ( my $basename, my $dirname_prod ) = fileparse($filename_prod);
     
    340339
    341340    my $dirname_repo  = normalize_path( $DASSCM_REPO . "/" . $dirname_prod );
    342     my $filename_repo = normalize_path( "$dirname_repo/$basename" );
     341    my $filename_repo = normalize_path("$dirname_repo/$basename");
    343342
    344343    if ($verbose) {
    345344        print "filename_repo:  " . $filename_repo . "\n";
    346         print "dirname_repo:   " . $dirname_repo ."\n";
     345        print "dirname_repo:   " . $dirname_repo . "\n";
    347346        print "filename_prod:  " . $filename_prod . "\n";
    348         print "dirname_prod:   " . $dirname_prod . "\n"; 
     347        print "dirname_prod:   " . $dirname_prod . "\n";
    349348        print "basename:       " . $basename . "\n";
    350349    }
     
    532531        print @result;
    533532        if ( $rc_update != 0 ) {
    534             error( "failed to update local repository ($update_path)" );
     533            error("failed to update local repository ($update_path)");
    535534        } elsif ( not $update_path ) {
    536535
     
    565564                my $name = normalize_path($File::Find::name);
    566565                $name =~ s|^$dirname_repo||;
     566
    567567                #print "($name)\n";# . $File::Find::dir . "\n";
    568568                if ( not $name ) {
     569
    569570                    # name string is empty (top directory).
    570571                    # do nothing
     
    579580                    push( @links, $name );
    580581                } elsif ( -d $_ ) {
     582
    581583                    #if( $name."/" eq dirname_repo ) {
    582                         # directories
    583                         push( @dirs, $name );
     584                    # directories
     585                    push( @dirs, $name );
     586
    584587                    #}
    585588                } elsif ( -f $_ ) {
     
    590593                    push( @others, $name );
    591594                }
    592             }
     595              }
    593596        },
    594597        ($filename_repo)
     
    598601}
    599602
    600 
    601 
    602603sub svn_revert( ;$ )
    603604{
     
    616617    my $path = shift || $DASSCM_REPO;
    617618
    618     ( my $rc_update, my @result ) = run_command("$SVN status '$path'" );
     619    ( my $rc_update, my @result ) = run_command("$SVN status '$path'");
    619620
    620621    if ( $rc_update != 0 ) {
     
    622623        error("failed to receive subversion repository information");
    623624    } else {
    624         foreach (@result) { 
    625             if( s/^\? +// ) {
     625        foreach (@result) {
     626            if (s/^\? +//) {
    626627                chomp;
     628
    627629                # if file is unknown to subversion (line starts with "?")
    628630                # remove it
    629631                print "removing $_\n";
    630                 unlink( $_ );
     632                unlink($_);
    631633            }
    632634        }
     
    661663
    662664            if ( -d $realfile ) {
     665
    663666                # directory
    664                 if( !-d "$cvsworkfile" ) {
     667                if ( !-d "$cvsworkfile" ) {
     668
    665669                    # real is directory, repository is not. This is a problem
    666670                    $changedfiles{"$realfile"} = $cvsworkfile;
     
    669673                $removedfiles{"$realfile"} = $cvsworkfile;
    670674            } elsif ( !-r $realfile ) {
     675
    671676                # don't have permission to read the file,
    672677                # can't check it
     
    11291134
    11301135    # return code for the shell
    1131     my $return_code = $RETURN_OK;
     1136    my $return_code   = $RETURN_OK;
    11321137    my $return_string = "OK: no modified files";
    11331138
     
    11371142    # get modified files
    11381143    ( my $refChangedFiles, my $refRemovedFiles, my $refUnknownFiles ) =
    1139       getModifiedFiles( "/" );
     1144      getModifiedFiles("/");
    11401145    my %changedfiles = %{$refChangedFiles};
    11411146    my %removedfiles = %{$refRemovedFiles};
     
    11441149    if ( %removedfiles or %changedfiles ) {
    11451150        $return_string = "Warning: ";
    1146         if( %changedfiles ) {
    1147             $return_string .= "changed: " . join( ", ", ( keys %changedfiles ) ) . ". ";
    1148         }
    1149         if( %removedfiles ) {
    1150             $return_string .= "removed: " . join( ", ", ( keys %removedfiles ) ) . ". ";
     1151        if (%changedfiles) {
     1152            $return_string .=
     1153              "changed: " . join( ", ", ( keys %changedfiles ) ) . ". ";
     1154        }
     1155        if (%removedfiles) {
     1156            $return_string .=
     1157              "removed: " . join( ", ", ( keys %removedfiles ) ) . ". ";
    11511158        }
    11521159        if (%unknownfiles) {
    1153             $return_string .= "unknown: " . join( ", ", ( keys %unknownfiles ) ) . ". ";
     1160            $return_string .=
     1161              "unknown: " . join( ", ", ( keys %unknownfiles ) ) . ". ";
    11541162        }
    11551163        $return_code = $RETURN_WARN;
     
    11601168    #Unknown
    11611169
    1162     print $return_string . "\n";
     1170    print "$return_string\n";
    11631171    return $return_code;
    11641172}
    1165 
    11661173
    11671174sub permissions()
     
    11991206        } else {
    12001207
    1201             if( $command eq "permission" ) {
     1208            if ( $command eq "permission" ) {
     1209
    12021210                # Pfad für Sicherungsdatei existiert nicht => schreiben auf stdout
    12031211                # Alias Filehandle für stdout erzeugen
    12041212                $return_code = $RETURN_WARN;
    1205                 *OUTFILE = *STDOUT;
     1213                *OUTFILE     = *STDOUT;
    12061214            } else {
     1215
    12071216                # TODO: improve this. Check for diff?
    12081217                $return_code = $RETURN_CRIT;
     
    12711280    }
    12721281
    1273     $DASSCM_PERMISSION_FILE = $config->{'DASSCM_PERMISSION_FILE'} || "/etc/permissions.d/dasscm.permission_backup";
     1282    $DASSCM_PERMISSION_FILE = $config->{'DASSCM_PERMISSION_FILE'}
     1283      || "/etc/permissions.d/dasscm.permission_backup";
    12741284
    12751285    # get command line options and store them in options hash
     
    13231333        $return_code = check();
    13241334    } elsif (m/^permissions$/i) {
    1325         $command = "permissions";
     1335        $command     = "permissions";
    13261336        $return_code = permissions();
    13271337    } elsif (m/^cleanup$/i) {
Note: See TracChangeset for help on using the changeset viewer.