Monday, May 28, 2007

wmii

I've evaluating wmmi, an even more minimalistic window manager and suckless.org does a fine job of explaining why. I like that it only has 10,000 lines of code. Let me show you my favorite feature so far:
bash-3.2# dmesg | grep cpu | grep Intel
cpu0: Intel Pentium 4 (686-class), 1794.24 MHz, id 0xf12
cpu0: "Intel(R) Pentium(R) 4 CPU 1.80GHz"
bash-3.2# pwd
/usr/pkgsrc/wm/wmii
bash-3.2# date && make && date                       
Mon May 28 06:25:53 EDT 2007
=> Required installed package digest>=20010302: digest-20060826 found
===> Checking for vulnerabilities in wmii-3.1
=> Checksum SHA1 OK for wmii-3.1.tar.gz
=> Checksum RMD160 OK for wmii-3.1.tar.gz
===> Installing dependencies for wmii-3.1
==========================================================================
The following variables will affect the build process of this package,
wmii-3.1.  Their current value is shown below:

        * PKG_SYSCONFBASE = /usr/pkg/etc

You may want to abort the process now with CTRL-C and change their value
before continuing.  Be sure to run `/usr/bin/make clean' after
the changes.
==========================================================================
=> Required installed package digest>=20010302: digest-20060826 found
=> Required installed package x11-links>=0.25: x11-links-0.30 found
===> Overriding tools for wmii-3.1
===> Extracting for wmii-3.1
===> Patching for wmii-3.1
=> Applying pkgsrc patches for wmii-3.1
===> Creating toolchain wrappers for wmii-3.1
===> Building for wmii-3.1
wmii build options:
LIBS     = -lc -lX11
CFLAGS   = -O2 -I/usr/pkg/include -DVERSION="3.1"
LDFLAGS  = -L/usr/pkg/lib -Wl,-R/usr/pkg/lib -L/usr/X11R6/lib -Wl,-R/usr/X11R6/l
ib -lc -lX11
CC       = cc
CC emallocz.c
CC strlcat.c
CC strlcpy.c
CC strtonum.c
CC tokenize.c
CC trim.c
CC vector.c
AR libcext.a
built libcext
CC color.c
CC font.c
CC draw.c
CC geometry.c
AR liblitz.a
built liblitz
CC client.c
CC convert.c
CC message.c
CC server.c
CC socket.c
CC transport.c
AR libixp.a
built libixp
CC wmiimenu.c
LD wmiimenu
CC wmiipsel.c
LD wmiipsel
CC wmiir.c
LD wmiir
CC wmiisetsid.c
LD wmiisetsid
CC wmiiwarp.c
LD wmiiwarp
built wmii commands
CC area.c
CC bar.c
CC client.c
CC column.c
CC event.c
CC frame.c
CC fs.c
CC key.c
CC mouse.c
CC rule.c
CC view.c
CC wm.c
LD wmiiwm
built core window manager
=> Unwrapping files-to-be-installed.
Mon May 28 06:26:17 EDT 2007
bash-3.2# 
I.e. it builds in less than one minute.

Using wmii (don't panic)

Menu:  Alt-p, xterm, Esc
Move:  Alt-shift-l
Tag:   Mod-shift-2 send current window to workspace 2
Quit:  Alt-a
I typically do the following:
startx
Alt-p, xterm
Alt-p, xterm
Mod-shift-l split them vertically
Alt-p, firefox
Mod-shift-2 send firefox to workspace 2
See the documentation for more information.

Sunday, May 20, 2007

Binary Packages

I've been a Debian user for a while and I'm trying to get used to pkgsrc. My goals for pkgsrc are:
  • Only install what I need
  • Stay current with updates
Note that the first goal will make the second one easier. Eventually I'd like to keep a CVS synchronized pkgsrc tree but for now I'm going to start by using binary packages. One thing that I like about apt that I want to talk about in this post is dependency management and security updates. When I was using packages not managed by my operating system I didn't want to search for dependent packages or drop whatever I was doing just to manually build the latest version of a package because a new vulnerability came out. This security update feature got me addicted to apt-get. I would just "apt-get upgrade" every few days and not have to worry about those exploits. Note that an operating system could also provide a managed system for updates that you automatically build (as opposed to manually) rather than install binary packages. I'm looking to explore this further when I get to know the src side of pkgsrc, but today I'm focusing on the pkg side.

Dependencies

Pkgsrc will manage your dependencies provided those packages "are present where you install" your package from. I.e. you can specify an FTP location as an argument to pkg_add and it will then download and install the package along with its dependencies. The trick is to not download the binary package itself first since when you try to pkg_add it, the dependent packages may not be present and pkg_add will complain that it can't find the dependencies. This is like downloading a .deb file without its dependencies and then trying to dpkg it. Instead, just give pkg_add a URL to a package instead of a package file itself and let pkg_add handle the dependencies. So if you search around and find a package that you want you should be able to copy the link for your platform and then pass it to the pkg_add command. E.g. I wanted madplay to play my MP3s for i386 so I used
bash-3.2# pkg_add <URL>
pkg_add: Warning: package 
...
was built for a different version of the OS:
pkg_add: NetBSD/i386 3.0 (pkg) vs. 
NetBSD/i386 3.1 (this host)
bash-3.2# which madplay
/usr/pkg/bin/madplay
bash-3.2#
Note that I try to use ftp8 and ftp7 since they are the closest mirrors (for madplay it linked back to the master ftp.netbsd.org).

Finding Newer Versions and Vulnerabilities

Pkgsrc will provide you a list of vulnerabilities and a list of newer versions. After installing audit-packages I ran "download-vulnerability-list" and then "audit-packages" to get a list of security threats. After installing pkglint I could also see that there were newer packages:
bash-3.2# lintpkgsrc -i
Scan Makefiles: 6607 packages                              
Version mismatch: 'MesaLib' 6.4.2nb2 vs 6.4.2nb3
Version mismatch: 'Xft2' 2.1.7nb2 vs 2.1.7nb3
Version mismatch: 'Xrender' 0.9.0nb1 vs 0.9.0nb2
Version mismatch: 'atk' 1.12.3 vs 1.18.0
Version mismatch: 'bash' 3.2 vs 3.2.9,2.05.2.7nb8
Version mismatch: 'cairo' 1.2.6 vs 1.4.2nb1
Version mismatch: 'emacs' 20.7nb7 vs 21.4anb10,20.7nb8
Version mismatch: 'esound' 0.2.36nb1 vs 0.2.37
Version mismatch: 'firefox' 2.0.0.1 vs 2.0.0.3nb1,1.5.0.11
Version mismatch: 'fluxbox' 0.9.15.1nb1 vs 1.0rc3nb1
Version mismatch: 'fontconfig' 2.4.2 vs 2.4.2nb2
Version mismatch: 'freetype2' 2.2.1nb2 vs 2.3.4
Version mismatch: 'glib2' 2.12.4nb1 vs 2.12.11
Version mismatch: 'gtk2+' 2.10.6 vs 2.10.11
Version mismatch: 'libIDL' 0.8.7 vs 0.8.8
Version mismatch: 'pango' 1.14.9 vs 1.16.2
Version mismatch: 'perl' 5.8.8nb3 vs 5.8.8nb4
Version mismatch: 'pkglint' 4.74 vs 4.76
Version mismatch: 'png' 1.2.14nb1 vs 1.2.16
bash-3.2# 
The documentation claims that I can then use "make update" to update the package and rebuild any dependencies. AFAICT this means that you have to cd into /usr/pkgsrc and run the "make update" command to make an update from source. I.e. it doesn't mean that it will download a newer binary package. For example after running the above I cd'd into /usr/pkgsrc/editors/emacs20 and ran a "make update" and then after running the above command it no longer included emacs20 (note that I should really get emacs21, but that's not the point). Here is the new output after the "make update":
bash-3.2# lintpkgsrc -i
Scan Makefiles: 6607 packages                              
Version mismatch: 'MesaLib' 6.4.2nb2 vs 6.4.2nb3
Version mismatch: 'Xft2' 2.1.7nb2 vs 2.1.7nb3
Version mismatch: 'Xrender' 0.9.0nb1 vs 0.9.0nb2
Version mismatch: 'atk' 1.12.3 vs 1.18.0
Version mismatch: 'bash' 3.2 vs 3.2.9,2.05.2.7nb8
Version mismatch: 'cairo' 1.2.6 vs 1.4.2nb1
Version mismatch: 'esound' 0.2.36nb1 vs 0.2.37
Version mismatch: 'firefox' 2.0.0.1 vs 2.0.0.3nb1,1.5.0.11
Version mismatch: 'fluxbox' 0.9.15.1nb1 vs 1.0rc3nb1
Version mismatch: 'fontconfig' 2.4.2 vs 2.4.2nb2
Version mismatch: 'freetype2' 2.2.1nb2 vs 2.3.4
Version mismatch: 'glib2' 2.12.4nb1 vs 2.12.11
Version mismatch: 'gtk2+' 2.10.6 vs 2.10.11
Version mismatch: 'libIDL' 0.8.7 vs 0.8.8
Version mismatch: 'pango' 1.14.9 vs 1.16.2
Version mismatch: 'perl' 5.8.8nb3 vs 5.8.8nb4
Version mismatch: 'pkglint' 4.74 vs 4.76
Version mismatch: 'png' 1.2.14nb1 vs 1.2.16
bash-3.2# 
It seems that the binary packages can get you a package quickly but that you should probably build from source to begin with in order to have the newer versions. I'll post more about this later.

Firefox Keys

Not having my keybindings in my browser is annoying. When filling out a form C-a should jump to the start of a line not highlight all of the text. C-u should clean out the text before a line, not show the page source. All I had to do was:
echo "gtk-key-theme-name = \"Emacs\"" > ~/.gtkrc-2.0
and restart firefox. See Emacs Keybindings - Firefox for more information.

Saturday, May 19, 2007

Network Basics

Gateway

When I set up my NetBSD system I only added the following to my /etc/rc.conf:
dhclient=YES
This worked but after a few days of leaving the system unattended I found that I was unable to ping outside of my network. I was able to fix this by adding a default route:
route add default 192.168.1.1
The above is just like the Linux command except 'gw' comes before the IP. The above can be set permanently by adding the following to /etc/rc.conf:
defaultroute="192.168.1.1"
Note how this varies across BSDs. In FreeBSD it's defaultrouter (with an 'r' at the end). OpenBSD encourages using /etc/mygate for this setting, which NetBSD supports but recommends using the above instead. "route add default gw 192.168.1.1"

Static IPs

Rather than guess how my hosts have changed based on who booted when, I prefer to hard code IPs. I think I'll run a home DNS server at some point, but for now my small network can just share /etc/host files. It's easy enough to have this kind of set up with a few boxen and a WRT54G. My mac is set with the following:

To do something similar in NetBSD I removed the DHCP entry from my /etc/rc.conf and added the following:

ifconfig_fxp0="inet 192.168.1.101 netmask 255.255.255.0"
Note that you should also make sure that DHCP is no longer running:
/etc/rc.d/dhclient stop
kill `cat /var/run/dhclient.pid`
My /etc/resolv.conf was set correctly by DHCP so I don't need to update it. Now I just share my /etc/hosts which I derived from properties of both systems:
# Sat May 19 12:23:11 EDT 2007

::1                     localhost           
127.0.0.1               localhost           
255.255.255.255         broadcasthost

# RFC 1918 specifies that these networks are "internal".
# 10.0.0.0      10.255.255.255
# 172.16.0.0    172.31.255.255
# 192.168.0.0   192.168.255.255

192.168.1.100   nenya  
192.168.1.101   narya

Thursday, May 17, 2007

Kill NFS Client Process

Yesterday I had a 8-core system with 16GB of RAM running a load average of 4. It was trying to connect to an NFS mount that it could no longer reach. Trying to view the mounted directory resulted in hangs. You get around those by doing:
killall -9 rpciod
But that won't kill the process since it's really using a kernel thread which will keep trying to get to the mount on NFS's behalf. I added a local firewall rule which was enough to convince it to give up:
iptables -I OUTPUT -d x.x.x.x -j REJECT
where x.x.x.x is the IP of the NFS server. I was then able to umount it after a little bit of delay from the above. The load average then dropped to 0.01. Looks like I'm on some kind of RedHat kick since I gleamed this from Interrupting those pesky "uninterruptible" processes. I'm curious about all of this and the following seem helpful: While looking around for how to kill the process I found Useless use of kill -9 which has a fitting picture for its content.

Tuesday, May 15, 2007

NIC Options

I recently had to change the speed, duplex and other parameters on an Ethernet card. It's easy to do this in redhat. I haven't yet had to do it on a BSD but it seems that I can pass an option to rc.conf (see Optimizing Your Configuration) and read the ifmedia man page. I was tweaking these settings to try to get a PowerEdge 1955 blade working with an older switch that doesn't support gigabit ethernet. Turns out that the chasis for these blades can't do that. It has to be plugged into a newer switch that supports gigabit ethernet. Dell told me that I could plug into a gig switch and then negotiate to 10 or 100, but that misses the point.