SetPartFrameSlot('PatchMunger,ReadStreamFile(HOME&"PatchMungerOriginal.stream"));

SetPartFrameSlot('DoNotInstall,
func()
begin
	local patchInfo, machineInfo;

/*
	patchInfo := Gestalt(kGestalt_Base + 5);
	if kPatchVersion = patchInfo.fPatch[0].fPatchVersion and
	   kPatchVersion = patchInfo.fPatch[1].fPatchVersion then
	begin
		GetRoot():Notify(3, kAppName, "This System Update is already installed on this Newton.");
		return true;
	end;
	if kPatchVersion < patchInfo.fPatch[0].fPatchVersion or
	   (kPatchVersion = patchInfo.fPatch[0].fPatchVersion and
	    kPatchVersion < patchInfo.fPatch[1].fPatchVersion) then
	begin
		GetRoot():Notify(3, kAppName, "\nThis System Update cannot be installed because it is older than the existing one in your Newton product.");
		return true;
	end;
*/
	
	machineInfo := Gestalt (kGestalt_SystemInfo);
	if machineInfo.machineType <> kMachineType or machineInfo.ROMStage <> kBaseROMStage then begin
		GetRoot():Notify(3, kAppName, "\nThis System Update can only be installed on a US MessagePad 2000 or 2100.");
		return true;
	end;

	ModalConfirm("Patch installed. Tap Ok to restart after five seconds.", [{value: nil, text: "Ok"}]);
	return nil;
end);

InstallScript := func (part, removeFrame)
begin
	if part:PatchMunger() = nil
	then AddDelayedCall(functions.Reboot, nil, 5000);
	else GetRoot():Notify(3, kAppName, "An error has occured during loading; probably out of memory.\nThe System Update was not installed.");
end;
