File:  [LON-CAPA] / doc / loncapafiles / removenolongerused.piml
Revision 1.1.2.11: download - view: text, annotated - select for diffs
Sun Sep 2 16:19:31 2018 UTC (5 years, 7 months ago) by raeburn
Branches: version_2_11_X
CVS tags: version_2_11_3_uiuc, version_2_11_3_msu, version_2_11_3
- For 2.11
  Backport 1.14.

    1: <piml>
    2: <targetroot>/</targetroot>
    3: <files>
    4: <file>
    5: <target dist="default"></target>
    6: <perlscript mode="fg">
    7: 
    8: use File::Path();
    9: 
   10: my %paths = (
   11:               'londaemons' =&gt; '/home/httpd/perl',
   12:               'apache'     =&gt; '/home/httpd/lib/perl/Apache',
   13:               'londocroot' =&gt; '/home/httpd/html',
   14:               'debug'      =&gt; '/home/httpd/perl/debug',
   15:             );
   16:  
   17: my %files = (
   18:               'londaemons' =&gt; ['lonManage','lchtmldir','lonhttpd','lcuseradd','lonc'],
   19:               'apache'     =&gt; ['londropadd.pm','lonconstruct.pm',
   20:                                'admbookmarks.pm','lonassignments.pm'],
   21:               'londocroot' =&gt; ['adm/rat/extpickcode.html',
   22:                                'adm/rat/extpickframe.html',
   23:                                'adm/help/gif/vbkm.gif',
   24:                                'adm/help/eps/vbkm.eps',
   25:                                'adm/jQuery/js/jquery-1.3.2.min.js',
   26:                                'adm/jQuery/js/jquery-1.6.2.min.js',
   27:                                'adm/jQuery/js/jquery-1.11.3.min.js',
   28:                                'adm/jQuery/js/jquery-ui-1.7.2.custom.min.js',
   29:                                'adm/jQuery/js/jquery-ui-1.8.16.custom.min.js',
   30:                                'adm/jQuery/js/jquery-ui-1.11.4.custom.min.js',
   31:                                'adm/jQuery/css/smoothness/jquery-ui-1.7.2.custom.css',
   32:                                'adm/jQuery/css/smoothness/jquery-ui-1.8.16.custom.css',
   33:                                'adm/jQuery/js/css/smoothness/jquery-ui-1.11.4.custom.css'],
   34:               'debug'      =&gt; ['archive_coursedata_tables.pl'],
   35:             );
   36: 
   37: my %dirs = (
   38:               'londocroot' =&gt; ['htmlarea',
   39:                                   'res/adm/pages/bookmarkmenu',
   40:                                   'res/adm/pages/reactionresponse',
   41:                                   'adm/jsMath',
   42:                                   'adm/jQuery/css/ui-lightness'],
   43:            );
   44: 
   45: my @filestodelete = ();
   46: my @dirstodelete = ();
   47: foreach my $key (sort(keys(%files))) {
   48:     if ($paths{$key} ne '') {
   49:         if (ref($files{$key}) eq 'ARRAY') {
   50:             foreach my $file (@{$files{$key}}) {
   51:                 if (($file ne '') && (-f $paths{$key}.'/'.$file)) {
   52:                     push(@filestodelete,$paths{$key}.'/'.$file);
   53:                 }
   54:             }
   55:         }
   56:     }
   57: }
   58: 
   59: foreach my $key (sort(keys(%dirs))) {
   60:     if ($paths{$key} ne '') {
   61:         if (ref($dirs{$key}) eq 'ARRAY') {
   62:             foreach my $dir (@{$dirs{$key}}) {
   63:                 if (($dir ne '') && (-d $paths{$key}.'/'.$dir)) {
   64:                     push(@dirstodelete,$paths{$key}.'/'.$dir);
   65:                 }
   66:             }
   67:         }
   68:     }
   69: }
   70: 
   71: if (@dirstodelete > 0) {
   72:     print "\nThe following directories were installed for an earlier version of LON-CAPA, and are no longer needed. It is recommended that you delete them. For each one, enter Y if you would the directory to be deleted.\n\n";
   73:     foreach my $dir (@dirstodelete) {
   74:         next if (($dir =~/\*/) || ($dir eq '') || ($dir eq '/'));  
   75:         print "$dir  -- delete? Enter: Y or N:\n";
   76:         my $choice=&lt;&gt;;
   77:         chomp($choice);
   78:         $choice =~ s/\s+//g;
   79:         if ($choice eq 'Y') {
   80:             File::Path::rmtree($dir);
   81:         }
   82:     }
   83: }
   84: 
   85: if (@filestodelete > 0) {
   86:    print "\nThe following files were installed for an earlier version of LON-CAPA, and are no longer needed. It is recommended that you delete them. For each one, enter Y if you would the file to be deleted.\n\n";
   87:     foreach my $file (@filestodelete) {
   88:         next if (($file =~/\*/) || ($file eq '') || ($file eq '/'));
   89:         print "$file -- remove? Enter? Y or N:\n";
   90:         my $choice=&lt;&gt;;
   91:         chomp($choice);
   92:         $choice =~ s/\s+//g;
   93:         if ($choice eq 'Y') {
   94:             unlink($file);
   95:         }
   96:     }
   97: }
   98: 
   99: </perlscript>
  100: </file>
  101: </files>
  102: </piml>

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>