File:  [LON-CAPA] / doc / loncapafiles / removenolongerused.piml
Revision 1.1.2.13: download - view: text, annotated - select for diffs
Tue Jul 2 02:02:51 2024 UTC (4 days, 9 hours ago) by raeburn
Branches: version_2_11_X
CVS tags: version_2_11_5
- For 2.11
  Backport 1.16

    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-3.2.1.min.js',
   29:                                'adm/jQuery/js/jquery-ui-1.7.2.custom.min.js',
   30:                                'adm/jQuery/js/jquery-ui-1.8.16.custom.min.js',
   31:                                'adm/jQuery/js/jquery-ui-1.11.4.custom.min.js',
   32:                                'adm/jQuery/js/jquery-ui-1.12.1.custom.min.js',
   33:                                'adm/jQuery/css/smoothness/jquery-ui-1.7.2.custom.css',
   34:                                'adm/jQuery/css/smoothness/jquery-ui-1.8.16.custom.css',
   35:                                'adm/jQuery/js/css/smoothness/jquery-ui-1.11.4.custom.css',
   36:                                'adm/jQuery/js/css/smoothness/jquery-ui-1.12.1.custom.min.css',
   37:                                'adm/reactionresponse/reaction_frame.html',
   38:                                'adm/reactionresponse/reaction_window.html'],
   39:               'debug'      =&gt; ['archive_coursedata_tables.pl'],
   40:             );
   41: 
   42: my %dirs = (
   43:               'londocroot' =&gt; ['htmlarea',
   44:                                   'res/adm/pages/bookmarkmenu',
   45:                                   'res/adm/pages/reactionresponse',
   46:                                   'adm/jsMath',
   47:                                   'adm/jQuery/css/ui-lightness'],
   48:            );
   49: 
   50: my @filestodelete = ();
   51: my @dirstodelete = ();
   52: foreach my $key (sort(keys(%files))) {
   53:     if ($paths{$key} ne '') {
   54:         if (ref($files{$key}) eq 'ARRAY') {
   55:             foreach my $file (@{$files{$key}}) {
   56:                 if (($file ne '') && (-f $paths{$key}.'/'.$file)) {
   57:                     push(@filestodelete,$paths{$key}.'/'.$file);
   58:                 }
   59:             }
   60:         }
   61:     }
   62: }
   63: 
   64: foreach my $key (sort(keys(%dirs))) {
   65:     if ($paths{$key} ne '') {
   66:         if (ref($dirs{$key}) eq 'ARRAY') {
   67:             foreach my $dir (@{$dirs{$key}}) {
   68:                 if (($dir ne '') && (-d $paths{$key}.'/'.$dir)) {
   69:                     push(@dirstodelete,$paths{$key}.'/'.$dir);
   70:                 }
   71:             }
   72:         }
   73:     }
   74: }
   75: 
   76: if (@dirstodelete > 0) {
   77:     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";
   78:     foreach my $dir (@dirstodelete) {
   79:         next if (($dir =~/\*/) || ($dir eq '') || ($dir eq '/'));  
   80:         print "$dir  -- delete? Enter: Y or N:\n";
   81:         my $choice=&lt;&gt;;
   82:         chomp($choice);
   83:         $choice =~ s/\s+//g;
   84:         if ($choice eq 'Y') {
   85:             File::Path::rmtree($dir);
   86:         }
   87:     }
   88: }
   89: 
   90: if (@filestodelete > 0) {
   91:    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";
   92:     foreach my $file (@filestodelete) {
   93:         next if (($file =~/\*/) || ($file eq '') || ($file eq '/'));
   94:         print "$file -- remove? Enter? Y or N:\n";
   95:         my $choice=&lt;&gt;;
   96:         chomp($choice);
   97:         $choice =~ s/\s+//g;
   98:         if ($choice eq 'Y') {
   99:             unlink($file);
  100:         }
  101:     }
  102: }
  103: 
  104: </perlscript>
  105: </file>
  106: </files>
  107: </piml>

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