Index: /main/trunk/ant-tasks/src/org/greenstone/anttasks/PatternSetToFile.java
===================================================================
--- /main/trunk/ant-tasks/src/org/greenstone/anttasks/PatternSetToFile.java	(revision 23210)
+++ /main/trunk/ant-tasks/src/org/greenstone/anttasks/PatternSetToFile.java	(revision 23210)
@@ -0,0 +1,79 @@
+package org.greenstone.anttasks;
+
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileWriter;
+import java.util.ArrayList;
+
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.DirectoryScanner;
+import org.apache.tools.ant.Task;
+import org.apache.tools.ant.types.FileSet;
+import org.apache.tools.ant.types.PatternSet;
+
+/**
+ * PatternSetToFile is an Ant task used to take an Ant PatternSet and output to a
+ * file all the files that it encompasses
+ * @author sjm84
+ */
+public class PatternSetToFile extends Task
+{
+	//The file the set will be written to
+	public File _outfile = null;
+
+	//The directory to check the PatternSet within
+	public File _dir = null;
+	
+	//An array of the child PatternSets of this task
+	public ArrayList<PatternSet> _sets = new ArrayList<PatternSet>();
+
+	/**
+	 * This function performs the main task
+	 */
+	public void execute() throws BuildException
+	{
+		try
+		{
+			System.out.println("Creating " + _outfile.getAbsolutePath());
+			BufferedWriter out = new BufferedWriter(new FileWriter(_outfile));
+			for(PatternSet set : _sets)
+			{
+				FileSet fs = new FileSet();
+				fs.setDir(_dir);
+				PatternSet ps = fs.createPatternSet();
+				ps.append(set, this.getProject());
+				
+				DirectoryScanner ds = fs.getDirectoryScanner(this.getProject());
+				for (String s : ds.getIncludedFiles())
+				{
+					out.write(s + "\n");
+				}
+			}
+			out.close();
+		}
+		catch(Exception ex)
+		{
+			ex.printStackTrace();
+		}
+	}
+	
+	public void setOutfile(File outfile)
+	{
+		_outfile = outfile;
+	}
+	
+	public void setDir(File dir)
+	{
+		_dir = dir;
+	}
+	
+	public void addConfiguredPatternset(PatternSet patternset) 
+	{
+		if (patternset == null || !(patternset instanceof PatternSet))
+		{
+			return;
+		}
+		
+		_sets.add((PatternSet) patternset);
+	}
+}
Index: /main/trunk/release-kits/kits/rk2/ant-scripts/create-components.xml
===================================================================
--- /main/trunk/release-kits/kits/rk2/ant-scripts/create-components.xml	(revision 23209)
+++ /main/trunk/release-kits/kits/rk2/ant-scripts/create-components.xml	(revision 23210)
@@ -3,7 +3,4 @@
 
 	<target name="create-components" depends="init,gs2-init">
-
-		<!-- core  -->
-		<antcall target="create-component"><param name="component" value="core"/></antcall>
 
 		<!-- imagemagick -->
@@ -18,4 +15,7 @@
 			<antcall target="create-component"><param name="component" value="ghostscript"/></antcall>
 		</if>
+		
+		<!-- core  -->
+		<antcall target="create-component"><param name="component" value="core"/></antcall>
 
 	</target>
Index: /main/trunk/release-kits/shared/core/ant-scripts/shared.xml
===================================================================
--- /main/trunk/release-kits/shared/core/ant-scripts/shared.xml	(revision 23209)
+++ /main/trunk/release-kits/shared/core/ant-scripts/shared.xml	(revision 23210)
@@ -86,4 +86,5 @@
 		<typedef name="rsr" classname="org.greenstone.anttasks.RegexSearchReplace" classpathref="project.classpath"/>
 		<typedef name="dcff" classname="org.greenstone.anttasks.DeleteChunkFromFile" classpathref="project.classpath"/>
+		<typedef name="pstf" classname="org.greenstone.anttasks.PatternSetToFile" classpathref="project.classpath"/>
 		<typedef name="rsplit" classname="org.greenstone.anttasks.SplitResource" classpathref="project.classpath"/>
 		<typedef name="get-property-value" classname="org.greenstone.anttasks.GetPropertyValue" classpathref="project.classpath"/>
@@ -238,5 +239,6 @@
 		<!-- create working build directory -->
 		<mkdir dir="compiled/uninstaller/build/resources" />
-
+		<mkdir dir="compiled/uninstall"/>
+		
 		<!-- copile to build -->
 		<javac
@@ -252,5 +254,5 @@
 		<!-- jar it all up -->
 		<jar
-			destfile="compiled/uninst.jar"
+			destfile="compiled/uninstall/uninst.jar"
 			manifest="${rk.home}/shared/core/uninstaller/manifest.mf"
 			basedir="compiled/uninstaller/build" />
@@ -260,5 +262,5 @@
 
 		<!-- put the associated script in place -->
-		<copy file="${rk.home}/shared/core/uninstaller/Uninstall.${os.script.format}" todir="compiled"/>
+		<copy file="${rk.home}/shared/core/uninstaller/Uninstall.${os.script.format}" todir="compiled/uninstall"/>
 
 	</target>
@@ -377,14 +379,18 @@
 	<!-- target to archive and compress a given component -->
 	<target name="create-component">
-	  <mkdir dir="components"/>
+		<mkdir dir="components"/>
 	  
-	  <zip destfile="components/${component}.comp" compress="false">
-	    <zipfileset dir="compiled">
-	      <patternset refid="greenstone${version.major}.${component}.component"/>
-	    </zipfileset>
-	  </zip>
+		<pstf dir="compiled" outfile="compiled/uninstall/${component}.uninstall">
+			<patternset refid="greenstone${version.major}.${component}.component"/>
+		</pstf>
+	  
+		<zip destfile="components/${component}.comp" compress="false">
+			<zipfileset dir="compiled">
+				<patternset refid="greenstone${version.major}.${component}.component"/>
+			</zipfileset>
+		</zip>
 	
-	  <!-- windows -->
-	  <if><bool><equals arg1="${rk.os}" arg2="windows"/></bool>
+		<!-- windows -->
+		<if><bool><equals arg1="${rk.os}" arg2="windows"/></bool>
 	    <exec executable="${rk.home}/shared/windows/7za/7za.exe" dir="components"><arg line="a -t7z -mx=9 ${component}.lzma ${component}.comp"/></exec>
 	    
Index: /main/trunk/release-kits/shared/core/uninstaller/Uninstall.bat
===================================================================
--- /main/trunk/release-kits/shared/core/uninstaller/Uninstall.bat	(revision 23209)
+++ /main/trunk/release-kits/shared/core/uninstaller/Uninstall.bat	(revision 23210)
@@ -10,5 +10,5 @@
 	echo The uninstaller cannot write to the Greenstone directory (%CD%)
 	echo Requesting elevated status to become admin user to continue.
-	bin\windows\gstart.exe %0 Elevated %1 %2 %3 %4 %5 %6 %7 %8 %9
+	..\bin\windows\gstart.exe %0 Elevated %1 %2 %3 %4 %5 %6 %7 %8 %9
     goto done
 	
@@ -28,21 +28,21 @@
 	if "%1" == "Elevated" shift
 
-if exist .\bin\windows\search4j.exe .\bin\windows\search4j.exe -p .\packages\jre -l .\uninst.jar
+if exist ..\bin\windows\search4j.exe ..\bin\windows\search4j.exe -p ..\packages\jre -l .\uninst.jar
 
-if exist .\gs2build\bin\windows\search4j.exe .\gs2build\bin\windows\search4j.exe -p .\packages\jre -l .\uninst.jar
+if exist ..\gs2build\bin\windows\search4j.exe ..\gs2build\bin\windows\search4j.exe -p ..\packages\jre -l .\uninst.jar
 
 
 if exist uninst.flag (
 
-	rd /s /q .\packages\jre
-	rmdir packages
+	rd /s /q ..\packages\jre
+	rmdir ..\packages
 	
-	if exist .\bin\windows\search4j.exe (
-		del .\bin\windows\search4j.exe
-		rmdir bin\windows
+	if exist ..\bin\windows\search4j.exe (
+		del ..\bin\windows\search4j.exe
+		rmdir ..\bin\windows
 	)
-	if exist .\gs2build\bin\windows\search4j.exe (
-		del .\gs2build\bin\windows\search4j.exe
-		rd /s /q gs2build
+	if exist ..\gs2build\bin\windows\search4j.exe (
+		del ..\gs2build\bin\windows\search4j.exe
+		rd /s /q ..\gs2build
 	)
 		
@@ -50,5 +50,10 @@
 	del uninst.flag
 	del Uninstall.*
+	del *.uninstall
+	del ..\bin
+	del ..\tmp
+	del ..\ext
 	
+	cd ..
 	if NOT EXIST *.* (
 		set GSDEL=%CD%
Index: /main/trunk/release-kits/shared/core/uninstaller/Uninstall.sh
===================================================================
--- /main/trunk/release-kits/shared/core/uninstaller/Uninstall.sh	(revision 23209)
+++ /main/trunk/release-kits/shared/core/uninstaller/Uninstall.sh	(revision 23210)
@@ -1,11 +1,11 @@
-if [ -f "setup.bash" ]; then
+if [ -f "../setup.bash" ]; then
 	#This is Greenstone 2
-	. ./setup.bash > /dev/null
+	. ../setup.bash > /dev/null
 	SEARCH4J_EXECUTABLE=$GSDLHOME/bin/$GSDLOS/search4j
 
-elif [ -f "gs2build/setup.bash" ]; then
+elif [ -f "../gs2build/setup.bash" ]; then
 	#This is Greenstone 3
-	. ./gs2build/setup.bash > /dev/null
-	SEARCH4J_EXECUTABLE=./bin/search4j
+	. ../gs2build/setup.bash > /dev/null
+	SEARCH4J_EXECUTABLE=../bin/search4j
 
 else
@@ -16,5 +16,5 @@
 
 if [ $GSDLOS = linux ]; then
-	"$SEARCH4J_EXECUTABLE" -p ./packages/jre -l ./uninst.jar
+	"$SEARCH4J_EXECUTABLE" -p ../packages/jre -l ./uninst.jar
 elif [ $GSDLOS = darwin ]; then
 	"$SEARCH4J_EXECUTABLE" -p /System/Library/Frameworks/JavaVM.framework/Home -l ./uninst.jar
@@ -23,8 +23,8 @@
 if [ -e "uninst.flag" ]; then
 
-	rm -rf packages/jre &> /dev/null
-	rmdir packages &> /dev/null
+	rm -rf ../packages/jre &> /dev/null
+	rmdir ../packages &> /dev/null
 	
-	rm -rf bin &> /dev/null
+	rm -rf ../bin &> /dev/null
 		
 	rm uninst.jar &> /dev/null
@@ -32,4 +32,5 @@
 	rm Uninstall.* &> /dev/null
 	
+	cd ..
 	CONTENTS=`ls`
 	if [ -z "$CONTENTS" ]; then
Index: /main/trunk/release-kits/shared/core/uninstaller/Uninstaller.java
===================================================================
--- /main/trunk/release-kits/shared/core/uninstaller/Uninstaller.java	(revision 23209)
+++ /main/trunk/release-kits/shared/core/uninstaller/Uninstaller.java	(revision 23210)
@@ -44,6 +44,6 @@
 	public static final ResourceBundle bundle = ResourceBundle.getBundle("resources.LanguagePack");
 
-	public static final File gs2InstallProps = new File("etc/installation.properties");
-	public static final File gs3InstallProps = new File("installation.properties");
+	public static final File gs2InstallProps = new File("../etc/installation.properties");
+	public static final File gs3InstallProps = new File("../installation.properties");
 
 	boolean keepCollections = true;
@@ -335,19 +335,17 @@
 
 			//never delete the things we are currently running
-			exceptions.add( new File("bin/search4j.exe") );
-			exceptions.add( new File("bin/search4j") );
-
-			exceptions.add( new File("bin/windows/search4j.exe") );
-			exceptions.add( new File("bin/linux/search4j") );
-			exceptions.add( new File("bin/darwin/search4j") );
-
-			exceptions.add( new File("packages/jre") );
-			exceptions.add( new File("uninst.jar") );
-			exceptions.add( new File("Uninstall.bat") );
-			exceptions.add( new File("Uninstall.sh") );
+			exceptions.add( new File("../bin/search4j.exe") );
+			exceptions.add( new File("../bin/search4j") );
+
+			exceptions.add( new File("../bin/windows/search4j.exe") );
+			exceptions.add( new File("../bin/linux/search4j") );
+			exceptions.add( new File("../bin/darwin/search4j") );
+
+			exceptions.add( new File("../packages/jre") );
+			exceptions.add( new File("../uninstall") );
 
 			if ( keepCollections ) {
-				exceptions.add( new File("web/sites/localsite/collect") );
-				exceptions.add( new File("collect") );
+				exceptions.add( new File("../web/sites/localsite/collect") );
+				exceptions.add( new File("../collect") );
 			}
 
@@ -366,5 +364,6 @@
 			}
 			
-			recursiveDelete( cd , ex );
+			//recursiveDelete( cd , ex );
+			selectiveDelete ( cd, ex );
 		} catch ( CancelledException ce ) {
 			log( bundle.getString("uninstaller.cancelled") + "\n" );
@@ -436,4 +435,49 @@
 		return null;
 
+	}
+	
+	public void selectiveDelete( File f, File[] exceptions ) throws CancelledException {
+		
+		File[] files = (new File(".")).listFiles();
+		
+		for ( int i=0; i < files.length; i++) {
+			if( files[i].getAbsolutePath().endsWith(".uninstall") ) {
+				String[] paths = getRelevantPathsFromUninstallFile(files[i]);
+				
+				for(int j=0; j < paths.length; j++) {
+					recursiveDelete( new File(".." + File.separator + paths[j]), exceptions );
+				}
+			}
+		}
+	}
+	
+	public String[] getRelevantPathsFromUninstallFile ( File uninstallFile ) {
+		
+		ArrayList paths = new ArrayList();
+		try {
+			BufferedReader in = new BufferedReader(new FileReader(uninstallFile));
+			
+			String line;
+			while ( (line = in.readLine()) != null ) {
+				int separatorIndex = line.indexOf(File.separator);
+				
+				if ( separatorIndex == -1 && line.length() > 0 && !paths.contains(line)) {
+					paths.add(line);
+				}
+				else if ( separatorIndex > -1 && line.length() > 0) {
+					String path = line.substring(0, separatorIndex);
+					if ( !paths.contains(path) ) {
+						paths.add(path);
+					}
+				}
+			}
+			
+			in.close();
+		}
+		catch( Exception ex ) {
+			ex.printStackTrace();
+			return null;
+		}
+		return (String[]) paths.toArray(new String[0]);
 	}
 
