Subversion Repositories Vertical

Rev

Blame | Last modification | View Log | Download | RSS feed

  1. #!/usr/local/bin/perl
  2. use Tk;
  3. my $mw = MainWindow->new;
  4. $mw->Button(  -text=>"Hello" , -command=>sub{exit}  )->grid;
  5. $box1 = $mw->Listbox(  -x=>1, -y=>10,-width=>10, -selectmode=>'single' ,-height=>0)->grid;
  6. $scr1 = $mw->Scrollbar( -x=>2, -y=>10, -command=>sub{exit})->grid;
  7. #$box1->configure(-command=>sub{exit});
  8. $box1->insert('end',"dd","eee","ff");
  9. $box1->insert('end',"ii","jj","kk");
  10. MainLoop;
  11.  
  12.  
  13. exit(0);
  14. $home = $ENV{"HOME"};
  15. $host = `hostname`;
  16. chomp $host;
  17. $directory = `pwd`;              
  18. chomp $directory;
  19. #
  20. # discover the pager tool in use
  21. $pager = $ENV{"PAGER"};
  22.  
  23.  
  24.  
  25. if (length($pager)== 0 || !-e $pager ) {
  26.   $pager = `which cat`;
  27.   };
  28.  
  29.  
  30.  
  31. # determine install files that need to be copied
  32. # tool repository
  33. $releases = "/user/mjames/altera_breadboarding/releases";
  34.  
  35. #where the help file is
  36. $helpfile = "$releases/makeversion.txt";
  37. #where the extended help file is
  38. $helpfile_long = "$releases/makeversion_long.txt";
  39.  
  40.  
  41.  
  42. #file to edit for version
  43. $versionf  = "version.h";
  44. $versiont  = "version.h.tmp";
  45.  
  46. # workout command line options
  47. #is this a query of releases
  48. # COde 0 : query (L option) versions
  49. # code 1 : install
  50. # code 2 : release
  51. # code 3 : help (short)
  52. # code 4 : show trial install
  53. # code 5 : help (full)
  54.  
  55. $oper = 3;
  56. $relnamegiven = 0;
  57. $relname = "Default";
  58. for($idx=0;$idx <= $#ARGV;$idx++) {
  59.   $item = $ARGV[$idx];
  60.   if (length($item)>0) {
  61.     if( $item =~ /^-Release/ ) {
  62.       print("Release\n");
  63.       $oper = 2;
  64.  
  65.       if (length( $item)>8) {
  66.         $relname = substr $item,8;
  67.         $relnamegiven = 1;
  68.         };
  69.       };
  70.     if( $item =~ /^-[iI]/ ) {
  71.       print("Install\n");
  72.       $oper = 1;
  73.       if (length($ARGV[0])>2) {
  74.         $relname = substr $item,2;
  75.         $relnamegiven = 1;
  76.         };
  77.       };
  78.     if( $item =~ /^-[tT]/ ) {
  79.       print("Trial Install\n");
  80.       $oper = 4;
  81.       if (length($ARGV[0])>2) {
  82.         $relname = substr $item,2;
  83.         $relnamegiven = 1;
  84.         };
  85.       };
  86.     if( $item =~ /^-[lL]/ ) {
  87.       print("List releases \n");
  88.       $oper = 0;
  89.       };
  90.     if( $item =~ /^-[hH]/ ) {
  91.       print("Extended Help \n");
  92.       $oper = 5;
  93.       };
  94.     if( $item =~ /^-[uU]/ ) {
  95.       print("UnInstall\n");
  96.       $oper = 6;
  97.       if (length($ARGV[0])>2) {
  98.         $relname = substr $item,2;
  99.         $relnamegiven = 1;
  100.         };
  101.       };
  102.     };
  103.   };
  104.  
  105.  
  106.  
  107.  
  108. if ( ($oper == 3 || $oper == 5) && -e "$helpfile") {
  109. #printout of revision number to a suitable pager
  110.     open (IN,"<$helpfile");
  111.     open (PAGER, "|$pager");
  112.     while (<IN>) {
  113.       print PAGER ;
  114.       };
  115.     close IN;
  116.     if ( $oper == 5 && -e "$helpfile_long") {
  117.       open (IN,"<$helpfile_long");
  118.       while (<IN>) {
  119.         print PAGER ;
  120.         };
  121.       };
  122.     close (PAGER);
  123.     exit;
  124.     };
  125.  
  126.  
  127.  
  128.  
  129. #make a date etc from it
  130. $tim =`date`;
  131. chomp $tim;
  132. #extract the time field from the date
  133. # Skip 4 read 6 skip 14 read rest chars
  134. $tim =~ s/^.{4}(.{6}).{14}(.*)$/$1 $2/;
  135.  
  136. $tim =~ s/:/_/g;
  137. $tim =~ s/ /_/g;
  138.  
  139. #use release name override for code release
  140. if( $oper == 2 && -e $versionf && -e "makefile") {
  141.   if(!$relnamegiven ) { $relname = "$tim"; };
  142.    
  143. # write a new version file
  144.   if ( -e $versiont ) {
  145.     unlink( $versiont );
  146.     };
  147. # Need to have a copy of version.h in this directory and a makefile
  148. # with the correct rules in it : make_tail for example
  149.   if (open (IN,"<$versionf") && open (OUT,">$versiont") ) {
  150.     while ( <IN> )  {
  151.      if ( /^#define RELDATE/ ) {
  152.        printf (OUT "\#define RELDATE \"Release $relname\"\n");
  153.        }
  154.      else {
  155.        printf(OUT "$_" ) ;
  156.        };
  157.      };
  158.    close (IN);
  159.    close (OUT);
  160.    rename $versiont,$versionf;
  161.    print("/usr/bin/make rel_tail RELDATE=\"$relname\"\n");
  162.    system("/usr/bin/make rel_tail RELDATE=\"$relname\"");
  163.   }
  164. # create a new version to attach to any of the files that will be built
  165.  
  166. #this is the release directory where all files and links are to be
  167. # installed.
  168.   $release_dir = "$releases/$relname";
  169.  
  170. # Remove any files that are in the directory
  171.  
  172.   # Make the directory anyway
  173.   mkdir $release_dir,0777;
  174.   if (! -f "$release_dir/release.ini") {
  175.     symlink "$releases/packages.ini","$release_dir/release.ini";
  176.     };
  177.   $packagefile = "$releases/packages.ini";
  178.   }
  179. #when creating a release use the parent  
  180.  
  181.  
  182. else {
  183. #not Releasing just querying or installing
  184.   $release_dir = "$releases/$relname";
  185.   $packagefile = "$release_dir/release.ini";
  186.   }
  187.  
  188.  
  189.  
  190. #if we are querying release files we need to check all of the
  191. #directories in which we may find a release
  192. if ($oper==0) {
  193. # startup a pager for any output
  194.   open (PAGER, "|$pager");
  195.   opendir (RELDIR,"$releases");
  196.   $dir = readdir(RELDIR);
  197.   while ($dir) {
  198.     if( -e "$releases/$dir/release.ini" ) {
  199.       printf(PAGER "Release $dir is available\n\n");  
  200.    
  201. #printout of revision number
  202.       if ( -e "$releases/$dir/readme.txt" ) {
  203.         open (IN,"$releases/$dir/readme.txt");
  204.         while (<IN>) { print PAGER "  ",$_; };
  205.         };
  206.       };
  207.     $dir = readdir(RELDIR);
  208.     }
  209.   close (PAGER);
  210.   }
  211.    
  212. else {
  213.  
  214. #sanity check on install
  215.   if($oper == 1 || $oper==4 || $oper==6) {
  216.     if (!$relnamegiven) {
  217.       print "No release name given\n";
  218.       exit (1);
  219.       };
  220.     if (!-e $packagefile ) {
  221.       print "Cant use release $relname\n";
  222.       exit(1);
  223.       };
  224.     };
  225.    
  226.  
  227. #setup the mode under which the files will be linked/copied
  228. $filemode = 0744;
  229.  
  230. # set how the file links will be made
  231. $lnflags = "-s";
  232.  
  233. # we have now built the tools in this directory.
  234. # read in the base description of the package
  235. $fileflag = 0;
  236. $oldflag = 0;
  237. $forceflag = 0;
  238.  
  239.  
  240. $resp=" ";
  241.  
  242. if (open (IN,"<$packagefile")) {
  243.  
  244.   LINE: while ( <IN> )  {
  245.     chomp;
  246.     if ( /#/ || length() < 2)    {  next LINE; }   ;
  247.     if ( /\[sourcedir\]/ ){$oldflag = $fileflag;$fileflag = 1;  next LINE; } ;
  248.     if ( /\[destdir\]/ )  {$oldflag   = $fileflag;$fileflag = 5;  next LINE; } ;
  249.     if ( /\[messages\]/ ) {$fileflag  = 6;  next LINE; } ;
  250.     if ( /\[files\]/ )    {$forceflag = 0; $fileflag = 2;  next LINE; } ;
  251.     if ( /\[links\]/ )    {$forceflag = 0; $fileflag = 3;  next LINE; } ;
  252.     if ( /\[mode\]/ )     {$oldflag   = $fileflag;$fileflag = 4;  next LINE; } ;
  253.     if ( /\[overwrite\]/ ) {$forceflag=1;  next LINE; } ;
  254.     if ( /\[query\]/ )     {$forceflag=0;  next LINE; } ;
  255. #pickup the file copy source path
  256.     if ($fileflag==1)   {
  257.       s/\~/$home/g; #expand special char
  258.       $compile_dir  = $_ ;
  259.       $fileflag=$oldflag;  
  260.       next LINE; } ;
  261. #these are actual release building flags
  262.     if ($fileflag==2 || $fileflag==3 )   {
  263.       @file = split ' ';
  264.       $destname   = $file[0];
  265.       $sourcename = $file[1];
  266. # no source name given (only one name on the line)
  267. # then source & dest are same name
  268.       if ($#file<1) {  # last index is 0 =>less than 2 elements , is one ...
  269.         $sourcename = $destname;
  270.         };
  271.      
  272.  
  273.       if ($oper == 1 || $oper ==4 || $oper ==6) { #perfoming an installation from releases
  274.         $newname = "$install_dir/$destname";
  275.         $oldname = "$release_dir/$sourcename";
  276.         $ok = 1;
  277.         $exists = -e $newname;
  278.         if ( $oper==1 && !$forceflag && $exists   ) { # check for overwrite permision
  279.           if ($resp =~ /[aA]/ ) { $resp=" "; }; #if already said 'all' ignore
  280.           while ( $resp =~ /[^YyNnAa]/ ) {
  281.             print ("\n\aFound file $newname : overwrite ? \n(y/n/a) a=dont ask again:");
  282.             $resp = getc;
  283.            if ( $resp =~ /\n/ ) { $resp = getc; };
  284.             };
  285.           if ( $resp =~ /[nN]/ ) {$ok=0;};
  286.           };
  287.        
  288.         if($ok && -e "$oldname") { #an installation linkage
  289.           if ( $oper== 1 ) {
  290.             unlink  "$newname";
  291.             symlink "$oldname","$newname";  
  292.             printf("install %-15s to %s mode %o\n",$sourcename,$newname,$filemode);
  293.             }
  294.           elsif ($oper==6) { #an uninstall operation
  295.             if($exists && $forceflag) {
  296.               unlink  "$newname";
  297.               printf("uninstall %-15s\n",$newname);
  298.               };
  299.             }
  300.           else {
  301.             printf("install %-15s to %s mode %o\n",$sourcename,$newname,$filemode);
  302.             }
  303.           };
  304.         };  
  305.          
  306.       if ($oper ==2) { #a release copy procedure is being performed
  307.         $newname = "$release_dir/$destname";
  308.         $oldname = "$compile_dir/$sourcename";
  309.  
  310.         if ( -d $release_dir) { unlink "$newname"; };
  311.         if ($fileflag == 2) { #file copy on release
  312.           system ("/usr/bin/cp $oldname $newname\n");
  313.           }
  314.         else { #file link
  315.           system ("/usr/bin/ln $lnflags $oldname $newname\n");
  316.           };
  317.         chmod $filemode,"$newname";
  318.         };
  319.       next LINE;
  320.       }
  321. #pickup file access mode
  322.     if ($fileflag==4)   {$filemode  = oct($_) ; $fileflag=$oldflag;  next LINE; } ;
  323. #pickup the file installation destination path
  324.     if ($fileflag==5)   {
  325.       s/\~/$home/g; #expand special char
  326.       $install_dir  = $_ ;
  327.       $fileflag=$oldflag;  
  328.       next LINE; } ;
  329. #pickup user message
  330.     if ($fileflag==6)   {print("$_\n") ;  next LINE; } ;
  331.  
  332.        
  333.       } ;
  334.    
  335.   };
  336.  };
  337.