Chocolatey - apt-get for Windows

    Chocolatey is a Windows package manager similar to apt-get in the Linux World.



    Started to use due to development on Node.js for Nodester. I would like to regularly update the node, git, dropbox, and the same skype, while not bothering with downloading msi installers and settings, but just updating it with one command:

    cup all

    It’s possible to update all packages . A general list of available commands on the Wiki. Unfortunately, there is no way to remove packages .

    So, how to work constantly requires access to the console, git, node, jade. I would like to illustrate a little bit the work with Chocolatey in the context (for example) of preparation for development for Nodester.

    Installation Requirements:

    Windows XP / Vista /
    7/2003/2008 .NET Framework 4.0
    PowerShell 2.0 is

    installed simply by executing such a simple command (it is not processed in PowerShell in cmd.exe):

    @powershell -NoProfile -ExecutionPolicy unrestricted -Command "iex ((new-object net.webclient).DownloadString('http://bit.ly/psChocInstall'))"

    Chocolatey installation process

    After that it is automatically installed in C: \ Chocolatey, in C: \ Chocolatey \ libs will contain package descriptions, libraries. The main modules of default programs are installed in Program Files (x86).

    All the basic and necessary packages for the developer are present . Interpreted languages, such as the PHP , the Ruby , the Python , Node.js . DB - MySQL , MongoDB , SQLite . Git Version Control, Mercurial, SVN . Notepad ++, Sublime. Caliber for processing books under the Kindle.

    1. Installing the Node.js package along with npm

    cinst nodejs.install

    This command is similar to the following

    chocolatey install nodejs.install



    True console will have to be closed and reopened so that the recorded paths in path become available.



    2. When the node is installed, it is already possible to conduct development and install modules through the package manager. Here’s a package for Nodster



    3. Without Git-a on Nodester, you won’t be able to deploy, so we install it using Chocolatey.



    Here is a list of what I have additionally installed. We try putty, the command opens the program window and looks at the fact that git was installed successfully (I remind you that you have to close the console and reopen it).

    cinst Console2
    cinst putty
    cinst curl
    cinst Wget






    4. We see that we can freely contact Nodester.



    Then the routine process remains, installing on the local machine via npm the modules required in the project, such as expressjs, jade, testing on the local web server that loads the node. All this business is conducted in git, commits, after which push in nodester turnips is committed. On nodester ( command list ), you will also need to install npm modules through nodester npm install appname.

    Not suitable for everything Chocolatey. The very ideology of Windows and applications created for the platform is inclined to the fact that they themselves must climb into startup and at every opportunity, without permission, climb to update. So, the packages have Chrome, but we know about GoogleUpdater.exe which updates everything already. So, about Notepad ++ which itself can climb for updates. Skype itself can be updated. However, if you initially set everything in chocolate, a quick update with one command will be fun, especially if it does not apply to GUI tools.

    Finally, I will attach a video clip from of. site



    UPD

    In the comments, they asked to add the Slik Subversion (SVN) package. I think it will be useful to illustrate how simple this is. The principle of the work of “chocolate” will also be clarified.

    Main description and installation script for the simplest case. All packages can be assembled yourself, here are examples .

    1. Create a description file C: \ sliksvn \ sliksvn.nuspec with the appropriate text ( original disc ):

    sliksvnSlikSVN1.7.4Slik CompanyanatoolySlik subversion reliable version control starts hereWe provide a standalone command line Subversion package for Windows. The installer contains all command line tools (svn, svnadmin, svnsync, svnserve, svnmucc, etc.) but no application bindings nor Apache modules. The tools are fully side-by-side compatible with other packages. Ideal for automated build and deploy scriptshttp://www.sliksvn.com/sliksvn svn subversionSlik Companyfalse


    2. Then we create the installation script C: \ sliksvn \ tools \ chocolateyInstall.ps1 From the code it becomes clear. What is downloaded from the office. The site is either 32-bit or 64-bit installer and will be installed in quiet mode without distracting questions. 3. Add. installation file (may be missing), but in this case it doesn’t matter C: \ sliksvn \ tools \ install.ps1 4. We compile the package. It can be assembled by NuGet. Register access to it in path, or access through the full path. Lies in C: \ Chocolatey \ chocolateyInstall \ NuGet.exe > cd C: \ sliksvn > nuget pack

    try {

    Install-ChocolateyPackage 'sliksvn' 'msi' '/quiet' 'www.sliksvn.com/pub/Slik-Subversion-1.7.4-win32.msi' 'http://www.sliksvn.com/pub/Slik-Subversion-1.7.4-x64.msi'

    Write-ChocolateySuccess 'SlikSVN'
    } catch {
    Write-ChocolateyFailure 'SlikSVN' "$($_.Exception.Message)"
    throw
    }






    param($installPath, $toolsPath, $package, $project)

    Write-Host 'This is not a package with dlls to reference in it.'
    Write-Host 'Please install using chocolatey'
    Write-Host "To get chocolatey just run 'Install-Package chocolatey' followed by 'Initialize-Chocolatey'"
    Write-Host 'chocolatey install sliksvn'
    write-host 'Removing this package...'
    uninstall-package sliksvn -ProjectName $project.Name







    Then we get C: \ sliksvn \ sliksvn.1.7.4.nupkg local package. You can already install it from it, check cinst sliksvn -source C: \ sliksvn (in the path there is only the path to the folder where the package is located, without its name). Installed locally. Then you can upload the package to the site. The post-moderation mode works there, so the package will be visible immediately and becomes available through cinst sliksvn.

    How does it work when installing the package? When installing, everything that is packaged in the nupkg package - installation scripts, description, and other files, binary archives (there are many interesting exampleswhatever it may be) gets into the folder C: \ Chocolatey \ lib \ PACKAGE_NAME, but the actions prescribed in the script, in our case, silent installation is performed by default, that is, SlikSVN I have a 64-bit system, so it is put in C: \ Program Files \ SlikSVN \ and itself is written in path. But in fact, the installation can be any unpacking from its own archive, which will be included in the package, or some other actions with its own incoming libraries. It all depends on the imagination.

    How to remove it? SlikSVN itself through Install-Uninstall, like any standard installed program, and from C: \ Chocolatey \ lib \ PACKAGE_NAME by hand.

    Update 2012-08-15 :

    In recent versions, package removal via chocolatey uninstall has already appeared. The command removes the contents of the package from C: \ Chocolatey \ lib \ the name of the package, that is, utilities that are installed by unpacking into this folder are deleted completely. What is installed on the system and in Program Files is not affected.

    There is no list of installed packages, as it would be logical to assume from the chocolatey list. But you can easily fix this, as an option with such a hack:

    diff --git "a/c:\\Chocolatey\\chocolateyInstall\\functions\\Chocolatey-List.ps1" "b/c:\\Chocolatey\\chocolateyInstall\\functions\\Chocolatey-List.ps1"
    index 67c2ecc..aa67027 100644
    --- "a/c:\\Chocolatey\\chocolateyInstall\\functions\\Chocolatey-List.ps1"
    +++ "b/c:\\Chocolatey\\chocolateyInstall\\functions\\Chocolatey-List.ps1"
    @@ -15,7 +15,12 @@ param(
         $parameters = "list"
         if ($selector -ne '') {
           $parameters = "$parameters ""$selector"""
    -    }
    +    } else {
    +	  $packageFolders = Get-ChildItem $nugetLibPath | sort name
    +	  $packages = $packageFolders -replace "(\.\d{1,})+"|gu 
    +	  Write-Host $packages
    +	  exit
    +	}
         if ($allVersions -eq $true) {
           Write-Debug "Showing all versions of packages"
    

    Now on the chocolatey list we get:

    7zip 7zip.install chocolatey Console2 curl foobar2000 git git.install miranda msysgit nodejs.install notepadplusplus notepadplusplus.install php php5-dev putty sliksvn sublimetext2 warmup Wget

    Also popular now: