software.jessies.org Evergreen salma-hayek SCM Terminator

Cygwin Setup

What is Cygwin?

Cygwin is a Linux-like environment for MS Windows. You can read more about it on the Cygwin home page, but this page assumes you know what it is and have already decided that you want it. If you're a Unix user and you're stuck with a Win32 box, you probably do. It's quite a remarkable hack.

Installation

Download the Cygwin setup.exe (and keep it for later, because you'll want it to update your installation too). Run it now, and hit Next. Answer "Install from Internet" and hit Next. Answer "c:\cygwin", "All Users", "Unix / binary", and hit Next. I don't think the local package directory matters, so just hit Next. Hit Next again. Choose a nearby server and hit Next.

Basic packages

You'll now be asked to select packages. The interface is a nightmare along the lines of a mouse-driven dselect(1), and not scriptable in any way. Most people seem to have trouble guessing how to use it, so read the next few paragraphs before you start clicking.

Click the "View" button until the label next to it says "Full". This flattens out the list of packages and makes it easier to peruse. Click once on each of the weird circular icons on the lines with packages you want. (The weird circular icons cycle between various of Skip, available version numbers, Keep, Uninstall, Reinstall and Source, depending on what's available and already installed. You want the first version number offered. If you accidentally click past it, keep clicking until it cycles round again.)

You might want to install the following packages:

ncurses    # see Terminator FAQ
perl
python
ruby       # run Perl, Python, or Ruby scripts
vim        # edit stuff locally
inetutils  # telnet(1)
openssh    # SSH (client and server, though the server's not so great)

When you've selected all the packages you want, hit Next. When the main part of the installation completes, allow the installer to create a desktop shortcut.

Cygwin is now installed.

(In future, assuming you only want to update the packages already on your system, rather than adding new ones, you can simply start the installer and keep hitting "Next" without any other interaction. It remembers what you've already told it.)

Configuration

Double-click on the Cygwin icon on your desktop. You'll get a message like this:

Your group is currently "mkgroup".  This indicates that
the /etc/group (and possibly /etc/passwd) files should be rebuilt.
See the man pages for mkpasswd and mkgroup then, for example, run
mkpasswd -l [-d] > /etc/passwd
mkgroup  -l [-d] > /etc/group
Note that the -d switch is necessary for domain users.

If you don't know otherwise then you should follow the suggestion. After doing that, double-click on the Cygwin icon again to set up your home directory. (If you don't then, for example, Terminator will fail to find your home directory and refuse to start.)

A better command prompt

The Cygwin icon on your desktop starts Microsoft's command prompt window, albeit with bash(1) inside. You can do better than that, though. There's a port of rxvt(1) that doesn't require X11, which you can install with the Cygwin setup.exe, or you can install Terminator.

Terminator will automatically install an icon on the desktop. If instead you choose rxvt(1), you'll have to make your own icon. To do so, right-click on the desktop, select New, Shortcut and paste the following into the presented field:

c:\cygwin\bin\rxvt.exe -fn Terminal -scrollBar_right -bg blue4 -fg white -ls --saveLines 9999

Miss off the background and foreground colors if you prefer dark-on-light, but you will want to use the Terminal font to avoid the default font.

Drag the Terminator or rxvt(1) icon (whichever you prefer) to the Quick Launch tool bar (next to the "Start" button) to save having to minimize all your windows to find the icon on the desktop.

Home directory

If you have a CIFS share on your real Unix box (via Samba, say), you should map that as a network drive (U:, say). You can then set the Win32 environment variable HOME to "U:\" and Cygwin will do the right thing, including running your existing login scripts. (You may want to have installed Perl and Ruby first, and you'll want to follow the usual rules when messing around with login scripts. In particular, keep a working window open at all times!)

You can set Win32 environment variables from the control panel. Double-click "System", click the "Advanced" tab, and click the "Environment Variables..." button. Click the upper "New..." button to create a new user variable.

Default permissions

As mentioned in http://cygwin.com/ml/cygwin/2006-01/msg00257.html, the default permissions for a Cygwin installation are rwxrwxrwx. Even if you don't care about the security implications, Ruby does. You might get sick of seeing Ruby make complaints like:

warning: Insecure world writable dir /usr/local/bin, mode 040777

The directory and exact mode may differ, but you'll need to chmod o-w the directory in question. Here's the minimal set of changes I needed to make to keep Ruby quiet:

chmod o-w /usr/local/bin
chmod o-w /usr/local
chmod o-w /usr
chmod o-w /etc
chmod o-w /usr/sbin
chmod o-w /usr/bin
chmod o-w /usr/X11R6/bin
chmod o-w /usr/X11R6
chmod o-w /cygdrive/c

Of course, this still leaves every binary on your system world-writable. Strangely, Ruby's happy to run world-writable binaries, as long as the directory they're in isn't world-writable.

Hints & Tips

Cygwin's setup log

If you update your Cygwin installation frequently, sometimes things will break or just change in a way you're not expecting, and you'll find yourself wondering what version you were running on a particular day. Matt Wilkie offers this tip to see the dates on which you installed the various versions you've used:

grep -e 'Installing .*cygwin-[0-9].*\.bz2' /var/log/setup.log

The log contains details of all the packages you've installed, in case you're interested in something other than the base.

Easier package installation with cyg-apt(1)

If you find yourself making heavy use of Cygwin, and you're used to Debian-based Linux distributions, you might want to check out cyg-apt(1). Sadly, there's no Cygwin package for it, so you'll have to download it yourself, and you'll have to install the "python" and "wget" packages first.

Once you've run cyg-apt setup, you'll have something approximating apt-get(1). "update" and "install" work as you'd expect, and "cyg-apt search" is like "apt-cache search".

There's also "cyg-apt upgrade", but it's not as useful as its analog on Linux: Windows doesn't let you update files while they're in use, meaning cyg-apt(1) can't update itself or its dependencies. You're better off using Cygwin's setup.exe to update your installation.