Changeset 23242


Ignore:
Timestamp:
2010-10-28T10:14:17+13:00 (13 years ago)
Author:
sjm84
Message:

A few minor updates to the uninstaller

Location:
main/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/ant-tasks/src/org/greenstone/anttasks/PatternSetToFile.java

    r23211 r23242  
    1515 * PatternSetToFile is an Ant task used to take an Ant PatternSet and output to a
    1616 * file all the files that it encompasses
    17  * @author sjm84
     17 * @author Sam McIntosh
    1818 */
    1919public class PatternSetToFile extends Task
    2020{
     21    //Sets whether or not only the top-level files and folders
     22    //are stored in the output file
     23    public boolean _toplevelonly = false;
     24   
    2125    //The file the set will be written to
    2226    public File _outfile = null;
     
    4852               
    4953                String[] includedFiles = ds.getIncludedFiles();
     54               
     55                if(_toplevelonly)
     56                {
     57                    ArrayList toplevel = new ArrayList();
     58                   
     59                    for(int j = 0; j < includedFiles.length; j++)
     60                    {
     61                        int separatorIndex = includedFiles[j].indexOf(File.separator);
     62                       
     63                        if ( separatorIndex == -1 && includedFiles[j].length() > 0 && !toplevel.contains(toplevel)) {
     64                            toplevel.add(includedFiles[j]);
     65                        }
     66                        else if ( separatorIndex > -1 && includedFiles[j].length() > 0) {
     67                            String path = includedFiles[j].substring(0, separatorIndex);
     68                            if ( !toplevel.contains(path) ) {
     69                                toplevel.add(path);
     70                            }
     71                        }
     72                    }
     73                    includedFiles = (String[])toplevel.toArray(new String[0]);
     74                }
     75               
    5076                for (int j = 0; j < includedFiles.length; j++)
    5177                {
     
    6086        }
    6187    }
    62    
     88
     89    public void setToplevelonly(boolean toplevelonly)
     90    {
     91        _toplevelonly = toplevelonly;
     92    }
     93
    6394    public void setOutfile(File outfile)
    6495    {
    6596        _outfile = outfile;
    6697    }
    67    
     98
    6899    public void setDir(File dir)
    69100    {
     
    73104    public void addConfiguredPatternset(PatternSet patternset)
    74105    {
    75         if (patternset == null || !(patternset instanceof PatternSet))
     106        if (patternset == null)
    76107        {
    77108            return;
  • main/trunk/release-kits/shared/core/ant-scripts/shared.xml

    r23210 r23242  
    381381        <mkdir dir="components"/>
    382382     
    383         <pstf dir="compiled" outfile="compiled/uninstall/${component}.uninstall">
     383        <!-- the PatternSet To File task takes one or more patternsets and outputs to a file all of the files it includes -->
     384        <pstf dir="compiled" outfile="compiled/uninstall/${component}.uninstall" toplevelonly="true">
    384385            <patternset refid="greenstone${version.major}.${component}.component"/>
    385386        </pstf>
  • main/trunk/release-kits/shared/core/uninstaller/Uninstall.bat

    r23210 r23242  
    5151    del Uninstall.*
    5252    del *.uninstall
    53     del ..\bin
    54     del ..\tmp
    55     del ..\ext
     53    rmdir /S /Q ..\bin
     54    rmdir /S /Q ..\tmp
     55    rmdir /S /Q ..\ext
     56    rmdir /S /Q ..\uninstall
    5657   
    5758    cd ..
  • main/trunk/release-kits/shared/core/uninstaller/Uninstaller.java

    r23210 r23242  
    443443        for ( int i=0; i < files.length; i++) {
    444444            if( files[i].getAbsolutePath().endsWith(".uninstall") ) {
    445                 String[] paths = getRelevantPathsFromUninstallFile(files[i]);
     445                String[] paths = getPathsFromUninstallFile(files[i]);
    446446               
    447447                for(int j=0; j < paths.length; j++) {
     
    481481        return (String[]) paths.toArray(new String[0]);
    482482    }
     483   
     484    public String[] getPathsFromUninstallFile ( File uninstallFile ) {
     485       
     486        ArrayList paths = new ArrayList();
     487        try {
     488            BufferedReader in = new BufferedReader(new FileReader(uninstallFile));
     489           
     490            String line;
     491            while ( (line = in.readLine()) != null ) {
     492                if (line.length() > 0 && !paths.contains(line)) {
     493                    paths.add(line);
     494                }
     495            }
     496           
     497            in.close();
     498        }
     499        catch( Exception ex ) {
     500            ex.printStackTrace();
     501            return null;
     502        }
     503        return (String[]) paths.toArray(new String[0]);
     504    }
    483505
    484506    public void recursiveDelete( File f, File[] exceptions ) throws CancelledException {
Note: See TracChangeset for help on using the changeset viewer.