Hallo zusammen,
bei der Verwendung von getOutStreamFromSection('DosBatch_Funktion') in einem Sub-Skript (wie z.B. im opsi-template Paket das Skript delsub.ins) wird die sekundäre Sektion ([DosBatch_Funktion]) leider nicht gefunden, wenn sie in delsub.ins unten angehängt wurde. Erst wenn ich die Funktion ins übergeordnete Skript einbinde (im Beispiel also opsi-template.ins), wird sie gefunden und ausgeführt.
Im Moment funktioniert der Workaround zwar für mich, aber schöner wäre es natürlich wenn die Funktion auch im Sub-Skript gefunden wird, damit man die Funktion nicht in jedem übergeordneten Skript eingefügt werden muss (im Beispiel also in opsi-template.ins und delopsi-template.ins).
Gruß,
Thomas
getOutStreamFromSection in delsub.ins
Re: getOutStreamFromSection in delsub.ins
Hallo,
das gleiche Problem tritt übrigens auch auf, wenn ich in einer Sub-Sektion in der delsub.ins ein WinBatch-Skript starten will. Auch hier hilft es das WinBatch-Skript in der übergeordneten Datei, also in z.B. opsi-template.ins hinzufügen.
Gruß,
Thomas
das gleiche Problem tritt übrigens auch auf, wenn ich in einer Sub-Sektion in der delsub.ins ein WinBatch-Skript starten will. Auch hier hilft es das WinBatch-Skript in der übergeordneten Datei, also in z.B. opsi-template.ins hinzufügen.
Gruß,
Thomas
Re: getOutStreamFromSection in delsub.ins
Hallo,
hier mal das Problem aufgezeigt an einem Installationsskript für tortoiseSVN basierend auf den opsi-template Skripten. Wenn ich die Abschnitte [DosBatch_UninstKeys] und [Winbatch_uninstall] aus tortoisesvn.ins entferne, werden diese in delsub.ins nicht mehr gefunden. Aus delsub.ins kann ich sie aber ohne Probleme entfernen.
tortoisesvn.ins
delsub.ins
Gruß,
Thomas
hier mal das Problem aufgezeigt an einem Installationsskript für tortoiseSVN basierend auf den opsi-template Skripten. Wenn ich die Abschnitte [DosBatch_UninstKeys] und [Winbatch_uninstall] aus tortoisesvn.ins entferne, werden diese in delsub.ins nicht mehr gefunden. Aus delsub.ins kann ich sie aber ohne Probleme entfernen.
tortoisesvn.ins
Code: Alles auswählen
; Copyright (c) uib gmbh (www.uib.de)
; This sourcecode is owned by uib
; and published under the Terms of the General Public License.
; credits: http://www.opsi.org/credits/
[Initial]
requiredWinstVersion >= "4.8.6"
LogLevel=2
; Log Errors in Logfile but don't abort:
ExitOnError=false
; Show syntax errors in the script:
ScriptErrorMessages=on
; Dont trace step by step through the script:
TraceMode=off
; let started programs run in front of the winst window
StayOnTop=false
[Aktionen]
DefVar $TEMP$
DefVar $ProductId$
DefVar $MinimumSpace$
DefVar $NewExe$
DefVar $InstallDir$
DefVar $ExitCode$
DefVar $LicenseRequired$
DefVar $LicenseKey$
DefVar $LicensePool$
; This should be edited
set $ProductId$ = "tortoisesvn"
set $MinimumSpace$ = "50 MB"
set $InstallDir$="%ProgramFilesDir%\"+$ProductId$
set $NewExe$=$InstallDir$+"\bin\"+$ProductId$+".dll"
set $LicenseRequired$ = "false"
set $LicensePool$ = "p_" + $ProductId$
Set $TEMP$ = EnvVar("TEMP")
; Message at install time:
Message "Installing "+$ProductId$+" ..."
if not(HasMinimumSpace ("%SYSTEMDRIVE%", $MinimumSpace$))
LogError "Not enough space on %SYSTEMDRIVE%: . "+$MinimumSpace$+" on Drive %SYSTEMDRIVE%: needed for "+$ProductId$+"."
isFatalError
; stop process and set installation status to failed
else
comment "show product picture"
ShowBitmap /3 "%scriptpath%\"+$ProductId$+".png" $ProductId$
if FileExists("%ScriptPath%\delsub.ins")
comment "start uninstall sub section"
sub "%ScriptPath%\delsub.ins"
endif
;Message at install time:
Message "Installing "+$ProductId$+" ..."
comment "if license management enabled, reserve license and get license key"
if ($LicenseRequired$ = "true")
sub_get_licensekey
endif
comment "start setup program"
Winbatch_install
sub_check_exitcode
comment "test for installation success"
if not(FileExists($NewExe$))
logError "Fatal: After Installation "+$NewExe$+" not found"
isFatalError
endif
ExitWindows /Reboot
endif
[DosBatch_UninstKeys]
@echo off
; Export the Uninstall registry keys
start /wait "" REGEDIT /E %Systemdrive%\TMP\registry.tmp HKEY_LOCAL_MACHINE\SOFTWARE\microsoft\windows\currentversion\uninstall
; Filter only the {} keys that TortoiseSVN might be in
type %Systemdrive%\TMP\registry.tmp | find /i "{" | find /i "}]"
[Winbatch_uninstall]
$UninstallCommand$
[Winbatch_install]
msiexec /qb! /i "%SCRIPTPATH%\TortoiseSVN.msi" /norestart
msiexec /qb! /i "%SCRIPTPATH%\LanguagePack.msi" /norestart
[sub_get_licensekey]
if opsiLicenseManagementEnabled
comment "license management is enabled and will be used"
comment "try to to get license key"
Set $licensekey$ = demandLicenseKey ($licensepool$)
; if there is an assignment of exactly one licensepool to the product the following call is possible:
; Set $licensekey$ = demandLicenseKey ("", $ProductId$)
; if there is an assignment of a license pool to a windows software id, it is possible to use
; DefVar $windowsSoftwareId$
; $windowsSoftwareId$ = "..."
; Set $licensekey$ = demandLicenseKey ("", "", $windowsSoftwareId$)
DefVar $serviceErrorClass$
set $serviceErrorClass$ = getLastServiceErrorClass
comment "error class: " + $serviceErrorClass$
if $serviceErrorClass$ = "None"
comment "everything fine"
comment "we got the license key '" + $licensekey$ + "'"
else
if $serviceErrorClass$ = "LicenseConfigurationError"
LogError "Fatal: license configuration must be corrected"
LogError getLastServiceErrorMessage
isFatalError
else
if $serviceErrorClass$ = "LicenseMissingError"
LogError "Fatal: required license is not supplied"
isFatalError
endif
endif
endif
else
LogError "Fatal: license required, but license management not enabled"
isFatalError
endif
[sub_check_exitcode]
comment "test for installation success via exit code"
set $ExitCode$ = getLastExitCode
; informations to exit codes see
; http://msdn.microsoft.com/en-us/library/aa372835(VS.85).aspx
; http://msdn.microsoft.com/en-us/library/aa368542.aspx
if ($ExitCode$ = "0")
comment "looks good: setup program gives exitcode zero"
else
comment "Setup program gives a exitcode unequal zero: "+$ExitCode$
if ($ExitCode$ = "1605")
comment "ERROR_UNKNOWN_PRODUCT 1605 This action is only valid for products that are currently installed."
comment "Uninstall of a not installed product failed - no problem"
else
if ($ExitCode$ = "1641")
comment "looks good: setup program gives exitcode 1641"
comment "ERROR_SUCCESS_REBOOT_INITIATED 1641 The installer has initiated a restart. This message is indicative of a success."
else
if ($ExitCode$ = "3010")
comment "looks good: setup program gives exitcode 3010"
comment "ERROR_SUCCESS_REBOOT_REQUIRED 3010 A restart is required to complete the install. This message is indicative of a success."
else
logError "Fatal: Setup program gives an unknown exitcode unequal zero: "+$ExitCode$
isFatalError
endif
endif
endif
endif
Code: Alles auswählen
; Message at install time:
Message "Deinstalling "+$ProductId$+" ..."
comment "start uninstall program if exists"
DefVar $UninstallCommand$
DefVar $DisplayName$
DefVar $save$
DefVar $TempVar$
DefStringList UninstStrings
loglevel = -1
Set $save$ = "0"
Set UninstStrings = getOutStreamFromSection ('DosBatch_UninstKeys')
For $s$ in UninstStrings do Sub_Uninstall
loglevel = 2
comment "delete files"
Files_uninstall
[Sub_Uninstall]
if $save$ = "0"
Set $save$ = "1"
Set $TempVar$ = "$s$"
else
Set $save$ = "0"
Set $TempVar$ = $TempVar$+"$s$"
set $DisplayName$ = GetRegistryStringValue ($TempVar$+" DisplayName")
if takeString(0,splitStringOnWhiteSpace($DisplayName$)) = "TortoiseSVN"
Message "Found "+$DisplayName$+" => uninstalling first"
set $DisplayName$ = GetRegistryStringValue ($TempVar$+" UninstallString")
set $TempVar$ = takeString(1,splitString(takeString(0,splitString($DisplayName$,"}")),"{"))
set $UninstallCommand$ = "MsiExec.exe /x {"+$TempVar$+"} /qb! REBOOT=ReallySuppress"
Winbatch_uninstall
sub_check_exitcode
endif
endif
[DosBatch_UninstKeys]
@echo off
; Export the Uninstall registry keys
start /wait "" REGEDIT /E %Systemdrive%\TMP\registry.tmp HKEY_LOCAL_MACHINE\SOFTWARE\microsoft\windows\currentversion\uninstall
; Filter only the {} keys that TortoiseSVN might be in
type %Systemdrive%\TMP\registry.tmp | find /i "{" | find /i "}]"
[Winbatch_uninstall]
$UninstallCommand$
[Files_uninstall]
; something like (don't forget the trailing backslash)
delete -sf "$InstallDir$\"
[sub_check_exitcode]
comment "test for installation success via exit code"
set $ExitCode$ = getLastExitCode
; informations to exit codes see
; http://msdn.microsoft.com/en-us/library/aa372835(VS.85).aspx
; http://msdn.microsoft.com/en-us/library/aa368542.aspx
if ($ExitCode$ = "0")
comment "looks good: setup program gives exitcode zero"
else
comment "Setup program gives a exitcode unequal zero: "+$ExitCode$
if ($ExitCode$ = "1605")
comment "ERROR_UNKNOWN_PRODUCT 1605 This action is only valid for products that are currently installed."
comment "Uninstall of a not installed product failed - no problem"
else
if ($ExitCode$ = "1641")
comment "looks good: setup program gives exitcode 1641"
comment "ERROR_SUCCESS_REBOOT_INITIATED 1641 The installer has initiated a restart. This message is indicative of a success."
else
if ($ExitCode$ = "3010")
comment "looks good: setup program gives exitcode 3010"
comment "ERROR_SUCCESS_REBOOT_REQUIRED 3010 A restart is required to complete the install. This message is indicative of a success."
else
logError "Fatal: Setup program gives an unknown exitcode unequal zero: "+$ExitCode$
isFatalError
endif
endif
endif
endif
Thomas
Re: getOutStreamFromSection in delsub.ins
Hi,
ja - also hiermit sei bestätigt, dass es innerhalb von Sub-Sektionen (und innerhalb von Sub-sektionen in Sub-Sektionen)
Ungereimtheiten gibt, wo eine aufgerufene Sektion gesucht wird.
Es kann durch aus sein, das man die aus einer subsektion aufgerufene Sektion in die aufrufende Datei verlegen muss.
Wir erden es kundtun, wenn das Problem gelöst ist.
gruss
d.oertel
ja - also hiermit sei bestätigt, dass es innerhalb von Sub-Sektionen (und innerhalb von Sub-sektionen in Sub-Sektionen)
Ungereimtheiten gibt, wo eine aufgerufene Sektion gesucht wird.
Es kann durch aus sein, das man die aus einer subsektion aufgerufene Sektion in die aufrufende Datei verlegen muss.
Wir erden es kundtun, wenn das Problem gelöst ist.
gruss
d.oertel
opsi support - uib gmbh
For productive opsi installations we recommend support contracts.
http://www.uib.de
http://www.opsi.org
For productive opsi installations we recommend support contracts.
http://www.uib.de
http://www.opsi.org
Re: getOutStreamFromSection in delsub.ins
Hi,
danke für die Information. Dann werd ich das Problem erstmal umgehen und geduldig warten.
Gruß,
Thomas
danke für die Information. Dann werd ich das Problem erstmal umgehen und geduldig warten.
Gruß,
Thomas
Re: getOutStreamFromSection in delsub.ins
Hallo,
das geschilderte Verhalten ist nicht wirklich ein Bug, sondern bei den ausgelagerten Sektionen der Konstruktion gemäß. Auch eine ausgelagerte Sub-Sektion enthält eigentlich nur Zeilen, die syntaktisch den Rang von Zeilen einer Sub-Sektion des Hauptskripts besitzen. Und diese endet, sobald eine neue Sektion beginnt! Dass es überhaupt eine Sub-Sub-Sektion in der ausgelagerten Datei gibt, ist schon ein Workaround.
Was man eigentlich wohl gern hätte, ist so eine Art Include-Funktion für ein externes Skript. Die Frage wäre, ob das externe Skripte dynamisch inkludiert werden soll, abhängig von Bedingungen. Und ob es ein komplettes winst-Skript sein soll, mit allen syntaktischen Eigenschaften. Insgesamt ergeben sich viele Fragen, und im Ergebnis auf jeden Fall eine deutlich gestiegene Komplexität.
Ein generell funktionierender Workaround für das Problem der Sub-Sub-Sektionen ist ansonsten, sie wiederum zu eigenen Dateien zu machen und als externe Subs aufzurufen.
Grüße,
Rupert Röder
das geschilderte Verhalten ist nicht wirklich ein Bug, sondern bei den ausgelagerten Sektionen der Konstruktion gemäß. Auch eine ausgelagerte Sub-Sektion enthält eigentlich nur Zeilen, die syntaktisch den Rang von Zeilen einer Sub-Sektion des Hauptskripts besitzen. Und diese endet, sobald eine neue Sektion beginnt! Dass es überhaupt eine Sub-Sub-Sektion in der ausgelagerten Datei gibt, ist schon ein Workaround.
Was man eigentlich wohl gern hätte, ist so eine Art Include-Funktion für ein externes Skript. Die Frage wäre, ob das externe Skripte dynamisch inkludiert werden soll, abhängig von Bedingungen. Und ob es ein komplettes winst-Skript sein soll, mit allen syntaktischen Eigenschaften. Insgesamt ergeben sich viele Fragen, und im Ergebnis auf jeden Fall eine deutlich gestiegene Komplexität.
Ein generell funktionierender Workaround für das Problem der Sub-Sub-Sektionen ist ansonsten, sie wiederum zu eigenen Dateien zu machen und als externe Subs aufzurufen.
Grüße,
Rupert Röder
opsi support - uib gmbh
For productive opsi installations we recommend maintainance + support contracts which are the base of opsi development.
Wondering who's using opsi? Have a look at the opsi map: http://opsi.org/opsi-map/.
For productive opsi installations we recommend maintainance + support contracts which are the base of opsi development.
Wondering who's using opsi? Have a look at the opsi map: http://opsi.org/opsi-map/.
Re: getOutStreamFromSection in delsub.ins
Hallo,
OK, jetzt verstehe ich warum [Winbatch_uninstall] nicht so ausgeführt wird, wie ich dachte. Ich denke ich kann das Problem dann tatsächlich über einbinden einer weiter sub-Datei umgehen ohne wirkliche Nachteile zu haben.
Bleibt nur noch die Frage, warum das getOutStreamFromSection ('DosBatch_UninstKeys') nicht in delsub.ins sucht. Die for-Schleife findet die [Sub_Uninstall] ja schließlich auch.
Gruß,
Thomas Schlien
OK, jetzt verstehe ich warum [Winbatch_uninstall] nicht so ausgeführt wird, wie ich dachte. Ich denke ich kann das Problem dann tatsächlich über einbinden einer weiter sub-Datei umgehen ohne wirkliche Nachteile zu haben.
Bleibt nur noch die Frage, warum das getOutStreamFromSection ('DosBatch_UninstKeys') nicht in delsub.ins sucht. Die for-Schleife
Code: Alles auswählen
For $s$ in UninstStrings do Sub_Uninstall
Gruß,
Thomas Schlien