ScoopInstaller / Main

📦 The default bucket for Scoop.
https://scoop.sh
The Unlicense
1.6k stars 966 forks source link

[Bug]: QEMU 7.2.0-rc2 unable to extract qemu-uninstall.exe.nsis #4164

Closed HeWhoWatches closed 1 year ago

HeWhoWatches commented 1 year ago

Prerequisites

Package Name

QEMU

Expected/Current Behaviour

Expected behaviour is to successfully install/update qemu. Current behaviour is that 7z is unable to extract lib\gdk-pixbuf-2.0\2.10.0\qemu-uninstall.exe.nsis from the archive during the installation process. 7zip.log

Steps to Reproduce

PS> scoop install qemu -k
WARN  Scoop uses 'aria2c' for multi-connection downloads.
WARN  Should it cause issues, run 'scoop config aria2-enabled false' to disable it.
WARN  To disable this warning, run 'scoop config aria2-warning-enabled false'.
Installing 'qemu' (7.2.0-rc2) [64bit] from main bucket
WARN  Cache is being ignored.
Starting download with aria2 ...
Download: Download Results:
Download: gid   |stat|avg speed  |path/URI
Download: ======+====+===========+=======================================================
Download: 27e395|OK  |   6.9MiB/s|C:/Tools/Scoop/cache/qemu#7.2.0-rc2#https_qemu.weilnetz.de_w64_qemu-w64-setup-20221123.exe_dl.7z
Download: Status Legend:
Download: (OK):download completed.
Checking hash of qemu-w64-setup-20221123.exe ... ok.
Extracting dl.7z ... ERROR Exit code was 2!
Failed to extract files from C:\Tools\Scoop\apps\qemu\7.2.0-rc2\dl.7z.
Log file:
  C:\Tools\Scoop\apps\qemu\7.2.0-rc2\7zip.log

Please try again or create a new issue by using the following link and paste your console output:
https://github.com/ScoopInstaller/Main/issues/new?title=qemu%407.2.0-rc2%3a+decompress+error

Possible Solution

While I don't have a solution, I did note that the same error occurs in the GUI version of 7-zip 22.01 if you try to manually extract the executable. The file that causes the error may be related to this change in the history notes for the new version: 2022-11-23: New QEMU installers (7.2.0-rc2). Signed uninstaller, enhanced file properties.

Scoop and Buckets Version

PS> scoop --version
Current Scoop version:
v0.3.1 - Released at 2022-11-15

'extras' bucket:
ca9395116 (HEAD -> master, origin/master, origin/HEAD) winscan2pdf: Update to version 8.31

'java' bucket:
6ca994b1 (HEAD -> master, origin/master, origin/HEAD) temurin8-nightly-jre: Update to version 8.0.362-3.0.202211231817

'main' bucket:
a9e99dd18 (HEAD -> master, origin/master, origin/HEAD) git-istage: Update to version 0.3.88

'nirsoft' bucket:
28db834 (HEAD -> master, origin/master, origin/HEAD) Excluded two pad files that require a password. They need to be updated manually.

Scoop Config

PS> scoop config

last_update                       scoop_branch scoop_repo
-----------                       ------------ ----------
2022-11-24T08:33:58.7296808+00:00 master       https://github.com/ScoopInstaller/Scoop

PowerShell Version

PS> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      5.1.19041.1682
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.19041.1682
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

Additional Softwares

No response

Zzyzx-Wolfe commented 1 year ago

Can confirm that I am having the same issue:

 ⚡Zzyzx ❯❯ scoop update qemu -k
qemu: 7.2.0-rc1 -> 7.2.0-rc2
Updating one outdated app:
Updating 'qemu' (7.2.0-rc1 -> 7.2.0-rc2)
Downloading new version
Loading qemu-w64-setup-20221123.exe from cache
Checking hash of qemu-w64-setup-20221123.exe ... ok.
Uninstalling 'qemu' (7.2.0-rc1)
Unlinking ~\scoop\apps\qemu\current
Installing 'qemu' (7.2.0-rc2) [64bit] from main bucket
WARN  Cache is being ignored.
qemu-w64-setup-20221123.exe (143.2 MB) [======================================================================] 100%
Extracting dl.7z ... ERROR Exit code was 2!
Failed to extract files from C:\Users\Zzyzx\scoop\apps\qemu\7.2.0-rc2\dl.7z.
Log file:
  ~\scoop\apps\qemu\7.2.0-rc2\7zip.log

Please try again or create a new issue by using the following link and paste your console output:
https://github.com/ScoopInstaller/Main/issues/new?title=qemu%407.2.0-rc2%3a+decompress+error
 ⚡Zzyzx ❯❯ scoop --version
Current Scoop version:
v0.3.1 - Released at 2022-11-15

'extras' bucket:
1f79ece33 (HEAD -> master, origin/master, origin/HEAD) tartube: Update to version 2.4.165

'main' bucket:
7b1ce9d17 (HEAD -> master, origin/master, origin/HEAD) zeebe: Update to version 8.1.4

 ⚡Zzyzx ❯❯ scoop config

aria2-enabled : False
last_update   : 11/24/2022 9:31:38 AM
use_lessmsi   : True
scoop_repo    : https://github.com/lukesampson/scoop
scoop_branch  : master

 ⚡Zzyzx ❯❯ $PSVersionTable

Name                           Value
----                           -----
PSVersion                      7.3.0
PSEdition                      Core
GitCommitId                    7.3.0
OS                             Microsoft Windows 10.0.22621
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

The output of ~\scoop\apps\qemu\7.2.0-rc2\7zip.log is as follows:

7-Zip 22.01 (x64) : Copyright (c) 1999-2022 Igor Pavlov : 2022-07-15

Scanning the drive for archives:
1 file, 150147352 bytes (144 MiB)

Extracting archive: C:\Users\Zzyzx\scoop\apps\qemu\7.2.0-rc2\dl.7z
WARNING:
C:\Users\Zzyzx\scoop\apps\qemu\7.2.0-rc2\dl.7z
Cannot open the file as [7z] archive
The file is open as [PE] archive

--
Path = C:\Users\Zzyzx\scoop\apps\qemu\7.2.0-rc2\dl.7z
Open WARNING: Cannot open the file as [7z] archive
Type = PE
Physical Size = 150147352
CPU = x86
Characteristics = Executable 32-bit NoLineNums NoLocalSyms NoDebugInfo
Created = 2022-08-14 22:58:35
Headers Size = 1024
Checksum = 150176849
Image Size = 438272
Section Alignment = 4096
File Alignment = 512
Code Size = 38400
Initialized Data Size = 56832
Uninitialized Data Size = 131072
Linker Version = 2.37
OS Version = 4.0
Image Version = 6.0
Subsystem Version = 4.0
Subsystem = Windows GUI
DLL Characteristics = Relocated NX-Compatible TerminalServerAware
Stack Reserve = 2097152
Stack Commit = 4096
Heap Reserve = 1048576
Heap Commit = 4096
Image Base = 4194304
----
Path = [0]
Size = 150039448
Packed Size = 150039448
Virtual Size = 150039448
Offset = 96256
--
Path = [0]
Type = Nsis
Offset = 7168
Physical Size = 150032275
Tail Size = 5
Method = LZMA:23
Solid = +
Headers Size = 573434
Embedded Stub Size = 0
SubType = NSIS-3 Unicode

Sub items Errors: 1

Archives with Errors: 1

Sub items Errors: 1
ERROR: Data Error : lib\gdk-pixbuf-2.0\2.10.0\qemu-uninstall.exe.nsis
rashil2000 commented 1 year ago

Can confirm this: lib\gdk-pixbuf-2.0\2.10.0\qemu-uninstall.exe.nsis is not extractable

onurbbr commented 1 year ago

I can confirm too. In the latest version of QEMU, the uninstaller is signed. So 7zip may not be able to extract this file. Screenshot_20221126_130406

We have no obligation to extract the lib file in the exe. With the following command, the qemu file is output without any problems.

Code: 7z x -y dl.7z -xr!lib\gdk-pixbuf-2.0\2.10.0\qemu-uninstall.exe.nsis

I also looked at the core files of scoop, but I have no clue how to implement it.

itsame-mcl commented 1 year ago

I can also confirm this issue with this version, and also with qemu 7.2.0-rc3. On the 7zip log, I have also this message :

Sub items Errors: 1
ERROR: Data Error : lib\gdk-pixbuf-2.0\2.10.0\qemu-uninstall.exe.nsis
hgkamath commented 1 year ago

I typed this all up, and then realized I have nothing new to add. sry, but yes, the signed uninstaller and enhanced file properties are the main changes to the nsis installer in qemu-7.2-rc2.

The nsis-installer command works when executed directly and installs to C:\Program Files\qemu

PS C:\> C:\tmpq\Downloads\qemu-w64-setup-20221130.exe

but not via scoop update -g qemu scoop extracts the 7x file from inside the exe and dumps the 7z in the scoop-cache folder. scoop then invokes 7z to extract contents to under appropriate folder under scoop apps directory, during which the error happens.

The decompression error is also shown in the log-dialogbox when executing a test operation on the exe from within 7zFM 22.01 2022-07-15.

Recently, there have been some changes in how qemu generates the windows nsis installer exectuables

last lines of log C:\vol\scoop_01\SCOOPG\apps\qemu\7.2.0-rc2\7zip.log

Sub items Errors: 1

Archives with Errors: 1

Sub items Errors: 1
ERROR: Data Error : lib\gdk-pixbuf-2.0\2.10.0\qemu-uninstall.exe.nsis

I had filed a bug in qemu-project. But it seems that this has to be handled properly by scoop's 7z unpackager. https://gitlab.com/qemu-project/qemu/-/issues/1349 Perhaps, is it by design, that the app-uninstall.exe.nsis can only be extracted and put in place by the nsis-installer-exe ? If so then as onurbbr said above, it ought to be skipped.

Reading Refs [1],[2] below, I wonder if it is because the nsis installer intends to extract the signed uninstaller binary to an absolute path directory specified by %INSTDIR% environment variable and overwrite a previously generated uninstaller binary there.

Does this happen with other scoop packages? qemu may not be the only package in the world that packages signed binaries. Is there something wrong with how qemu-project does it? or Perhaps, if this is a new trend, then going forwards, different packages are going to have different problem files in extraction. So may be an exclusion file-list must be provided as a list in the manifest file, which scoop heeds by passing appropriate arguments to the unpackager during unpackaging.

The error shows up whether one uses 7zfm file-browser on qemu-w64-setup-20221130.exe or on C:\vol\scoop_01\scoop\cache\qemu#7.2.0-rc3#https_qemu.weilnetz.de_w64_qemu-w64-setup-20221130.exe_dl.7z in scoop cache folder. The 7zFM file-brower-gui shows lib\gdk-pixbuf-2.0\2.10.0\qemu-uninstall.exe.nsis to be a size 0 byte file. offset in 7zarchive to be 912,201,779. Being the last file added to the archive, the offset position is perhaps pointing to end of archive. Previous file zlib1.dll size 120,302, has offset 912,081,473. (912,081,302+120,302=912,201,775 which leaves a 4 bytes gap to prev file). The whole package unpacked size is shown in properties to be 924,087,926, I wonder what the remainder of the unpacked 7z file (11,886,147 bytes) contains, maybe 7z decompression data.
I just now filed this as a tentative bug in 7z: https://sourceforge.net/p/sevenzip/bugs/2373/

misc:

  1. https://nsis.sourceforge.io/Signing_an_Uninstaller
  2. https://gitlab.com/qemu-project/qemu/-/blob/master/qemu.nsi
  3. I wonder if the 7zip not opting for code-signed binaries has anything to do with it. https://sourceforge.net/p/sevenzip/discussion/45797/thread/b93e3d5d1c/
  4. https://sourceforge.net/projects/sevenzip/
jpovixwm commented 1 year ago

A hacky workaround exists for those who just want to install QEMU with scoop today:

  1. Locate your 7z.shim file (e.g. ~/scoop/shims/7z.shim)
  2. Append the line args = -xr!lib\gdk-pixbuf-2.0\2.10.0\qemu-uninstall.exe.nsis to it
  3. (Optional) Inspect the value of Scoop's use_external_7z config option, so that you can later restore it to the initial value: scoop config use_external_7z
  4. Instruct scoop to use an external 7zip executable: scoop config use_external_7z true (this will only work under the assumption that ~/scoop/shims/ is in your PATH and ~/scoop/shims/7z.exe is the first match for 7z.exe)
  5. Run scoop install qemu as usual
  6. Revert the changes made to the 7z.shim file and to your Scoop configuration: scoop config rm use_external_7z (if it was unset previously) or scoop config use_external_7z initial_value
ciarancourtney commented 1 year ago

A hacky workaround exists for those who just want to install QEMU with scoop today:

  1. Locate your 7z.shim file (e.g. ~/scoop/shims/7z.shim)
  2. Append the line args = -xr!lib\gdk-pixbuf-2.0\2.10.0\qemu-uninstall.exe.nsis to it
  3. (Optional) Inspect the value of Scoop's use_external_7z config option, so that you can later restore it to the initial value: scoop config use_external_7z
  4. Instruct scoop to use an external 7zip executable: scoop config use_external_7z true (this will only work under the assumption that ~/scoop/shims/ is in your PATH and ~/scoop/shims/7z.exe is the first match for 7z.exe)
  5. Run scoop install qemu as usual
  6. Revert the changes made to the 7z.shim file and to your Scoop configuration: scoop config rm use_external_7z (if it was unset previously) or scoop config use_external_7z initial_value

@jpovixwm Spotted a typo there, the correct config var is use_external_7zip, not use_external_7z

Lutra-Fs commented 1 year ago

it seems like there is the same issue with tesseract@5.3.0.20221214

rashil2000 commented 1 year ago

Code:

7z x -y dl.7z -xr!lib\gdk-pixbuf-2.0\2.10.0\qemu-uninstall.exe.nsis

As a temporary fix (for both qemu and tesseract), we can use Expand-7zipArchive in the pre_install field of the manifest to exclude the uninstaller file. See https://github.com/ScoopInstaller/Extras/blob/master/bucket/cdex.json#L10 for example.

Can someone submit a PR?