Thursday, November 29, 2012

Cygwin package manager and auto updates

I use Cygwin on my Windows machine to get access to all the wonderful Linux tools like grep, wget, etc. One problem with Cygwin is you have to run it's GUI installer again manually each time you want to add tools or update the ones you already have.
apt-cyg provides a command-line package manager that you can use to install tools without using the GUI installer. However, I didn't see a way to update the existing tools. You can write a simple batch script to do the automatic updates for you. You only need the three lines below, assuming you've installed cygwin to C:\cygwin. Then, run the batch file as administrator or create a shortcut to do that for you.
cd C:\cygwin
wget -N http://cygwin.com/setup.exe
setup.exe --no-desktop --no-shortcuts --no-startmenu --quiet-mode
If you want to pretty it up so you can scan the results of the commands easier, just add some echo statements:
@ECHO off
cd C:\cygwin
echo ======================================
echo Downloading latest cygwin installer...
echo ======================================
echo.
wget -N http://cygwin.com/setup.exe
echo.
echo ======================================
echo Updating all cygwin packages...
echo ======================================
echo.
setup.exe --no-desktop --no-shortcuts --no-startmenu --quiet-mode
echo.
echo ======================================
echo Update finished.
echo ======================================
echo.
pause