[wpkg-users] failing check condition with a variable
Marco Schmidt
schmidt at fgcz.ethz.ch
Mon Apr 29 13:54:26 CEST 2024
Hello,
there are two different processes involved in expanding the variable.
Remember, this is Windows ... nearly DOS :-)
The wpkg.js uses
ActiveXObject("WScript.Shell").ExpandEnvironmentStrings(value)
Which can not handle "%PKG_VERSION:~-2% and therefore returns the string literally.
Usind "%COMSPEC%" which is "cmd.exe" gets the string "%PKG_VERSION:~-2%" and does what it should and
expands the string.
No magic ... just stings interpreted by different commands.
Better do it the other way round:
<variable name="PKG_VERSION_MAJOR" value="4" />
<variable name="PKG_VERSION_MINOR" value="67" />
<variable name="PKG_VERSION" value="%PKG_VERSION_MAJOR%.%PKG_VERSION_MINOR%" />
<variable name="PKG_VERSION_SHORT" value="%PKG_VERSION_MAJOR%%PKG_VERSION_MINOR%" />
Greetings ...
Marco
On 29/04/2024 08:34, Jens Kalinowsky wrote:
> Am 24.04.2024 um 20:32 schrieb Andreas Schamanek:
>
> I had already answered Andreas directly, but here again for the mailing list:
>
>> Am I misunderstanding something, or is the reason really relatively obvious?
>> "3.00" != "3.0.0.0"
>
> oh yes, how embarrassing. At some point I was blind after all the tests yesterday. I had been
> concentrating on the fact that the variable name was in the log, so I assumed that it wasn't
> expanded, and overlooked the actual target value.
>
> I expected the variables in the log file to be expanded. However, I have now read that this is an
> expected behavior:
> https://wpkg.org/FAQ:en#Why_aren.27t_my_variables_showing_up_.28.22expanding.22.29_in_my_logs.3F
>
> I have another question about the behavior of the variables, which I can't explain yet.
>
> The following excerpt from a package is given:
>
> <variable name="PKG_VERSION" value="4.67" />
> <variable name="PKG_VERSION_SHORT" value="%PKG_VERSION:~0,1%%PKG_VERSION:~-2%" />
> <variable name="PKG_SETUP_IVIEW" value="iview%PKG_VERSION_SHORT%g_x64_setup.exe" architecture="x64" />
> ...
> <command type="install" cmd="%COMSPEC% /c echo PKG_VERSION: '%PKG_VERSION%' >
> %temp%\info.txt" />
> <command type="install" cmd="%COMSPEC% /c echo PKG_VERSION_SHORT: '%PKG_VERSION_SHORT%' >>
> %temp%\info.txt" />
> <command type="install" cmd="%COMSPEC% /c echo PKG_SETUP_IVIEW: '%PKG_SETUP_IVIEW%' >>
> %temp%\info.txt" />
> <command type="install" cmd="%PKG_SOURCE%\%PKG_SETUP_IVIEW%" /silent /folder="%PKG_DESTINATION%"
> /desktop=0 /group=1 /allusers=1 /assoc=1' />
>
> The excution of the setup command fails:
>
> 2024-04-29 07:48:17, ERROR : Command '"%PKG_SOURCE%\%PKG_SETUP_IVIEW%" /silent
> /folder="%PKG_DESTINATION%" /desktop=0 /group=1 /allusers=1 /assoc=1'
> ('"\\smh\admin\install\Grafik\iview%PKG_VERSION:~0,1%%PKG_VERSION:~-2%g_x64_setup.exe" /silent
> /folder="C:\Program Files\Irfanview" /desktop=0 /group=1 /allusers=1 /assoc=1') was
> unsuccessful.|Das System kann die angegebene Datei nicht finden.|
>
> But the debug output seems to be fine:
>
> PKG_VERSION: '4.67'
> PKG_VERSION_SHORT: '467'
> PKG_SETUP_IVIEW: 'iview467g_x64_setup.exe'
>
> If I change the variable definition PKG_VERSION_SHORT to the static value '467' the package works.
>
> If I leave the variable PKG_VERSION_SHORT dynamic as described above, so that it depends on
> PKG_VERSION and put an '%COMSPEC% /c start "" /wait' in front of the setup command, it works also.
>
> Can someone explain this to me?
>
> Jens
>
>
> ---------------------------------
> wpkg-users mailing list archives >> http://lists.wpkg.org/pipermail/wpkg-users/
> _______________________________________________
> wpkg-users mailing list
> wpkg-users at lists.wpkg.org
> https://lists.wpkg.org/mailman/listinfo/wpkg-users
More information about the wpkg-users
mailing list