Changeset 23210

Show
Ignore:
Timestamp:
26.10.2010 15:12:23 (9 years ago)
Author:
sjm84
Message:

The uninstaller has been modified so that it no longer will delete files or folders in the top-level directory that do not belong to Greenstone

Location:
main/trunk
Files:
1 added
5 modified

Legend:

Unmodified
Added
Removed
  • main/trunk/release-kits/kits/rk2/ant-scripts/create-components.xml

    r22325 r23210  
    33 
    44    <target name="create-components" depends="init,gs2-init"> 
    5  
    6         <!-- core  --> 
    7         <antcall target="create-component"><param name="component" value="core"/></antcall> 
    85 
    96        <!-- imagemagick --> 
     
    1815            <antcall target="create-component"><param name="component" value="ghostscript"/></antcall> 
    1916        </if> 
     17         
     18        <!-- core  --> 
     19        <antcall target="create-component"><param name="component" value="core"/></antcall> 
    2020 
    2121    </target> 
  • main/trunk/release-kits/shared/core/ant-scripts/shared.xml

    r22490 r23210  
    8686        <typedef name="rsr" classname="org.greenstone.anttasks.RegexSearchReplace" classpathref="project.classpath"/> 
    8787        <typedef name="dcff" classname="org.greenstone.anttasks.DeleteChunkFromFile" classpathref="project.classpath"/> 
     88        <typedef name="pstf" classname="org.greenstone.anttasks.PatternSetToFile" classpathref="project.classpath"/> 
    8889        <typedef name="rsplit" classname="org.greenstone.anttasks.SplitResource" classpathref="project.classpath"/> 
    8990        <typedef name="get-property-value" classname="org.greenstone.anttasks.GetPropertyValue" classpathref="project.classpath"/> 
     
    238239        <!-- create working build directory --> 
    239240        <mkdir dir="compiled/uninstaller/build/resources" /> 
    240  
     241        <mkdir dir="compiled/uninstall"/> 
     242         
    241243        <!-- copile to build --> 
    242244        <javac 
     
    252254        <!-- jar it all up --> 
    253255        <jar 
    254             destfile="compiled/uninst.jar" 
     256            destfile="compiled/uninstall/uninst.jar" 
    255257            manifest="${rk.home}/shared/core/uninstaller/manifest.mf" 
    256258            basedir="compiled/uninstaller/build" /> 
     
    260262 
    261263        <!-- put the associated script in place --> 
    262         <copy file="${rk.home}/shared/core/uninstaller/Uninstall.${os.script.format}" todir="compiled"/> 
     264        <copy file="${rk.home}/shared/core/uninstaller/Uninstall.${os.script.format}" todir="compiled/uninstall"/> 
    263265 
    264266    </target> 
     
    377379    <!-- target to archive and compress a given component --> 
    378380    <target name="create-component"> 
    379       <mkdir dir="components"/> 
     381        <mkdir dir="components"/> 
    380382       
    381       <zip destfile="components/${component}.comp" compress="false"> 
    382         <zipfileset dir="compiled"> 
    383           <patternset refid="greenstone${version.major}.${component}.component"/> 
    384         </zipfileset> 
    385       </zip> 
     383        <pstf dir="compiled" outfile="compiled/uninstall/${component}.uninstall"> 
     384            <patternset refid="greenstone${version.major}.${component}.component"/> 
     385        </pstf> 
     386       
     387        <zip destfile="components/${component}.comp" compress="false"> 
     388            <zipfileset dir="compiled"> 
     389                <patternset refid="greenstone${version.major}.${component}.component"/> 
     390            </zipfileset> 
     391        </zip> 
    386392     
    387       <!-- windows --> 
    388       <if><bool><equals arg1="${rk.os}" arg2="windows"/></bool> 
     393        <!-- windows --> 
     394        <if><bool><equals arg1="${rk.os}" arg2="windows"/></bool> 
    389395        <exec executable="${rk.home}/shared/windows/7za/7za.exe" dir="components"><arg line="a -t7z -mx=9 ${component}.lzma ${component}.comp"/></exec> 
    390396         
  • main/trunk/release-kits/shared/core/uninstaller/Uninstall.bat

    r22577 r23210  
    1010    echo The uninstaller cannot write to the Greenstone directory (%CD%) 
    1111    echo Requesting elevated status to become admin user to continue. 
    12     bin\windows\gstart.exe %0 Elevated %1 %2 %3 %4 %5 %6 %7 %8 %9 
     12    ..\bin\windows\gstart.exe %0 Elevated %1 %2 %3 %4 %5 %6 %7 %8 %9 
    1313    goto done 
    1414     
     
    2828    if "%1" == "Elevated" shift 
    2929 
    30 if exist .\bin\windows\search4j.exe .\bin\windows\search4j.exe -p .\packages\jre -l .\uninst.jar 
     30if exist ..\bin\windows\search4j.exe ..\bin\windows\search4j.exe -p ..\packages\jre -l .\uninst.jar 
    3131 
    32 if exist .\gs2build\bin\windows\search4j.exe .\gs2build\bin\windows\search4j.exe -p .\packages\jre -l .\uninst.jar 
     32if exist ..\gs2build\bin\windows\search4j.exe ..\gs2build\bin\windows\search4j.exe -p ..\packages\jre -l .\uninst.jar 
    3333 
    3434 
    3535if exist uninst.flag ( 
    3636 
    37     rd /s /q .\packages\jre 
    38     rmdir packages 
     37    rd /s /q ..\packages\jre 
     38    rmdir ..\packages 
    3939     
    40     if exist .\bin\windows\search4j.exe ( 
    41         del .\bin\windows\search4j.exe 
    42         rmdir bin\windows 
     40    if exist ..\bin\windows\search4j.exe ( 
     41        del ..\bin\windows\search4j.exe 
     42        rmdir ..\bin\windows 
    4343    ) 
    44     if exist .\gs2build\bin\windows\search4j.exe ( 
    45         del .\gs2build\bin\windows\search4j.exe 
    46         rd /s /q gs2build 
     44    if exist ..\gs2build\bin\windows\search4j.exe ( 
     45        del ..\gs2build\bin\windows\search4j.exe 
     46        rd /s /q ..\gs2build 
    4747    ) 
    4848         
     
    5050    del uninst.flag 
    5151    del Uninstall.* 
     52    del *.uninstall 
     53    del ..\bin 
     54    del ..\tmp 
     55    del ..\ext 
    5256     
     57    cd .. 
    5358    if NOT EXIST *.* ( 
    5459        set GSDEL=%CD% 
  • main/trunk/release-kits/shared/core/uninstaller/Uninstall.sh

    r17808 r23210  
    1 if [ -f "setup.bash" ]; then 
     1if [ -f "../setup.bash" ]; then 
    22    #This is Greenstone 2 
    3     . ./setup.bash > /dev/null 
     3    . ../setup.bash > /dev/null 
    44    SEARCH4J_EXECUTABLE=$GSDLHOME/bin/$GSDLOS/search4j 
    55 
    6 elif [ -f "gs2build/setup.bash" ]; then 
     6elif [ -f "../gs2build/setup.bash" ]; then 
    77    #This is Greenstone 3 
    8     . ./gs2build/setup.bash > /dev/null 
    9     SEARCH4J_EXECUTABLE=./bin/search4j 
     8    . ../gs2build/setup.bash > /dev/null 
     9    SEARCH4J_EXECUTABLE=../bin/search4j 
    1010 
    1111else 
     
    1616 
    1717if [ $GSDLOS = linux ]; then 
    18     "$SEARCH4J_EXECUTABLE" -p ./packages/jre -l ./uninst.jar 
     18    "$SEARCH4J_EXECUTABLE" -p ../packages/jre -l ./uninst.jar 
    1919elif [ $GSDLOS = darwin ]; then 
    2020    "$SEARCH4J_EXECUTABLE" -p /System/Library/Frameworks/JavaVM.framework/Home -l ./uninst.jar 
     
    2323if [ -e "uninst.flag" ]; then 
    2424 
    25     rm -rf packages/jre &> /dev/null 
    26     rmdir packages &> /dev/null 
     25    rm -rf ../packages/jre &> /dev/null 
     26    rmdir ../packages &> /dev/null 
    2727     
    28     rm -rf bin &> /dev/null 
     28    rm -rf ../bin &> /dev/null 
    2929         
    3030    rm uninst.jar &> /dev/null 
     
    3232    rm Uninstall.* &> /dev/null 
    3333     
     34    cd .. 
    3435    CONTENTS=`ls` 
    3536    if [ -z "$CONTENTS" ]; then 
  • main/trunk/release-kits/shared/core/uninstaller/Uninstaller.java

    r20648 r23210  
    4444    public static final ResourceBundle bundle = ResourceBundle.getBundle("resources.LanguagePack"); 
    4545 
    46     public static final File gs2InstallProps = new File("etc/installation.properties"); 
    47     public static final File gs3InstallProps = new File("installation.properties"); 
     46    public static final File gs2InstallProps = new File("../etc/installation.properties"); 
     47    public static final File gs3InstallProps = new File("../installation.properties"); 
    4848 
    4949    boolean keepCollections = true; 
     
    335335 
    336336            //never delete the things we are currently running 
    337             exceptions.add( new File("bin/search4j.exe") ); 
    338             exceptions.add( new File("bin/search4j") ); 
    339  
    340             exceptions.add( new File("bin/windows/search4j.exe") ); 
    341             exceptions.add( new File("bin/linux/search4j") ); 
    342             exceptions.add( new File("bin/darwin/search4j") ); 
    343  
    344             exceptions.add( new File("packages/jre") ); 
    345             exceptions.add( new File("uninst.jar") ); 
    346             exceptions.add( new File("Uninstall.bat") ); 
    347             exceptions.add( new File("Uninstall.sh") ); 
     337            exceptions.add( new File("../bin/search4j.exe") ); 
     338            exceptions.add( new File("../bin/search4j") ); 
     339 
     340            exceptions.add( new File("../bin/windows/search4j.exe") ); 
     341            exceptions.add( new File("../bin/linux/search4j") ); 
     342            exceptions.add( new File("../bin/darwin/search4j") ); 
     343 
     344            exceptions.add( new File("../packages/jre") ); 
     345            exceptions.add( new File("../uninstall") ); 
    348346 
    349347            if ( keepCollections ) { 
    350                 exceptions.add( new File("web/sites/localsite/collect") ); 
    351                 exceptions.add( new File("collect") ); 
     348                exceptions.add( new File("../web/sites/localsite/collect") ); 
     349                exceptions.add( new File("../collect") ); 
    352350            } 
    353351 
     
    366364            } 
    367365             
    368             recursiveDelete( cd , ex ); 
     366            //recursiveDelete( cd , ex ); 
     367            selectiveDelete ( cd, ex ); 
    369368        } catch ( CancelledException ce ) { 
    370369            log( bundle.getString("uninstaller.cancelled") + "\n" ); 
     
    436435        return null; 
    437436 
     437    } 
     438     
     439    public void selectiveDelete( File f, File[] exceptions ) throws CancelledException { 
     440         
     441        File[] files = (new File(".")).listFiles(); 
     442         
     443        for ( int i=0; i < files.length; i++) { 
     444            if( files[i].getAbsolutePath().endsWith(".uninstall") ) { 
     445                String[] paths = getRelevantPathsFromUninstallFile(files[i]); 
     446                 
     447                for(int j=0; j < paths.length; j++) { 
     448                    recursiveDelete( new File(".." + File.separator + paths[j]), exceptions ); 
     449                } 
     450            } 
     451        } 
     452    } 
     453     
     454    public String[] getRelevantPathsFromUninstallFile ( File uninstallFile ) { 
     455         
     456        ArrayList paths = new ArrayList(); 
     457        try { 
     458            BufferedReader in = new BufferedReader(new FileReader(uninstallFile)); 
     459             
     460            String line; 
     461            while ( (line = in.readLine()) != null ) { 
     462                int separatorIndex = line.indexOf(File.separator); 
     463                 
     464                if ( separatorIndex == -1 && line.length() > 0 && !paths.contains(line)) { 
     465                    paths.add(line); 
     466                } 
     467                else if ( separatorIndex > -1 && line.length() > 0) { 
     468                    String path = line.substring(0, separatorIndex); 
     469                    if ( !paths.contains(path) ) { 
     470                        paths.add(path); 
     471                    } 
     472                } 
     473            } 
     474             
     475            in.close(); 
     476        } 
     477        catch( Exception ex ) { 
     478            ex.printStackTrace(); 
     479            return null; 
     480        } 
     481        return (String[]) paths.toArray(new String[0]); 
    438482    } 
    439483