February 26, 2006

UDP directed broadcast helper

I wrote a little program called pbh to forward directed UDP broadcasts along. If this doesn’t quite make sense, see my last entry. Note that the script is in Python and has only been tested on Python 2.3 (FC2) and 2.4 (CentOS 4; er, I think CentOS 4 has Python 2.4). Also note that python setup.py install probably won’t do what you want; better to python setup.py bdist_rpm and install the resulting RPM. If RPM isn’t your thing, either extract (rpm2cpio dist/pbh-0.2-1.noarch.rpm | cpio -ivdm off the top of my head) or alien it. If there’s demand I can post the “binary” RPM (pbh-0.2-1.noarch.rpm) or maybe I can even be convinced to look at making the install command work correctly. I’ve done minimal testing and it seems to work; I’ll know more when the client actually starts using it with their messaging application.

A few nice things I found while building the distribution for this program. distutils isn’t horrible. Check out setup.cfg in this distribution to see how I override the defaults for the bdist_rpm command. Note, though, that when overriding the %install script for the generated RPM, it replaces (not appends!) the default script, which means your install script needs to install everything. In my case that wasn’t a problem, but I noticed there’s no way to get the name/path of the Python interpreter from inside the provided script (bdist_rpm_install in this case).

Also, I found the fedora-rpmdevtools package which includes skeletons for RPM spec files and, more importantly to this project, an initscript (/usr/share/fedora/template.init).