This site is now 100% read-only, and retired.

XML Logo

Posted by redbeard on Sun 24 Jun 2007 at 06:00
Tags: ,

There's probably more ways to do this (including checking for the actual man files (just thought of that)), but I wanted man pages for all the executables in a package a little while ago. This is what I did:

dpkg -L package-name |
  awk -F / '/^\/usr\/bin\// { print $4 }' |
  xargs -n 1 man

If you have wajig installed you can use this:

wajig listfiles package-name |
  awk -F / '/^\/usr\/bin\// { print $4 }' |
  xargs -n 1 man

Both of these show off a couple of (I think) neat little tricks.

The first is the awk command. I've just started to use awk exensively. It's starting to replace grep and egrep in a lot of my pipelines. I'm also learning to use sed some.

Anyway, the trick, obvious to any halfway proficient awk user, is the -F option. It sets the field separator. In this case, each line from dpkg or wajig is a path, so I'm using a slash (/) as a the field separator. No biggie.

The second trick is the use of xargs. I have been putting everything in a for loop in cases like this. However, the other day I realized that xargs can simplify things. In this case the -n 1 parameter tells xargs to only send one parameter at a time to the called command. So, man is executed once for every line passing through awk, with that line as the only parameter.

I used the xargs trick the other day to move files to destinations specified in a file, with source and destination on the same line, separated by spaces. The file looked like:

source1 dest1
source2 dest2
source3 dest3

It was generated automatically but then edited by hand. I know there are tools available for this (the moreutils package includes vidir, for instance) but I didn't have one available. So, I ran the following command on the above file:

cat movelist | xargs -n 2 mv

Quick and simple, and got the job done.


Posted by redbeard on Mon 17 Apr 2006 at 21:08
Tags: none.

I'm working on setting up a new e-mail server. It will be handling two primary domains, as well as a few domains that will just forward to one or the other of the main domains. I want to use Dovecot to handle the IMAP services for the sites. So I found an interesting bit on the Dovecot wiki for setting up virtual users in multiple domains. I liked the Linuxconf configuration information so I plan to use it, sans Linuxconf. There is a corresponding article on the Exim wiki about setting Exim up for it.

So, why this post? Well, the Dovecot configuration claims to require version 1.0test79 or later. Sarge's version is in the 0.99 range. Version 1.0 Beta 2 is currently in testing. I'd try just installing it but it has dependencies that aren't in Sarge. The biggest one is libc6. I don't want to open that can of worms. So, I've decided to try backporting the Dovecot package. If all else fails, I can always back the package out.

Disclaimer. Before I go any further, please keep in mind that this might not be the "right" way of doing things. It might also melt your computer's processor, or do something else dastardly. I don't really know. But, so far, it works for me.


First thing I did was search Debain Administration for an article that might help. I found Rebuilding Debian packages by Steve. It's old, but has what I need to get started. The only issue is that I am pulling from a different repository. So rather than using the nice apt-get source and apt-get build-dep commands, I manually installed build dependencies (all but one were available in Sarge, thankfully) and downloaded the source package directly.

I had forgotten, though, that libpq-dev wasn't available. So when I ran debuild -us -uc I got an error saying I was missing a dependency. Since I won't be using PostgreSQL, I modified debian/control to remove that dependency (and the libldap2-dev dependency, since I won't be using LDAP, either). Then I edited debian/rules and changed the config.status rule so it runs configure without the --with-pgsql and --with-ldap options. After these two minor tweaks, running debuild was successful.


Since I don't have a custom repository set up yet (it's on the list :), I installed it using dpkg --install. The precise command was:

dpkg --install dovecot-common_1.0.beta2-1.1etch1_i386.deb dovecot-imapd_1.0.beta2-1.1etch1_i386.deb

In the process of running that, I discovered there is a new configuration file format. Ick. Of course, all I had really done originall is enable only IMAPS. So I used the distributed file and then tweaked the configuration to enable IMAPS, like I had originally.

Finally, started Dovecot with /etc/init.d/dovecot start and sent an e-mail to the server. I was then able to successfully read it using an IMAP client. Success!

What's next?

My next step is to set up the multiple server/virtual user configuration. Once I get that figured out, I'll post again.