public UpgradePlanSet(ResData rdata, int sysVersion)
{
	this.sysVersion = sysVersion;
	outer : for (RtResKey rk : rdata.relevant) {
System.out.println("Considering upgrade of rk = " + rk);
		int reqVersion = rk.res.getRequiredVersion(sysVersion);
		
		// Look at all existing versions, from highest number to lowest.
		UpgradePlan uplan = null;
		for (int i=rk.availVersions.size()-1; i >= 0; --i) {
			RtVers vers = rk.availVersions.get(i);
			// See if required version is already available
			if (vers.version == reqVersion) {
				upToDate.add(rk);
				continue outer;
			}
			
			// See if we can make required version from this version
			uplan = rk.getUpgradePlan(vers.version, reqVersion);
			if (uplan != null) {
				uplans.add(uplan);
				continue outer;
			}
		}
		
		if (rk.availVersions.size() > 0) {
			// A previous version exists, but we cannot upgrade.
			// Throw in right bin.
			if (!rk.res.isRequired()) {
				optNotUpgradeable.add(rk);
			} else {
				reqNotUpgradeable.add(rk);
			}
		} else {
			// No previous version exists.
			// For required resources, see if we can create it.
			if (rk.res.isRequired()) {
				// See if we can create required version
				uplan = rk.getCreatorPlan(reqVersion);
				if (uplan != null) {
					uplans.add(uplan);
					continue outer;
				} else {
					// Required resource but cannot create --- system error.
					reqCannotCreate.add(rk);
				}
			} else {
				// Resource is optional and does not exist ----
				// that's entirely OK!
			}
		}
	}
}