Changeset 238


Ignore:
Timestamp:
Oct 9, 2008, 12:05:11 AM (16 years ago)
Author:
joergs
Message:

cleanup

Location:
trunk/dasscm
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/dasscm/dasscm

    r237 r238  
    2626my $permissions_file = "/etc/permissions.d/dasscm.permission_backup";
    2727
     28# documentation file (for usage)
     29my $doc_file = "/usr/share/doc/packages/dasscm/dasscm_howto.txt";
     30
    2831# configuration file
    2932my $config_file = "/etc/dasscm.conf";
     
    3336my $DASSCM_SVN_REPOSITORY;
    3437
     38# current directory at program start
     39my $StartDirectory = cwd();
     40
    3541my $SVN                    = "svn ";
    3642my $svnOptions             = "";
    3743my $svnCheckoutCredentials = "";
    3844my $svnPasswordCredentials = "";
    39 my $DIFF                   = "diff --exclude .svn ";
     45my $diff                   = "diff --exclude .svn ";
    4046
    4147# command line options get stored in options hash
     
    6975    print "   permissions\n";
    7076    print "\n";
    71     print "preperation:\n", "  if dasscm is already configured,\n",
     77    print "preparation:\n", "  if dasscm is already configured,\n",
    7278      "  use 'dasscm login' and then eg. 'add'.\n",
    7379      "  The environment variables\n", "    DASSCM_REPO\n", "    DASSCM_PROD\n",
     
    7581      "  are evaluated, but set automatically by 'dasscm login'.\n", "\n",
    7682      "  If dasscm is not yet configured, read",
    77       "  /usr/share/doc/packages/dasscm/dasscm_howto.txt\n";
     83      "  $doc_file\n";
    7884}
    7985
     
    95101}
    96102
     103
     104#
     105# reading config file and return key/value pairs as hash
     106#
    97107sub get_config
    98108{
     
    115125            }
    116126            if ( $_ =~ /=/g ) {
    117                 ## splitting in 2 fields at maximum
     127                # splitting in 2 fields at maximum
    118128                my ( $option, $value ) = split( /=/, $_, 2 );
    119129                $option =~ s/^\s+//g;
     
    212222sub check_parameter(@)
    213223{
    214     if( not @_ ) {
    215         fatalerror( "no files specified. See 'dasscm --help'" );
    216     }
    217 }
    218 
     224}
     225
     226
     227#
     228# generate from (relative) filename
     229# all required file and directory names:
     230# $basename,      $dirname_prod, $dirname_repo,
     231# $filename_prod, $filename_repo
     232#
    219233sub get_filenames(@)
    220234{
    221235    my $filename_prod = $_[0];
    222236
    223     # remove leading './' from relative directories
    224     #$filename_prod =~ s/^\.\///;
    225 
     237    # make filename absolut
    226238    if ( !( $filename_prod =~ m/^\// ) ) {
    227239        $filename_prod = cwd() . "/" . $filename_prod;
     
    231243        fatalerror( $filename_prod  . " is not accessable" );
    232244    }
    233     #      elsif( -l $filename_prod ) {
    234     #         my $dest = readlink($filename_prod);
    235     #         # TODO:
    236     #         #   default: disallow, but offer cmd switch to activate
    237     #         #   (or check, if file is already checked in and has been a link before)
    238     #         warning( "'$filename_prod' is a link to '$dest'.", "Please check, if '$dest' should be stored in repository instead" );
    239     #         if( ! -f $dest ) {
    240     #             fatalerror( "link target '$dest' is not a regular file. Giving up" );
    241     #         }
    242     #     } elsif( ! -f $filename_prod ) {
    243     #         #fatalerror( $filename_prod . " is not a regular file" );
    244     #     }
    245245
    246246    # TODO: dirname buggy: eg. "/etc/" is reduced to "/",
    247247    #   "/etc" is used as filename
    248248    my $dirname_prod = dirname($filename_prod);
    249     my $oldpath = cwd();
     249
     250    # uses chdir to determine real directory in a unique way
    250251    chdir $dirname_prod or die $!;
    251252    $dirname_prod = cwd();
    252     chdir $oldpath;
     253    chdir $StartDirectory;
     254
    253255    my $basename = basename($filename_prod);
    254256
     
    362364    print "checking credentials ... ";
    363365
     366    if( ! $username ) {
     367        fatalerror( "no username given" );
     368    }
     369
     370    if( ! $password ) {
     371        fatalerror( "no password given" );
     372    }
     373
    364374    # Options for "svn info" are not supported by subversion 1.0.0 (SLES9),
    365375    # therefore switching to "svn status"
     
    376386
    377387    if ( $rc_update != 0 ) {
    378         print @result;
    379         die;
     388        print "\n", @result;
     389        fatalerror();
    380390    }
    381391
     
    390400    print @result;
    391401    if ( $rc_update != 0 ) {
    392         die;
     402        fatalerror();
    393403    }
    394404}
     
    410420    if ( $rc != 0 ) {
    411421        print @result;
    412         die;
     422        fatalerror;
    413423    }
    414424    chomp(@result);
     
    417427
    418428
     429#
     430# from an array of files/dirs,
     431# generates list of files
     432# sorted by type
     433#
    419434sub get_files( @ )
    420435{
     
    496511    print "\n";
    497512
    498     svn_check_credentials( $input_username, $input_password );
     513    svn_check_credentials( $input_username || $DASSCM_USERNAME, $input_password );
    499514
    500515    #
     
    571586    }
    572587
     588    # TODO: are permissions also copied?
    573589    copy( $filename_prod, $filename_repo ) or error "failed to copy $filename_prod to repository: $!";
    574590
    575591    if ( $command eq "add" ) {
    576592
    577         my $oldpath = cwd();
    578593        # already checked in?
    579         chdir($DASSCM_REPO);
     594        chdir $DASSCM_REPO;
    580595
    581596        # also add the path to filename.
     
    593608            print join( "\n", @out );
    594609        }
    595         chdir($oldpath);
     610        chdir $StartDirectory;
    596611    }
    597612}
     
    633648        print "\n";
    634649    }
     650
     651    # TODO: confirm
    635652
    636653    # copy files one by one to local repository
     
    700717    }
    701718
    702     ( my $rc_diff, my @diff ) =
    703       run_command( $DIFF . " $filename_repo $filename_prod");
    704     print @diff;
     719    ( my $rc_diff, my @diff_result ) =
     720      run_command( $diff . " $filename_repo $filename_prod");
     721
     722    print @diff_result;
    705723}
    706724
  • trunk/dasscm/dasscm.conf

    r223 r238  
    2727# server settings dass-it
    2828#
    29 DASSCM_SVN_REPOSITORY_BASE=https://dass-it.de/svn/dasscm/
     29DASSCM_SVN_REPOSITORY_BASE=https://svn.dass-it.net/svn/dasscm/
    3030DASSCM_CHECKOUT_USERNAME=dasscm
    3131DASSCM_CHECKOUT_PASSWORD=dcmdst
     
    3535# server settings LVermGeo
    3636#
    37 ##DASSCM_SVN_REPOSITORY_BASE=https://svn.dass-it.net/svn/lvermgeo/technical/config/server
    38 #DASSCM_SVN_REPOSITORY_BASE=https://dass-it.de/svn/lvermgeo/technical/config/server
     37#DASSCM_SVN_REPOSITORY_BASE=https://svn.dass-it.net/svn/lvermgeo/technical/config/server
    3938#DASSCM_CHECKOUT_USERNAME=lvermgeo
    4039#DASSCM_CHECKOUT_PASSWORD=
     
    4443# server settings Debeka
    4544#
    46 #DASSCM_SVN_REPOSITORY_BASE=https://dass-it.de/svn/smartclient/branches/Debeka/SC-03_01_add_NAH_Branch_Debeka/config/
     45#DASSCM_SVN_REPOSITORY_BASE=https://svn.dass-it.net/svn/smartclient/branches/Debeka/SC-03_01_add_NAH_Branch_Debeka/config/
    4746#DASSCM_CHECKOUT_USERNAME=debekadasscm
    4847#DASSCM_CHECKOUT_PASSWORD=
Note: See TracChangeset for help on using the changeset viewer.