How to update a package?

Antworten
bobzbobz
Beiträge: 169
Registriert: 30 Nov 2012, 10:41
Wohnort: Denmark

How to update a package?

Beitrag von bobzbobz »

Hi

What is the proper way to update a package, if a new version of the program is available?

Example:

Now we use Fsecure v. 9.32.
When 9.33 is released, how do i update the package so that all clients who have fsecure installed will auto-update?
bobzbobz
Beiträge: 169
Registriert: 30 Nov 2012, 10:41
Wohnort: Denmark

Re: How to update a package?

Beitrag von bobzbobz »

Do you know what i mean?

If i have a program - Fsecure Client 9.32 with the control-file below:

Code: Alles auswählen

[Package]
version: 1
depends: 
incremental: False

[Product]
type: localboot
id: fsecureclient
name: F-Secure Client Version
description: Antivirus
advice: 
version: 9.32
priority: 0
licenseRequired: False
productClasses: 
setupScript: setup32.ins
uninstallScript: uninstall32.ins
updateScript: 
alwaysScript: 
onceScript: 
customScript: 
userLoginScript: 
The installer is called "fsecureclient.exe" and my current productfile is called "fsecureclient_9.32-1.opsi".



But then lets say that F-Secure releases version 9.33 - what do i do now?
Do i simply replace the installer, edit the control file to display 9.33 and then run "opsi-makeproductfile" and then "opsi-package-manager -i fsecureclient_9.33-1.opsi".
Will this replace the "fsecureclient" package in opsi-configed, or cause a conflict?

If this is the correct way - will the PC's then recognize that their current installed version of fsecureclient is out-of-date and autoupdate on next reboot? or do i have to do this manually? or is it done by a update-script?

Best Regards,
Soren
aellert
Beiträge: 37
Registriert: 16 Mai 2012, 11:30

Re: How to update a package?

Beitrag von aellert »

Hi,

You're right when you says :
edit the control file to display 9.33 and then run "opsi-makeproductfile" and then "opsi-package-manager -i fsecureclient_9.33-1.opsi"
Note that this will replace the existing 9.32 version with 9.33.
When you will deploy a new opsi client, 9.33 will be installed.
For you existing clients with 9.32 installed, you need to trigger the action "Setup" on each one.
Warning : you need to manage the upgrade process from 9.32 to 9.33 in your packaging script. for exemple, you probably need to uninstall old version and then do the install of the new version.
If you want to trigger action "Setup" on all opsi clients that have this package already install (in other terms upgrade them all), then add the option -S with opsi-package-manager :

Code: Alles auswählen

opsi-package-manager -S -i fsecureclient_9.33-1.opsi
bobzbobz
Beiträge: 169
Registriert: 30 Nov 2012, 10:41
Wohnort: Denmark

Re: How to update a package?

Beitrag von bobzbobz »

Hi

Thank you for your answer :)

Then i guess the solution for a .msi-package would be to add MsiID for all previous versions, and then run the command

Code: Alles auswählen

opsi-package-manager -S -i <productfile>
aellert
Beiträge: 37
Registriert: 16 Mai 2012, 11:30

Re: How to update a package?

Beitrag von aellert »

Most of the time, you don't need to uninstall the old .msi because when you install the new .msi, it will automatically uninstall the previous version.
But, if the vendor didn't implement this correctly inside his .msi, this will fail...
To handle this situation, I have a hack to uninstall the .msi which is really installed on the client. If the real version is not found, then fallback to install new msiid (hoping it will uninstall previous version) :

1. In the setup.ins script, define new variables Old_MsiD and OpsiIni :

Code: Alles auswählen

DefVar $old_MsiId$
DefVar $OpsiIni$
Set $OpsiIni$         = $InstallDir$ + "\opsi.ini"
Set $old_MsiId$       = GetValueFromInifile($OpsiIni$,"version","msiid","")
2. add a Patches section after Winbatch_install section :

Code: Alles auswählen

comment "Create/update opsi.ini"
Patches_majversion $InstallDir$+"\opsi.ini"
Put this content on Patches_majversion section :

Code: Alles auswählen

[Patches_majversion]
set [version] msiid=$MsiId$
This will create or update an opsi.ini file in the install directory which will contains the msiID. The opsi.ini file looks like this :

Code: Alles auswählen

[version]
msiid={xxxx-xxxxx-xxxx-xxxx}
3. In the uninstall.ins script, look if opsi.ini exists and if the corresponding registry key match then msiid found in opsi.ini. If that matches, then invokes Winbatch_uninstall_oldmsi else use Winbatch_uninstall_msi :

Code: Alles auswählen

if FileExists($OpsiIni$) and not (GetRegistryStringValue32("[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\" + $old_MsiId$ + "] DisplayName") = "")
	comment "old MSI id " + $old_MsiId$ + " found in registry, starting msiexec to uninstall"
	Winbatch_uninstall_oldmsi
	sub_check_exitcode
else
	if not (GetRegistryStringValue32("[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\" + $MsiId$ + "] DisplayName") = "")
		comment "MSI id " + $MsiId$ + " found in registry, starting msiexec to uninstall"
		Winbatch_uninstall_msi
		sub_check_exitcode
	endif
endif
bobzbobz
Beiträge: 169
Registriert: 30 Nov 2012, 10:41
Wohnort: Denmark

Re: How to update a package?

Beitrag von bobzbobz »

Thanks - i will try this :)
bobzbobz
Beiträge: 169
Registriert: 30 Nov 2012, 10:41
Wohnort: Denmark

Re: How to update a package?

Beitrag von bobzbobz »

If i use this hack, then i will need to define MsiId in the setup-script and the uninstall-script in stead of the delsub-script, right?
Benutzeravatar
SisterOfMercy
Beiträge: 1524
Registriert: 22 Jun 2012, 19:18

Re: How to update a package?

Beitrag von SisterOfMercy »

aellert hat geschrieben:Warning : you need to manage the upgrade process from 9.32 to 9.33 in your packaging script. for example, you probably need to uninstall old version and then do the install of the new version.
Isn't opsi using the uninstall script of the version that has to be uninstalled? Or is this only done when you uninstall the package first before installing the newer version?
Bitte schreiben Sie Deutsch, when I'm responding in the German-speaking part of the forum!
aellert
Beiträge: 37
Registriert: 16 Mai 2012, 11:30

Re: How to update a package?

Beitrag von aellert »

@bobzbobz
If i use this hack, then i will need to define MsiId in the setup-script and the uninstall-script in stead of the delsub-script, right?
Yes. I use this hack only when i need it (for exemple, i have a software which need to first uninstall old msi, delete some registry key and finally install new msi. If I install directly the new msi, then it fail with an error)

@SisterOfMercy
Isn't opsi using the uninstall script of the version that has to be uninstalled? Or is this only done when you uninstall the package first before installing the newer version?
If you make your package from template provided with opsi (by default in directory /opt/pcbin/install/opsi-template), then the answer is yes. When you trigger action "setup", it will first check if uninstall script is present and then launch uninstall before install script.
Antworten