diff U3 wpkg-0.9-test2\wpkg.js wpkg-0.9-test2-gok\wpkg.js
--- wpkg-0.9-test2\wpkg.js	Sun Jul 03 19:57:03 2005
+++ wpkg-0.9-test2-gok\wpkg.js	Thu Jul 07 21:56:37 2005
@@ -480,15 +480,23 @@
         
         // search for the installed package in available packages
         var found = false;
+        var toBeRemovedPackage = null;
         for (j in packageArray) {
             if (debug) { info("testing available package: " + packageArray[j].getAttribute("id")); }
 
+// changes: package with missing "revision" is considered to be removed (->using global settings!)
 
             if (packageArray[j].getAttribute("id") ==
                 installedPackageNode.getAttribute("id")) {
-                if (debug) { info("package: " + installedPackageNode.getAttribute("id") + " found in available packages."); }
-
-                found = true;
+// now we must check, wether there is a "revision" tag or not
+                if (packageArray[j].getAttribute("revision") != null) {
+                    if (debug) { info("package: " + installedPackageNode.getAttribute("id") + " found in available packages."); }
+                    found = true;
+                } else {
+                    if (debug) { info("package: " + installedPackageNode.getAttribute("id") + " found to be removed."); }
+                    toBeRemovedPackage = packageArray[j];
+                    found = false;
+                }
                 break;
             }
         }
@@ -498,7 +506,7 @@
             if (debug) { info("removing package: " + installedPackageNode.getAttribute("id")); }
 
             notifyUserStart();
-            removePackage(installedPackageNode);
+            removePackage(installedPackageNode,toBeRemovedPackage);
         }
     }
     
@@ -558,6 +566,8 @@
         var installedPackage = settings.selectSingleNode("package[@id='" +
             packageId + "']");
             
+// additionally check and skip for not existing packageRev just to be sure
+    if (packageRev != null) {
         if (executeAttr == "once") {
             if (null == installedPackage) {
                 try {
@@ -592,6 +602,11 @@
                 }
             }
         }
+
+// end of skipping with "revision=null"
+    } else {
+        if (debug) { info("skipping because of \"revision\" is null");}
+    }
     }
     
     // if we had previously warned the user about an impending installation, let
@@ -722,6 +737,11 @@
         info("Package " + name + " not found!");
         return;
     }
+//added: revision=null
+    if (node.getAttribute("revision") == null) {
+        info("Package " + name + " not installable! (declared as removed)");
+        return;
+    }
 
     var executeAttr = node.getAttribute("execute");
     if (executeAttr == "once") {
@@ -748,6 +768,11 @@
         info("New package " + name + " not found!");
         return;
     }
+//added: revision=null
+    if (nodeNew.getAttribute("revision") == null) {
+        info("New package " + name + " not found! (declared as removed)");
+        return;
+    }
 
     var executeAttr = nodeNew.getAttribute("execute");
     if (executeAttr != "once") {
@@ -767,7 +792,13 @@
         return;
     }
     
-    removePackage(node);
+//added: revision=null (THIS SHOULD NEVER HAPPEN but who knows?)
+    if (node.getAttribute("revision") == null) {
+        info("Package " + name + " not currently installed.");
+        return;
+    }
+    var packagesNode = packages.selectSingleNode("package[@id='" + name + "']");
+    removePackage(node,packagesNode);
 }
 
 
@@ -1225,7 +1256,6 @@
         }
     }
 
-
     if (!checkInstalled(newPackageNode)) {
 
         if (!checkInstalled(oldPackageNode)) {
@@ -1256,14 +1286,26 @@
 /**
  * Removes the specified package node from the system.
  */
-function removePackage(packageNode) {
+function removePackage(settingsNode,packagesNode) {
     var  failure = false;
+    var rebootAfterAction = false;
 
-    var packageName = packageNode.getAttribute("name");
-    info("Removing " + packageName + "...");
+    var xPackageName = settingsNode.getAttribute("name");
+    info("Removing " + xPackageName + "...");
     
     // select command lines to remove
-    var cmds = packageNode.selectNodes("remove");
+
+    // try to get the uninstall-information from server before using
+    // client-based uninstall-cmd's
+    if (packagesNode != null) {
+        var cmds = packagesNode.selectNodes("remove");
+        rebootAfterAction = packagesNode.getAttribute("reboot");
+        var nodeToBeCheckedFor = packagesNode;
+    } else {
+        var cmds = settingsNode.selectNodes("remove");
+        rebootAfterAction = settingsNode.getAttribute("reboot");
+        var nodeToBeCheckedFor = settingsNode;
+    }
     
     // execute each command line
     for (i = 0; i < cmds.length; i++) {
@@ -1294,7 +1336,7 @@
                 
             // if found, command was successful
             if (exitNode != null) {
-                info("Command in removal of " + packageName + " returned " +
+                info("Command in removal of " + xPackageName + " returned " +
                     "non-zero exit code [" + result + "]. This exit code " +
                     "is not an error.");
                 continue;
@@ -1304,13 +1346,13 @@
             if (exitNode != null) {
                 if (exitNode.getAttribute("reboot") = "true") {
                     // this exit code forces a reboot
-                    info("Command in removal of " + packageName + " returned " +
+                    info("Command in removal of " + xPackageName + " returned " +
                         "non-zero exit code [" + result + "]. This exit code " +
                         "is not an error.");
                     reboot();
                 } else {
                     // this exit code is successful
-                    info("Command in removal of " + packageName + " returned " +
+                    info("Command in removal of " + xPackageName + " returned " +
                         "non-zero exit code [" + result + "]. This exit code " +
                         "requires an immediate reboot.");
                     continue;
@@ -1330,9 +1372,11 @@
     }
     
 
-    if (!checkInstalled(packageNode)) {
+    if (!checkInstalled(nodeToBeCheckedFor)) {
         // remove package node from local xml
-        settings.removeChild(packageNode);
+
+        // careful with the Node to remove (must be from correct XML File)
+        settings.removeChild(settingsNode);
         saveXml(settings, settings_file);
     } else {
         failure = true;
@@ -1344,14 +1388,14 @@
     
     // log a nice informational message
     if (!failure) {
-        info("Removal of " + packageNode.getAttribute("name") + " successful.");
+        info("Removal of " + xPackageName + " successful.");
     } else {
-        info("Errors occurred while removing " + packageName + ". ");
+        info("Errors occurred while removing " + xPackageName + ". ");
         return;
     }
     
     // reboot the system if this package is suppose to
-    if (packageNode.getAttribute("reboot") == "true") {
+    if (rebootAfterAction) {
         reboot();
     }
 }
@@ -1822,6 +1866,10 @@
  * Reboots the system.
  */
 function reboot() {
+    if (dryrun) {
+        if (debug) { info("simulating reboot!"); }
+        exit(0);
+    }
     var wmi = GetObject("winmgmts:{(Shutdown)}//./root/cimv2");
     var win = wmi.ExecQuery("select * from Win32_OperatingSystem where Primary=true");
     var e = new Enumerator(win);
