Wednesday, October 10, 2018

Automate the repetitive stuff: Scoop


Scoop: Command line installer for windows

All right, so you've just finished reading up on a stack, language, tool and want to practice, but don't really wanna take the time to dive into the details of setting up the new environment tools. Fear not, Scoop is here to the rescue.

Scoop is written as a bunch of powershell commands that shield you from the details and locations of the different packages and versions you want to try out.


Installation


All you gotta do is install it by running the following command on Powershell

//Set the perimission rights
Set-ExecutionPolicy RemoteSigned -scope CurrentUser

//install it
iex (new-object net.webclient).downloadstring('https://get.scoop.sh')

//Optional, if you do not have git already
scoop install git

//install all buckets (we'll get to that in a moment)
1scoop bucket known | % { scoop bucket add $_ }


You end up with the following directory in your home directory





type in scoop in your console





Please note that you have to run scoop under powershell, otherwise you might run into


The term 'C:\Users\lhechma\scoop\apps\scoop\current\bin\scoop.ps1' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.


Architecture

Layout

Scoop adds itself to the home directory as a powershell scipt under ~/scoop/shims

All its commands are themselves scripts distributes accross three main subfolders






  • bin: The main entrypoint, mainly through scoop.ps1 script
  • lib: Its internal supporting librairies, for example installing shortcuts on the start menu, or parsing json
  • libexec: wich almost mirror the commands you get on the console.

How about buckets?

Scoop uses the term bucket in its literal meaning. It is the isolation and addressing mechanism for addressing the different meta-repositories, which contain configuration details for all the software packages within it. This means that is necessary to find buckets for your desired package if it is not bundled with the default list of buckets that are preconfigured with Scoop. In the example below, I wanted to try out Clojure (it is about time I guess). Since it is not there by default on any bucket.


So I had to add a new bucket with clojure in it

scoop bucket add wangzq https://github.com/wangzq/scoop-bucket

scoop install clojure


This is what I ended up with





Go your console and type clojure


I finally got clojure working, with a maximum of 5 commands and without leaving my console. What a scoop!


Minimal intrusion/Transparency:


Scoop does its magic while doing its best not to pollute your PATH environment with the newly installed packages (sometimes it has to do, like for Java JDK). The trick is to create a new cmd command with the name of the package under ~/scoop/shims. Only this path is added to your user path.

Conceptual integrity:


Scoop manages itself in the same way it manages its own packages. DRY at its best.

Simplicity:


Version management has always been a headache. Think back at ANT, Maven with its optional dependencies,...  Scoop manages package versioning with .... folder shorctus. Basically, a new shim (executable if you will) will point to a version folder, that points to the proper version, so you can have multiple versions of the same package without any issues. The old moto: add one level of inderction does wonders here.

Additionally, scoop is based upon well established and understood technologies: GIT, JSON. Your learning curve is almost inexistant if you've been doing any software development in the last years.

Criticism


Just because I love to have the rebel attitude, I'm going to mention that I would have loved to have less verbositiy at the level of the commands used internally to extract and run installers (like for pre_install and post_install hooks). But again, I guess that interoperability is not required here, since scoop is tailored to Windows, a DSL would do more harm than good.

Comparison

I can't do better than the creator. So I'll let check how Scoop compares to Chocolatey here


See you on the next installent for more production tools.
Thanks for reading





No comments:

Functional Java: Hate the player not the game

We've all heard it over and over, Java 8 is not really functional programming. I admit that features like tail call optimization, closu...