winetricks icon indicating copy to clipboard operation
winetricks copied to clipboard

Any way to check installed_file1 for md5sum?

Open SveSop opened this issue 3 years ago • 5 comments

I want to update a package, but the new version do not have any new files.. just updated files. This means that if i have the old version installed, winetricks will fail with already installed, skipping

Is there a way for the filecheck installed_file1 to do a md5sum comparison (or similar) toward a installed file to check if it should be updated?

SveSop avatar Nov 02 '21 15:11 SveSop

Currently, no (but I'm open to changing that, if you have ideas).

If you don't specify installed_file1, then winetricks won't check for the file's presence before attempting to install. Then within the main verb function, you could use w_verify_shasum() to check the checksum.

austin987 avatar Nov 29 '21 05:11 austin987

Instead of me trying to fiddle with the script for hours, how would this be used in practice? This is the culprit i am having issues with:

w_metadata physx dlls \
    title="PhysX" \
    publisher="Nvidia" \
    year="2019" \
    media="download" \
    file1="PhysX-9.19.0218-SystemSoftware.exe" \
    installed_file1="${W_PROGRAMS_X86_WIN}/NVIDIA Corporation/PhysX/Engine/86C5F4F22ECD/APEX_Particles_x64.dll"

load_physx()
{
    w_download https://uk.download.nvidia.com/Windows/9.19.0218/PhysX-9.19.0218-SystemSoftware.exe 4f36389fcbfbdef4781fb85e7a68373542903235f65d93f7143693738324917c
    w_try_cd "${W_CACHE}/${W_PACKAGE}"
    w_try "${WINE}" PhysX-9.19.0218-SystemSoftware.exe ${W_OPT_UNATTENDED:+/s}
}

Would i somewhat replace installed_file1 with w_verify_shasum() to check for the shasum on APEX_Particles_x64.dll before the installer is run?

SveSop avatar Nov 29 '21 15:11 SveSop

This would be a hack (and is totally untested):

w_metadata physx dlls \
    title="PhysX" \
    publisher="Nvidia" \
    year="2019" \
    media="download" \
    file1="PhysX-9.19.0218-SystemSoftware.exe"
 
load_physx()
{
    if w_verify_shasum "${expected_shasum}" "${W_PROGRAMS_X86_WIN}/NVIDIA Corporation/PhysX/Engine/86C5F4F22ECD/APEX_Particles_x64.dll"; then
        w_warn "${W_PACKAGE} is already installed, and file has expected shasum, not updating"
        return
    fi
    
    w_download https://uk.download.nvidia.com/Windows/9.19.0218/PhysX-9.19.0218-SystemSoftware.exe 4f36389fcbfbdef4781fb85e7a68373542903235f65d93f7143693738324917c
    w_try_cd "${W_CACHE}/${W_PACKAGE}"
    w_try "${WINE}" PhysX-9.19.0218-SystemSoftware.exe ${W_OPT_UNATTENDED:+/s}
}

A proper solution (at least, at first glance, haven't tried it) would be to have support for an optional installed_file1_shasum field to w_metadata, that would allow verifying the checksum automatically after installation completes.

It would require more careful examination on how to handle existing installs though; I suspect not every installer will offer a clean upgrade option, for example...

austin987 avatar Dec 06 '21 05:12 austin987

It seems w_verify_shasum needs UNIX available path, or i just got "file not found" error, but it did not work quite as well, as the w_verify_shasum function will break if it is NOT the same, and that was not the intention i guess.

I created a new function, and ended up like this:

# verify sha256sum of installed file
w_installed_shasum()
{
    _W_vs_wantsum=$1
    _W_vs_file=$2

    w_get_sha256sum "${_W_vs_file}"
    if [ "${_W_gotsha256sum}"x != "${_W_vs_wantsum}"x ] ; then
        w_warn "${W_PACKAGE} does not seem installed or needs upgrading! Running the installer."
        unset _W_vs_wantsum _W_vs_file _W_gotsha256sum
        return 1
    fi
    unset _W_vs_wantsum _W_vs_file _W_gotsha256sum
}

With these changes to the verb:

w_metadata physx dlls \
    title="PhysX" \
    publisher="Nvidia" \
    year="2019" \
    media="download" \
    file1="PhysX-9.19.0218-SystemSoftware.exe"

load_physx()
{
    if w_installed_shasum 2d15a7150b4ad43515f3962357c9eceeb73166b5424ba401d29691832d60d988 "${W_PROGRAMS_X86_UNIX}/NVIDIA Corporation/PhysX/Engine/86C5F4F22ECD/APEX_Particles_x64.dll"; then
        w_warn "${W_PACKAGE} is already installed, and file has expected shasum, not updating"
        return
    else
        w_download https://uk.download.nvidia.com/Windows/9.19.0218/PhysX-9.19.0218-SystemSoftware.exe 4f36389fcbfbdef4781fb85e7a68373542903235f65d93f7143693738324>
        w_try_cd "${W_CACHE}/${W_PACKAGE}"
        w_try "${WINE}" PhysX-9.19.0218-SystemSoftware.exe ${W_OPT_UNATTENDED:+/s}
    fi
}

This seemed to do the trick - If shasum is the same, it will throw: is already installed, and file has expected shasum, not updating vs does not seem installed or needs upgrading! Running the installer. and run the installer if the shasum does not match.

Not really sure it is anything smoother than baking this into the installed_file1 function with a new installed_file1_shasum field, as that would be preferred :smile: Not really sure how to attack this tho, as it needs some intricate elaboration to check for shasum if it is given, or ignore it if it is empty i guess...

SveSop avatar Dec 06 '21 16:12 SveSop

Sorry for late reply, missed this one.

I mean, it's worth trying; I don't think it would be terribly hard, and as long as it's opt-in, it shouldn't break anything else ;). Like I said, it may be tricky for certain installers, but that's okay, because those installers will keep their current behavior. We just need to be careful before blindly adding it to existing verbs.

austin987 avatar Apr 19 '22 07:04 austin987