ScoopInstaller / Scoop

A command-line installer for Windows.
https://scoop.sh
Other
20.86k stars 1.39k forks source link

Install on Air Gapped Computer #3505

Open a59 opened 5 years ago

a59 commented 5 years ago

I have been using scoop apps on an air-gapped computer (it doesn't have an internet connection.) My method for doing this is to copy the whole scoop directory from PC1 (has internet connection) over to the new machine PC2 (does not have internet connection), then recreate all the current directory Directory Junctions. This works but isn't ideal.

Is there a better way?

In my mind, the ideal way would be to create a new bucket containing all the app manifests for the apps I need and then edit them so that the url points to a local folder containing the installers. I could get the installers from the scoop/cache directory on PC1. I'd then copy both the bucket and the installer over to PC2. Then I could use scoop install or scoop update on PC2.

Could this work? Would there be a better way of doing it? What if I wanted to install the apps globally?

Ash258 commented 5 years ago

Setup $env:SCOOP_CACHE to point to some UNC path (for example \\PC1\C\SCOOP\cache)

Then if you download anything on PC1 installers will be available for second PC.

Or just manually copy content of $env:SCOOP\cache folder of PC with internet to second PC.

shoogle commented 5 years ago

Your use-case is probably out of scope for scoop strictly speaking, but as @Ash258 said, if you copy the cache from PC1 to PC2 then scoop on PC2 shouldn't go looking online anyway, so no need to modify any manifest URLs.

a59 commented 5 years ago

Thanks for the suggestions. I tried out this process.

  1. On PC1, install scoop and the apps that I need on PC2.
  2. On PC2, uninstall all the apps except for scoop.
  3. Copy the scoop folder from PC1 to PC2.
  4. On PC2, set the PATH adding ~\scoop\shims
  5. On PC2, use scoop to install all the apps from the cache folder.

This process seems to work fine. I would like to have a script to make the process smoother.

In the past I had copied the scoop folder without the cache but with the apps "installed", but had problems with the Directory Junctions.

xeijin commented 5 years ago

@a59 I had a similar but different use-case (behind corporate firewall and couldnt do a scoop update to upgrade a package, had to bring it into our network through an internal process).

To this end I was working on a scoop add-on command called scoop dlcache the idea being you do a scoop dlcache <app> and instead of extracting and installing, just downloads a cache file that you can then transport (however you wish) on to another PC.

Unfortunately it's been broken by several scoop updates (which to be fair is not surprising given it's mostly crudely copied from bits of the existing installer functions):

https://gitlab.com/xeijin-dev/werk/blob/master/libexec/scoop-dlcache.ps1

@Ash258 @r15ch13 I guess there's not much appetite for including this as a feature given limited appeal, but is there a way I can re-write my script such that it's less likely to break?

shoogle commented 5 years ago

@xeijin, downloading is a necessary part of doing a normal install, so there should be no objections to including a function to download without installing, providing you do it right.

By doing it right, I mean you shouldn't copy and paste existing code. Instead you should move the existing download code out of the install function and into a new function of its own (or new file, whatever). Obviously this breaks the install function, but to get it working again you simply call your new download function from inside the install function.

This avoids code duplication, and it means that any future improvements made to the download function will benfit both scoop dlcache and scoop install.

hopenbr commented 2 years ago

In past two years has there been any improvements on this?

I have a large need to work with Air Gapped windows servers, these servers do have access to our backend network just not outside world.

I was thinking just to create my own bucket copy the apps needed and pointed to msi/installed hosted on Artifactory.

rashil2000 commented 1 year ago

From @roysubs in #5265:

Feature Request

Is your feature request related to a problem? Please describe.

I would like to avoid having to run the full scoop installation process on every new VM because it is quite slow. I would like to have instant access to scoop.

Describe the solution you'd like

I would like an offline scoop install, so that I can immediately have access to scoop in Hyper-V Windows VM's and the Windows Sandbox. i.e. not having to download scoop from the internet, not having to extract the zip's, just a pristine/vanilla scoop install folder that I can robocopy into the new system (so will be less than 1 second to do that) and then attach whatever environment variables and PATH settings are required to turn that folder into a full scoop installation that is fully usable inside that new VM. My goal is for this to simply be a normal scoop install, just without the internet download then 2x zip extractions that happen during the install etc. I've looked around the existing issues on here but found none that fit this desccription.

Describe alternatives you've considered

I have tried this myself and cannot get it to work. I installed vanilla scoop on a system. I then robocopy'd that to a backup location. I go to the VM. I robocopy scoop into place, I add the shims folder to the PATH, and ... nothing works. I would really like to get this working as I am creating lots of new VM's and the scoop internet install process can be quite slow, downloading the file, doing the 2x zip extractions (the second is particularly slow). It seems inefficient to have to download every time and do the extractions every time. How can we do an offline install for scoop as above? (Note that I have achieved the above with chocolatey to create an offline install of it so that I have instant access to that package manager just by robocopying into place and setting one environment variable and adding to the PATH, but I prefer scoop and so would like to use scoop as much as possible).

roysubs commented 1 year ago

The slow part of the process that I see whenever adding scoop to new VM's is the zip extraction. But that part is just an unzip so has no complexity (does not create junctions etc, right?). The install script is quite complex, so I've not been able to unravel it, but ...

Step 1 : Download the files and extract them. This should be trivial and should be the basis for a vanilla install of scoop. i.e. the static files that an install is based on.

Step 2 : Apply Secret-Sauce (environment variables, PATH, junctions, anytihng else required) that turns those extracted files into a full scoop installation.

Can Step 2 be achieved in 5-10 lines of PowerShell? Hopefully just a few required actions to turn the static install files into a fully-powered scoop install. That is all that I want, but if other folk want to be able to port packages etc, this would probably be a good starting point for that.

This would also solve all issues around corporate environments blocking normal scoop installs from the internet (just get the vanilla extracted files from another system and then apply the required components to enable full scoop) so seems generally really useful to have as an install option.

roysubs commented 1 year ago

Just to note, my process above to create an air-gapped scoop install almost works (I install a pristine / vanilla scoop on another system, then robocopying that to other systems and VM's, then just add the shims folder to the PATH). Can scoop experts here see what is missing that causes the below errors? Notably, 7Zip and vim install fine and are usable, so scoop does (sort of) work, it's just that it throws a bunch of errors and will not update. What do we need to add to complete the offline / air-gapped install?

Specifically these errors need to be fixed: • error setting certificate verify locations: CAfile: C:/Program Files/Git/mingw64/ssl/certs/ca-bundle.crt CApath: none • Remove-Item : Cannot find path 'C:\Users\WDAGUtilityAccount\scoop\apps\scoop\new' because it does not exist. At C:\Users\WDAGUtilityAccount\scoop\apps\scoop\current\libexec\scoop-update.ps1:79 char:13. Remove-Item $newdir -Force -Recurse

C:\> scoop install vim
Updating Scoop...
fatal: unable to access 'https://github.com/ScoopInstaller/Scoop/': error setting certificate verify locations:  CAfile: C:/Program Files/Git/mingw64/ssl/certs/ca-bundle.crt CApath: none
Remove-Item : Cannot find path 'C:\Users\WDAGUtilityAccount\scoop\apps\scoop\new' because it does not exist.
At C:\Users\WDAGUtilityAccount\scoop\apps\scoop\current\libexec\scoop-update.ps1:79 char:13
+             Remove-Item $newdir -Force -Recurse
+             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (C:\Users\WDAGUt...\apps\scoop\new:String) [Remove-Item], ItemNotFoundEx
   ception
    + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.RemoveItemCommand

Scoop download failed. If this appears several times, try removing SCOOP_REPO by 'scoop config rm SCOOP_REPO'
Installing '7zip' (22.01) [64bit] from main bucket
7z2201-x64.msi (1.8 MB) [=====================================================================================] 100%
Checking hash of 7z2201-x64.msi ... ok.
Extracting 7z2201-x64.msi ... done.
Linking ~\scoop\apps\7zip\current => ~\scoop\apps\7zip\22.01
Creating shim for '7z'.
Adding ~\scoop\shims to your path.
Creating shim for '7zFM'.
Creating shim for '7zG'.
Creating shortcut for 7-Zip (7zFM.exe)
Persisting Codecs
Persisting Formats
Running post_install script...
'7zip' (22.01) was installed successfully!
Notes
-----
Add 7-Zip as a context menu option by running:
"C:\Users\WDAGUtilityAccount\scoop\apps\7zip\current\install-context.reg"
Installing 'vim' (9.0) [64bit] from main bucket
gvim90.exe (9.7 MB) [=========================================================================================] 100%
Checking hash of gvim90.exe ... ok.
Extracting dl.7z ... done.
Running pre_install script...
Linking ~\scoop\apps\vim\current => ~\scoop\apps\vim\9.0
Creating shim for 'vim'.
Creating shim for 'vi'.
Creating shim for 'ex'.
Creating shim for 'view'.
Creating shim for 'rvim'.
Creating shim for 'rview'.
Creating shim for 'vimdiff'.
Creating shim for 'gvim'.
Creating shim for 'gview'.
Creating shim for 'evim'.
Creating shim for 'eview'.
Creating shim for 'rgvim'.
Creating shim for 'rgview'.
Creating shim for 'gvimdiff'.
Creating shim for 'xxd'.
Creating shortcut for gVim (gvim.exe)
Running post_install script...
'vim' (9.0) was installed successfully!
Notes
-----
Add gVim as a context menu option by running: "C:\Users\WDAGUtilityAccount\scoop\apps\vim\current\install-context.reg"
'vim' suggests installing 'vimtutor'.
rashil2000 commented 1 year ago

Will look into it

phanirithvij commented 1 year ago

@roysubs scoop install -u ... skips the autoupdate.

pbb72 commented 1 year ago

I've been playing around with setting SCOOP_CACHE to a UNC path, but I still need to copy over the buckets folders to the air gapped computer, and keep these up to date to be able to install updates, right?

Setting SCOOP to the UNC path will cause Scoop to try and install everything on the networked computer.

rashil2000 commented 1 year ago

but I still need to copy over the buckets folders to the air gapped computer, and keep these up to date to be able to install updates, right?

Yes

chafidz0000000 commented 10 months ago

I wish the scoop download had one more switch for downloading the app including its manifest and then packing it into a zip file. Then scoop install is also able to read a zip file generated by the scoop download command. This will simplify the offline package shipment (via a local network, USB, etc.) to another scoop-enabled workstation that doesn't have an internet connection.

shodanx2 commented 4 months ago

Hi,

From #3818

Here is how to create an internal alias to always disable autoupdate

scoop alias add i 'scoop install -u @args' "Install package without updating scoop" scoop alias add s 'scoop status -l @args' "Show package status without updating scoop"