Changeset 252 for trunk/dasscm
- Timestamp:
- Dec 22, 2008, 6:10:02 PM (16 years ago)
- Location:
- trunk/dasscm
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/dasscm/dasscm
r251 r252 24 24 # 25 25 26 my $RETURN_OK = 0; 27 my $RETURN_NOK = 1; 28 26 29 # file to store permissions 27 30 my $permissions_file = "/etc/permissions.d/dasscm.permission_backup"; … … 29 32 # documentation file (for usage) 30 33 my $doc_file = "/usr/share/doc/packages/dasscm/dasscm_howto.txt"; 34 35 my @COMMANDS_REQUIRE_WRITE = ( 'add', "commit" ); 31 36 32 37 # configuration file … … 38 43 my $DASSCM_CHECKOUT_USERNAME; 39 44 my $DASSCM_CHECKOUT_PASSWORD; 40 41 45 42 46 # current directory at program start … … 180 184 if ($verbose) { print "DASSCM_REPO: " . $DASSCM_REPO . "\n"; } 181 185 182 183 186 # 184 187 # subversion checkout user 185 188 # 186 if ( !$DASSCM_CHECKOUT_USERNAME ) {187 fatalerror( 189 if ( !$DASSCM_CHECKOUT_USERNAME ) { 190 fatalerror( 188 191 "variable DASSCM_CHECKOUT_USERNAME is not defined.", 189 "Use file $config_file to configure it." ); 190 } 191 192 if( ! $DASSCM_CHECKOUT_PASSWORD ) { 193 fatalerror( 192 "Use file $config_file to configure it." 193 ); 194 } 195 196 if ( !$DASSCM_CHECKOUT_PASSWORD ) { 197 fatalerror( 194 198 "variable DASSCM_CHECKOUT_PASSWORD is not defined.", 195 "Use file $config_file to configure it." );196 }197 199 "Use file $config_file to configure it." 200 ); 201 } 198 202 199 203 # … … 220 224 # otherwise USER can be used 221 225 if ( "$USER" eq "root" ) { 222 if ( ( not $DASSCM_USERNAME ) and ( $command ne "login" ) ) { 223 fatalerror( "Envirnonment variable DASSCM_USERNAME not set.", "Set DASSCM_USERNAME to your subversion user account or", "use 'dasscm login'" ); 226 if ( ( not $DASSCM_USERNAME ) 227 and ( grep { m|^$command$| } @COMMANDS_REQUIRE_WRITE ) ) 228 { 229 230 #( $command ne "login" ) and ( $command ne "status" ) ) { 231 fatalerror( 232 "Envirnonment variable DASSCM_USERNAME not set.", 233 "Set DASSCM_USERNAME to your subversion user account or", 234 "use 'dasscm login'" 235 ); 224 236 } 225 237 $svnOptions .= " --no-auth-cache "; … … 376 388 } 377 389 378 379 380 390 sub svn_check_credentials( $$;$$ ) 381 391 { … … 383 393 my $password = shift; 384 394 385 # check silently are allow user interaction? 395 # check silently are allow user interaction? 386 396 my $interactive = shift || 0; 387 397 … … 389 399 # (do not exit for 'init') 390 400 my $fatalerror = shift || 1; 391 392 393 401 394 402 print "checking credentials "; … … 413 421 414 422 my $rc_update; 415 if( $interactive ) { 416 $rc_update = run_interactive( "$SVN ls --no-auth-cache --username $username --password $password $DASSCM_SVN_REPOSITORY" ); 423 if ($interactive) { 424 $rc_update = 425 run_interactive( 426 "$SVN ls --no-auth-cache --username $username --password $password $DASSCM_SVN_REPOSITORY" 427 ); 417 428 } else { 418 429 ( $rc_update, my @result ) = 419 run_command(430 run_command( 420 431 "$SVN ls --non-interactive --no-auth-cache --username $username --password $password $DASSCM_SVN_REPOSITORY" 421 );422 432 ); 433 423 434 if ( $rc_update != 0 ) { 424 435 print "\n", @result; 425 if ( $fatalerror) {436 if ($fatalerror) { 426 437 fatalerror(); 427 438 } … … 433 444 return $rc_update == 0; 434 445 } 435 436 437 446 438 447 sub svn_update( ;$ ) … … 562 571 563 572 # checking checkout username/password 564 svn_check_credentials( $DASSCM_CHECKOUT_USERNAME, $DASSCM_CHECKOUT_PASSWORD ); 573 svn_check_credentials( $DASSCM_CHECKOUT_USERNAME, 574 $DASSCM_CHECKOUT_PASSWORD ); 565 575 print "checkout access okay\n"; 566 576 … … 594 604 my $retcode = 595 605 run_interactive( 596 "cd $DASSCM_LOCAL_REPOSITORY_BASE; $SVN checkout $svnCheckoutCredentials $svnOptions $DASSCM_SVN_REPOSITORY; touch $permissions_file"606 "cd $DASSCM_LOCAL_REPOSITORY_BASE; $SVN checkout $svnCheckoutCredentials $svnOptions $DASSCM_SVN_REPOSITORY; mkdir -p `dirname $permissions_file`; touch $permissions_file" 597 607 ); 598 608 } … … 782 792 check_env(); 783 793 794 # return code for the shell 795 # default: error 796 my $return_code = $RETURN_NOK; 797 784 798 # 785 799 # update local repository … … 833 847 } else { 834 848 print "no modified files found in $dir\n"; 849 $return_code = $RETURN_OK; 835 850 } 836 851 837 852 print "\n"; 853 854 return $return_code; 838 855 } 839 856 … … 891 908 # 892 909 910 my $return_code = $RETURN_OK; 893 911 my $number_arguments = @ARGV; 894 912 … … 966 984 diff(@ARGV); 967 985 } elsif ( (m/status/i) || (m/st/i) ) { 968 $command = "status";969 status(@ARGV);986 $command = "status"; 987 $return_code = status(@ARGV); 970 988 } elsif (m/permissions/i) { 971 989 $command = "permissions"; … … 975 993 usage(); 976 994 check_env(); 995 $return_code = $RETURN_NOK; 977 996 } 978 997 … … 982 1001 # activate 983 1002 # rm 984 } 1003 1004 } 1005 1006 exit $return_code; -
trunk/dasscm/debian/control
r240 r252 8 8 Package: dasscm 9 9 Architecture: any 10 Depends: subversion, perl, libterm-readkey-perl , libconfig-inifiles-perl10 Depends: subversion, perl, libterm-readkey-perl 11 11 Description: dass configuration management tool 12 12 tools for handling configuration files with subversion -
trunk/dasscm/debian/rules
r240 r252 63 63 install -d $(CURDIR)/debian/dasscm/etc 64 64 install -d $(CURDIR)/debian/dasscm/etc/subversion 65 install -d $(CURDIR)/var/lib/dasscm/ 65 66 install -m 0755 dasscm $(CURDIR)/debian/dasscm/usr/bin 66 67 install -m 0644 dasscm.conf $(CURDIR)/debian/dasscm/etc
Note:
See TracChangeset
for help on using the changeset viewer.