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.
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“
]
}
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
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.
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.
Why not just write a bulk install script using .bat or .ps1?
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
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'.
Make a small cmd or ps1, name it developer and run it if needed.
could you guys provide a simple working example for this type of requirement. would appreciate the help.
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.
@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.
@r15ch13 i just tested my example and it installed the 3 apps from the 3 buckets
Only if they where added beforehand :stuck_out_tongue:
Sorry, I don’t follow. I have never installed any of the 3 apps on this box.
@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 https://github.com/lukesampson/scoop/issues/2289#issuecomment-393816060 above should do the trick.
@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?
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.
@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
Thanks, it worked.
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.
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.
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.
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.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.
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
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?
Most helpful comment
@wenmin92 From #1543
You can use this in source system:
And then, in target:
And also, for "unknown" buckets:
https://gist.github.com/nuno-andre/77f2b1adf42f29005045c04f0ed8d059