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

How to install list of app through scoop . #2289

Closed
hareramcse opened this issue Jun 1, 2018 · 24 comments
Closed

How to install list of app through scoop . #2289

hareramcse opened this issue Jun 1, 2018 · 24 comments

Comments

@hareramcse
Copy link

I have a requirement where I have to install bunch of app for a particular role.
As an example for developer i need to install eclipse, maven, jdk……… so i want to pack all the related app for a particular role in one list and would like to install this list like bellow.
Scoop install listOfApp.
If I execute above command in powershell it should install all the app which I have added in the list.
How can I do this ??
Help is much appreciated.

Thanks.

@rasa
Copy link
Member

rasa commented Jun 1, 2018

You could do this:

scoop bucket add extras
scoop bucket add java

and then:

scoop install https://gist.githubusercontent.com/rasa/b9e8127833004d2afd312cc5fddfa7b5/raw/listOfApp.json

where listOfApps.json is:

{
    "version": "1.0",
    "url": "https://gist.githubusercontent.com/rasa/76456d5d4e71676f21883f3bcc7a9e01/raw/noop.cmd",
    "depends": [
        "extras/eclipse-sdk",
        "maven",
        “java/oraclejdk“
    ]
}

@hareramcse
Copy link
Author

hareramcse commented Jun 1, 2018

I am new bi of this scoop things. so please don't mind my question.
i have some more queries here.
in this bellow command

scoop install https://gist.githubusercontent.com/rasa/b9e8127833004d2afd312cc5fddfa7b5/raw/listOfApp.json

can we give some alias name for this app " https://gist.githubusercontent.com/rasa/b9e8127833004d2afd312cc5fddfa7b5/raw/listOfApp.json " like listOfApp. it will be more readable.

so we can directly use the command like scoop install listOfApp.

and in url section of the listOfApp.json
"url": "https://gist.githubusercontent.com/rasa/76456d5d4e71676f21883f3bcc7a9e01/raw/noop.cmd",

what is noop.cmd ? how can we put some other abc.cmd file on this location.

how can we put here user defined url like "url": "https://xyz.com/hareramcse/abc.cmd",

i want to make user defined url here. please help me.

Thanks

@rasa
Copy link
Member

rasa commented Jun 1, 2018

You can do:

wget https://gist.githubusercontent.com/rasa/b9e8127833004d2afd312cc5fddfa7b5/raw/listOfApp.json

then:

scoop install listOfApp.json

noop.json does nothing, but is included as the url and version values are required. The url can be set to anything you want.

@hareramcse
Copy link
Author

after doing all the mentioned steps i am getting error. once i execute this command scoop install listOfApp.json i get this error

Couldn't find manifest for 'listOfApp.json'

please help me.

@chawyehsu
Copy link
Member

Why not just write a bulk install script using .bat or .ps1?

@r15ch13
Copy link
Member

r15ch13 commented Jun 1, 2018

Or simply create a developer.cmd

@echo off
scoop bucket add extras
scoop bucket add java
scoop install extras/eclipse-sdk maven java/oraclejdk

Edit: changed to batch script

@hareramcse
Copy link
Author

it will be lengthy to write all the app name each and every time whenever we need to install it. it will be fine to write if there are 2 or 3 app but suppose if we need to install more than 10 or 20 app for a particular role then we need to write all the app each and every time. that's why i wanted to sort it in one line. so that we can add all the app name in one list and we can directly install that list and it will install all the app associated with it. i tried above mentioned way but i get error. Couldn't find manifest for 'listOfApp.json'.

@r15ch13
Copy link
Member

r15ch13 commented Jun 1, 2018

Make a small cmd or ps1, name it developer and run it if needed.

@hareramcse
Copy link
Author

could you guys provide a simple working example for this type of requirement. would appreciate the help.

@rasa
Copy link
Member

rasa commented Jun 1, 2018

Perhaps we should allow:

echo extras/eclipse-sdk >listOfApp.txt
echo maven >>listOfApp.txt
echo java/oraclejdk >>listOfApp.txt
scoop install @listOfApp.txt

or perhaps we should remove the requirement that a manifest have a version/url, if it has a depends, to avoid having listOfApp listed as an installed app.

Or both.

@r15ch13
Copy link
Member

r15ch13 commented Jun 1, 2018

@rasa these kind of meta packages won't work with different buckets. Simply running a script (like my and @h404bi's example above) that adds the buckets and just runs a fixed install command is a better solution.

@rasa
Copy link
Member

rasa commented Jun 1, 2018

@r15ch13 i just tested my example and it installed the 3 apps from the 3 buckets

@r15ch13
Copy link
Member

r15ch13 commented Jun 1, 2018

Only if they where added beforehand 😛

@rasa
Copy link
Member

rasa commented Jun 1, 2018

Sorry, I don’t follow. I have never installed any of the 3 apps on this box.

@r15ch13
Copy link
Member

r15ch13 commented Jun 2, 2018

@rasa when you try to install a meta package (like your listOfApp.json example) on a new machine (like @hareramcse is probably trying to use scoop) then it will not work because the buckets are not added. So you have to write a script to add the buckets anyway. This diminishes the use of meta package.

The batch from my #2289 (comment) above should do the trick.

@rasa
Copy link
Member

rasa commented Jun 3, 2018

@r15ch13 Of course, you’re right. But we might want scoop install to automatically add a known bucket, if one is listed in a depends, yes?

@rasa rasa closed this as completed Jun 3, 2018
@wenmin92
Copy link

There should be a batch install support.

When I work on a new machine, I run scoop list > apps.txt on my old machine, then, if I could use scoop install apps.txt to install all these apps in my new machine, how wonderful.

@nuno-andre
Copy link

nuno-andre commented Sep 11, 2019

@wenmin92 From #1543

You can use this in source system:

scoop export | sls '\[(\w+)\]' |% { $_.matches.groups[1].value } | select -unique > buckets.txt
scoop export | sls '(\w+)' |% { $_.matches.groups[1].value } > apps.txt

And then, in target:

gc buckets.txt |% { scoop bucket add $_ }
gc apps.txt |%  {scoop install $_}

And also, for "unknown" buckets:

https://gist.github.com/nuno-andre/77f2b1adf42f29005045c04f0ed8d059

@wenmin92
Copy link

Thanks, it worked.

@Lockszmith-GH
Copy link
Contributor

Lockszmith-GH commented Oct 4, 2019

Posting a fix to @nuno-andre 's code, as it missed some buckets and applications I had (which contained dashes in their name).
Instead of \w which excludes those symbols, I'm basing the regex on the fact that anything from the beginning of the line until the (v:... is the application name, and everything after the ) and within the square brackets [] is the bucket name.

scoop export | select-string '\) \[(.+)\]$' |% { $_.matches.groups[1].value } | select -unique > buckets.txt
scoop export | select-string '^(.+)\W\(v:' |% { $_.matches.groups[1].value } > apps.txt

However, I would preferred the output of scoop export to not be string based, but object based, since this is PowerShell.
An object with 3 fields, AppName, Version and Bucket would have been much simpler to export and import, because it would have been a native PowerShell object.

EDIT (Nov 4th 2019): Code UPDATED, read comments below

So I rolled my own version (which is now part of my FreshInstall.ps1 script:

# add a scoop alias, to create a collection of objects:
scoop alias add 'export-ps' 'param([string[]]$filter,[switch]$WithPath)
 scoop export | sls ''^(.+)\W\(v:(.+)\)( \*global\*)? \[(.+)\]$'' |% {
     $local:p=$_.matches.groups;
     if($filter -and $p[1].value -notin $filter){return};
     $local:r = [ordered]@{
         AppName=$p[1].value;
         Version=$p[2].value;
         Scope=if($p[3].value){"Global"}else{"Local"};
         Bucket=$p[4].value
     };
     if($WithPath){
         $r.AppPath=$(($local:tmp = scoop info $p[1].value) | sls "Installed:" | % { Join-Path (Split-Path -Parent (($tmp[$_.LineNumber].Replace(" *global*","")).Trim())) "current" })
     };
     [PSCustomObject]($r)
 }'

To grab relevant data from it, like in the examples posted before me

$appList = scoop export-ps
$appList | Select-Object -Unique -ExpandProperty Bucket
$appList.AppName

The object list can be saved into any format, for example json or clixml:

scoop export-ps | ConvertTo-Json | Out-File scoop-export.json
# or
scoop export-ps | Export-Clixml scoop-export.clixml

Which is easily imported back into an object:

$appList = Get-Content scoop-export.json | ConvertFrom-Json
# or 
$appList = Import-Clixml scoop-export.clixml

After importing the object back, instructing scoop to install everything would be very similar to the example by @nuno-andre :

$appList | Select-Object -Unique -ExpandProperty Bucket | % { scoop bucket add $_ }
$appList.AppName | %  { scoop install $_ }

Anyway - scoop is an amazing tool regardless of my wishes.
And the community around it is awesome. Keep up the good work everyone.

@nuno-andre
Copy link

Oops, dashes. Good catch!

I don't really care too much about versions because I always install latest version, but indeed your fixes add robustness and reproducibility. It would be a better format for exports than the current one.

@Lockszmith-GH
Copy link
Contributor

Lockszmith-GH commented Nov 4, 2019

I've updated the code in my alias command above just now.
The list was missing the *global* entries.

I've also added 2 parameters to the Aliases, -Filter and -WithPath.

  • -Filter will to create a limited list.
  • -WithPath will add an additional column: The path to the current app location.
    Because this operation is a slow one, it will only happen when the switch is added.

Example invocation:

$appList = scoop export-ps -Filter processhacker,sysinternals -WithPath

An example output for $appList | Format-Table -AutoSize would be*

AppName       Version           Scope  Bucket AppPath
-------       -------           -----  ------ -------
processhacker 2.39              Global extras C:\_\bin\_scoop\apps\processhacker\current
sysinternals  September.20.2019 Local  extras C:\_\bin\_scoop\_local\apps\sysinternals\current

* I set my $env:SCOOP to C:\_\bin\_scoop\_local and my $env:SCOOP_GLOBAL to C:\_\bin\_scoop.

This allows me to create easier automation around scoop based installations.

@chengxuncc
Copy link

I wrote a script to export scoop installed buckets and softwares to an installing script.

$buckets = (scoop bucket list)
$knownBuckets = (scoop bucket known)
Push-Location
$output = $buckets | ForEach-Object {
  $outputBucket = $_
  if ($_ -notin $knownBuckets) {
    Set-Location $env:SCOOP\buckets\$_
    $outputBucket += ' ' + (git config --get remote.origin.url)
  }
  $outputBucket = 'scoop bucket add ' + $outputBucket
  $outputBucket
}
Pop-Location

$sofwares = (scoop export)
$output += 'scoop install ' + ($sofwares | ForEach-Object { $_.split(' ')[0] })

$output | Out-File -FilePath 'install-scoop-softwares.ps1' -Encoding utf8
Write-Output $output

@teddue
Copy link

teddue commented Mar 13, 2020

gc buckets.txt |% { scoop bucket add $_ }
gc apps.txt |%  {scoop install $_}

And also, for "unknown" buckets:

https://gist.github.com/nuno-andre/77f2b1adf42f29005045c04f0ed8d059

When trying to import the buckets, I get following error for every "unknown" bucket. (used dodorz’ bucket in example)

Unknown bucket 'dodorz https://github.com/dodorz/scoop-bucket'. Try specifying <repo>.
usage: scoop bucket add <name> [<repo>]

The entries in the file are all in the format <name> <repo>

When trying to import manually it works.

Does PowerShell have issues to read the url or is it a user error?

TheWiresharkGuy pushed a commit to TheWiresharkGuy/szcoop that referenced this issue Mar 22, 2020
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

9 participants