Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

README: Manually: Unzip the latest release, and add to the path. #296

Closed
rfay opened this issue Aug 31, 2023 · 4 comments
Closed

README: Manually: Unzip the latest release, and add to the path. #296

rfay opened this issue Aug 31, 2023 · 4 comments

Comments

@rfay
Copy link
Contributor

rfay commented Aug 31, 2023

Issue Description

I've been using a fork for DDEV's install for some time but really want to use your releases. It's by far easiest to use a exe file, as requested in #88, but I'm moving on!

It seems like the README may be from long ago. it says:

Manually: Unzip the latest release, and add to the path

I assume this means "Unzip gsudo_portable.zip" and extract the gsudo.exe from it. But there are lots of things in there:

$ unzip -l gsudo.portable.zip
Archive:  gsudo.portable.zip
  Length      Date    Time    Name
---------  ---------- -----   ----
      717  07-17-2023 23:23   x86/gsudo
 16965760  07-17-2023 23:24   x86/gsudo.exe
    20323  07-17-2023 23:24   x86/gsudoModule.psd1
    26037  07-17-2023 23:24   x86/gsudoModule.psm1
    22814  07-17-2023 23:24   x86/Invoke-gsudo.ps1
      717  07-17-2023 23:23   x64/gsudo
  5871568  07-17-2023 23:24   x64/gsudo.exe
    20323  07-17-2023 23:24   x64/gsudoModule.psd1
    26037  07-17-2023 23:24   x64/gsudoModule.psm1
    22814  07-17-2023 23:24   x64/Invoke-gsudo.ps1
      717  07-17-2023 23:23   arm64/gsudo
  6063056  07-17-2023 23:24   arm64/gsudo.exe
    20323  07-17-2023 23:24   arm64/gsudoModule.psd1
    26037  07-17-2023 23:24   arm64/gsudoModule.psm1
    22814  07-17-2023 23:24   arm64/Invoke-gsudo.ps1
      717  07-17-2023 23:23   net46-AnyCpu/gsudo
   192464  07-17-2023 23:24   net46-AnyCpu/gsudo.exe
      174  07-17-2023 23:23   net46-AnyCpu/gsudo.exe.config
    20323  07-17-2023 23:24   net46-AnyCpu/gsudoModule.psd1
    26037  07-17-2023 23:24   net46-AnyCpu/gsudoModule.psm1
    22814  07-17-2023 23:24   net46-AnyCpu/Invoke-gsudo.ps1

I would bet that I would want the x64/gsudo.exe for any ordinary Windows machine. Is that the only thing I need?

@gerardog
Copy link
Owner

gerardog commented Sep 1, 2023

Well, you need to choose a version according to your windows version/processor-platform... In the past I had only one build that worked for any platform, but to gain the performance improvements of net7.0 (related blog post) I had to build separatedly for each platform. Initially I kept one .MSI installer, but got negative feedback around it, so I did a poll and... I had to do what everyone else is doing, one installer per platform...

You have 3 options built using the faster net7.0

  • x86 is for x86 processors (windows 32-bits)
  • x64 is for x64 processors (windows 64-bits)
  • arm64 is for arm64 processors. (windows for arm)

and the old build (net46-AnyCpu) using net4.6 is still available. I can't guarantee it will stay forever, given that keeping it means I can't use many of modern net features. It's only advantage is that it's works on any-cpu, so you don't need to check the processor type... You just need net4.6, which is ubiquitous in win 10 & 11.

If I were in your spot, I would embed the latest '.msi' that matches the platform and trigger it's installation silently.
I see ddev is only targeting x64 on windows (which is fine by me since arm64 has great emulation for x64, and gsudo-x64 works fine on win-arm64), so you can embed the x64 gsudo. BTW, who is using x86 in 2023?

Also you can make your packer scripts download the latest directly:
https://github.com/gerardog/gsudo/releases/latest/download/gsudo.portable.zip
https://github.com/gerardog/gsudo/releases/latest/download/gsudo.setup.x64.msi

Or, if you are familiar with nuget, you can download from the nuget feed: https://www.nuget.org/packages/gsudo

I can help you automate this part of your installer builder if you want. It should be easy to download a zip and extract a file. Probably easier to do it before generating the ddev_windows_installer.vX.Y.Z.exe.

For example if the install builder is embedding the gsudo.exe from ./3rdParty/gsudo.exe just run this powershell before building:

$zipUrl = "https://github.com/gerardog/gsudo/releases/latest/download/gsudo.portable.zip"
$localTempfile = "$env:temp/gsudo.portable.zip"
$localTempFolder = "$env:temp/gsudo-installer"
$finalLocation = "./3rdParty/"

# Download
Invoke-WebRequest -Uri $zipUrl -OutFile $localTempfile
# Unzip  
Expand-Archive -Path $localTempfile -DestinationPath $localTempFolder -Force
# create target folder (force to swallow 'already exists error'
mkdir $finalLocation -force
# pick the relevant file
copy-Item -Path "$localTempFolder/x64/gsudo.exe" -Destination $finalLocation -Force

@rfay
Copy link
Contributor Author

rfay commented Sep 1, 2023

Thanks, I'll try to do a little PR to the README if you don't get there first.

Unfortunately I'm using nsis for the Windows installer and embedding gsudo.exe that way, here's the new technique:

It's a lot harder to do with a way-off-brand scripting language like nsis.

@gerardog
Copy link
Owner

gerardog commented Sep 1, 2023

Oh I see.... I thought your installer had gsudo.exe embedded inside ddev_windows_installer.vX.Y.Z.exe.... If that was the case, then your build pipeline preparation script ./.ci-scripts/generate_artifacts.sh could pre-download and extract the files prior to the NSIS builder running and picking it and compressing it inside the installer.


Given that's not the case then...

  • May I ask why don't you download and install the gsudo's msi directly? Using just gsudo.exe skips the installation of the powershell module, which is kind of awesome. 😊

    • Only issue I think of is that console windows needs to be restarted after msi install for the PATH variable to refresh.

    • And detecting your platform, since you need to download the appropiate gsudo's x86, x64 or arm64 installer.

      • But this is already handled in gsudo one-liner install script:
        PowerShell -Command "Set-ExecutionPolicy RemoteSigned -scope Process; [Net.ServicePointManager]::SecurityProtocol = 'Tls12'; iwr -useb https://raw.githubusercontent.com/gerardog/gsudo/master/installgsudo.ps1 | iex"
    • So why don't you try to add this line to your nsis installer?
      Exec '"powershell.exe" -Command "Set-ExecutionPolicy RemoteSigned -scope Process; [Net.ServicePointManager]::SecurityProtocol = ''Tls12''; iwr -useb https://raw.githubusercontent.com/gerardog/gsudo/master/installgsudo.ps1 | iex"'
      If the 'press any key to continue' message bothers, we can work on it

  • Alternatively, have you considered calling choco or winget ?

@rfay
Copy link
Contributor Author

rfay commented Sep 1, 2023

I thought your installer had gsudo.exe embedded inside ddev_windows_installer.vX.Y.Z.exe

We stopped doing this a couple of years ago because chocolatey called gsudo a virus popping us over the allowed detection count.

Alternatively, have you considered calling choco or winget ?

The reality I think is that everybody uses chocolatey to install DDEV, and gsudo is listed as a dependency there, so they end up using the choco-installed gsudo anyway. But since they can just download the installer we have to handle it somehow.

Traditional Windows isn't really what we want to do, last choice for everything after WSL2.

The idea of calling one installer from another sounds pretty scary.

And I barely (or don't?) understand nsis at all :(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants