PDA

View Full Version : [InstallScript] Issue with manual upgrade



DemonPiggies
11-22-2013, 04:58 PM
I'll try and get right to the point here...

I was tasked with creating an installer that would uninstall the previous installation and install the current one. I did this and everything seemed ok at least for 4 different releases. Someone decided to change the entire directory structure we shared and had to sort of redo the installer.

Over half the Features and Components were removed and consolidated into 2 different parent Features. Since doing this my entire installation is now broken. I've gotten to a point where the new files appear BUT when I go to uninstall the application I get an error and the in the list of installed applications is refreshed and my application is gone. So I know I may have messed things up and I don't know how to fix this. I've tried to comment on everything and I could use all the help I can get. Also does reusing Features and Components cause issues like I've described?


When the application has been installed we go right into the ELSE and call VersionComparison() which determines the flow. When the installed application is older than the installer then we call into PerformActualUninstall()...


function OnMaintUIBefore()

begin

//--- Coming from the Add/Remove dialog?
if (ADDREMOVE) then

PerformAddRemoveDialogLogic();

//--- Are we uninstalling?
elseif (DetermineIfUninstall()) then

//--- Find out if we CAN unistall and fall thru to OnMoveData()
if (!DetermineIfCanUninstall()) then

//--- Warning user that they cannot uninstall
if (!DetermineIfRunningSilent()) then
MessageBox(@IDS_UNINSTALLATION_WARNING, SEVERE);
endif;

//--- And either way exit out without doing anything
abort;

endif;

else

//--- For all other instances
VersionComparison();

endif;

end;



... Here I try and uninstall the previous installation. This section was copied directly from the OnMoveData()'s stock code. After this is performed we end up at the very end of OnMaintUIBefore which will then fall into OnMoveData()...



function BOOL PerformActualUninstall()
NUMBER nErrorReturnCode;
STRING sFormattedMsg;

begin

//--- Hide any dialog currently showing
Disable( DIALOGCACHE );

//--- If we are not doing a COMPLETE uninstall...
if(DetermineIfUpgrade() || DetermineIfRevert()) then
//--- Remove all installed features that were installed before
nErrorReturnCode = FeatureRemoveAllInLogOnly();
else
//--- Remove all installed features and 'media'
nErrorReturnCode = FeatureRemoveAllInMediaAndLog();
endif;

//--- Make sure that everything was fine
if (nErrorReturnCode < ISERR_SUCCESS) then
MessageBoxEx(FormatMessage(nErrorReturnCode), @IDS_QUICKLABEL_SYSTEMS, SEVERE);
return FALSE;
endif;

//--- If we are running silent then do not show the uninstallation dialog
if (!DetermineIfRunningSilent()) then

//--- Set appropriate StatusEx static text.
Sprintf(sFormattedMsg, @IDS_STATICTEXT_MAINTUI_REMOVEALL, @IDS_READABLE_VERSION_STRING);
SetStatusExStaticText(sFormattedMsg);

SetStatusWindow( 0, "" );
Enable( STATUSEX );
StatusUpdate( ON, 100 );
Disable( CANCELBUTTON );
else
Disable( STATUSEX );
endif;

// ...uninstalls features appropriately based on their selection state and whether
// they are currently installed.
nErrorReturnCode = FeatureTransferData(MEDIA);

//--- Check for error and report it
if (nErrorReturnCode < ISERR_SUCCESS) then
ComponentErrorInfo();
return FALSE;
endif;

//--- Delete the key we made during installation
RemoveMediaKey();

//--- Delete the custom config file if user wants
KeepOriginalSettings();

//--- Hide the progress dialog if we aren't running silent
if (!DetermineIfRunningSilent()) then
Disable( STATUSEX );
endif;

//--- Everything went fine
return TRUE;

end;



...And here I determine the how I will install the current version. Here is where the breakdown is, I believe. I have changed the Upgrade section and now my files appear but the installation is severly wrecked.



function OnMoveData()
NUMBER nResult;
NUMBER nMediaFlags;
STRING sFormattedMsg;

begin

//--- If we are reinstalling...
if (DetermineIfReinstall()) then

//--- Set the installation directory to the %ALLUSERSPROFILE%
TARGETDIR = GetCurrentTargetDirectory();

FeatureReinstall();

//--- Set appropriate StatusEx static text.
Sprintf(sFormattedMsg, @IDS_STATICTEXT_MAINTUI_REINSTALL, @IDS_READABLE_VERSION_STRING);
SetStatusExStaticText(sFormattedMsg);

//--- If we are updating...
elseif (DetermineIfUpgrade()) then

//--- Set the installation directory to the %ALLUSERSPROFILE%
TARGETDIR = GetCurrentTargetDirectory();

FeatureSelectNew( MEDIA, TRUE );

FeatureRemoveAllInLogOnly();

//--- Set appropriate StatusEx static text.
Sprintf(sFormattedMsg, @IDS_STATICTEXT_MAINTUI_UPGRADE, @IDS_READABLE_VERSION_STRING);
SetStatusExStaticText(sFormattedMsg);

//--- If we are reverting...
elseif (DetermineIfRevert()) then

//--- Set the installation directory to the %ALLUSERSPROFILE%
TARGETDIR = GetCurrentTargetDirectory();

FeatureReinstall();

//--- Set appropriate StatusEx static text.
Sprintf(sFormattedMsg, @IDS_STATICTEXT_MAINTUI_REVERT, @IDS_READABLE_VERSION_STRING);
SetStatusExStaticText(sFormattedMsg);

//--- If we are uninstalling...
elseif (DetermineIfUninstall()) then

//--- Make sure to abort if something bad happened else return out
if (!PerformActualUninstall()) then
abort;
else
return 0;
endif;

else

//--- Set appropriate StatusEx static text.
Sprintf(sFormattedMsg, @IDS_STATICTEXT_FIRSTUI, @IDS_READABLE_VERSION_STRING);
SetStatusExStaticText(sFormattedMsg);

endif;

// Don't install the DISK1COMPONENT if MAINT_OPTION_NONE was specified.
if( MAINT_OPTION = MAINT_OPTION_NONE ) then
FeatureSelectItem( MEDIA, DISK1COMPONENT, FALSE );
endif;

// Show Status?
if (!DetermineIfRunningSilent()) then
SetStatusWindow( 1, "" );
Enable( STATUSEX );
StatusUpdate( ON, 100 );
Disable( CANCELBUTTON );
else
// Disable Status
Disable( STATUSEX );
endif;

// Create the uninstall infomation (after displaying the progress dialog)
// Don't create uninstall information if MAINT_OPTION_NONE was specified.
//if (MAINT_OPTION != MAINT_OPTION_NONE) then
CreateInstallationInfo();
//endif;

// Move Data
nResult = FeatureTransferData( MEDIA );

// Moved in 11.0, Check for failure before creating uninstall key.
// Handle move data error and abort if error occured.
if (nResult < ISERR_SUCCESS) then
OnComponentError();
abort;
endif;

// Create uninstall key (force if upgrading or reverting because this will be skipped otherwise)
if (IFX_DISK1INSTALLED || DetermineIfUpgrade() || DetermineIfRevert()) then

// Store text-subs for maintenance mode later, only do this when
// disk 1 is installed. Note that any text-subs that are updated after
// this call will not be remembered during maintenance mode.
FeatureSaveTarget("");

// Write uninstall information.
MaintenanceStart();

// Customize Uninstall Information
OnCustomizeUninstInfo();

endif;

//--- Create reg keys
CreateMediaKey();

//--- Update Dat files
MergeOldSettings();

//--- Disable dialog if it was enabled above
if (!DetermineIfRunningSilent()) then
Disable( STATUSEX );
endif;

end;