root/branches/newmole/scripts/nightly_copy_source.pl
| Revision 687, 5.4 kB (checked in by peter, 2 years ago) | |
|---|---|
|
|
| Line | |
|---|---|
| 1 | #!perl -w |
| 2 | |
| 3 | # This script copies source from pc to linux cluster |
| 4 | # This is a perl script to convert ascii pc source files into unix eol files |
| 5 | |
| 6 | # bring in the perl module that includes copy |
| 7 | use File::Copy; |
| 8 | |
| 9 | # base name for where we are |
| 10 | $basename = "c:/projects/cloudy/trunk/"; |
| 11 | |
| 12 | # -------------------------------------------------------------------------- |
| 13 | # this block - set up paths to all targets on various machines |
| 14 | |
| 15 | # this is where the original source files live on my pc |
| 16 | #$original_source_dir = "c:/projects/cloudy/trunk/source"; |
| 17 | $original_source_dir = "$basename"."source_hot"; |
| 18 | |
| 19 | # the root dir where the unix files will live on the linux cluster |
| 20 | $cluster_unix_source_dir = "u:/cloudy/trunk/source"; |
| 21 | |
| 22 | # this is the ftp site on gradj |
| 23 | $ftp_last = "u:/pub/gary/bleeding_edge/last/"; |
| 24 | |
| 25 | # the root dir where the unix files will live on my pc |
| 26 | #$local_unix_source_dir = "c:/projects/cloudy/trunk/unix/source"; |
| 27 | $local_unix_source_dir = "$basename"."unix/source"; |
| 28 | |
| 29 | #$local_unix_main_dir = "c:/projects/cloudy/trunk/unix"; |
| 30 | $local_unix_main_dir = "$basename"."unix"; |
| 31 | |
| 32 | # the win dir within the unix set |
| 33 | #$local_win_source_dir = "c:/projects/cloudy/trunk/win/source"; |
| 34 | $local_win_source_dir = "$basename"."win/source"; |
| 35 | |
| 36 | #this is where backup files will be dropped |
| 37 | #$unixhome = "c:/projects/cloudy/trunk/unix"; |
| 38 | $unixhome = "$basename"."unix"; |
| 39 | |
| 40 | #$winhome = "c:/projects/cloudy/trunk/win"; |
| 41 | $winhome = "$basename"."win"; |
| 42 | # end block - set up paths to all targets on various machines |
| 43 | |
| 44 | # -------------------------------------------------------------------------- |
| 45 | # -------------------------------------------------------------------------- |
| 46 | # this block - clean out the target directories so we get fresh copies |
| 47 | # move to the old unix source directory, where we will delete all files |
| 48 | # |
| 49 | # move to pc unix source dir |
| 50 | chdir( "$local_unix_source_dir" ) or die " invalid pc unix target directory for source\n"; |
| 51 | print(" moved to pc unix target source directory, about to delete all files\n"); |
| 52 | # remove the unix source files |
| 53 | unlink <*> ; |
| 54 | |
| 55 | # move to win source dir |
| 56 | chdir( "$local_win_source_dir" ) or die " invalid win target directory for source\n"; |
| 57 | print(" moved to win target source directory, about to delete all files\n"); |
| 58 | # remove the win source files |
| 59 | unlink <*> ; |
| 60 | |
| 61 | # move to the cluster source directory |
| 62 | chdir( "$cluster_unix_source_dir" ) or die " invalid cluster target directory for source\n"; |
| 63 | print(" moved to unix target source directory, about to delete all files\n"); |
| 64 | # remove the old source files |
| 65 | unlink <*.cpp> ; |
| 66 | |
| 67 | |
| 68 | # -------------------------------------------------------------------------- |
| 69 | # move to where the original source files live |
| 70 | chdir( "$original_source_dir" ) or die " invalid original target directory for source\n"; |
| 71 | |
| 72 | # this loops over all files in the original source directory |
| 73 | # and copies unix eol version to subdir unix, which is now empty |
| 74 | # also copies win version to subdir win/source, which is now empty |
| 75 | while( defined( $input = glob("*") ) ) |
| 76 | { |
| 77 | print( "$input going to " ); |
| 78 | $output = "$local_unix_source_dir"."/"."$input"; |
| 79 | print("$output\n"); |
| 80 | # actually execute the code |
| 81 | system "dos2unix < $input > $output"; |
| 82 | # |
| 83 | # now do win version |
| 84 | print( "$input going to " ); |
| 85 | $output = "$local_win_source_dir"."/"."$input"; |
| 86 | print("$output\n"); |
| 87 | # simply copy the source here |
| 88 | copy( $input , $output ); |
| 89 | } |
| 90 | |
| 91 | # this jpeg file was damaged above, so now copy straight version over |
| 92 | copy( "clouds.jpg" , "$local_unix_source_dir"."/"."clouds.jpg" ); |
| 93 | |
| 94 | print("\n=========================\n"); |
| 95 | print("All source files have been copies to unix/source subdir\n"); |
| 96 | print("=========================\n"); |
| 97 | |
| 98 | # move to local unix source directory with unix eol source |
| 99 | chdir( $local_unix_source_dir ) or die " invalid local unix source directory for input\n"; |
| 100 | |
| 101 | # this loops over all files in the local unix source directory |
| 102 | # and copies unix version to cluster source, which should be empty |
| 103 | while( defined( $input = glob("*") ) ) |
| 104 | { |
| 105 | print( "$input going to " ); |
| 106 | $output = "$cluster_unix_source_dir"."/"."$input"; |
| 107 | print("$output\n"); |
| 108 | # actually execute the code |
| 109 | copy( $input , $output); |
| 110 | } |
| 111 | # we have now clobbered the path.cpp file, and need to copy a valid one from 1 dir up |
| 112 | # so that version on unix cluster will compile & execute |
| 113 | copy( "u:/cloudy/trunk/path.cpp" , "u:/cloudy/trunk/source/path.cpp" ); |
| 114 | |
| 115 | # ---------------------------------------------------------- |
| 116 | # now create compressed archives of the files we created |
| 117 | chdir( "$unixhome" ) or die " invalid unix home directory for source\n"; |
| 118 | print(" moved to unix home directory\n"); |
| 119 | |
| 120 | # remove old gzipd file if it exists |
| 121 | if( -e "source.tar.gz" ) |
| 122 | { |
| 123 | unlink("source.tar.gz" ); |
| 124 | } |
| 125 | |
| 126 | # tar the files |
| 127 | chdir( "$local_unix_source_dir" ) or die " invalid directory for local unix source\n"; |
| 128 | $tarfile = "../"."source.tar"; |
| 129 | system "tar -cf $tarfile * "; |
| 130 | print( "about to gzip $tarfile\n" ); |
| 131 | system "gzip $tarfile "; |
| 132 | |
| 133 | |
| 134 | # move to main dir so that we can copy tar.gz files to ftp site |
| 135 | chdir( "$local_unix_main_dir" ) or die " invalid directory for main unix\n"; |
| 136 | # finally copy the newly created files to the ftp site |
| 137 | copy( "source.tar.gz" , $ftp_last ); |
| 138 | |
| 139 | # how go to win home and zip the win source dir |
| 140 | # |
| 141 | # move to win home directory |
| 142 | chdir( "$winhome" ) or die " invalid directory for win home\n"; |
| 143 | if( -e "source.zip" ) |
| 144 | { |
| 145 | unlink("source.zip" ); |
| 146 | } |
| 147 | |
| 148 | # win source |
| 149 | system "c:\\u\\wzzip source.zip $local_win_source_dir "; |
| 150 | |
| 151 | # finally copy the newly created files to the ftp site |
| 152 | copy( "source.zip" , $ftp_last ); |
| 153 | |
| 154 | print("\n=========================\n"); |
Note: See TracBrowser
for help on using the browser.
